[gimp/metadata-browser] Set the property icons in the advanced tab on focus.
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] Set the property icons in the advanced tab on focus.
- Date: Wed, 5 Oct 2011 11:11:07 +0000 (UTC)
commit 6e2478d9e949b88e7f33a131df810fc0c8fe9160
Author: Roman Joost <roman bromeco de>
Date: Sun Oct 2 15:32:02 2011 +1000
Set the property icons in the advanced tab on focus.
Once the tree view is focused by the user, we update the icons. This is
currently only necessary, because the XMPModel functions overwrite the
icon once the user changes a property. An update function should handle
this in the future to make this perhaps obsolete.
plug-ins/metadata/interface.c | 65 ++++++++++++++++++++++++----------------
1 files changed, 39 insertions(+), 26 deletions(-)
---
diff --git a/plug-ins/metadata/interface.c b/plug-ins/metadata/interface.c
index f193e32..e1bb610 100644
--- a/plug-ins/metadata/interface.c
+++ b/plug-ins/metadata/interface.c
@@ -65,8 +65,6 @@ typedef struct
{
GtkWidget *dlg;
XMPModel *xmp_model;
- GdkPixbuf *edit_icon;
- GdkPixbuf *auto_icon;
gboolean run_ok;
} MetadataGui;
@@ -160,35 +158,55 @@ icon_foreach_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
- gboolean editable;
- MetadataGui *mgui = user_data;
+ gboolean editable;
+ GtkTreeView *treeview = GTK_TREE_VIEW (user_data);
+ GdkPixbuf *icon = NULL;
gtk_tree_model_get (model, iter,
COL_XMP_EDITABLE, &editable,
-1);
+
if (editable == XMP_AUTO_UPDATE)
+ {
+ icon = gtk_widget_render_icon (GTK_WIDGET (treeview),
+ GIMP_STOCK_WILBER,
+ GTK_ICON_SIZE_MENU, NULL);
gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- COL_XMP_EDIT_ICON, mgui->auto_icon,
+ COL_XMP_EDIT_ICON, icon,
-1);
+ }
else if (editable == TRUE)
+ {
+ icon = gtk_widget_render_icon (GTK_WIDGET (treeview),
+ GTK_STOCK_EDIT,
+ GTK_ICON_SIZE_MENU, NULL);
gtk_tree_store_set (GTK_TREE_STORE (model), iter,
- COL_XMP_EDIT_ICON, mgui->edit_icon,
+ COL_XMP_EDIT_ICON, icon,
-1);
+ }
else
+ {
gtk_tree_store_set (GTK_TREE_STORE (model), iter,
COL_XMP_EDIT_ICON, NULL,
-1);
+ }
+
+ if (icon != NULL)
+ g_object_unref (icon);
+
return FALSE;
}
static void
-update_icons (MetadataGui *mgui)
+update_icons (GtkTreeView *treeview,
+ GtkDirectionType direction,
+ gpointer user_data)
{
GtkTreeModel *model;
/* add the edit icon to the rows that are editable */
- model = xmp_model_get_tree_model (mgui->xmp_model);
- gtk_tree_model_foreach (model, icon_foreach_func, mgui);
+ model = gtk_tree_view_get_model (treeview);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (model), icon_foreach_func, treeview);
}
static void
@@ -339,11 +357,14 @@ add_thumbnail_tab (GtkWidget *notebook)
}
static void
-add_advanced_tab (GtkWidget *notebook,
- GtkTreeModel *model)
+add_advanced_tab (GtkWidget *notebook,
+ MetadataGui *mgui)
{
- GtkWidget *sw;
- GtkWidget *treeview;
+ GtkWidget *sw;
+ GtkWidget *treeview;
+ GtkTreeModel *model;
+
+ model = xmp_model_get_tree_model (mgui->xmp_model);
/* Advanced tab */
sw = gtk_scrolled_window_new (NULL, NULL);
@@ -363,6 +384,10 @@ add_advanced_tab (GtkWidget *notebook,
gtk_container_add (GTK_CONTAINER (sw), treeview);
+ /* update property icons when the user views this tab */
+ g_signal_connect (treeview, "focus",
+ G_CALLBACK (update_icons), NULL);
+
/* expand all rows after the treeview widget has been realized */
g_signal_connect (treeview, "realize",
G_CALLBACK (gtk_tree_view_expand_all), NULL);
@@ -426,8 +451,6 @@ import_dialog_response (GtkWidget *dlg,
return;
}
- update_icons (mgui);
-
g_free (buffer);
g_free (filename);
}
@@ -639,12 +662,6 @@ metadata_dialog (gint32 image_ID,
gtk_widget_show (notebook);
mgui.xmp_model = xmp_model;
- mgui.edit_icon = gtk_widget_render_icon (mgui.dlg, GTK_STOCK_EDIT,
- GTK_ICON_SIZE_MENU, NULL);
- mgui.auto_icon = gtk_widget_render_icon (mgui.dlg, GIMP_STOCK_WILBER,
- GTK_ICON_SIZE_MENU, NULL);
- update_icons (&mgui);
-
mgui.run_ok = FALSE;
/* add the tabs to the notebook */
@@ -654,7 +671,7 @@ metadata_dialog (gint32 image_ID,
add_camera1_tab (notebook);
add_camera2_tab (notebook);
add_thumbnail_tab (notebook);
- add_advanced_tab (notebook, xmp_model_get_tree_model (mgui.xmp_model));
+ add_advanced_tab (notebook, &mgui);
gtk_window_set_default_size (GTK_WINDOW (mgui.dlg), 400, 500);
gtk_widget_show (mgui.dlg);
@@ -662,9 +679,5 @@ metadata_dialog (gint32 image_ID,
/* run, baby, run! */
gtk_main ();
- /* clean up and return */
- g_object_unref (mgui.auto_icon);
- g_object_unref (mgui.edit_icon);
-
return mgui.run_ok;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]