[gnome-system-monitor] Use an helper method for saving column size
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Use an helper method for saving column size
- Date: Wed, 24 Jul 2013 19:53:33 +0000 (UTC)
commit 38d2966df2d2e4fd04384ed237b2e1ad35ae3a99
Author: Stefano Facchini <stefano facchini gmail com>
Date: Wed Jul 24 17:41:18 2013 +0200
Use an helper method for saving column size
Instead of sharing the callback
https://bugzilla.gnome.org/show_bug.cgi?id=704800
src/callbacks.cpp | 23 -----------------------
src/callbacks.h | 2 --
src/disks.cpp | 7 +++++++
src/proctable.cpp | 7 +++++++
src/util.cpp | 18 ++++++++++++++++++
src/util.h | 2 ++
6 files changed, 34 insertions(+), 25 deletions(-)
---
diff --git a/src/callbacks.cpp b/src/callbacks.cpp
index 6c767bd..ed50620 100644
--- a/src/callbacks.cpp
+++ b/src/callbacks.cpp
@@ -55,26 +55,3 @@ cb_timeout (gpointer data)
return TRUE;
}
-
-void
-cb_column_resized(GtkWidget *widget, GParamSpec* param, gpointer data)
-{
- GSettings * settings = static_cast<GSettings *>(data);
- GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(widget);
- gint width;
- gchar *key;
- int id;
-
- gint saved_width;
-
- id = gtk_tree_view_column_get_sort_column_id (column);
- width = gtk_tree_view_column_get_width (column);
- key = g_strdup_printf ("col-%d-width", id);
-
- g_settings_get (settings, key, "i", &saved_width);
- if (saved_width!=width)
- {
- g_settings_set_int(settings, key, width);
- }
- g_free (key);
-}
diff --git a/src/callbacks.h b/src/callbacks.h
index 7d16344..b4cb914 100644
--- a/src/callbacks.h
+++ b/src/callbacks.h
@@ -26,6 +26,4 @@
gint cb_update_disks (gpointer data);
gint cb_timeout (gpointer data);
-void cb_column_resized (GtkWidget* column, GParamSpec* param, gpointer data);
-
#endif /* _PROCMAN_CALLBACKS_H_ */
diff --git a/src/disks.cpp b/src/disks.cpp
index a3ec25b..9a42a37 100644
--- a/src/disks.cpp
+++ b/src/disks.cpp
@@ -290,6 +290,13 @@ cb_disk_list_destroying (GtkWidget *self, gpointer data)
g_signal_handlers_disconnect_by_func(self, (gpointer) cb_disk_columns_changed, data);
}
+static void
+cb_column_resized (GtkWidget *column, GParamSpec *pspec, gpointer data)
+{
+ save_column_size (GTK_TREE_VIEW_COLUMN (column), G_SETTINGS (data));
+}
+
+
void
create_disk_view(ProcmanApp *app, GtkBuilder *builder)
{
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 28ff1a3..50f423a 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -273,6 +273,13 @@ cb_refresh_icons (GtkIconTheme *theme, gpointer data)
cb_timeout(app);
}
+static void
+cb_column_resized (GtkWidget *column, GParamSpec *pspec, gpointer data)
+{
+ save_column_size (GTK_TREE_VIEW_COLUMN (column), G_SETTINGS (data));
+}
+
+
GtkWidget *
proctable_new (ProcmanApp * const app)
{
diff --git a/src/util.cpp b/src/util.cpp
index f06745b..4db248f 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -652,4 +652,22 @@ namespace procman
}
+void
+save_column_size (GtkTreeViewColumn *column, GSettings *settings)
+{
+ int width;
+ char *key;
+ int id;
+ int saved_width;
+
+ id = gtk_tree_view_column_get_sort_column_id (column);
+ width = gtk_tree_view_column_get_width (column);
+ key = g_strdup_printf ("col-%d-width", id);
+
+ g_settings_get (settings, key, "i", &saved_width);
+ if (saved_width != width) {
+ g_settings_set_int (settings, key, width);
+ }
+ g_free (key);
+}
diff --git a/src/util.h b/src/util.h
index f55f821..cc643a6 100644
--- a/src/util.h
+++ b/src/util.h
@@ -167,5 +167,7 @@ namespace procman
std::string format_network_rate(guint64 rate, guint64 max_rate = 0);
}
+void save_column_size (GtkTreeViewColumn *column, GSettings *settings);
+
#endif /* H_GNOME_SYSTEM_MONITOR_UTIL_1123178725 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]