[gnome-video-arcade] Save "Properties" window state.



commit 857ea621d238ccece5e9b85c2a820f6b55a4be37
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat May 14 23:17:40 2011 -0400

    Save "Properties" window state.
    
    Save "Properties" window dimensions and position across sessions.
    Was previously using GConfBridge for this.  Less automated now.

 data/gnome-video-arcade.builder                |    2 +
 docs/reference/gnome-video-arcade-sections.txt |    2 +
 docs/reference/tmpl/gva-properties.sgml        |   20 +++++++
 src/gva-properties.c                           |   64 ++++++++++++++++++++++--
 src/gva-properties.h                           |    6 ++
 5 files changed, 89 insertions(+), 5 deletions(-)
---
diff --git a/data/gnome-video-arcade.builder b/data/gnome-video-arcade.builder
index e83d283..e90b84b 100644
--- a/data/gnome-video-arcade.builder
+++ b/data/gnome-video-arcade.builder
@@ -1205,8 +1205,10 @@
     <property name="destroy_with_parent">True</property>
     <property name="transient_for">main-window</property>
     <signal name="show" handler="gva_properties_show_cb" swapped="no"/>
+    <signal name="configure-event" handler="gva_properties_configure_event_cb" swapped="no"/>
     <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
     <signal name="hide" handler="gva_properties_hide_cb" swapped="no"/>
+    <signal name="window-state-event" handler="gva_properties_window_state_event_cb" swapped="no"/>
     <child>
       <object class="GtkVBox" id="properties-vbox">
         <property name="visible">True</property>
diff --git a/docs/reference/gnome-video-arcade-sections.txt b/docs/reference/gnome-video-arcade-sections.txt
index e57cac9..660fcb5 100644
--- a/docs/reference/gnome-video-arcade-sections.txt
+++ b/docs/reference/gnome-video-arcade-sections.txt
@@ -369,6 +369,8 @@ gva_properties_init
 gva_properties_show_game
 gva_properties_hide_cb
 gva_properties_show_cb
+gva_properties_configure_event_cb
+gva_properties_window_state_event_cb
 </SECTION>
 
 <SECTION>
diff --git a/docs/reference/tmpl/gva-properties.sgml b/docs/reference/tmpl/gva-properties.sgml
index 1a17e26..f6d46f9 100644
--- a/docs/reference/tmpl/gva-properties.sgml
+++ b/docs/reference/tmpl/gva-properties.sgml
@@ -52,3 +52,23 @@
 @window: 
 
 
+<!-- ##### FUNCTION gva_properties_configure_event_cb ##### -->
+<para>
+
+</para>
+
+ window: 
+ event: 
+ Returns: 
+
+
+<!-- ##### FUNCTION gva_properties_window_state_event_cb ##### -->
+<para>
+
+</para>
+
+ window: 
+ event: 
+ Returns: 
+
+
diff --git a/src/gva-properties.c b/src/gva-properties.c
index 8f2da71..dd5a895 100644
--- a/src/gva-properties.c
+++ b/src/gva-properties.c
@@ -796,11 +796,13 @@ gva_properties_init (void)
                 GVA_WIDGET_PROPERTIES_MUSIC_BUTTON, "notify::status",
                 G_CALLBACK (properties_notify_music_status_cb), NULL);
 
-#if 0 /* GSETTINGS */
-        gconf_bridge_bind_window (
-                gconf_bridge_get (), GVA_GCONF_PROPERTIES_PREFIX,
-                GTK_WINDOW (GVA_WIDGET_PROPERTIES_WINDOW), TRUE, FALSE);
-#endif
+        gtk_window_resize (
+                GTK_WINDOW (GVA_WIDGET_PROPERTIES_WINDOW),
+                g_settings_get_int (settings, "properties-width"),
+                g_settings_get_int (settings, "properties-height"));
+
+        if (g_settings_get_boolean (settings, "properties-maximized"))
+                gtk_window_maximize (GTK_WINDOW (GVA_WIDGET_PROPERTIES_WINDOW));
 
         font_name = gva_get_monospace_font_name ();
         desc = pango_font_description_from_string (font_name);
@@ -919,3 +921,55 @@ gva_properties_show_cb (GtkWindow *window)
 
         properties_scroll_to_top ();
 }
+
+/**
+ * gva_properties_configure_event_cb:
+ * @window: the "Properties" window
+ * @event: a #GdkEventConfigure
+ *
+ * Handler for #GtkWidget::configure-event signals to the "Properties"
+ * window.
+ *
+ * Saves the "Properties" window state to dconf.
+ *
+ * Returns: %FALSE always
+ **/
+gboolean
+gva_properties_configure_event_cb (GtkWindow *window,
+                                   GdkEventConfigure *event)
+{
+        gva_save_window_state (
+                window,
+                "properties-width",
+                "properties-height",
+                "properties-maximized",
+                NULL, NULL);
+
+        return FALSE;
+}
+
+/**
+ * gva_properties_window_state_event_cb:
+ * @window: the "Properties" window
+ * @event: a #GdkEventWindowState
+ *
+ * Handler for #GtkWidget::window-state-event signals to the "Properties"
+ * window.
+ *
+ * Saves the "Properties" window state to dconf.
+ *
+ * Returns: %FALSE always
+ **/
+gboolean
+gva_properties_window_state_event_cb (GtkWindow *window,
+                                      GdkEventWindowState *event)
+{
+        gva_save_window_state (
+                window,
+                "properties-width",
+                "properties-height",
+                "properties-maximized",
+                NULL, NULL);
+
+        return FALSE;
+}
diff --git a/src/gva-properties.h b/src/gva-properties.h
index 93fb801..5282cf7 100644
--- a/src/gva-properties.h
+++ b/src/gva-properties.h
@@ -37,6 +37,12 @@ void            gva_properties_show_game        (const gchar *game);
 
 void            gva_properties_hide_cb          (GtkWindow *window);
 void            gva_properties_show_cb          (GtkWindow *window);
+gboolean        gva_properties_configure_event_cb
+                                                (GtkWindow *window,
+                                                 GdkEventConfigure *event);
+gboolean        gva_properties_window_state_event_cb
+                                                (GtkWindow *window,
+                                                 GdkEventWindowState *event);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]