Save properties window width and height to rc file and restore
authorLaurent Monin <geeqie@norz.org>
Thu, 29 May 2008 07:52:05 +0000 (07:52 +0000)
committerLaurent Monin <geeqie@norz.org>
Thu, 29 May 2008 07:52:05 +0000 (07:52 +0000)
them on next session if layout.save_window_positions is set to TRUE.

src/info.c
src/info.h
src/options.c
src/options.h
src/rcfile.c

index 3c523d3..2e5160d 100644 (file)
@@ -33,8 +33,6 @@
 #define IMAGE_SIZE_W 200
 #define IMAGE_SIZE_H 200
 
-#define DEF_PROPERTY_WIDTH  600
-#define DEF_PROPERTY_HEIGHT 400
 
 typedef struct _TabData TabData;
 struct _TabData
@@ -716,9 +714,6 @@ static void info_window_dnd_init(InfoData *id)
  *-------------------------------------------------------------------
  */
 
-static gint info_window_last_width = DEF_PROPERTY_WIDTH;
-static gint info_window_last_height = DEF_PROPERTY_HEIGHT;
-
 static void info_window_image_update_cb(ImageWindow *imd, gpointer data)
 {
        InfoData *id = data;
@@ -798,9 +793,9 @@ static void info_window_image_scroll_cb(ImageWindow *imd, GdkScrollDirection dir
 
 static void info_window_close(InfoData *id)
 {
-       gdk_drawable_get_size(id->window->window, &info_window_last_width, &info_window_last_height);
-       info_window_last_width = MAX(info_window_last_width, DEF_PROPERTY_WIDTH);
-       info_window_last_height = MAX(info_window_last_height, DEF_PROPERTY_HEIGHT);
+       gdk_drawable_get_size(id->window->window, &options->layout.properties_window.w, &options->layout.properties_window.h);
+       options->layout.properties_window.w = MAX(options->layout.properties_window.w, DEF_PROPERTY_WIDTH);
+       options->layout.properties_window.h = MAX(options->layout.properties_window.h, DEF_PROPERTY_HEIGHT);
 
        gtk_widget_destroy(id->window);
 }
@@ -871,8 +866,11 @@ void info_window_new(FileData *fd, GList *list, GtkWidget *parent)
        gtk_window_set_geometry_hints(GTK_WINDOW(id->window), NULL, &geometry,
                                      GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
 
+       if (options->layout.save_window_positions)
+               gtk_window_set_default_size(GTK_WINDOW(id->window), options->layout.properties_window.w, options->layout.properties_window.h);
+       else
+               gtk_window_set_default_size(GTK_WINDOW(id->window), DEF_PROPERTY_WIDTH, DEF_PROPERTY_HEIGHT);
 
-       gtk_window_set_default_size(GTK_WINDOW(id->window), info_window_last_width, info_window_last_height);
        gtk_container_set_border_width(GTK_CONTAINER(id->window), PREF_PAD_BORDER);
 
        g_signal_connect(G_OBJECT(id->window), "delete_event",
index 167ac8b..d9c38de 100644 (file)
@@ -14,6 +14,9 @@
 #ifndef INFO_H
 #define INFO_H
 
+#define DEF_PROPERTY_WIDTH  600
+#define DEF_PROPERTY_HEIGHT 400
+
 
 typedef struct _InfoData InfoData;
 struct _InfoData
index 1ed7022..bfcbd51 100644 (file)
@@ -102,6 +102,8 @@ ConfOptions *init_options(ConfOptions *options)
        options->layout.main_window.x = 0;
        options->layout.main_window.y = 0;
        options->layout.order = NULL;
+       options->layout.properties_window.w = DEF_PROPERTY_WIDTH;
+       options->layout.properties_window.h = DEF_PROPERTY_HEIGHT;
        options->layout.save_window_positions = FALSE;
        options->layout.show_marks = FALSE;
        options->layout.show_thumbnails = FALSE;
index 32709b9..6f5d0d0 100644 (file)
@@ -182,6 +182,11 @@ struct _ConfOptions
                        gint vdivider_pos;
                } float_window;
 
+               struct {
+                       gint w;
+                       gint h;
+               } properties_window;
+
                gint save_window_positions;
 
                gint tools_float;
index 202ee0d..4f25dfd 100644 (file)
@@ -396,6 +396,10 @@ static gboolean save_options_to(const gchar *utf8_path, ConfOptions *options)
        WRITE_INT(layout.float_window.vdivider_pos);
        WRITE_SEPARATOR();
 
+       WRITE_INT(layout.properties_window.w);
+       WRITE_INT(layout.properties_window.h);
+       WRITE_SEPARATOR();
+
        WRITE_BOOL(layout.tools_float);
        WRITE_BOOL(layout.tools_hidden);
        WRITE_BOOL(layout.tools_restore_state);
@@ -733,13 +737,18 @@ static gboolean load_options_from(const gchar *utf8_path, ConfOptions *options)
                READ_INT(layout.main_window.w);
                READ_INT(layout.main_window.h);
                READ_BOOL(layout.main_window.maximized);
+               READ_INT(layout.main_window.hdivider_pos);
+               READ_INT(layout.main_window.vdivider_pos);
+
                READ_INT(layout.float_window.x);
                READ_INT(layout.float_window.y);
                READ_INT(layout.float_window.w);
                READ_INT(layout.float_window.h);
                READ_INT(layout.float_window.vdivider_pos);
-               READ_INT(layout.main_window.hdivider_pos);
-               READ_INT(layout.main_window.vdivider_pos);
+       
+               READ_INT(layout.properties_window.w);
+               READ_INT(layout.properties_window.h);
+
                READ_BOOL(layout.tools_float);
                READ_BOOL(layout.tools_hidden);
                READ_BOOL(layout.tools_restore_state);