Skip to content

Commit

Permalink
Save properties window width and height to rc file and restore
Browse files Browse the repository at this point in the history
them on next session if layout.save_window_positions is set to TRUE.
  • Loading branch information
Laurent Monin committed May 29, 2008
1 parent f89fbbf commit 05f3eb8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 11 additions & 2 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 05f3eb8

Please sign in to comment.