Commit 5da78e0a authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

Migrated from stock icons to icon names

GladeApp GladePointerMode icons and devhelp icon are now registered as icon names

GladeWindow: replaced deprecated gtk_tool_button_new_from_stock() with
gtk_tool_button_new() + gtk_image_new_from_icon_name() to create actions tool items

GTK+ Catalog, glade.glade: replaced every stock icon with the corresponding icon name
TODO: the only stock icon that does not seem to have a replacement is gtk-edit
parent 58aef70f
......@@ -268,36 +268,31 @@ glade_app_get_lib_dir (void)
}
static void
pointer_mode_register_icon (GtkIconFactory *factory,
const gchar *icon_name,
pointer_mode_register_icon (const gchar *icon_name,
gint real_size,
GladePointerMode mode,
GtkIconSize size)
{
GdkPixbuf *pixbuf;
pixbuf = glade_utils_pointer_mode_render_icon (mode, size);
if (pixbuf)
if ((pixbuf = glade_utils_pointer_mode_render_icon (mode, size)))
{
GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
gtk_icon_factory_add (factory, icon_name, icon_set);
gtk_icon_theme_add_builtin_icon (icon_name, real_size, pixbuf);
g_object_unref (pixbuf);
}
}
static void
register_stock_icon (GtkIconFactory *factory,
const gchar *stock_id,
const gchar *icon_name,
const gchar *file_name,
GtkIconSize size)
register_icon (const gchar *new_icon_name,
gint size,
const gchar *icon_name,
const gchar *file_name)
{
GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
GdkPixbuf *pixbuf;
GtkIconInfo *info;
gint w, h;
if (gtk_icon_size_lookup (size, &w, &h) &&
(info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, MIN (w, h), 0)))
if ((info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 0)))
{
pixbuf = gtk_icon_info_load_icon (info, NULL);
}
......@@ -310,36 +305,37 @@ register_stock_icon (GtkIconFactory *factory,
if (pixbuf)
{
GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
gtk_icon_factory_add (factory, stock_id, icon_set);
gtk_icon_theme_add_builtin_icon (new_icon_name, size, pixbuf);
g_object_unref (pixbuf);
}
}
/*
* glade_app_register_stock_icons:
* glade_app_register_icon_names:
* @size: icon size
*
* Register a new stock icon for most of GladePointerMode.
* Register a new icon name for most of GladePointerMode.
* After calling this function "glade-selector", "glade-drag-resize",
* "glade-margin-edit" and "glade-align-edit" stock icons will be available.
* "glade-margin-edit" and "glade-align-edit" icon names will be available.
*/
static void
glade_app_register_stock_icons (GtkIconSize size)
glade_app_register_icon_names (GtkIconSize size)
{
GtkIconFactory *factory = gtk_icon_factory_new ();
gint w, h, real_size;
pointer_mode_register_icon (factory, "glade-selector", GLADE_POINTER_SELECT, size);
pointer_mode_register_icon (factory, "glade-drag-resize", GLADE_POINTER_DRAG_RESIZE, size);
pointer_mode_register_icon (factory, "glade-margin-edit", GLADE_POINTER_MARGIN_EDIT, size);
pointer_mode_register_icon (factory, "glade-align-edit", GLADE_POINTER_ALIGN_EDIT, size);
if (gtk_icon_size_lookup (size, &w, &h) == FALSE)
return;
register_stock_icon (factory, "glade-devhelp",
GLADE_DEVHELP_ICON_NAME,
GLADE_DEVHELP_FALLBACK_ICON_FILE,
size);
gtk_icon_factory_add_default (factory);
real_size = MIN (w, h);
pointer_mode_register_icon ("glade-selector", real_size, GLADE_POINTER_SELECT, size);
pointer_mode_register_icon ("glade-drag-resize", real_size, GLADE_POINTER_DRAG_RESIZE, size);
pointer_mode_register_icon ("glade-margin-edit", real_size, GLADE_POINTER_MARGIN_EDIT, size);
pointer_mode_register_icon ("glade-align-edit", real_size, GLADE_POINTER_ALIGN_EDIT, size);
register_icon ("glade-devhelp", real_size,
GLADE_DEVHELP_ICON_NAME,
GLADE_DEVHELP_FALLBACK_ICON_FILE);
}
/**
......@@ -358,7 +354,7 @@ glade_init (void)
glade_init_check ();
/* Register icons needed by the UI */
glade_app_register_stock_icons (GTK_ICON_SIZE_LARGE_TOOLBAR);
glade_app_register_icon_names (GTK_ICON_SIZE_LARGE_TOOLBAR);
init = TRUE;
}
......
......@@ -34,10 +34,10 @@
</signals>
<actions>
<action id="preview" _name="Preview snapshot" stock="gtk-execute" important="True"/>
<action id="preview" _name="Preview snapshot" stock="system-run" important="True"/>
<action id="edit_separate" _name="Edit Separately" stock="gtk-edit"/>
<action id="remove_parent" _name="Remove Parent" stock="gtk-remove"/>
<action id="add_parent" _name="Add Parent" stock="gtk-add">
<action id="remove_parent" _name="Remove Parent" stock="list-remove"/>
<action id="add_parent" _name="Add Parent" stock="list-add">
<action id="alignment" _name="Alignment"/>
<action id="viewport" _name="Viewport"/>
<action id="eventbox" _name="Event Box"/>
......@@ -50,7 +50,7 @@
<action id="paned" _name="Paned"/>
</action>
<action id="sizegroup_add" _name="Add to Size Group"/>
<action id="clear_properties" _name="Clear properties" stock="gtk-clear"/>
<action id="clear_properties" _name="Clear properties" stock="edit-clear"/>
<action id="read_documentation" _name="Read documentation" stock="glade-devhelp" important="True"/>
</actions>
......@@ -629,9 +629,9 @@
<child-action-activate-function>glade_gtk_box_child_action_activate</child-action-activate-function>
<packing-actions>
<action id="insert_before" _name="Insert Before" stock="gtk-add"/>
<action id="insert_after" _name="Insert After" stock="gtk-add"/>
<action id="remove_slot" _name="Remove Slot" stock="gtk-remove"/>
<action id="insert_before" _name="Insert Before" stock="list-add"/>
<action id="insert_after" _name="Insert After" stock="list-add"/>
<action id="remove_slot" _name="Remove Slot" stock="list-remove"/>
</packing-actions>
<properties>
......@@ -2195,16 +2195,16 @@
<child-action-activate-function>glade_gtk_table_child_action_activate</child-action-activate-function>
<packing-actions>
<action id="insert_row" _name="Insert Row" stock="gtk-add">
<action id="insert_row" _name="Insert Row" stock="list-add">
<action id="before" _name="Before"/>
<action id="after" _name="After"/>
</action>
<action id="insert_column" _name="Insert Column" stock="gtk-add">
<action id="insert_column" _name="Insert Column" stock="list-add">
<action id="before" _name="Before"/>
<action id="after" _name="After"/>
</action>
<action id="remove_row" _name="Remove Row" stock="gtk-remove"/>
<action id="remove_column" _name="Remove Column" stock="gtk-remove"/>
<action id="remove_row" _name="Remove Row" stock="list-remove"/>
<action id="remove_column" _name="Remove Column" stock="list-remove"/>
</packing-actions>
<properties>
......@@ -2245,16 +2245,16 @@
<child-action-activate-function>glade_gtk_grid_child_action_activate</child-action-activate-function>
<packing-actions>
<action id="insert_row" _name="Insert Row" stock="gtk-add">
<action id="insert_row" _name="Insert Row" stock="list-add">
<action id="before" _name="Before"/>
<action id="after" _name="After"/>
</action>
<action id="insert_column" _name="Insert Column" stock="gtk-add">
<action id="insert_column" _name="Insert Column" stock="list-add">
<action id="before" _name="Before"/>
<action id="after" _name="After"/>
</action>
<action id="remove_row" _name="Remove Row" stock="gtk-remove"/>
<action id="remove_column" _name="Remove Column" stock="gtk-remove"/>
<action id="remove_row" _name="Remove Row" stock="list-remove"/>
<action id="remove_column" _name="Remove Column" stock="list-remove"/>
</packing-actions>
<properties>
......@@ -2338,9 +2338,9 @@
</signals>
<packing-actions>
<action id="insert_page_before" _name="Insert Page Before" stock="gtk-add"/>
<action id="insert_page_after" _name="Insert Page After" stock="gtk-add"/>
<action id="remove_page" _name="Remove Page" stock="gtk-remove"/>
<action id="insert_page_before" _name="Insert Page Before" stock="list-add"/>
<action id="insert_page_after" _name="Insert Page After" stock="list-add"/>
<action id="remove_page" _name="Remove Page" stock="list-remove"/>
</packing-actions>
<properties>
......@@ -2427,12 +2427,12 @@
<child-get-property-function>glade_gtk_listbox_get_child_property</child-get-property-function>
<actions>
<action id="add_row" _name="Add Row" stock="gtk-add" important="True"/>
<action id="add_row" _name="Add Row" stock="list-add" important="True"/>
</actions>
<packing-actions>
<action id="insert_before" _name="Insert Before" stock="gtk-add"/>
<action id="insert_after" _name="Insert After" stock="gtk-add"/>
<action id="insert_before" _name="Insert Before" stock="list-add"/>
<action id="insert_after" _name="Insert After" stock="list-add"/>
</packing-actions>
<properties>
......
......@@ -410,6 +410,7 @@ add_actions (GladeWindow *window, GladeWidget *widget, GList *actions)
{
GladeWidgetAction *action = l->data;
GWActionClass *aclass = glade_widget_action_get_class (action);
GtkWidget *image;
if (!aclass->important || !glade_widget_action_get_visible (action))
continue;
......@@ -420,12 +421,11 @@ add_actions (GladeWindow *window, GladeWidget *widget, GList *actions)
continue;
}
item = gtk_tool_button_new_from_stock ((aclass->stock) ? aclass->stock : "gtk-execute");
image = gtk_image_new_from_icon_name ((aclass->stock) ? aclass->stock : "system-run",
GTK_ICON_SIZE_LARGE_TOOLBAR);
item = gtk_tool_button_new (image, NULL);
if (aclass->label)
{
gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), aclass->label);
gtk_widget_set_tooltip_text (GTK_WIDGET (item), aclass->label);
}
gtk_widget_set_tooltip_text (GTK_WIDGET (item), aclass->label);
g_object_set_data (G_OBJECT (item), "glade-widget", widget);
......@@ -445,7 +445,7 @@ add_actions (GladeWindow *window, GladeWidget *widget, GList *actions)
gtk_toolbar_insert (bar, item, -1);
gtk_tool_item_set_homogeneous (item, FALSE);
gtk_widget_show (GTK_WIDGET (item));
gtk_widget_show_all (GTK_WIDGET (item));
n++;
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0
<!-- Generated with glade 3.18.1
Glade - A user interface designer for GTK+ and GNOME.
Copyright (C) 2012-2014 Juan Pablo Ugarte
......@@ -95,7 +95,6 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Select</property>
<property name="short_label" translatable="yes">Select</property>
<property name="tooltip" translatable="yes">Select widgets in the workspace</property>
<property name="stock_id">glade-selector</property>
<property name="icon_name">glade-selector</property>
<property name="draw_as_radio">True</property>
<signal name="changed" handler="on_selector_radioaction_changed" swapped="no"/>
......@@ -106,7 +105,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Drag Resize</property>
<property name="short_label" translatable="yes">Drag Resize</property>
<property name="tooltip" translatable="yes">Drag and resize widgets in the workspace</property>
<property name="stock_id">glade-drag-resize</property>
<property name="icon_name">glade-drag-resize</property>
<property name="draw_as_radio">True</property>
<property name="value">2</property>
<property name="group">selector_radioaction</property>
......@@ -117,7 +116,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Margin Edit</property>
<property name="short_label" translatable="yes">Margin Edit</property>
<property name="tooltip" translatable="yes">Edit widget margins</property>
<property name="stock_id">glade-margin-edit</property>
<property name="icon_name">glade-margin-edit</property>
<property name="draw_as_radio">True</property>
<property name="value">3</property>
<property name="group">selector_radioaction</property>
......@@ -128,7 +127,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Alignment Edit</property>
<property name="short_label" translatable="yes">Alignment Edit</property>
<property name="tooltip" translatable="yes">Edit widget alignment</property>
<property name="stock_id">glade-align-edit</property>
<property name="icon_name">glade-align-edit</property>
<property name="draw_as_radio">True</property>
<property name="value">4</property>
<property name="group">selector_radioaction</property>
......@@ -144,7 +143,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="save_action">
<property name="label" translatable="yes">Save</property>
<property name="tooltip" translatable="yes">Save the current project</property>
<property name="stock_id">gtk-save</property>
<property name="icon_name">document-save</property>
<signal name="activate" handler="on_save_action_activate" swapped="no"/>
</object>
<accelerator key="s" modifiers="GDK_CONTROL_MASK"/>
......@@ -153,7 +152,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="save_as_action">
<property name="label" translatable="yes">Save _As</property>
<property name="tooltip" translatable="yes">Save the current project with a different name</property>
<property name="stock_id">gtk-save-as</property>
<property name="icon_name">document-save-as</property>
<signal name="activate" handler="on_save_as_action_activate" swapped="no"/>
</object>
</child>
......@@ -161,7 +160,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="properties_action">
<property name="label" translatable="yes">Properties</property>
<property name="tooltip" translatable="yes">Edit project properties</property>
<property name="stock_id">gtk-properties</property>
<property name="icon_name">document-properties</property>
<signal name="activate" handler="on_properties_action_activate" swapped="no"/>
</object>
<accelerator key="p" modifiers="GDK_CONTROL_MASK"/>
......@@ -170,7 +169,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="close_action">
<property name="label" translatable="yes">Close</property>
<property name="tooltip" translatable="yes">Close the current project</property>
<property name="stock_id">gtk-close</property>
<property name="icon_name">window-close</property>
<signal name="activate" handler="on_close_action_activate" swapped="no"/>
</object>
<accelerator key="w" modifiers="GDK_CONTROL_MASK"/>
......@@ -180,7 +179,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Undo</property>
<property name="short_label" translatable="yes">Undo</property>
<property name="tooltip" translatable="yes">Undo the last action</property>
<property name="stock_id">gtk-undo</property>
<property name="icon_name">edit-undo</property>
<signal name="activate" handler="on_undo_action_activate" swapped="no"/>
</object>
<accelerator key="z" modifiers="GDK_CONTROL_MASK"/>
......@@ -190,7 +189,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Redo</property>
<property name="short_label" translatable="yes">Redo</property>
<property name="tooltip" translatable="yes">Redo the last action</property>
<property name="stock_id">gtk-redo</property>
<property name="icon_name">edit-redo</property>
<signal name="activate" handler="on_redo_action_activate" swapped="no"/>
</object>
<accelerator key="z" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
......@@ -200,7 +199,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Cut</property>
<property name="short_label" translatable="yes">Cut</property>
<property name="tooltip" translatable="yes">Cut the selection</property>
<property name="stock_id">gtk-cut</property>
<property name="icon_name">edit-cut</property>
<signal name="activate" handler="on_cut_action_activate" swapped="no"/>
</object>
<accelerator key="x" modifiers="GDK_CONTROL_MASK"/>
......@@ -210,7 +209,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Copy</property>
<property name="short_label" translatable="yes">Copy</property>
<property name="tooltip" translatable="yes">Copy the selection</property>
<property name="stock_id">gtk-copy</property>
<property name="icon_name">edit-copy</property>
<signal name="activate" handler="on_copy_action_activate" swapped="no"/>
</object>
<accelerator key="c" modifiers="GDK_CONTROL_MASK"/>
......@@ -220,7 +219,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Paste</property>
<property name="short_label" translatable="yes">Paste</property>
<property name="tooltip" translatable="yes">Paste the clipboard</property>
<property name="stock_id">gtk-paste</property>
<property name="icon_name">edit-paste</property>
<signal name="activate" handler="on_paste_action_activate" swapped="no"/>
</object>
<accelerator key="v" modifiers="GDK_CONTROL_MASK"/>
......@@ -230,7 +229,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Delete</property>
<property name="short_label" translatable="yes">Delete</property>
<property name="tooltip" translatable="yes">Delete the selection</property>
<property name="stock_id">Delete</property>
<property name="icon_name">edit-delete</property>
<signal name="activate" handler="on_delete_action_activate" swapped="no"/>
</object>
<accelerator key="Delete"/>
......@@ -367,7 +366,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="new_action">
<property name="label" translatable="yes">New</property>
<property name="tooltip" translatable="yes">Create a new project</property>
<property name="stock_id">gtk-new</property>
<property name="icon_name">document-new</property>
<signal name="activate" handler="glade_window_new_project" swapped="yes"/>
</object>
<accelerator key="n" modifiers="GDK_CONTROL_MASK"/>
......@@ -376,7 +375,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="open_action">
<property name="label" translatable="yes">Open</property>
<property name="tooltip" translatable="yes">Open a project</property>
<property name="stock_id">gtk-open</property>
<property name="icon_name">document-open</property>
<signal name="activate" handler="on_open_action_activate" swapped="no"/>
</object>
<accelerator key="o" modifiers="GDK_CONTROL_MASK"/>
......@@ -385,7 +384,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="quit_action">
<property name="label" translatable="yes">Quit</property>
<property name="tooltip" translatable="yes">Quit the program</property>
<property name="stock_id">gtk-quit</property>
<property name="icon_name">application-exit</property>
<signal name="activate" handler="on_quit_action_activate" swapped="no"/>
</object>
<accelerator key="q" modifiers="GDK_CONTROL_MASK"/>
......@@ -394,7 +393,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="about_action">
<property name="label" translatable="yes">About</property>
<property name="tooltip" translatable="yes">About this application</property>
<property name="stock_id">gtk-about</property>
<property name="icon_name">help-about</property>
<signal name="activate" handler="on_about_action_activate" swapped="no"/>
</object>
</child>
......@@ -402,6 +401,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<object class="GtkAction" id="reference_action">
<property name="label" translatable="yes">_Developer Reference</property>
<property name="tooltip" translatable="yes">Display the developer reference manual</property>
<property name="icon_name">help-contents</property>
<signal name="activate" handler="on_reference_action_activate" swapped="no"/>
</object>
<accelerator key="F1"/>
......@@ -411,6 +411,7 @@ Andreas Nilsson &lt;andreas@andreasn.se&gt;</property>
<property name="label" translatable="yes">Preferences</property>
<property name="tooltip" translatable="yes">Edit Glade preferences</property>
<property name="stock_id">gtk-preferences</property>
<property name="icon_name">document-properties</property>
<signal name="activate" handler="on_preferences_action_activate" swapped="no"/>
</object>
</child>
......
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