changeset 684:9f00d0d874fa

Save order of Properties dialog tabs to rc file. Users of GTK+ <2.10 can set tabs order directly in the rc file, others can move tabs using drag'n drop. The option is named properties.tabs_order, its default value is "123" which is General, Keywords, Exif tabs (left to right).
author zas_
date Sun, 18 May 2008 21:14:01 +0000
parents fece9ff5c624
children f20e7cebcb12
files src/info.c src/info.h src/main.c src/options.h src/rcfile.c
diffstat 5 files changed, 94 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/info.c	Sun May 18 12:56:18 2008 +0000
+++ b/src/info.c	Sun May 18 21:14:01 2008 +0000
@@ -488,20 +488,94 @@
 	return -1;
 }
 
+static gpointer info_tab_new_funcs[] = {
+	info_tab_general_new,
+	info_tab_meta_new,
+	info_tab_exif_new,
+};
+
+gchar *info_tab_default_order(void)
+{
+	gint i;
+	static gchar str[G_N_ELEMENTS(info_tab_new_funcs) + 1];
+
+	for (i = 0; i < G_N_ELEMENTS(info_tab_new_funcs); i++)
+		str[i] = i + '1';
+	str[i] = '\0';
+
+	return str;
+}
+
+static void info_tab_get_order_string(gchar **dest)
+{
+	GList *work;
+	gchar str[G_N_ELEMENTS(info_tab_new_funcs) + 1];
+
+	g_assert(dest);
+
+	if (!info_tabs_pos_list)
+		return;
+	
+	memset(str, 0, G_N_ELEMENTS(info_tab_new_funcs) + 1);
+
+	work = info_tabs_pos_list;
+	while (work)
+		{
+		gint i;
+		InfoTabsPos *t = work->data;
+		work = work->next;
+
+		for (i = 0; i < G_N_ELEMENTS(info_tab_new_funcs); i++)
+			{
+			if (t->func == info_tab_new_funcs[i])
+				{
+				g_assert(t->pos >= 0 && t->pos < G_N_ELEMENTS(info_tab_new_funcs));
+				str[t->pos] = i + '1';
+				}
+			}
+		}
+	
+	if (strlen(str) != G_N_ELEMENTS(info_tab_new_funcs)) return;
+
+	g_free(*dest);
+	*dest = g_strdup(str);
+}
+
 static void info_tabs_init(InfoData *id)
 {
 	GList *work;
 
 	if (!info_tabs_pos_list)
 		{
-		/* First run, default tabs order is defined here. */
-		info_tabs_pos_list_append(info_tab_general_new);
-		info_tabs_pos_list_append(info_tab_meta_new);
-		info_tabs_pos_list_append(info_tab_exif_new);
+		gint count = 0;
+		gint i;
+		gchar *order = options->properties.tabs_order;
+		
+		for (i = 0; i < strlen(order); i++)
+			{
+			gint n = order[i] - '1';
+
+			if (n < 0 || n >= G_N_ELEMENTS(info_tab_new_funcs)) break;
+			count++;
+			}
+
+		if (count != G_N_ELEMENTS(info_tab_new_funcs))
+			order = info_tab_default_order();
+
+		for (i = 0; i < strlen(order); i++)
+			{
+			gint n = order[i] - '1';
+
+			if (n < 0 || n >= G_N_ELEMENTS(info_tab_new_funcs)) continue;
+			if (g_list_find(info_tabs_pos_list, info_tab_new_funcs[n])) continue;
+			info_tabs_pos_list_append(info_tab_new_funcs[n]);
+			}
 		}
 	else
 		info_tabs_pos_list = g_list_sort(info_tabs_pos_list, compare_info_tabs_pos);
 
+	info_tab_get_order_string(&options->properties.tabs_order);
+
 	work = info_tabs_pos_list;
 	while (work)
 		{
@@ -568,6 +642,9 @@
 				}
 			}
 		}
+	
+	info_tabs_pos_list = g_list_sort(info_tabs_pos_list, compare_info_tabs_pos);
+	info_tab_get_order_string(&options->properties.tabs_order);
 }
 
 /*
--- a/src/info.h	Sun May 18 12:56:18 2008 +0000
+++ b/src/info.h	Sun May 18 21:14:01 2008 +0000
@@ -45,5 +45,6 @@
 GtkWidget *table_add_line(GtkWidget *table, gint x, gint y,
 			  const gchar *description, const gchar *text);
 
+gchar *info_tab_default_order(void);
 
 #endif
--- a/src/main.c	Sun May 18 12:56:18 2008 +0000
+++ b/src/main.c	Sun May 18 21:14:01 2008 +0000
@@ -23,6 +23,7 @@
 #include "fullscreen.h"
 #include "image-overlay.h"
 #include "img-view.h"
+#include "info.h"
 #include "layout.h"
 #include "layout_image.h"
 #include "menu.h"
@@ -578,6 +579,7 @@
 	set_default_image_overlay_template_string(options);
 	sidecar_ext_add_defaults();
 	options->layout.order = g_strdup("123");
+	options->properties.tabs_order = g_strdup(info_tab_default_order());
 }
 
 static void exit_program_final(void)
--- a/src/options.h	Sun May 18 12:56:18 2008 +0000
+++ b/src/options.h	Sun May 18 21:14:01 2008 +0000
@@ -207,6 +207,10 @@
 		} sort;
 	} panels;
 
+	/* properties dialog */
+	struct {
+		gchar *tabs_order;
+	} properties;
 
 	/* color profiles */
 	struct {
--- a/src/rcfile.c	Sun May 18 12:56:18 2008 +0000
+++ b/src/rcfile.c	Sun May 18 21:14:01 2008 +0000
@@ -418,6 +418,9 @@
 	WRITE_INT(panels.sort.mode_state);
 	WRITE_INT(panels.sort.selection_state);
 
+	WRITE_SUBTITLE("Properties dialog Options");
+	WRITE_CHAR(properties.tabs_order);
+
 	WRITE_SUBTITLE("Image Options");
 
 	secure_fprintf(ssi, "# image.zoom_mode possible values are:\n"
@@ -727,6 +730,9 @@
 		READ_INT(panels.sort.mode_state);
 		READ_INT(panels.sort.selection_state);
 
+		/* properties dialog options */
+		READ_CHAR(properties.tabs_order);
+
 		/* image options */
 		if (g_ascii_strcasecmp(option, "image.zoom_mode") == 0)
 			{