]> Pileus Git - aweather/commitdiff
Save and restore window size
authorAndy Spencer <andy753421@gmail.com>
Sat, 4 Feb 2012 07:55:09 +0000 (07:55 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 4 Feb 2012 07:56:06 +0000 (07:56 +0000)
data/main.ui.in
src/aweather-gui.c

index cd9d2160956e5849ca6a808b022cfc34e01f123d..54245ceb13ce54050b450bb90b914a342cf10d25 100644 (file)
@@ -361,6 +361,7 @@ The hypothetical commands `show w' and `show c' should show the appropriate part
     <property name="title" translatable="yes">AWeather</property>
     <property name="default_width">600</property>
     <property name="default_height">400</property>
+    <signal name="configure-event" handler="on_configure" swapped="no"/>
     <child>
       <object class="GtkVBox" id="main_body">
         <property name="visible">True</property>
index 9c88987f8eff424d7bd7282de98809366fe983eb..fcaf87c71ab2857d845990d00c677a780aabf357 100644 (file)
@@ -317,6 +317,14 @@ static void update_time_widget(GritsViewer *viewer, time_t time, AWeatherGui *se
        //}
 }
 
+G_MODULE_EXPORT gboolean on_configure(AWeatherGui *self, GdkEventConfigure *config)
+{
+       g_debug("AWeatherGui: on_configure - %dx%d", config->width, config->height);
+       grits_prefs_set_integer(self->prefs, "aweather/width",  config->width);
+       grits_prefs_set_integer(self->prefs, "aweather/height", config->height);
+       return FALSE;
+}
+
 /* Prefs callbacks */
 G_MODULE_EXPORT void on_offline(GtkToggleAction *action, AWeatherGui *self)
 {
@@ -617,6 +625,12 @@ static void aweather_gui_parser_finished(GtkBuildable *_self, GtkBuilder *builde
        prefs_setup(self);
        icons_setup(self);
 
+       /* Default size */
+       gint width  = grits_prefs_get_integer(self->prefs, "aweather/width",  NULL);
+       gint height = grits_prefs_get_integer(self->prefs, "aweather/height", NULL);
+       if (width && height)
+               gtk_window_set_default_size(GTK_WINDOW(self), width, height);
+
        /* Connect signals */
        gtk_builder_connect_signals(self->builder, self);
        g_signal_connect(self, "key-press-event",