[gthumb/ext: 71/79] added ability to specify the thumbnail caption



commit e31a1d8c5dd1804c5151131674122b77b8f9cdf5
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Jul 25 18:48:11 2009 +0200

    added ability to specify the thumbnail caption

 data/gthumb.schemas.in     |   13 ++++++
 data/ui/preferences.ui     |   41 ++++++++++++++++++-
 extensions/comments/main.c |    2 +-
 gthumb/dlg-preferences.c   |   95 ++++++++++++++++++++++++++++++++++++++++---
 gthumb/gth-browser.c       |   46 +++++++++++++++++++--
 gthumb/gth-file-list.c     |   53 +++++++++++++++++++++++-
 gthumb/gth-file-list.h     |    2 +
 gthumb/gth-main.c          |   30 +++++++++++++-
 gthumb/gth-preferences.h   |    3 +-
 9 files changed, 265 insertions(+), 20 deletions(-)
---
diff --git a/data/gthumb.schemas.in b/data/gthumb.schemas.in
index e846034..51c31d7 100644
--- a/data/gthumb.schemas.in
+++ b/data/gthumb.schemas.in
@@ -204,6 +204,19 @@
       </schema>
 
       <schema>
+	<key>/schemas/apps/gthumb/browser/thumbnail_caption</key>
+	<applyto>/apps/gthumb/browser/thumbnail_caption</applyto>
+	<owner>gthumb</owner>
+	<type>string</type>
+	<default>standard::display-name</default>
+	<locale name="C">
+	  <short></short>
+	  <long>
+	  </long>
+	</locale>
+      </schema>
+
+      <schema>
 	<key>/schemas/apps/gthumb/browser/confirm_deletion</key>
 	<applyto>/apps/gthumb/browser/confirm_deletion</applyto>
 	<owner>gthumb</owner>
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index df7e7be..27ad77a 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -11,6 +11,7 @@
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox4">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">8</property>
         <child>
           <object class="GtkNotebook" id="notebook">
@@ -21,10 +22,12 @@
               <object class="GtkVBox" id="vbox11">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox25">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkHBox" id="hbox66">
@@ -95,6 +98,7 @@
                 <child>
                   <object class="GtkVBox" id="vbox26">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkHBox" id="hbox34">
@@ -125,6 +129,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox8">
                             <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkRadioButton" id="current_location_radiobutton">
@@ -181,8 +186,8 @@
                                 <child>
                                   <object class="GtkFileChooserButton" id="startup_dir_filechooserbutton">
                                     <property name="visible">True</property>
-                                    <property name="local_only">False</property>
                                     <property name="action">select-folder</property>
+                                    <property name="local_only">False</property>
                                     <property name="title" translatable="yes">Choose startup folder</property>
                                   </object>
                                   <packing>
@@ -236,6 +241,7 @@
                 <child>
                   <object class="GtkVBox" id="vbox57">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkHBox" id="hbox110">
@@ -267,6 +273,7 @@
                         <child>
                           <object class="GtkVBox" id="vbox10">
                             <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <child>
                               <object class="GtkCheckButton" id="confirm_deletion_checkbutton">
@@ -327,14 +334,17 @@
               <object class="GtkVBox" id="vbox12">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
+                <property name="orientation">vertical</property>
                 <property name="spacing">12</property>
                 <child>
                   <object class="GtkVBox" id="vbox30">
                     <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
                     <property name="spacing">6</property>
                     <child>
                       <object class="GtkTable" id="table14">
                         <property name="visible">True</property>
+                        <property name="n_rows">2</property>
                         <property name="n_columns">2</property>
                         <property name="column_spacing">12</property>
                         <property name="row_spacing">6</property>
@@ -355,7 +365,7 @@
                           <object class="GtkHBox" id="hbox113">
                             <property name="visible">True</property>
                             <child>
-                              <object class="GtkHBox" id="thumbnail_size_combobox_box">
+                              <object class="GtkHBox" id="thumbnail_size_box">
                                 <property name="visible">True</property>
                                 <child>
                                   <placeholder/>
@@ -373,6 +383,33 @@
                             <property name="y_options">GTK_FILL</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkLabel" id="label1">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Thumbnail c_aption:</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="thumbnail_caption_box">
+                            <property name="visible">True</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
diff --git a/extensions/comments/main.c b/extensions/comments/main.c
index dc7a54a..1ac92da 100644
--- a/extensions/comments/main.c
+++ b/extensions/comments/main.c
@@ -40,7 +40,7 @@ GthMetadataInfo comments_metadata_info[] = {
 	{ "comment::note", N_("Comment"), "comment", 1, GTH_METADATA_ALLOW_NOWHERE },
 	{ "comment::place", N_("Place"), "comment", 2, GTH_METADATA_ALLOW_EVERYWHERE },
 	{ "comment::time", N_("Date"), "comment", 3, GTH_METADATA_ALLOW_EVERYWHERE },
-	{ "comment::categories", N_("Tags"), "comment", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+	{ "comment::categories", N_("Tags"), "comment", 4, GTH_METADATA_ALLOW_EVERYWHERE },
 	{ "comment::rating", N_("Rating"), "comment", 5, GTH_METADATA_ALLOW_EVERYWHERE },
 	{ NULL, NULL, NULL, 0, 0 }
 };
diff --git a/gthumb/dlg-preferences.c b/gthumb/dlg-preferences.c
index fc18184..ccd7a25 100644
--- a/gthumb/dlg-preferences.c
+++ b/gthumb/dlg-preferences.c
@@ -35,12 +35,19 @@
 
 #define GET_WIDGET(name) _gtk_builder_get_widget (data->builder, (name))
 
+enum {
+	CAPTION_COLUMN_NAME,
+	CAPTION_COLUMN_ID,
+	CAPTION_COLUMNS
+};
+
 typedef struct {
 	GthBrowser *browser;
 	GtkBuilder *builder;
 	GtkWidget  *dialog;
 	GtkWidget  *toolbar_style_combobox;
 	GtkWidget  *thumbnail_size_combobox;
+	GtkWidget  *thumbnail_caption_combobox;
 } DialogData;
 
 static int thumb_size[] = { 48, 64, 85, 95, 112, 128, 164, 200, 256 };
@@ -159,14 +166,31 @@ ask_to_save_toggled_cb (GtkToggleButton *button,
 
 
 static void
-thumbs_size_changed_cb (GtkOptionMenu *option_menu,
-			DialogData    *data)
+thumbnail_size_changed_cb (GtkOptionMenu *option_menu,
+			   DialogData    *data)
 {
 	eel_gconf_set_integer (PREF_THUMBNAIL_SIZE, thumb_size[gtk_combo_box_get_active (GTK_COMBO_BOX (data->thumbnail_size_combobox))]);
 }
 
 
 static void
+thumbnail_caption_changed_cb (GtkOptionMenu *option_menu,
+			      DialogData    *data)
+{
+	GtkTreeIter  iter;
+	char        *attribute;
+
+	gtk_combo_box_get_active_iter (GTK_COMBO_BOX (data->thumbnail_caption_combobox), &iter);
+	gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (data->thumbnail_caption_combobox)), &iter,
+			    CAPTION_COLUMN_ID, &attribute,
+			    -1);
+	eel_gconf_set_string (PREF_THUMBNAIL_CAPTION, attribute);
+
+	g_free (attribute);
+}
+
+
+static void
 fast_file_type_toggled_cb (GtkToggleButton *button,
 			   DialogData      *data)
 {
@@ -177,9 +201,15 @@ fast_file_type_toggled_cb (GtkToggleButton *button,
 void
 dlg_preferences (GthBrowser *browser)
 {
-	DialogData    *data;
-	char          *startup_location;
-	GthFileSource *file_source;
+	DialogData       *data;
+	char             *startup_location;
+	GthFileSource    *file_source;
+	GtkListStore     *caption_store;
+	GtkCellRenderer  *renderer;
+	GtkTreeIter       iter;
+	char             *current_caption;
+	char            **attributes_v;
+	int               i;
 
 	if (gth_browser_get_dialog (browser, "preferences") != NULL) {
 		gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "preferences")));
@@ -201,11 +231,58 @@ dlg_preferences (GthBrowser *browser)
 	data->toolbar_style_combobox = _gtk_combo_box_new_with_texts (_("System settings"), _("Text below icons"), _("Text beside icons"), _("Icons only"), _("Text only"), NULL);
 	data->thumbnail_size_combobox = _gtk_combo_box_new_with_texts (_("48"), _("64"), _("85"), _("95"), _("112"), _("128"), _("164"), _("200"), _("256"), NULL);
 
+	caption_store = gtk_list_store_new (CAPTION_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
+	data->thumbnail_caption_combobox = gtk_combo_box_new_with_model (GTK_TREE_MODEL (caption_store));
+
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (data->thumbnail_caption_combobox), renderer, TRUE);
+	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (data->thumbnail_caption_combobox),
+					renderer,
+					"text", CAPTION_COLUMN_NAME,
+					NULL);
+
+	current_caption = eel_gconf_get_string (PREF_THUMBNAIL_CAPTION, "standard::display-name");
+
+	/* no caption */
+
+	gtk_list_store_append (caption_store, &iter);
+	gtk_list_store_set (caption_store, &iter,
+			    CAPTION_COLUMN_NAME, _("None"),
+			    CAPTION_COLUMN_ID, "none",
+			    -1);
+	if (strcmp (current_caption, "none") == 0)
+		gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->thumbnail_caption_combobox), &iter);
+
+	/* other captions */
+
+	attributes_v = gth_main_get_metadata_attributes ("*");
+	for (i = 0; attributes_v[i] != NULL; i++) {
+		GthMetadataInfo *info;
+
+		info = gth_main_get_metadata_info (attributes_v[i]);
+		if ((info == NULL) || ((info->flags & GTH_METADATA_ALLOW_IN_FILE_LIST) == 0))
+			continue;
+
+		gtk_list_store_append (caption_store, &iter);
+		gtk_list_store_set (caption_store, &iter,
+				    CAPTION_COLUMN_NAME, info->display_name,
+				    CAPTION_COLUMN_ID, info->id,
+				    -1);
+
+		if (strcmp (current_caption, info->id) == 0)
+			gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->thumbnail_caption_combobox), &iter);
+	}
+	g_strfreev (attributes_v);
+	g_free (current_caption);
+	g_object_unref (caption_store);
+
 	gtk_widget_show (data->toolbar_style_combobox);
 	gtk_widget_show (data->thumbnail_size_combobox);
+	gtk_widget_show (data->thumbnail_caption_combobox);
 
 	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("toolbar_style_combobox_box")), data->toolbar_style_combobox, FALSE, FALSE, 0);
-	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("thumbnail_size_combobox_box")), data->thumbnail_size_combobox, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("thumbnail_size_box")), data->thumbnail_size_combobox, FALSE, FALSE, 0);
+	gtk_box_pack_start (GTK_BOX (GET_WIDGET ("thumbnail_caption_box")), data->thumbnail_caption_combobox, FALSE, FALSE, 0);
 
 	/* * general */
 
@@ -288,7 +365,11 @@ dlg_preferences (GthBrowser *browser)
 
 	g_signal_connect (G_OBJECT (data->thumbnail_size_combobox),
 			  "changed",
-			  G_CALLBACK (thumbs_size_changed_cb),
+			  G_CALLBACK (thumbnail_size_changed_cb),
+			  data);
+	g_signal_connect (G_OBJECT (data->thumbnail_caption_combobox),
+			  "changed",
+			  G_CALLBACK (thumbnail_caption_changed_cb),
 			  data);
 	g_signal_connect (G_OBJECT (GET_WIDGET ("slow_mime_type_checkbutton")),
 			  "toggled",
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 09add66..b62454a 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -60,7 +60,7 @@
 #define GO_FORWARD_HISTORY_POPUP "/GoForwardHistoryPopup"
 #define GO_PARENT_POPUP "/GoParentPopup"
 #define MAX_HISTORY_LENGTH 15
-#define GCONF_NOTIFICATIONS 9
+#define GCONF_NOTIFICATIONS 10
 #define DEF_SIDEBAR_WIDTH 250
 #define DEF_PROPERTIES_HEIGHT 128
 #define DEF_THUMBNAIL_SIZE 128
@@ -1234,7 +1234,9 @@ metadata_ready_cb (GList    *files,
 static const char *
 _gth_browser_get_list_attributes (GthBrowser *browser)
 {
-	GString *attributes;
+	GString  *attributes;
+	char    **attributes_v;
+	int       i;
 
 	if (browser->priv->list_attributes != NULL)
 		return browser->priv->list_attributes;
@@ -1245,12 +1247,21 @@ _gth_browser_get_list_attributes (GthBrowser *browser)
 	else
 		g_string_append (attributes, GFILE_STANDARD_ATTRIBUTES_WITH_CONTENT_TYPE);
 
-	/* FIXME: make the attribute list based on the data required to
-	 * filter and view the file list. */
+	attributes_v = gth_main_get_metadata_attributes ("*");
+	for (i = 0; attributes_v[i] != NULL; i++) {
+		GthMetadataInfo *info;
+
+		info = gth_main_get_metadata_info (attributes_v[i]);
+		if ((info == NULL) || ((info->flags & GTH_METADATA_ALLOW_IN_FILE_LIST) == 0))
+			continue;
+
+		g_string_append (attributes, ",");
+		g_string_append (attributes, attributes_v[i]);
+	}
 
-	g_string_append (attributes, ",comment::*");
 	browser->priv->list_attributes = attributes->str;
 
+	g_strfreev (attributes_v);
 	g_string_free (attributes, FALSE);
 
 	return browser->priv->list_attributes;
@@ -2751,6 +2762,22 @@ pref_thumbnail_size_changed (GConfClient *client,
 }
 
 
+static void
+pref_thumbnail_caption_changed (GConfClient *client,
+			        guint        cnxn_id,
+			        GConfEntry  *entry,
+			        gpointer     user_data)
+{
+	GthBrowser *browser = user_data;
+	char       *caption;
+
+	caption = eel_gconf_get_string (PREF_THUMBNAIL_CAPTION, "standard::display-name");
+	gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->file_list), caption);
+
+	g_free (caption);
+}
+
+
 static gboolean
 _gth_browser_realize (GtkWidget *browser,
 		      gpointer  *data)
@@ -2779,6 +2806,7 @@ _gth_browser_construct (GthBrowser *browser)
 	GtkWidget      *scrolled_window;
 	GtkWidget      *menubar;
 	char           *general_filter;
+	char           *caption;
 	int             i;
 
 	gtk_window_set_default_size (GTK_WINDOW (browser),
@@ -2987,6 +3015,10 @@ _gth_browser_construct (GthBrowser *browser)
 				    FALSE);
 	gth_browser_enable_thumbnails (browser, eel_gconf_get_boolean (PREF_SHOW_THUMBNAILS, TRUE));
 	gth_file_list_set_thumb_size (GTH_FILE_LIST (browser->priv->file_list), eel_gconf_get_integer (PREF_THUMBNAIL_SIZE, DEF_THUMBNAIL_SIZE));
+	caption = eel_gconf_get_string (PREF_THUMBNAIL_CAPTION, "standard::display-name");
+	gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->file_list), caption);
+	g_free (caption);
+
 	gtk_widget_show (browser->priv->file_list);
 	gtk_box_pack_start (GTK_BOX (vbox), browser->priv->file_list, TRUE, TRUE, 0);
 
@@ -3113,6 +3145,10 @@ _gth_browser_construct (GthBrowser *browser)
 					   PREF_THUMBNAIL_SIZE,
 					   pref_thumbnail_size_changed,
 					   browser);
+	browser->priv->cnxn_id[i++] = eel_gconf_notification_add (
+					   PREF_THUMBNAIL_CAPTION,
+					   pref_thumbnail_caption_changed,
+					   browser);
 
 	gth_window_set_current_page (GTH_WINDOW (browser), GTH_BROWSER_PAGE_BROWSER);
 
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index f7d0e09..4f1d5e2 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -106,6 +106,8 @@ struct _GthFileListPrivateData
 	GtkCellRenderer *thumbnail_renderer;
 	GtkCellRenderer *text_renderer;
 
+	char            *caption_attribute;
+
 	DoneFunc         done_func;
 	gpointer         done_func_data;
 };
@@ -235,6 +237,7 @@ gth_file_list_finalize (GObject *object)
 	if (file_list->priv != NULL) {
 		if (file_list->priv->icon_cache != NULL)
 			gth_icon_cache_free (file_list->priv->icon_cache);
+		g_free (file_list->priv->caption_attribute);
 		g_free (file_list->priv);
 		file_list->priv = NULL;
 	}
@@ -513,7 +516,7 @@ gth_file_list_construct (GthFileList *file_list)
 	file_list->priv->thumbnail_renderer = renderer = gth_cell_renderer_thumbnail_new ();
 	g_object_set (renderer,
 		      "size", file_list->priv->thumb_size,
-		      "yalign", 1.0,
+		      "yalign", 0.5,
 		      NULL);
 	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (file_list->priv->view), renderer, FALSE);
 	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (file_list->priv->view),
@@ -710,8 +713,7 @@ gfl_add_files (GthFileList *file_list,
 					  fd,
 					  pixbuf,
 					  TRUE,
-					  /* FIXME: make this user configurable */
-					  g_file_info_get_attribute_string (fd->info, "standard::display-name"));
+					  gth_file_data_get_attribute_as_string (fd, file_list->priv->caption_attribute));
 
 		if (pixbuf != NULL)
 			g_object_unref (pixbuf);
@@ -1033,6 +1035,51 @@ gth_file_list_set_thumb_size (GthFileList *file_list,
 }
 
 
+void
+gth_file_list_set_caption (GthFileList *file_list,
+			   const char  *attribute)
+{
+	GthFileStore *file_store;
+	GList        *list;
+	GList        *scan;
+	int           pos;
+	gboolean      metadata_visible;
+
+	g_free (file_list->priv->caption_attribute);
+	file_list->priv->caption_attribute = g_strdup (attribute);
+
+	metadata_visible = (strcmp (file_list->priv->caption_attribute, "none") != 0);
+	g_object_set (file_list->priv->text_renderer,
+		      "visible", metadata_visible,
+		      "height", metadata_visible ? -1 : 0,
+		      NULL);
+
+	file_store = (GthFileStore *) gth_file_view_get_model (GTH_FILE_VIEW (file_list->priv->view));
+
+	list = gth_file_store_get_all (file_store);
+	for (scan = list, pos = 0; scan; scan = scan->next, pos++) {
+		GthFileData *file_data = scan->data;
+		char        *metadata;
+
+		metadata = gth_file_data_get_attribute_as_string (file_data, file_list->priv->caption_attribute);
+		if (metadata == NULL)
+			metadata = g_strdup ("");
+
+		gth_file_store_queue_set (file_store,
+					  pos,
+					  NULL,
+					  NULL,
+					  -1,
+					  metadata);
+
+		g_free (metadata);
+	}
+	gth_file_store_exec_set (file_store);
+
+	_g_object_list_unref (list);
+}
+
+
 GtkWidget *
 gth_file_list_get_view (GthFileList *file_list)
 {
diff --git a/gthumb/gth-file-list.h b/gthumb/gth-file-list.h
index 2f10193..067a5d0 100644
--- a/gthumb/gth-file-list.h
+++ b/gthumb/gth-file-list.h
@@ -81,6 +81,8 @@ void           gth_file_list_enable_thumbs  (GthFileList          *file_list,
 					     gboolean              enable);
 void           gth_file_list_set_thumb_size (GthFileList          *file_list,
 					     int                   size);
+void           gth_file_list_set_caption    (GthFileList          *file_list,
+					     const char           *attribute);
 GtkWidget *    gth_file_list_get_view       (GthFileList          *file_list);
 int            gth_file_list_first_file     (GthFileList          *file_list,
 					     gboolean              skip_broken,
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index 0a09452..4551fcc 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -92,6 +92,7 @@ struct _GthMainPrivate
 	GList               *metadata_provider;
 	GPtrArray           *metadata_category;
 	GPtrArray           *metadata_info;
+	gboolean             metadata_info_sorted;
 	GHashTable          *sort_types;
 	GHashTable          *tests;
 	GHashTable          *loaders;
@@ -170,6 +171,7 @@ gth_main_init (GthMain *main)
 	main->priv->loaders = g_hash_table_new (g_str_hash, g_str_equal);
 	main->priv->metadata_category = g_ptr_array_new ();
 	main->priv->metadata_info = g_ptr_array_new ();
+	main->priv->metadata_info_sorted = FALSE;
 }
 
 
@@ -404,6 +406,7 @@ gth_main_register_metadata_info (GthMetadataInfo *metadata_info)
 
 	g_static_mutex_lock (&metadata_info_mutex);
 	g_ptr_array_add (Main->priv->metadata_info, info);
+	Main->priv->metadata_info_sorted = FALSE;
 	g_static_mutex_unlock (&metadata_info_mutex);
 
 	return info;
@@ -439,6 +442,26 @@ gth_main_get_all_metadata_providers (void)
 }
 
 
+static int
+metadata_info_sort_func (gconstpointer a,
+			 gconstpointer b)
+{
+	GthMetadataInfo *info_a = *((GthMetadataInfo **) a);
+	GthMetadataInfo *info_b = *((GthMetadataInfo **) b);
+
+	if (info_a->display_name == NULL) {
+		if (info_b->display_name == NULL)
+			return 0;
+		else
+			return -1;
+	}
+	else if (info_b->display_name == NULL)
+		return 1;
+	else
+		return g_utf8_collate (info_a->display_name, info_b->display_name);
+}
+
+
 char **
 gth_main_get_metadata_attributes (const char *mask)
 {
@@ -449,12 +472,17 @@ gth_main_get_metadata_attributes (const char *mask)
 	GList                  *scan;
 	char                  **values;
 
+	if (! Main->priv->metadata_info_sorted) {
+		g_ptr_array_sort (Main->priv->metadata_info, metadata_info_sort_func);
+		Main->priv->metadata_info_sorted = TRUE;
+	}
+
 	matcher = g_file_attribute_matcher_new (mask);
 	for (n = 0, i = 0; i < Main->priv->metadata_info->len; i++) {
 		GthMetadataInfo *metadata_info = g_ptr_array_index (Main->priv->metadata_info, i);
 
 		if (g_file_attribute_matcher_matches (matcher, metadata_info->id)) {
-			list = g_list_append (list, (char *) metadata_info->id);
+			list = g_list_prepend (list, (char *) metadata_info->id);
 			n++;
 		}
 	}
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index ebee44b..26c9dbc 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -47,6 +47,7 @@ G_BEGIN_DECLS
 #define PREF_SAVE_THUMBNAILS        "/apps/gthumb/browser/save_thumbnails"
 #define PREF_THUMBNAIL_SIZE         "/apps/gthumb/browser/thumbnail_size"
 #define PREF_THUMBNAIL_LIMIT        "/apps/gthumb/browser/thumbnail_limit"
+#define PREF_THUMBNAIL_CAPTION      "/apps/gthumb/browser/thumbnail_caption"
 #define PREF_CLICK_POLICY           "/apps/gthumb/browser/click_policy"
 #define PREF_SORT_TYPE              "/apps/gthumb/browser/sort_type"
 #define PREF_SORT_INVERSE           "/apps/gthumb/browser/sort_inverse"
@@ -95,7 +96,7 @@ G_BEGIN_DECLS
 #define DEFAULT_UI_WINDOW_WIDTH 690
 #define DEFAULT_UI_WINDOW_HEIGHT 460
 #define DEFAULT_FAST_FILE_TYPE TRUE
-#define DEFAULT_THUMBNAIL_SIZE 95
+#define DEFAULT_THUMBNAIL_SIZE 112
 #define DEFAULT_CONFIRM_DELETION TRUE
 #define DEFAULT_MSG_SAVE_MODIFIED_IMAGE TRUE
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]