[gnome-system-monitor] Save column info on change instead of quit (bug 649398)
- From: Chris KÃhl <chriskuehl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Save column info on change instead of quit (bug 649398)
- Date: Tue, 8 Nov 2011 08:45:40 +0000 (UTC)
commit bc2a8c221604fe335b690ba7d180022bf0430fff
Author: Robert Roth <robert roth off gmail com>
Date: Sun Nov 6 07:10:51 2011 +0200
Save column info on change instead of quit (bug 649398)
src/procdialogs.cpp | 9 +++++++++
src/procman.cpp | 27 +--------------------------
src/proctable.cpp | 26 +++++++++++++++++++++++++-
3 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/src/procdialogs.cpp b/src/procdialogs.cpp
index b3fb209..aa5b53f 100644
--- a/src/procdialogs.cpp
+++ b/src/procdialogs.cpp
@@ -377,6 +377,9 @@ field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
GtkTreeIter iter;
GtkTreeViewColumn *column;
gboolean toggled;
+ GSettings *settings = g_settings_get_child (ProcData::get_instance()->settings, "proctree");
+ gchar *key;
+ int id;
if (!path)
return;
@@ -389,6 +392,12 @@ field_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data)
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !toggled, -1);
gtk_tree_view_column_set_visible (column, !toggled);
+ id = gtk_tree_view_column_get_sort_column_id (column);
+
+ key = g_strdup_printf ("col-%d-visible", id);
+ g_settings_set_boolean (settings, key, !toggled);
+ g_free (key);
+
gtk_tree_path_free (path);
}
diff --git a/src/procman.cpp b/src/procman.cpp
index 1ecfd0d..bf58b79 100644
--- a/src/procman.cpp
+++ b/src/procman.cpp
@@ -445,7 +445,7 @@ void
procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *child_schema)
{
GtkTreeModel *model;
- GList *it, *columns;
+ GList *columns;
gint sort_col;
GtkSortType order;
@@ -463,31 +463,6 @@ procman_save_tree_state (GSettings *settings, GtkWidget *tree, const gchar *chil
columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (tree));
- if(!g_strcmp0(child_schema, "proctree"))
- {
- for(it = columns; it; it = it->next)
- {
- GtkTreeViewColumn *column;
- gboolean visible;
- gint width;
- gchar *key;
- int id;
-
- column = static_cast<GtkTreeViewColumn*>(it->data);
- id = gtk_tree_view_column_get_sort_column_id (column);
- visible = gtk_tree_view_column_get_visible (column);
- width = gtk_tree_view_column_get_width (column);
-
- key = g_strdup_printf ("col-%d-width", id);
- g_settings_set_int (pt_settings, key, width);
- g_free (key);
-
- key = g_strdup_printf ("col-%d-visible", id);
- g_settings_set_boolean (pt_settings, key, visible);
- g_free (key);
- }
- }
-
if(!g_strcmp0(child_schema, "proctree") || !g_strcmp0(child_schema, "disktreenew"))
{
GSList *order;
diff --git a/src/proctable.cpp b/src/proctable.cpp
index 473094a..2429373 100644
--- a/src/proctable.cpp
+++ b/src/proctable.cpp
@@ -168,6 +168,28 @@ proctable_get_columns_order(GtkTreeView *treeview)
return order;
}
+void
+cb_proctable_column_resized(GtkWidget *widget)
+{
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(widget);
+ gint width;
+ gchar *key;
+ int id;
+ GSettings *settings;
+ gint saved_width;
+
+ settings = g_settings_get_child (ProcData::get_instance()->settings, "proctree");
+ 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);
+}
static gboolean
search_equal_func(GtkTreeModel *model,
@@ -292,6 +314,7 @@ proctable_new (ProcData * const procdata)
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_min_width (column, 1);
+ g_signal_connect(G_OBJECT(column), "notify::width", G_CALLBACK(cb_proctable_column_resized), NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (proctree), column);
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (proctree), column);
@@ -307,6 +330,7 @@ proctable_new (ProcData * const procdata)
gtk_tree_view_column_set_title(col, _(titles[i]));
gtk_tree_view_column_set_resizable(col, TRUE);
gtk_tree_view_column_set_sort_column_id(col, i);
+ g_signal_connect(G_OBJECT(col), "notify::width", G_CALLBACK(cb_proctable_column_resized), NULL);
gtk_tree_view_column_set_reorderable(col, TRUE);
gtk_tree_view_append_column(GTK_TREE_VIEW(proctree), col);
@@ -356,7 +380,7 @@ proctable_new (ProcData * const procdata)
break;
}
- // xaling
+ // xalign
switch(i)
{
case COL_VMSIZE:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]