changeset 489:3809ffa3567b

Save state and width of exif, info and sort panels to rc file. Width is restored only if save windows dimensions is set.
author zas_
date Tue, 22 Apr 2008 22:44:10 +0000
parents a884e7fa26aa
children 2b85ad4c59bd
files src/bar_exif.c src/bar_info.c src/globals.c src/layout.c src/layout_util.c src/main.h src/rcfile.c src/typedefs.h
diffstat 8 files changed, 82 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/bar_exif.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/bar_exif.c	Tue Apr 22 22:44:10 2008 +0000
@@ -509,7 +509,7 @@
 	gtk_widget_destroy(eb->vbox);
 }
 
-static void bar_exif_size(ExifBar *eb, gint val)
+static void bar_exif_width(ExifBar *eb, gint val)
 {
 	gint size;
 
@@ -517,20 +517,21 @@
 	size = CLAMP(size + val, EXIF_BAR_SIZE_INCREMENT * 2, EXIF_BAR_SIZE_INCREMENT * 16);
 
 	gtk_widget_set_size_request(eb->vbox, size, -1);
+	options->panels.exif.width = eb->vbox->allocation.width;
 }
 
 static void bar_exif_larger(GtkWidget *widget, gpointer data)
 {
 	ExifBar *eb = data;
 
-	bar_exif_size(eb, EXIF_BAR_SIZE_INCREMENT);
+	bar_exif_width(eb, EXIF_BAR_SIZE_INCREMENT);
 }
 
 static void bar_exif_smaller(GtkWidget *widget, gpointer data)
 {
 	ExifBar *eb = data;
 
-	bar_exif_size(eb, -EXIF_BAR_SIZE_INCREMENT);
+	bar_exif_width(eb, -EXIF_BAR_SIZE_INCREMENT);
 }
 
 static void bar_exif_destroy(GtkWidget *widget, gpointer data)
--- a/src/bar_info.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/bar_info.c	Tue Apr 22 22:44:10 2008 +0000
@@ -1371,5 +1371,6 @@
 	if (bd->label_file_name)
 		{
 		gtk_widget_set_size_request(bd->vbox, width, -1);
+		options->panels.info.width = bd->vbox->allocation.width;
 		}
 }
--- a/src/globals.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/globals.c	Tue Apr 22 22:44:10 2008 +0000
@@ -106,6 +106,13 @@
 	options->mousewheel_scrolls = FALSE;
 	options->open_recent_list_maxsize = 10;
 	options->place_dialogs_under_mouse = FALSE;
+
+	options->panels.exif.enabled = FALSE;
+	options->panels.exif.width = PANEL_DEFAULT_WIDTH;
+	options->panels.info.enabled = FALSE;
+	options->panels.info.width = PANEL_DEFAULT_WIDTH;
+	options->panels.sort.enabled = FALSE;
+
 	options->progressive_key_scrolling = FALSE;
 	options->show_icon_names = TRUE;
 
--- a/src/layout.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/layout.c	Tue Apr 22 22:44:10 2008 +0000
@@ -1899,11 +1899,14 @@
 
 	lw->utility_box = NULL;
 	lw->bar_sort = NULL;
-	lw->bar_sort_enabled = FALSE;
+	lw->bar_sort_enabled = options->panels.sort.enabled;
+
 	lw->bar_exif = NULL;
-	lw->bar_exif_enabled = FALSE;
-	lw->bar_exif_size = -1;
+	lw->bar_exif_enabled = options->panels.exif.enabled;
 	lw->bar_exif_advanced = FALSE;
+	
+	lw->bar_info = NULL;
+	lw->bar_info_enabled = options->panels.info.enabled;
 
 	/* default layout */
 
@@ -1919,12 +1922,16 @@
 		lw->div_h = options->layout.main_window.hdivider_pos;
 		lw->div_v = options->layout.main_window.vdivider_pos;
 		lw->div_float = options->layout.float_window.vdivider_pos;
+		lw->bar_exif_width = options->panels.exif.width;
+		lw->bar_info_width = options->panels.info.width;
 		}
 	else
 		{
 		lw->div_h = MAIN_WINDOW_DIV_HPOS;
 		lw->div_v = MAIN_WINDOW_DIV_VPOS;
 		lw->div_float = MAIN_WINDOW_DIV_VPOS;
+		lw->bar_exif_width = PANEL_DEFAULT_WIDTH;
+		lw->bar_info_width = PANEL_DEFAULT_WIDTH;
 		}
 
 	/* window */
--- a/src/layout_util.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/layout_util.c	Tue Apr 22 22:44:10 2008 +0000
@@ -1623,8 +1623,6 @@
  *-----------------------------------------------------------------------------
  */
 
-#define SIDEBAR_WIDTH 288
-
 static void layout_bar_info_destroyed(GtkWidget *widget, gpointer data)
 {
 	LayoutWindow *lw = data;
@@ -1646,6 +1644,15 @@
 	return layout_selection_list(lw);
 }
 
+static void layout_bar_info_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
+{
+	LayoutWindow *lw = data;
+
+	if (!lw->bar_info) return;
+	
+	options->panels.info.width = lw->bar_info_width = allocation->width;
+}
+
 static void layout_bar_info_new(LayoutWindow *lw)
 {
 	if (!lw->utility_box) return;
@@ -1653,10 +1660,13 @@
 	lw->bar_info = bar_info_new(layout_image_get_fd(lw), FALSE, lw->utility_box);
 	bar_info_set_selection_func(lw->bar_info, layout_bar_info_list_cb, lw);
 	bar_info_selection(lw->bar_info, layout_selection_count(lw, NULL) - 1);
-	bar_info_size_request(lw->bar_info, SIDEBAR_WIDTH * 3 / 4);
 	g_signal_connect(G_OBJECT(lw->bar_info), "destroy",
 			 G_CALLBACK(layout_bar_info_destroyed), lw);
-	lw->bar_info_enabled = TRUE;
+	g_signal_connect(G_OBJECT(lw->bar_info), "size_allocate",
+			 G_CALLBACK(layout_bar_info_sized), lw);
+
+	options->panels.info.enabled = lw->bar_info_enabled = TRUE;
+	gtk_widget_set_size_request(lw->bar_info, lw->bar_info_width, -1);
 
 	gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_info, FALSE, FALSE, 0);
 	gtk_widget_show(lw->bar_info);
@@ -1669,7 +1679,7 @@
 		bar_info_close(lw->bar_info);
 		lw->bar_info = NULL;
 		}
-	lw->bar_info_enabled = FALSE;
+	options->panels.info.enabled = lw->bar_info_enabled = FALSE;
 }
 
 void layout_bar_info_toggle(LayoutWindow *lw)
@@ -1727,10 +1737,9 @@
 {
 	LayoutWindow *lw = data;
 
-	if (lw->bar_exif)
-		{
-		lw->bar_exif_size = allocation->width;
-		}
+	if (!lw->bar_exif) return;
+	
+	options->panels.exif.width = lw->bar_exif_width = allocation->width;
 }
 
 static void layout_bar_exif_new(LayoutWindow *lw)
@@ -1743,10 +1752,10 @@
 			 G_CALLBACK(layout_bar_exif_destroyed), lw);
 	g_signal_connect(G_OBJECT(lw->bar_exif), "size_allocate",
 			 G_CALLBACK(layout_bar_exif_sized), lw);
-	lw->bar_exif_enabled = TRUE;
 
-	if (lw->bar_exif_size < 1) lw->bar_exif_size = SIDEBAR_WIDTH;
-	gtk_widget_set_size_request(lw->bar_exif, lw->bar_exif_size, -1);
+	options->panels.exif.enabled = lw->bar_exif_enabled = TRUE;
+	gtk_widget_set_size_request(lw->bar_exif, lw->bar_exif_width, -1);
+
 	gtk_box_pack_start(GTK_BOX(lw->utility_box), lw->bar_exif, FALSE, FALSE, 0);
 	if (lw->bar_info) gtk_box_reorder_child(GTK_BOX(lw->utility_box), lw->bar_exif, 1);
 	gtk_widget_show(lw->bar_exif);
@@ -1759,7 +1768,7 @@
 		bar_exif_close(lw->bar_exif);
 		lw->bar_exif = NULL;
 		}
-	lw->bar_exif_enabled = FALSE;
+	options->panels.exif.enabled = lw->bar_exif_enabled = FALSE;
 }
 
 void layout_bar_exif_toggle(LayoutWindow *lw)
@@ -1803,7 +1812,7 @@
 	lw->bar_sort = bar_sort_new(lw);
 	g_signal_connect(G_OBJECT(lw->bar_sort), "destroy",
 			 G_CALLBACK(layout_bar_sort_destroyed), lw);
-	lw->bar_sort_enabled = TRUE;
+	options->panels.sort.enabled = lw->bar_sort_enabled = TRUE;
 
 	gtk_box_pack_end(GTK_BOX(lw->utility_box), lw->bar_sort, FALSE, FALSE, 0);
 	gtk_widget_show(lw->bar_sort);
@@ -1816,7 +1825,7 @@
 		bar_sort_close(lw->bar_sort);
 		lw->bar_sort = NULL;
 		}
-	lw->bar_sort_enabled = FALSE;
+	options->panels.sort.enabled = lw->bar_sort_enabled = FALSE;
 }
 
 void layout_bar_sort_toggle(LayoutWindow *lw)
--- a/src/main.h	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/main.h	Tue Apr 22 22:44:10 2008 +0000
@@ -101,6 +101,9 @@
 #define IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MIN 		1
 #define IMAGE_LOADER_IDLE_READ_LOOP_COUNT_MAX		16
 
+#define PANEL_MIN_WIDTH	64
+#define PANEL_DEFAULT_WIDTH 288
+#define PANEL_MAX_WIDTH 1200
 
 #define DEFAULT_OVERLAY_INFO 	"%collection%(%number%/%total%) [%zoom%] <b>%name%</b>\n" \
 				"%res%|%date%|%size%\n" \
--- a/src/rcfile.c	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/rcfile.c	Tue Apr 22 22:44:10 2008 +0000
@@ -369,6 +369,13 @@
 
 	WRITE_BOOL(layout.toolbar_hidden);
 
+	WRITE_SUBTITLE("Panels Options");
+
+	WRITE_BOOL(panels.exif.enabled);
+	WRITE_INT(panels.exif.width);
+	WRITE_BOOL(panels.info.enabled);
+	WRITE_INT(panels.info.width);
+	WRITE_BOOL(panels.sort.enabled);
 
 	WRITE_SUBTITLE("Image Options");
 
@@ -655,6 +662,12 @@
 		READ_BOOL(layout.tools_restore_state);
 		READ_BOOL(layout.toolbar_hidden);
 
+		/* panels */
+		READ_BOOL(panels.exif.enabled);
+		READ_INT_CLAMP(panels.exif.width, PANEL_MIN_WIDTH, PANEL_MAX_WIDTH);
+		READ_BOOL(panels.info.enabled);
+		READ_INT_CLAMP(panels.info.width, PANEL_MIN_WIDTH, PANEL_MAX_WIDTH);
+		READ_BOOL(panels.sort.enabled);
 
 		/* image options */
 		if (strcasecmp(option, "image.zoom_mode") == 0)
--- a/src/typedefs.h	Tue Apr 22 19:26:07 2008 +0000
+++ b/src/typedefs.h	Tue Apr 22 22:44:10 2008 +0000
@@ -541,8 +541,9 @@
 	gint bar_exif_enabled;
 	gint bar_info_enabled;
 
-	gint bar_exif_size;
+	gint bar_exif_width;
 	gint bar_exif_advanced;
+	gint bar_info_width;
 };
 
 struct _ViewDir
@@ -900,6 +901,24 @@
 
 	} layout;
 
+	/* panels */
+	struct {
+		struct {
+			gint enabled;
+			gint width;
+		} info;
+
+		struct {
+			gint enabled;
+			gint width;
+		} exif;
+
+		struct {
+			gint enabled;
+		} sort;
+	} panels;
+
+
 	/* color profiles */
 	struct {
 		gint enabled;