[gthumb/ext: 73/79] allow to specify more than one metadata attribute in the file list
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext: 73/79] allow to specify more than one metadata attribute in the file list
- Date: Sun, 2 Aug 2009 20:32:18 +0000 (UTC)
commit addab8370deee4a9d86140da0dfc50e2e640c7f8
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Jul 30 00:27:55 2009 +0200
allow to specify more than one metadata attribute in the file list
data/ui/preferences.ui | 170 ++++++++++++++++++++++++++------------------
extensions/exiv2/main.c | 14 ++--
gthumb/dlg-preferences.c | 174 ++++++++++++++++++++++++++++++++++------------
gthumb/glib-utils.c | 15 ++++
gthumb/glib-utils.h | 2 +
gthumb/gth-file-list.c | 69 ++++++++++++------
gthumb/gth-main.c | 21 +++---
7 files changed, 311 insertions(+), 154 deletions(-)
---
diff --git a/data/ui/preferences.ui b/data/ui/preferences.ui
index 27ad77a..837d7ab 100644
--- a/data/ui/preferences.ui
+++ b/data/ui/preferences.ui
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
<interface>
- <requires lib="gtk+" version="2.14"/>
+ <requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="preferences_dialog">
<property name="border_width">6</property>
<property name="title" translatable="yes">gthumb Preferences</property>
- <property name="resizable">False</property>
<property name="type_hint">dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@@ -342,97 +341,128 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkTable" id="table14">
+ <object class="GtkCheckButton" id="slow_mime_type_checkbutton">
+ <property name="label" translatable="yes">D_etermine image type from content (slower)</property>
<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>
- <child>
- <object class="GtkLabel" id="label113">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Th_umbnail size:</property>
- <property name="use_underline">True</property>
- <property name="justify">center</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
<child>
- <object class="GtkHBox" id="hbox113">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkHBox" id="thumbnail_size_box">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="size_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Size:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="thumbnail_size_box">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
+ <property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <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/>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="caption_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">C_aption:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="caption_scrolledwindow">
+ <property name="height_request">150</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</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>
- <property name="position">0</property>
- </packing>
</child>
- <child>
- <object class="GtkCheckButton" id="slow_mime_type_checkbutton">
- <property name="label" translatable="yes">D_etermine image type from content (slower)</property>
+ <child type="label">
+ <object class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
+ <property name="label" translatable="yes">Thumbnail</property>
+ <property name="use_markup">True</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/extensions/exiv2/main.c b/extensions/exiv2/main.c
index c5281be..9bc85d6 100644
--- a/extensions/exiv2/main.c
+++ b/extensions/exiv2/main.c
@@ -52,24 +52,24 @@ GthMetadataInfo exiv2_metadata_info[] = {
{ "Exif::Photo::SubSecTime", NULL, "Exif::General", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::DateTimeOriginal", NULL, "Exif::General", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW},
{ "Exif::Photo::SubSecTimeOriginal", NULL, "Exif::General", 7, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::DateTimeDigitized", NULL, "Exif::General", 8, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "Exif::Photo::DateTimeDigitized", NULL, "Exif::General", 8, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Photo::SubSecTimeDigitized", NULL, "Exif::General", 9, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Image::Artist", NULL, "Exif::General", 11, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Image::Copyright", NULL, "Exif::General", 12, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::UniqueID", NULL, "Exif::General", 13, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::SoundFile", NULL, "Exif::General", 14, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::ISOSpeedRatings", NULL, "Exif::Conditions", 2, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::BrightnessValue", NULL, "Exif::Conditions", 3, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::FNumber", NULL, "Exif::Conditions", 4, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "Exif::Photo::ISOSpeedRatings", NULL, "Exif::Conditions", 2, GTH_METADATA_ALLOW_EVERYWHERE },
+ { "Exif::Photo::BrightnessValue", NULL, "Exif::Conditions", 3, GTH_METADATA_ALLOW_EVERYWHERE },
+ { "Exif::Photo::FNumber", NULL, "Exif::Conditions", 4, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Photo::ApertureValue", NULL, "Exif::Conditions", 5, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::MaxApertureValue", NULL, "Exif::Conditions", 6, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::ExposureTime", NULL, "Exif::Conditions", 7, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "Exif::Photo::MaxApertureValue", NULL, "Exif::Conditions", 6, GTH_METADATA_ALLOW_EVERYWHERE },
+ { "Exif::Photo::ExposureTime", NULL, "Exif::Conditions", 7, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Photo::ExposureProgram", NULL, "Exif::Conditions", 8, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::ExposureIndex", NULL, "Exif::Conditions", 9, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::ExposureBiasValue", NULL, "Exif::Conditions", 10, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::ExposureMode", NULL, "Exif::Conditions", 11, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
- { "Exif::Photo::ShutterSpeedValue", NULL, "Exif::Conditions", 12, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
+ { "Exif::Photo::ShutterSpeedValue", NULL, "Exif::Conditions", 12, GTH_METADATA_ALLOW_EVERYWHERE },
{ "Exif::Photo::MeteringMode", NULL, "Exif::Conditions", 13, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::LightSource", NULL, "Exif::Conditions", 14, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::WhiteBalance", NULL, "Exif::Conditions", 15, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
diff --git a/gthumb/dlg-preferences.c b/gthumb/dlg-preferences.c
index ccd7a25..c2f03d2 100644
--- a/gthumb/dlg-preferences.c
+++ b/gthumb/dlg-preferences.c
@@ -30,6 +30,7 @@
#include "gth-main.h"
#include "gth-preferences.h"
#include "gtk-utils.h"
+#include "glib-utils.h"
#include "typedefs.h"
@@ -38,6 +39,7 @@
enum {
CAPTION_COLUMN_NAME,
CAPTION_COLUMN_ID,
+ CAPTION_COLUMN_USED,
CAPTION_COLUMNS
};
@@ -47,7 +49,7 @@ typedef struct {
GtkWidget *dialog;
GtkWidget *toolbar_style_combobox;
GtkWidget *thumbnail_size_combobox;
- GtkWidget *thumbnail_caption_combobox;
+ GtkWidget *thumbnail_caption_list_view;
} DialogData;
static int thumb_size[] = { 48, 64, 85, 95, 112, 128, 164, 200, 256 };
@@ -174,27 +176,115 @@ thumbnail_size_changed_cb (GtkOptionMenu *option_menu,
static void
-thumbnail_caption_changed_cb (GtkOptionMenu *option_menu,
- DialogData *data)
+fast_file_type_toggled_cb (GtkToggleButton *button,
+ DialogData *data)
+{
+ eel_gconf_set_boolean (PREF_FAST_FILE_TYPE, ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("slow_mime_type_checkbutton"))));
+}
+
+
+static void
+update_caption_from_list_view (DialogData *data)
{
- GtkTreeIter iter;
- char *attribute;
+ GtkTreeModel *tree_model;
+ GtkTreeIter iter;
+ GString *attributes;
+
+ attributes = g_string_new ("");
+ tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (data->thumbnail_caption_list_view));
+ if (gtk_tree_model_get_iter_first (tree_model, &iter)) {
+ do {
+ gboolean used;
+ char *attribute_id;
+
+ gtk_tree_model_get (tree_model, &iter,
+ CAPTION_COLUMN_ID, &attribute_id,
+ CAPTION_COLUMN_USED, &used,
+ -1);
+
+ if (used) {
+ if (attributes->len > 0)
+ g_string_append (attributes, ",");
+ g_string_append (attributes, attribute_id);
+ }
+
+ g_free (attribute_id);
+ }
+ while (gtk_tree_model_iter_next (tree_model, &iter));
+ }
- 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);
+ if (attributes->len > 0)
+ eel_gconf_set_string (PREF_THUMBNAIL_CAPTION, attributes->str);
+ else
+ eel_gconf_set_string (PREF_THUMBNAIL_CAPTION, "none");
- g_free (attribute);
+ g_string_free (attributes, TRUE);
}
static void
-fast_file_type_toggled_cb (GtkToggleButton *button,
- DialogData *data)
+cell_renderer_toggle_toggled_cb (GtkCellRendererToggle *cell_renderer,
+ char *path,
+ gpointer user_data)
{
- eel_gconf_set_boolean (PREF_FAST_FILE_TYPE, ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("slow_mime_type_checkbutton"))));
+ DialogData *data = user_data;
+ GtkTreePath *tpath;
+ GtkTreeModel *tree_model;
+ GtkTreeIter iter;
+
+ tpath = gtk_tree_path_new_from_string (path);
+ if (tpath == NULL)
+ return;
+
+ tree_model = gtk_tree_view_get_model (GTK_TREE_VIEW (data->thumbnail_caption_list_view));
+ if (gtk_tree_model_get_iter (tree_model, &iter, tpath)) {
+ gboolean used;
+
+ gtk_tree_model_get (tree_model, &iter,
+ CAPTION_COLUMN_USED, &used,
+ -1);
+ gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter,
+ CAPTION_COLUMN_USED, ! used,
+ -1);
+ }
+
+ update_caption_from_list_view (data);
+
+ gtk_tree_path_free (tpath);
+}
+
+
+static void
+caption_list_view_add_columns (GtkTreeView *treeview,
+ DialogData *data)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ /* the checkbox column */
+
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer,
+ "toggled",
+ G_CALLBACK (cell_renderer_toggle_toggled_cb),
+ data);
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "active", CAPTION_COLUMN_USED,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ /* the name column. */
+
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", CAPTION_COLUMN_NAME,
+ NULL);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
}
@@ -205,10 +295,10 @@ dlg_preferences (GthBrowser *browser)
char *startup_location;
GthFileSource *file_source;
GtkListStore *caption_store;
- GtkCellRenderer *renderer;
GtkTreeIter iter;
char *current_caption;
char **attributes_v;
+ char **active_attributes_v;
int i;
if (gth_browser_get_dialog (browser, "preferences") != NULL) {
@@ -231,58 +321,56 @@ 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);
+ caption_store = gtk_list_store_new (CAPTION_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ data->thumbnail_caption_list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (caption_store));
+ g_object_unref (caption_store);
- current_caption = eel_gconf_get_string (PREF_THUMBNAIL_CAPTION, "standard::display-name");
+ gtk_tree_view_set_reorderable (GTK_TREE_VIEW (data->thumbnail_caption_list_view), FALSE);
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (data->thumbnail_caption_list_view), FALSE);
- /* no caption */
+ caption_list_view_add_columns (GTK_TREE_VIEW (data->thumbnail_caption_list_view), data);
- 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);
+ gtk_widget_show (data->thumbnail_caption_list_view);
+ gtk_container_add (GTK_CONTAINER (GET_WIDGET ("caption_scrolledwindow")), data->thumbnail_caption_list_view);
- /* other captions */
+ /* caption list */
+ current_caption = eel_gconf_get_string (PREF_THUMBNAIL_CAPTION, "standard::display-name");
+ active_attributes_v = g_strsplit (current_caption, ",", -1);
attributes_v = gth_main_get_metadata_attributes ("*");
for (i = 0; attributes_v[i] != NULL; i++) {
GthMetadataInfo *info;
+ const char *name;
+ gboolean used;
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);
+
+ name = info->display_name;
+ if (name == NULL)
+ name = info->id;
+ used = _g_strv_find (active_attributes_v, info->id) != -1;
gtk_list_store_set (caption_store, &iter,
- CAPTION_COLUMN_NAME, info->display_name,
+ CAPTION_COLUMN_NAME, name,
CAPTION_COLUMN_ID, info->id,
+ CAPTION_COLUMN_USED, used,
-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_strfreev (active_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_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);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("caption_label")), data->thumbnail_caption_list_view);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("size_label")), data->thumbnail_size_combobox);
/* * general */
@@ -367,10 +455,6 @@ dlg_preferences (GthBrowser *browser)
"changed",
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",
G_CALLBACK (fast_file_type_toggled_cb),
diff --git a/gthumb/glib-utils.c b/gthumb/glib-utils.c
index 00078b0..fb8c1b4 100644
--- a/gthumb/glib-utils.c
+++ b/gthumb/glib-utils.c
@@ -953,6 +953,21 @@ _g_rand_string (int len)
}
+int
+_g_strv_find (char **v,
+ const char *s)
+{
+ int i;
+
+ for (i = 0; v[i] != NULL; i++) {
+ if (strcmp (v[i], s) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+
/* Regexp utils */
static char **
diff --git a/gthumb/glib-utils.h b/gthumb/glib-utils.h
index 383ace1..bb9620c 100644
--- a/gthumb/glib-utils.h
+++ b/gthumb/glib-utils.h
@@ -170,6 +170,8 @@ GList * _g_list_insert_list_before (GList *list1,
GList *list2);
const char * get_static_string (const char *s);
char * _g_rand_string (int len);
+int _g_strv_find (char **v,
+ const char *s);
/* Regexp utils */
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index 6d20cf0..94e53b7 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -106,7 +106,7 @@ struct _GthFileListPrivateData
GtkCellRenderer *thumbnail_renderer;
GtkCellRenderer *text_renderer;
- char *caption_attribute;
+ char **caption_attributes_v;
DoneFunc done_func;
gpointer done_func_data;
@@ -237,7 +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_strfreev (file_list->priv->caption_attributes_v);
g_free (file_list->priv);
file_list->priv = NULL;
}
@@ -265,7 +265,8 @@ gth_file_list_init (GthFileList *file_list)
file_list->priv->thumb_size = DEFAULT_THUMBNAIL_SIZE;
file_list->priv->ignore_hidden_thumbs = FALSE;
- file_list->priv->load_thumbs = TRUE; /* FIXME: make this cnfigurable */
+ file_list->priv->load_thumbs = TRUE; /* FIXME: make this configurable */
+ file_list->priv->caption_attributes_v = g_strsplit ("none", ",", -1);
}
@@ -533,7 +534,7 @@ gth_file_list_construct (GthFileList *file_list)
"ellipsize", PANGO_ELLIPSIZE_END,
"alignment", PANGO_ALIGN_CENTER,
"width", file_list->priv->thumb_size + (8 * 2) /* FIXME: remove the numbers */,
- "single-paragraph-mode", TRUE,
+ /*"single-paragraph-mode", TRUE,*/
NULL);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (file_list->priv->view), renderer, FALSE);
@@ -686,6 +687,31 @@ _gth_file_list_update_pane (GthFileList *file_list)
}
+static GString *
+_gth_file_list_get_metadata (GthFileList *file_list,
+ GthFileData *file_data)
+{
+ GString *metadata;
+ int i;
+
+ metadata = g_string_new ("");
+ for (i = 0; file_list->priv->caption_attributes_v[i] != NULL; i++) {
+ char *value;
+
+ value = gth_file_data_get_attribute_as_string (file_data, file_list->priv->caption_attributes_v[i]);
+ if (value != NULL) {
+ if (metadata->len > 0)
+ g_string_append (metadata, "\n");
+ g_string_append (metadata, value);
+
+ g_free (value);
+ }
+ }
+
+ return metadata;
+}
+
+
static void
gfl_add_files (GthFileList *file_list,
GList *files)
@@ -699,6 +725,7 @@ gfl_add_files (GthFileList *file_list,
GthFileData *fd = scan->data;
GIcon *icon;
GdkPixbuf *pixbuf = NULL;
+ GString *metadata;
if (g_file_info_get_file_type (fd->info) != G_FILE_TYPE_REGULAR)
continue;
@@ -708,13 +735,14 @@ gfl_add_files (GthFileList *file_list,
icon = g_file_info_get_icon (fd->info);
pixbuf = gth_icon_cache_get_pixbuf (file_list->priv->icon_cache, icon);
-
+ metadata = _gth_file_list_get_metadata (file_list, fd);
gth_file_store_queue_add (file_store,
fd,
pixbuf,
TRUE,
- gth_file_data_get_attribute_as_string (fd, file_list->priv->caption_attribute));
+ metadata->str);
+ g_string_free (metadata, TRUE);
if (pixbuf != NULL)
g_object_unref (pixbuf);
}
@@ -1037,18 +1065,18 @@ gth_file_list_set_thumb_size (GthFileList *file_list,
void
gth_file_list_set_caption (GthFileList *file_list,
- const char *attribute)
+ const char *attributes)
{
- GthFileStore *file_store;
- GList *list;
- GList *scan;
- int pos;
- gboolean metadata_visible;
+ 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);
+ g_strfreev (file_list->priv->caption_attributes_v);
+ file_list->priv->caption_attributes_v = g_strsplit (attributes, ",", -1);
- metadata_visible = (strcmp (file_list->priv->caption_attribute, "none") != 0);
+ metadata_visible = (strcmp (file_list->priv->caption_attributes_v[0], "none") != 0);
g_object_set (file_list->priv->text_renderer,
"visible", metadata_visible,
"height", metadata_visible ? -1 : 0,
@@ -1059,20 +1087,17 @@ gth_file_list_set_caption (GthFileList *file_list,
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 ("");
+ GString *metadata;
+ metadata = _gth_file_list_get_metadata (file_list, file_data);
gth_file_store_queue_set (file_store,
pos,
NULL,
NULL,
-1,
- metadata);
+ metadata->str);
- g_free (metadata);
+ g_string_free (metadata, TRUE);
}
gth_file_store_exec_set (file_store);
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index 4551fcc..e44d2d5 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -448,17 +448,18 @@ metadata_info_sort_func (gconstpointer a,
{
GthMetadataInfo *info_a = *((GthMetadataInfo **) a);
GthMetadataInfo *info_b = *((GthMetadataInfo **) b);
+ const char *name_a;
+ const char *name_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);
+ name_a = info_a->display_name;
+ if (name_a == NULL)
+ name_a = info_a->id;
+
+ name_b = info_b->display_name;
+ if (name_b == NULL)
+ name_b = info_b->id;
+
+ return g_utf8_collate (name_a, name_b);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]