save/restore position of the window divider
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 25 Oct 2011 23:19:35 +0000 (23:19 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 25 Oct 2011 23:19:35 +0000 (23:19 +0000)
src/cfg.c
src/cfg.h
src/ui.c

index 73cc7e8..3e66927 100644 (file)
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -69,6 +69,8 @@
 #define KEY_INTERFACE_WINDOW_W "/apps/psensor/interface/window_w"
 #define KEY_INTERFACE_WINDOW_H "/apps/psensor/interface/window_h"
 
+#define KEY_INTERFACE_WINDOW_DIVIDER_POS \
+"/apps/psensor/interface/window_divider_pos"
 
 GConfClient *client;
 
@@ -480,6 +482,10 @@ struct config *config_load()
        c->window_h = gconf_client_get_int(client,
                                           KEY_INTERFACE_WINDOW_H,
                                           NULL);
+       c->window_divider_pos
+               = gconf_client_get_int(client,
+                                      KEY_INTERFACE_WINDOW_DIVIDER_POS,
+                                      NULL);
 
        if (!c->window_w || !c->window_h) {
                c->window_w = 800;
@@ -543,4 +549,9 @@ void config_save(struct config *c)
                             KEY_INTERFACE_WINDOW_H,
                             c->window_h,
                             NULL);
+
+       gconf_client_set_int(client,
+                            KEY_INTERFACE_WINDOW_DIVIDER_POS,
+                            c->window_divider_pos,
+                            NULL);
 }
index eebfc60..c9e3ef5 100644 (file)
--- a/src/cfg.h
+++ b/src/cfg.h
@@ -49,6 +49,8 @@ struct config {
        /* Last saved size of the window. */
        int window_w;
        int window_h;
+       /* Last saved position of the window divider. */
+       int window_divider_pos;
 
        int graph_update_interval;
        int graph_monitoring_duration;
index fa93fe3..ff5d8b1 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -53,6 +53,9 @@ static void save_window_pos(struct ui_psensor *ui)
                           cfg->window_w,
                           cfg->window_h);
 
+               cfg->window_divider_pos
+                       = gtk_paned_get_position(GTK_PANED(ui->sensor_box));
+
                config_save(cfg);
        }
 }
@@ -334,6 +337,10 @@ void ui_window_update(struct ui_psensor *ui)
                                GTK_WIDGET(ui->w_graph), TRUE, TRUE);
        }
 
+       gtk_paned_set_position(GTK_PANED(ui->sensor_box),
+                              ui->config->window_divider_pos);
+
+
        if (!init)
                g_object_unref(GTK_WIDGET(ui->ui_sensorlist->widget));