[Xfce4-commits] <xfce4-settings:jeromeg/settings-editor> Remember the size and layout of the editor window.

Jérôme Guelfucci noreply at xfce.org
Mon Dec 21 14:28:02 CET 2009


Updating branch refs/heads/jeromeg/settings-editor
         to e1ddb79f30fbe1ee07a7b80315dd489218199552 (commit)
       from 20c905367bd298fd02144101c76ee8a88b7058e7 (commit)

commit e1ddb79f30fbe1ee07a7b80315dd489218199552
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Mon Dec 21 14:29:27 2009 +0100

    Remember the size and layout of the editor window.

 xfce4-settings-editor/main.c                      |    2 -
 xfce4-settings-editor/main_window.c               |   40 +++++++++++++++++++++
 xfce4-settings-editor/xfce4-settings-editor.glade |    5 +--
 3 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/xfce4-settings-editor/main.c b/xfce4-settings-editor/main.c
index c1971d0..8c6dcab 100644
--- a/xfce4-settings-editor/main.c
+++ b/xfce4-settings-editor/main.c
@@ -100,8 +100,6 @@ main(gint argc, gchar **argv)
 
     gtk_dialog_run (dialog);
 
-    gtk_widget_destroy (GTK_WIDGET (dialog));
-
     /* shutdown xfconf */
     xfconf_shutdown ();
 
diff --git a/xfce4-settings-editor/main_window.c b/xfce4-settings-editor/main_window.c
index d293067..f201186 100644
--- a/xfce4-settings-editor/main_window.c
+++ b/xfce4-settings-editor/main_window.c
@@ -36,6 +36,10 @@
 #include "xfce4-settings-editor_ui.h"
 #include "main_window.h"
 
+#define WINDOW_WIDTH 600
+#define WINDOW_HEIGHT 380
+#define HPANED_POSITION 200
+
 static GtkBuilder *builder = NULL;
 static XfconfChannel *current_channel = NULL;
 static gchar *current_property = NULL;
@@ -70,15 +74,20 @@ static void
 cb_property_edit_button_clicked (GtkButton *button, gpointer user_data);
 static void
 cb_property_revert_button_clicked (GtkButton *button, gpointer user_data);
+static void
+xfce_settings_editor_dialog_response (GtkWidget *dialog, gint response, gpointer user_data);
 
 
 
 GtkDialog *
 xfce4_settings_editor_main_window_new(void)
 {
+    gint width, height, position;
     GObject *dialog;
     GObject *channel_treeview;
     GObject *property_treeview;
+    GObject *hpaned;
+    XfconfChannel *channel;
     GtkListStore *channel_list_store;
     GtkTreeStore *property_tree_store;
     GtkCellRenderer *renderer;
@@ -101,6 +110,19 @@ xfce4_settings_editor_main_window_new(void)
     {
         dialog = gtk_builder_get_object (builder, "main_dialog");
     }
+
+    hpaned = gtk_builder_get_object (builder, "hpaned2");
+
+    /* Set the default size of the window */
+    channel = xfconf_channel_get ("xfce4-settings-editor");
+    width = xfconf_channel_get_int (channel, "/window-width", WINDOW_WIDTH);
+    height = xfconf_channel_get_int (channel, "/window-height", WINDOW_HEIGHT);
+    position = xfconf_channel_get_int (channel, "/hpaned-position", HPANED_POSITION);
+    gtk_window_set_default_size (GTK_WINDOW (dialog), width, height);
+    gtk_paned_set_position (GTK_PANED (hpaned), position);
+
+    g_signal_connect (dialog, "response", G_CALLBACK (xfce_settings_editor_dialog_response), NULL);
+
     channel_treeview = gtk_builder_get_object (builder, "channel_treeview");
     property_treeview = gtk_builder_get_object (builder, "property_treeview");
 
@@ -704,3 +726,21 @@ cb_property_revert_button_clicked (GtkButton *button, gpointer user_data)
 
     gtk_widget_destroy (dialog);
 }
+
+static void
+xfce_settings_editor_dialog_response (GtkWidget *dialog, gint response, gpointer user_data)
+{
+    XfconfChannel *channel;
+    gint width, height;
+    GObject *hpaned;
+
+    hpaned = gtk_builder_get_object (builder, "hpaned2");
+
+    channel = xfconf_channel_get ("xfce4-settings-editor");
+    gtk_window_get_size (GTK_WINDOW (dialog), &width, &height);
+    xfconf_channel_set_int (channel, "/window-width", width);
+    xfconf_channel_set_int (channel, "/window-height", height);
+    xfconf_channel_set_int (channel, "/hpaned-position", gtk_paned_get_position (GTK_PANED (hpaned)));
+
+    gtk_widget_destroy (dialog);
+}
diff --git a/xfce4-settings-editor/xfce4-settings-editor.glade b/xfce4-settings-editor/xfce4-settings-editor.glade
index 46763db..a552131 100644
--- a/xfce4-settings-editor/xfce4-settings-editor.glade
+++ b/xfce4-settings-editor/xfce4-settings-editor.glade
@@ -244,8 +244,6 @@
     </action-widgets>
   </object>
   <object class="XfceTitledDialog" id="main_dialog">
-    <property name="width_request">600</property>
-    <property name="height_request">380</property>
     <property name="title" translatable="yes">Settings Editor</property>
     <property name="icon_name">preferences-system</property>
     <property name="type_hint">normal</property>
@@ -265,7 +263,6 @@
               <object class="GtkHPaned" id="hpaned2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="position">200</property>
                 <property name="position_set">True</property>
                 <child>
                   <object class="GtkScrolledWindow" id="scrolledwindow3">
@@ -406,7 +403,7 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button1</action-widget>
+      <action-widget response="-7">button1</action-widget>
     </action-widgets>
   </object>
 </interface>



More information about the Xfce4-commits mailing list