From a91e05fb7359ae2b357898d6d7318e2b2f440f80 Mon Sep 17 00:00:00 2001 From: Harald Judt Date: Fri, 19 Dec 2014 15:56:48 +0100 Subject: [PATCH] Save and restore the handle position across restarts --- src/process-window-gtk3.ui | 2 +- src/process-window.c | 24 ++++++++++++++++++++---- src/process-window.ui | 2 +- src/settings.c | 3 +++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/process-window-gtk3.ui b/src/process-window-gtk3.ui index 83ce1aa..2ecaf82 100644 --- a/src/process-window-gtk3.ui +++ b/src/process-window-gtk3.ui @@ -111,7 +111,7 @@ - + True True vertical diff --git a/src/process-window.c b/src/process-window.c index a9d1ba2..fd18e2c 100644 --- a/src/process-window.c +++ b/src/process-window.c @@ -50,6 +50,7 @@ struct _XtmProcessWindow GtkWidget * filter_entry; GtkWidget * cpu_monitor; GtkWidget * mem_monitor; + GtkWidget * vpaned; GtkWidget * treeview; GtkWidget * statusbar; GtkWidget * exec_button; @@ -146,8 +147,16 @@ xtm_process_window_init (XtmProcessWindow *window) { GtkWidget *toolitem; guint refresh_rate; + gint handle_position; - g_object_get (window->settings, "refresh-rate", &refresh_rate, NULL); + g_object_get (window->settings, + "refresh-rate", &refresh_rate, + "handle-position", &handle_position, + NULL); + + window->vpaned = GTK_WIDGET (gtk_builder_get_object (window->builder, "mainview-vpaned")); + if (handle_position > -1) + gtk_paned_set_position (GTK_PANED (window->vpaned), handle_position); toolitem = GTK_WIDGET (gtk_builder_get_object (window->builder, "graph-cpu")); window->cpu_monitor = xtm_process_monitor_new (); @@ -211,15 +220,22 @@ xtm_process_window_finalize (GObject *object) if (GTK_IS_WINDOW (window->window)) { - gint width, height; + gint width, height, handle_position; guint sort_column_id; GtkSortType sort_type; gtk_window_get_size (GTK_WINDOW (window->window), &width, &height); xtm_process_tree_view_get_sort_column_id (XTM_PROCESS_TREE_VIEW (window->treeview), (gint*)&sort_column_id, &sort_type); - g_object_set (window->settings, "window-width", width, "window-height", height, - "sort-column-id", sort_column_id, "sort-type", sort_type, NULL); + handle_position = gtk_paned_get_position (GTK_PANED (window->vpaned)); + + g_object_set (window->settings, + "window-width", width, + "window-height", height, + "sort-column-id", sort_column_id, + "sort-type", sort_type, + "handle-position", handle_position, + NULL); } if (GTK_IS_TREE_VIEW (window->treeview)) diff --git a/src/process-window.ui b/src/process-window.ui index 00d02b4..beb00c1 100644 --- a/src/process-window.ui +++ b/src/process-window.ui @@ -113,7 +113,7 @@ - + True True 100 diff --git a/src/settings.c b/src/settings.c index 1e9dc12..7c2268e 100644 --- a/src/settings.c +++ b/src/settings.c @@ -55,6 +55,7 @@ enum PROP_SORT_TYPE, PROP_WINDOW_WIDTH, PROP_WINDOW_HEIGHT, + PROP_HANDLE_POSITION, PROP_PROCESS_TREE, N_PROPS, }; @@ -133,6 +134,8 @@ xtm_settings_class_init (XtmSettingsClass *klass) g_param_spec_int ("window-width", "WindowWidth", "Window width", -1, G_MAXINT, -1, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_WINDOW_HEIGHT, g_param_spec_int ("window-height", "WindowHeight", "Window height", -1, G_MAXINT, -1, G_PARAM_READWRITE)); + g_object_class_install_property (class, PROP_HANDLE_POSITION, + g_param_spec_int ("handle-position", "HandlePosition", "Handle position", -1, G_MAXINT, -1, G_PARAM_READWRITE)); g_object_class_install_property (class, PROP_PROCESS_TREE, g_param_spec_boolean ("process-tree", "ProcessTreeView", "Process tree", FALSE, G_PARAM_READWRITE)); }