diff options
-rw-r--r-- | src/callbacks.cpp | 10 | ||||
-rw-r--r-- | src/interface.cpp | 2 | ||||
-rw-r--r-- | src/procdialogs.cpp | 64 | ||||
-rw-r--r-- | src/proctable.cpp | 8 | ||||
-rw-r--r-- | src/proctable.h | 3 |
5 files changed, 59 insertions, 28 deletions
diff --git a/src/callbacks.cpp b/src/callbacks.cpp index 8306fd1..3afff0a 100644 --- a/src/callbacks.cpp +++ b/src/callbacks.cpp @@ -346,16 +346,6 @@ cb_net_out_color_changed (GSMColorButton *cp, gpointer data) change_settings_color(procdata->settings, "net-out-color", cp); } -static void -get_last_selected (GtkTreeModel *model, GtkTreePath *path, - GtkTreeIter *iter, gpointer data) -{ - ProcInfo **info = static_cast<ProcInfo**>(data); - - gtk_tree_model_get (model, iter, COL_POINTER, info, -1); -} - - void cb_row_selected (GtkTreeSelection *selection, gpointer data) { diff --git a/src/interface.cpp b/src/interface.cpp index f7dbe84..3d259d2 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -785,7 +785,7 @@ update_sensitivity(ProcData *data) GtkAction *action; processes_sensitivity = (data->config.current_tab == PROCMAN_TAB_PROCESSES); - selected_sensitivity = (processes_sensitivity && data->selected_process != NULL); + selected_sensitivity = (processes_sensitivity && data->selection && gtk_tree_selection_count_selected_rows (data->selection) > 0); if(data->endprocessbutton) { /* avoid error on startup if endprocessbutton diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp index ee695bc..ec06916 100644 --- a/src/procdialogs.cpp +++ b/src/procdialogs.cpp @@ -66,29 +66,49 @@ procdialog_create_kill_dialog (ProcData *procdata, int signal) kargs = g_new(KillArgs, 1); kargs->procdata = procdata; kargs->signal = signal; + gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection); + + if ( selected_count == 1 ) { + ProcInfo *selected_process = NULL; + // get the last selected row + gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected, + &selected_process); + if (signal == SIGKILL) { + /*xgettext: primary alert message for killing single process*/ + primary = g_strdup_printf (_("Are you sure you want to kill the selected process “%s” (PID: %u)?"), + selected_process->name, + selected_process->pid); + } else { + /*xgettext: primary alert message for ending single process*/ + primary = g_strdup_printf (_("Are you sure you want to end the selected process “%s” (PID: %u)?"), + selected_process->name, + selected_process->pid); + } + } else { + if (signal == SIGKILL) { + /*xgettext: primary alert message for killing multiple processes*/ + primary = g_strdup_printf (_("Are you sure you want to kill the %d selected processes?"), + selected_count); + } else { + /*xgettext: primary alert message for ending multiple processes*/ + primary = g_strdup_printf (_("Are you sure you want to end the %d selected processes?"), + selected_count); + + } + } - - if (signal == SIGKILL) { - /*xgettext: primary alert message*/ - primary = g_strdup_printf (_("Kill the selected process “%s” (PID: %u)?"), - procdata->selected_process->name, - procdata->selected_process->pid); + if ( signal == SIGKILL ) { /*xgettext: secondary alert message*/ secondary = _("Killing a process may destroy data, break the " "session or introduce a security risk. " "Only unresponsive processes should be killed."); - button_text = _("_Kill Process"); - } - else { - /*xgettext: primary alert message*/ - primary = g_strdup_printf (_("End the selected process “%s” (PID: %u)?"), - procdata->selected_process->name, - procdata->selected_process->pid); + button_text = ngettext("_Kill Process", "_Kill Processes", selected_count); + } else { /*xgettext: secondary alert message*/ secondary = _("Ending a process may destroy data, break the " "session or introduce a security risk. " "Only unresponsive processes should be ended."); - button_text = _("_End Process"); + button_text = ngettext("_End Process", "_End Processes", selected_count); } kill_alert_dialog = gtk_message_dialog_new (GTK_WINDOW (procdata->app), @@ -147,7 +167,7 @@ renice_dialog_button_pressed (GtkDialog *dialog, gint id, gpointer data) void procdialog_create_renice_dialog (ProcData *procdata) { - ProcInfo *info = procdata->selected_process; + ProcInfo *info; GtkWidget *dialog = NULL; GtkWidget *dialog_vbox; GtkWidget *vbox; @@ -164,11 +184,21 @@ procdialog_create_renice_dialog (ProcData *procdata) if (renice_dialog) return; + gtk_tree_selection_selected_foreach (procdata->selection, get_last_selected, + &info); + gint selected_count = gtk_tree_selection_count_selected_rows (procdata->selection); + if (!info) return; - dialog_title = g_strdup_printf (_("Change Priority of Process “%s” (PID: %u)"), - info->name, info->pid); + if ( selected_count == 1 ) { + dialog_title = g_strdup_printf (_("Change Priority of Process “%s” (PID: %u)"), + info->name, info->pid); + } else { + dialog_title = g_strdup_printf (_("Change Priority of %d Selected Processes"), + selected_count); + } + dialog = gtk_dialog_new_with_buttons (dialog_title, NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "gtk-cancel", GTK_RESPONSE_CANCEL, diff --git a/src/proctable.cpp b/src/proctable.cpp index b9b0a75..faab2b0 100644 --- a/src/proctable.cpp +++ b/src/proctable.cpp @@ -71,6 +71,14 @@ ProcInfo* ProcInfo::find(pid_t pid) return (it == ProcInfo::all.end() ? NULL : it->second); } +void +get_last_selected (GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, gpointer data) +{ + ProcInfo **info = static_cast<ProcInfo**>(data); + + gtk_tree_model_get (model, iter, COL_POINTER, info, -1); +} static void cb_columns_changed(GtkTreeView *treeview, gpointer user_data) diff --git a/src/proctable.h b/src/proctable.h index e47c6d8..afad7e2 100644 --- a/src/proctable.h +++ b/src/proctable.h @@ -71,4 +71,7 @@ void proctable_set_columns_order(GtkTreeView *treeview, GSList *order char* make_loadavg_string(void); +void get_last_selected (GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, gpointer data); + #endif /* _PROCMAN_PROCTABLE_H_ */ |