Commit 19383d0e authored by Nick Schermer's avatar Nick Schermer

Use the icon-name property for GtkAction's in uca.

Since GTK+ 2.10 there is an icon-name property for GtkActions.
Use this property instead of creating stock-id's.
parent 7136ce54
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment