[gnome-system-monitor] Move a few callbacks where they belong to
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Move a few callbacks where they belong to
- Date: Wed, 24 Jul 2013 19:53:23 +0000 (UTC)
commit 88229868f662d0eed363c7ef7f18271033c9ac6d
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Jul 24 13:26:43 2013 +0200
Move a few callbacks where they belong to
https://bugzilla.gnome.org/show_bug.cgi?id=704800
src/callbacks.cpp | 194 -----------------------------------------------------
src/callbacks.h | 15 ----
src/interface.cpp | 127 ++++++++++++++++++++++++++++++++++-
src/proctable.cpp | 61 +++++++++++++++++
4 files changed, 187 insertions(+), 210 deletions(-)
---
diff --git a/src/callbacks.cpp b/src/callbacks.cpp
index 5967531..60667c9 100644
--- a/src/callbacks.cpp
+++ b/src/callbacks.cpp
@@ -36,184 +36,6 @@
#include "disks.h"
#include "lsof.h"
-void
-cb_about (GtkAction *action, gpointer data)
-{
- ProcmanApp *app = static_cast<ProcmanApp *>(data);
-
- const gchar * const authors[] = {
- "Kevin Vandersloot",
- "Erik Johnsson",
- "Jorgen Scheibengruber",
- "Benoît Dejean",
- "Paolo Borelli",
- "Karl Lattimer",
- "Chris Kühl",
- "Robert Roth",
- NULL
- };
-
- const gchar * const documenters[] = {
- "Bill Day",
- "Sun Microsystems",
- NULL
- };
-
- const gchar * const artists[] = {
- "Baptiste Mille-Mathias",
- NULL
- };
-
- gtk_show_about_dialog (
- GTK_WINDOW (app->main_window),
- "name", _("System Monitor"),
- "comments", _("View current processes and monitor "
- "system state"),
- "version", VERSION,
- "copyright", "Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
- "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
- "Copyright \xc2\xa9 2011 Chris Kühl",
- "logo-icon-name", "utilities-system-monitor",
- "authors", authors,
- "artists", artists,
- "documenters", documenters,
- "translator-credits", _("translator-credits"),
- "license", "GPL 2+",
- "wrap-license", TRUE,
- NULL
- );
-}
-
-gboolean
-cb_main_window_delete (GtkWidget *window, GdkEvent *event, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
- app->shutdown ();
-
- return TRUE;
-}
-
-void
-cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
-{
- guint cpu_i = GPOINTER_TO_UINT (data);
- GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
-
- /* Get current values */
- GVariant *cpu_colors_var = g_settings_get_value(settings, "cpu-colors");
- gsize children_n = g_variant_n_children(cpu_colors_var);
-
- /* Create builder to contruct new setting with updated value for cpu i */
- GVariantBuilder builder;
- g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
-
- for (guint i = 0; i < children_n; i++) {
- if(cpu_i == i) {
- gchar *color;
- GdkRGBA button_color;
- gsm_color_button_get_color(cp, &button_color);
- color = gdk_rgba_to_string (&button_color);
- g_variant_builder_add(&builder, "(us)", i, color);
- g_free (color);
- } else {
- g_variant_builder_add_value(&builder,
- g_variant_get_child_value(cpu_colors_var, i));
- }
- }
-
- /* Just set the value and let the changed::cpu-colors signal callback do the rest. */
- g_settings_set_value(settings, "cpu-colors", g_variant_builder_end(&builder));
-}
-
-static void change_settings_color(GSettings *settings, const char *key,
- GSMColorButton *cp)
-{
- GdkRGBA c;
- char *color;
-
- gsm_color_button_get_color(cp, &c);
- color = gdk_rgba_to_string (&c);
- g_settings_set_string (settings, key, color);
- g_free (color);
-}
-
-void
-cb_mem_color_changed (GSMColorButton *cp, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
- change_settings_color(app->settings, "mem-color", cp);
-}
-
-
-void
-cb_swap_color_changed (GSMColorButton *cp, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
- change_settings_color(app->settings, "swap-color", cp);
-}
-
-void
-cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
- change_settings_color(app->settings, "net-in-color", cp);
-}
-
-void
-cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
- change_settings_color(app->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)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
-
- app->selection = selection;
-
- app->selected_process = NULL;
-
- /* get the most recent selected process and determine if there are
- ** no selected processes
- */
- gtk_tree_selection_selected_foreach (app->selection, get_last_selected,
- &app->selected_process);
- if (app->selected_process) {
- GVariant *priority;
- gint nice = app->selected_process->nice;
- if (nice < -7)
- priority = g_variant_new_string ("very-high");
- else if (nice < -2)
- priority = g_variant_new_string ("high");
- else if (nice < 3)
- priority = g_variant_new_string ("normal");
- else if (nice < 7)
- priority = g_variant_new_string ("low");
- else
- priority = g_variant_new_string ("very-low");
-
- GAction *action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
- "priority");
-
- g_action_change_state (action, priority);
- }
- update_sensitivity(app);
-}
-
-
gint
cb_timeout (gpointer data)
{
@@ -235,22 +57,6 @@ cb_timeout (gpointer data)
}
void
-cb_refresh_icons (GtkIconTheme *theme, gpointer data)
-{
- ProcmanApp * const app = static_cast<ProcmanApp *>(data);
- if(app->timeout) {
- g_source_remove (app->timeout);
- }
-
- for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
- app->pretty_table->set_icon(*(it->second));
- }
-
- cb_timeout(app);
-}
-
-
-void
cb_column_resized(GtkWidget *widget, GParamSpec* param, gpointer data)
{
GSettings * settings = static_cast<GSettings *>(data);
diff --git a/src/callbacks.h b/src/callbacks.h
index bd8df1b..6ad43c2 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -22,25 +22,10 @@
#define _PROCMAN_CALLBACKS_H_
#include <gtk/gtk.h>
-#include "gsm_color_button.h"
-
-void cb_about (GtkAction *action, gpointer data);
-
-gboolean cb_main_window_delete (GtkWidget *window, GdkEvent *event, gpointer data);
-
-void cb_cpu_color_changed (GSMColorButton *widget, gpointer user_data);
-void cb_mem_color_changed (GSMColorButton *widget, gpointer user_data);
-void cb_swap_color_changed (GSMColorButton *widget, gpointer user_data);
-void cb_net_in_color_changed (GSMColorButton *widget, gpointer user_data);
-void cb_net_out_color_changed (GSMColorButton *widget, gpointer user_data);
-
-void cb_row_selected (GtkTreeSelection *selection, gpointer data);
gint cb_update_disks (gpointer data);
gint cb_timeout (gpointer data);
-void cb_refresh_icons (GtkIconTheme *theme, gpointer data);
-
void cb_column_resized (GtkWidget* column, GParamSpec* param, gpointer data);
gboolean cb_column_header_clicked (GtkTreeViewColumn* column,
diff --git a/src/interface.cpp b/src/interface.cpp
index 21b7f75..870a58e 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -68,6 +68,79 @@ create_proc_view(ProcmanApp *app, GtkBuilder * builder)
gtk_menu_attach_to_widget (GTK_MENU (app->popup_menu), app->main_window, NULL);
}
+void
+cb_cpu_color_changed (GSMColorButton *cp, gpointer data)
+{
+ guint cpu_i = GPOINTER_TO_UINT (data);
+ GSettings *settings = g_settings_new (GSM_GSETTINGS_SCHEMA);
+
+ /* Get current values */
+ GVariant *cpu_colors_var = g_settings_get_value(settings, "cpu-colors");
+ gsize children_n = g_variant_n_children(cpu_colors_var);
+
+ /* Create builder to contruct new setting with updated value for cpu i */
+ GVariantBuilder builder;
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+
+ for (guint i = 0; i < children_n; i++) {
+ if(cpu_i == i) {
+ gchar *color;
+ GdkRGBA button_color;
+ gsm_color_button_get_color(cp, &button_color);
+ color = gdk_rgba_to_string (&button_color);
+ g_variant_builder_add(&builder, "(us)", i, color);
+ g_free (color);
+ } else {
+ g_variant_builder_add_value(&builder,
+ g_variant_get_child_value(cpu_colors_var, i));
+ }
+ }
+
+ /* Just set the value and let the changed::cpu-colors signal callback do the rest. */
+ g_settings_set_value(settings, "cpu-colors", g_variant_builder_end(&builder));
+}
+
+static void change_settings_color(GSettings *settings, const char *key,
+ GSMColorButton *cp)
+{
+ GdkRGBA c;
+ char *color;
+
+ gsm_color_button_get_color(cp, &c);
+ color = gdk_rgba_to_string (&c);
+ g_settings_set_string (settings, key, color);
+ g_free (color);
+}
+
+static void
+cb_mem_color_changed (GSMColorButton *cp, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+ change_settings_color(app->settings, "mem-color", cp);
+}
+
+
+static void
+cb_swap_color_changed (GSMColorButton *cp, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+ change_settings_color(app->settings, "swap-color", cp);
+}
+
+static void
+cb_net_in_color_changed (GSMColorButton *cp, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+ change_settings_color(app->settings, "net-in-color", cp);
+}
+
+static void
+cb_net_out_color_changed (GSMColorButton *cp, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+ change_settings_color(app->settings, "net-out-color", cp);
+}
+
static void
create_sys_view (ProcmanApp *app, GtkBuilder * builder)
{
@@ -231,7 +304,49 @@ create_sys_view (ProcmanApp *app, GtkBuilder * builder)
static void
on_activate_about (GSimpleAction *, GVariant *, gpointer data)
{
- cb_about (NULL, data);
+ ProcmanApp *app = (ProcmanApp *) data;
+
+ const gchar * const authors[] = {
+ "Kevin Vandersloot",
+ "Erik Johnsson",
+ "Jorgen Scheibengruber",
+ "Benoît Dejean",
+ "Paolo Borelli",
+ "Karl Lattimer",
+ "Chris Kühl",
+ "Robert Roth",
+ NULL
+ };
+
+ const gchar * const documenters[] = {
+ "Bill Day",
+ "Sun Microsystems",
+ NULL
+ };
+
+ const gchar * const artists[] = {
+ "Baptiste Mille-Mathias",
+ NULL
+ };
+
+ gtk_show_about_dialog (
+ GTK_WINDOW (app->main_window),
+ "name", _("System Monitor"),
+ "comments", _("View current processes and monitor "
+ "system state"),
+ "version", VERSION,
+ "copyright", "Copyright \xc2\xa9 2001-2004 Kevin Vandersloot\n"
+ "Copyright \xc2\xa9 2005-2007 Benoît Dejean\n"
+ "Copyright \xc2\xa9 2011 Chris Kühl",
+ "logo-icon-name", "utilities-system-monitor",
+ "authors", authors,
+ "artists", artists,
+ "documenters", documenters,
+ "translator-credits", _("translator-credits"),
+ "license", "GPL 2+",
+ "wrap-license", TRUE,
+ NULL
+ );
}
static void
@@ -443,6 +558,16 @@ cb_change_current_page (GtkNotebook *notebook, GParamSpec *pspec, gpointer data)
update_page_activities ((ProcmanApp *)data);
}
+static gboolean
+cb_main_window_delete (GtkWidget *window, GdkEvent *event, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+
+ app->shutdown ();
+
+ return TRUE;
+}
+
void
create_main_window (ProcmanApp *app)
{
diff --git a/src/proctable.cpp b/src/proctable.cpp
index d01ef10..28ff1a3 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -212,6 +212,67 @@ cb_tree_popup_menu (GtkWidget *widget, gpointer data)
return TRUE;
}
+static void
+get_last_selected (GtkTreeModel *model, GtkTreePath *path,
+ GtkTreeIter *iter, gpointer data)
+{
+ ProcInfo **info = (ProcInfo**) data;
+
+ gtk_tree_model_get (model, iter, COL_POINTER, info, -1);
+}
+
+void
+cb_row_selected (GtkTreeSelection *selection, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+
+ app->selection = selection;
+
+ app->selected_process = NULL;
+
+ /* get the most recent selected process and determine if there are
+ ** no selected processes
+ */
+ gtk_tree_selection_selected_foreach (app->selection, get_last_selected,
+ &app->selected_process);
+ if (app->selected_process) {
+ GVariant *priority;
+ gint nice = app->selected_process->nice;
+ if (nice < -7)
+ priority = g_variant_new_string ("very-high");
+ else if (nice < -2)
+ priority = g_variant_new_string ("high");
+ else if (nice < 3)
+ priority = g_variant_new_string ("normal");
+ else if (nice < 7)
+ priority = g_variant_new_string ("low");
+ else
+ priority = g_variant_new_string ("very-low");
+
+ GAction *action = g_action_map_lookup_action (G_ACTION_MAP (app->main_window),
+ "priority");
+
+ g_action_change_state (action, priority);
+ }
+ update_sensitivity(app);
+}
+
+static void
+cb_refresh_icons (GtkIconTheme *theme, gpointer data)
+{
+ ProcmanApp *app = (ProcmanApp *) data;
+
+ if(app->timeout) {
+ g_source_remove (app->timeout);
+ }
+
+ for (ProcInfo::Iterator it(ProcInfo::begin()); it != ProcInfo::end(); ++it) {
+ app->pretty_table->set_icon(*(it->second));
+ }
+
+ cb_timeout(app);
+}
+
GtkWidget *
proctable_new (ProcmanApp * const app)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]