[Xfce4-commits] <thunar:nick/fixes-for-master> Use then icon-name property for GtkActions in uca.

Nick Schermer noreply at xfce.org
Tue Dec 15 12:24:03 CET 2009


Updating branch refs/heads/nick/fixes-for-master
         to 0d68804fdf331893ec00d80d182c54f20853b552 (commit)
       from 764212cfa1147d190955351c3ef464c6a5bfdfa9 (commit)

commit 0d68804fdf331893ec00d80d182c54f20853b552
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Dec 15 12:12:19 2009 +0100

    Use then icon-name property for GtkActions in uca.
    
    Since GTK+ 2.10 there is an icon-name property for GtkActions.
    Use this property instead of creating stock-id's.

 plugins/thunar-uca/thunar-uca-chooser.c  |    2 +-
 plugins/thunar-uca/thunar-uca-model.c    |   32 ------------------------------
 plugins/thunar-uca/thunar-uca-model.h    |    1 -
 plugins/thunar-uca/thunar-uca-provider.c |    9 ++++---
 4 files changed, 6 insertions(+), 38 deletions(-)

diff --git a/plugins/thunar-uca/thunar-uca-chooser.c b/plugins/thunar-uca/thunar-uca-chooser.c
index f9f40f8..f58799d 100644
--- a/plugins/thunar-uca/thunar-uca-chooser.c
+++ b/plugins/thunar-uca/thunar-uca-chooser.c
@@ -159,7 +159,7 @@ thunar_uca_chooser_init (ThunarUcaChooser *uca_chooser)
 
   renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF, "stock-size", GTK_ICON_SIZE_DND, "xpad", 2, "ypad", 2, NULL);
   gtk_tree_view_column_pack_start (column, renderer, FALSE);
-  gtk_tree_view_column_set_attributes (column, renderer, "stock-id", THUNAR_UCA_MODEL_COLUMN_STOCK_ID, NULL);
+  gtk_tree_view_column_set_attributes (column, renderer, "icon-name", THUNAR_UCA_MODEL_COLUMN_ICON, NULL);
 
   renderer = gtk_cell_renderer_text_new ();
   gtk_tree_view_column_pack_start (column, renderer, TRUE);
diff --git a/plugins/thunar-uca/thunar-uca-model.c b/plugins/thunar-uca/thunar-uca-model.c
index 822c8a2..fefb101 100644
--- a/plugins/thunar-uca/thunar-uca-model.c
+++ b/plugins/thunar-uca/thunar-uca-model.c
@@ -165,7 +165,6 @@ struct _ThunarUcaModelItem
   ThunarUcaTypes types;
 
   /* derived attributes */
-  gchar         *stock_id;
   gboolean       multiple_selection : 1;
 };
 
@@ -330,9 +329,6 @@ thunar_uca_model_get_column_type (GtkTreeModel *tree_model,
     case THUNAR_UCA_MODEL_COLUMN_TYPES:
       return G_TYPE_UINT;
 
-    case THUNAR_UCA_MODEL_COLUMN_STOCK_ID:
-      return G_TYPE_STRING;
-
     case THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL:
       return G_TYPE_STRING;
 
@@ -390,8 +386,6 @@ thunar_uca_model_get_value (GtkTreeModel *tree_model,
 {
   ThunarUcaModelItem *item = ((GList *) iter->user_data)->data;
   ThunarUcaModel     *uca_model = THUNAR_UCA_MODEL (tree_model);
-  GtkIconSource      *icon_source;
-  GtkIconSet         *icon_set;
   gchar              *str;
 
   g_return_if_fail (THUNAR_UCA_IS_MODEL (uca_model));
@@ -427,31 +421,6 @@ thunar_uca_model_get_value (GtkTreeModel *tree_model,
       g_value_set_uint (value, item->types);
       break;
 
-    case THUNAR_UCA_MODEL_COLUMN_STOCK_ID:
-      if (item->stock_id == NULL && item->icon != NULL)
-        {
-          /* allocate a new icon set for the item */
-          icon_set = gtk_icon_set_new ();
-          icon_source = gtk_icon_source_new ();
-          if (g_path_is_absolute (item->icon))
-            gtk_icon_source_set_filename (icon_source, item->icon);
-          else
-            gtk_icon_source_set_icon_name (icon_source, item->icon);
-          gtk_icon_set_add_source (icon_set, icon_source);
-          gtk_icon_source_free (icon_source);
-
-          /* generate a unique stock-id for the icon */
-          item->stock_id = g_strdup_printf ("thunar-uca-%p", item);
-
-          /* register the icon set */
-          gtk_icon_factory_add (uca_model->icon_factory, item->stock_id, icon_set);
-
-          /* cleanup */
-          gtk_icon_set_unref (icon_set);
-        }
-      g_value_set_static_string (value, item->stock_id);
-      break;
-
     case THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL:
       str = g_markup_printf_escaped ("<b>%s</b>\n%s", (item->name != NULL) ? item->name : "", (item->description != NULL) ? item->description : "");
       g_value_take_string (value, str);
@@ -608,7 +577,6 @@ thunar_uca_model_item_reset (ThunarUcaModelItem *item)
   /* release the previous values... */
   g_strfreev (item->patterns);
   g_free (item->description);
-  g_free (item->stock_id);
   g_free (item->command);
   g_free (item->name);
   g_free (item->icon);
diff --git a/plugins/thunar-uca/thunar-uca-model.h b/plugins/thunar-uca/thunar-uca-model.h
index 2d8e291..d778270 100644
--- a/plugins/thunar-uca/thunar-uca-model.h
+++ b/plugins/thunar-uca/thunar-uca-model.h
@@ -43,7 +43,6 @@ typedef enum
   THUNAR_UCA_MODEL_COLUMN_COMMAND,
   THUNAR_UCA_MODEL_COLUMN_PATTERNS,
   THUNAR_UCA_MODEL_COLUMN_TYPES,
-  THUNAR_UCA_MODEL_COLUMN_STOCK_ID,
   THUNAR_UCA_MODEL_COLUMN_STOCK_LABEL,
   THUNAR_UCA_MODEL_N_COLUMNS,
 } ThunarUcaModelColumn;
diff --git a/plugins/thunar-uca/thunar-uca-provider.c b/plugins/thunar-uca/thunar-uca-provider.c
index 63bae6c..3c5550a 100644
--- a/plugins/thunar-uca/thunar-uca-provider.c
+++ b/plugins/thunar-uca/thunar-uca-provider.c
@@ -208,7 +208,7 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
   GList               *actions = NULL;
   GList               *paths;
   GList               *lp;
-  gchar               *stock_id;
+  gchar               *icon_name;
   gchar               *tooltip;
   gchar               *label;
   gchar               *name;
@@ -222,7 +222,7 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
           /* determine the label, tooltip and stock-id for the item */
           gtk_tree_model_get (GTK_TREE_MODEL (uca_provider->model), &iter,
                               THUNAR_UCA_MODEL_COLUMN_NAME, &label,
-                              THUNAR_UCA_MODEL_COLUMN_STOCK_ID, &stock_id,
+                              THUNAR_UCA_MODEL_COLUMN_ICON, &icon_name,
                               THUNAR_UCA_MODEL_COLUMN_DESCRIPTION, &tooltip,
                               -1);
 
@@ -230,7 +230,8 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
           name = g_strdup_printf ("ThunarUca::action-%d", ++uca_provider->last_action_id);
 
           /* create the new action with the given parameters */
-          action = gtk_action_new (name, label, tooltip, stock_id);
+          action = gtk_action_new (name, label, tooltip, NULL);
+          gtk_action_set_icon_name (action, icon_name);
 
           /* grab a tree row reference on the given path */
           row = gtk_tree_row_reference_new (GTK_TREE_MODEL (uca_provider->model), lp->data);
@@ -253,7 +254,7 @@ thunar_uca_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
           actions = g_list_prepend (actions, action);
 
           /* cleanup */
-          g_free (stock_id);
+          g_free (icon_name);
           g_free (tooltip);
           g_free (label);
           g_free (name);



More information about the Xfce4-commits mailing list