[gimp] libgimpwidgets: mostly port from stock IDs to icon names
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: mostly port from stock IDs to icon names
- Date: Wed, 7 May 2014 19:34:01 +0000 (UTC)
commit 79bd9c60de27c2f26b641b2efdc52a33a9d87907
Author: Michael Natterer <mitch gimp org>
Date: Wed May 7 21:27:57 2014 +0200
libgimpwidgets: mostly port from stock IDs to icon names
Add some new API and deprecate old one.
libgimpwidgets/gimpbrowser.c | 4 +-
libgimpwidgets/gimpchainbutton.c | 8 +-
libgimpwidgets/gimpcolorbutton.c | 8 +-
libgimpwidgets/gimpcolornotebook.c | 10 +-
libgimpwidgets/gimpenumcombobox.c | 24 +++++-
libgimpwidgets/gimpenumcombobox.h | 4 +
libgimpwidgets/gimpenumstore.c | 37 ++++++--
libgimpwidgets/gimpenumstore.h | 4 +
libgimpwidgets/gimpenumwidgets.c | 161 ++++++++++++++++++++++++++--------
libgimpwidgets/gimpenumwidgets.h | 21 ++++-
libgimpwidgets/gimpfileentry.c | 12 ++--
libgimpwidgets/gimphintbox.c | 41 +++++++--
libgimpwidgets/gimpintstore.c | 2 +-
libgimpwidgets/gimpintstore.h | 10 ++-
libgimpwidgets/gimppickbutton.c | 4 +-
libgimpwidgets/gimppropwidgets.c | 57 +++++++++---
libgimpwidgets/gimppropwidgets.h | 8 ++
libgimpwidgets/gimpquerybox.c | 14 ++--
libgimpwidgets/gimpquerybox.h | 2 +-
libgimpwidgets/gimpscrolledpreview.c | 3 +-
libgimpwidgets/gimpwidgets.def | 6 ++
libgimpwidgets/gimpzoommodel.c | 20 ++---
22 files changed, 346 insertions(+), 114 deletions(-)
---
diff --git a/libgimpwidgets/gimpbrowser.c b/libgimpwidgets/gimpbrowser.c
index c418ea7..c063256 100644
--- a/libgimpwidgets/gimpbrowser.c
+++ b/libgimpwidgets/gimpbrowser.c
@@ -124,8 +124,8 @@ gimp_browser_init (GimpBrowser *browser)
G_CALLBACK (gimp_browser_entry_changed),
browser);
- gtk_entry_set_icon_from_stock (GTK_ENTRY (browser->search_entry),
- GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (browser->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
gtk_entry_set_icon_activatable (GTK_ENTRY (browser->search_entry),
GTK_ENTRY_ICON_SECONDARY, TRUE);
gtk_entry_set_icon_sensitive (GTK_ENTRY (browser->search_entry),
diff --git a/libgimpwidgets/gimpchainbutton.c b/libgimpwidgets/gimpchainbutton.c
index 7823431..3ee2e46 100644
--- a/libgimpwidgets/gimpchainbutton.c
+++ b/libgimpwidgets/gimpchainbutton.c
@@ -87,7 +87,7 @@ G_DEFINE_TYPE (GimpChainButton, gimp_chain_button, GTK_TYPE_TABLE)
static guint gimp_chain_button_signals[LAST_SIGNAL] = { 0 };
-static const gchar * const gimp_chain_stock_items[] =
+static const gchar * const gimp_chain_icon_names[] =
{
GIMP_STOCK_HCHAIN,
GIMP_STOCK_HCHAIN_BROKEN,
@@ -308,9 +308,9 @@ gimp_chain_button_update_image (GimpChainButton *button)
i = ((button->position & GIMP_CHAIN_LEFT) << 1) + (button->active ? 0 : 1);
- gtk_image_set_from_stock (GTK_IMAGE (button->image),
- gimp_chain_stock_items[i],
- GTK_ICON_SIZE_BUTTON);
+ gtk_image_set_from_icon_name (GTK_IMAGE (button->image),
+ gimp_chain_icon_names[i],
+ GTK_ICON_SIZE_BUTTON);
}
diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c
index eee071a..d74fb4e 100644
--- a/libgimpwidgets/gimpcolorbutton.c
+++ b/libgimpwidgets/gimpcolorbutton.c
@@ -331,10 +331,10 @@ gimp_color_button_init (GimpColorButton *button,
GtkAction *action;
action = g_object_new (klass->get_action_type (button),
- "name", actions[i].name,
- "label", label,
- "tooltip", tooltip,
- "stock-id", actions[i].stock_id,
+ "name", actions[i].name,
+ "label", label,
+ "tooltip", tooltip,
+ "icon-name", actions[i].stock_id,
NULL);
if (actions[i].callback)
diff --git a/libgimpwidgets/gimpcolornotebook.c b/libgimpwidgets/gimpcolornotebook.c
index 8ee6999..7a7580f 100644
--- a/libgimpwidgets/gimpcolornotebook.c
+++ b/libgimpwidgets/gimpcolornotebook.c
@@ -203,7 +203,7 @@ gimp_color_notebook_style_set (GtkWidget *widget,
selector_class = GIMP_COLOR_SELECTOR_GET_CLASS (list->data);
- image = gtk_image_new_from_stock (selector_class->stock_id, icon_size);
+ image = gtk_image_new_from_icon_name (selector_class->stock_id, icon_size);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook->notebook),
GTK_WIDGET (list->data),
@@ -392,8 +392,8 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
menu_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
- image = gtk_image_new_from_stock (selector_class->stock_id,
- GTK_ICON_SIZE_MENU);
+ image = gtk_image_new_from_icon_name (selector_class->stock_id,
+ GTK_ICON_SIZE_MENU);
gtk_box_pack_start (GTK_BOX (menu_widget), image, FALSE, FALSE, 0);
gtk_widget_show (image);
@@ -401,8 +401,8 @@ gimp_color_notebook_add_page (GimpColorNotebook *notebook,
gtk_box_pack_start (GTK_BOX (menu_widget), label, FALSE, FALSE, 0);
gtk_widget_show (label);
- image = gtk_image_new_from_stock (selector_class->stock_id,
- DEFAULT_TAB_ICON_SIZE);
+ image = gtk_image_new_from_icon_name (selector_class->stock_id,
+ DEFAULT_TAB_ICON_SIZE);
gtk_notebook_append_page_menu (GTK_NOTEBOOK (notebook->notebook),
page, image, menu_widget);
diff --git a/libgimpwidgets/gimpenumcombobox.c b/libgimpwidgets/gimpenumcombobox.c
index 456eb53..e1aa736 100644
--- a/libgimpwidgets/gimpenumcombobox.c
+++ b/libgimpwidgets/gimpenumcombobox.c
@@ -192,16 +192,38 @@ gimp_enum_combo_box_new_with_model (GimpEnumStore *enum_store)
* @stock_prefix.
*
* Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
**/
void
gimp_enum_combo_box_set_stock_prefix (GimpEnumComboBox *combo_box,
const gchar *stock_prefix)
{
+ gimp_enum_combo_box_set_icon_prefix (combo_box, stock_prefix);
+}
+
+/**
+ * gimp_enum_combo_box_set_icon_prefix:
+ * @combo_box: a #GimpEnumComboBox
+ * @icon_prefix: a prefix to create icon names from enum values
+ *
+ * Attempts to create icons for all items in the @combo_box. See
+ * gimp_enum_store_set_icon_prefix() to find out what to use as
+ * @icon_prefix.
+ *
+ * Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
+ **/
+void
+gimp_enum_combo_box_set_icon_prefix (GimpEnumComboBox *combo_box,
+ const gchar *icon_prefix)
+{
GtkTreeModel *model;
g_return_if_fail (GIMP_IS_ENUM_COMBO_BOX (combo_box));
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
- gimp_enum_store_set_stock_prefix (GIMP_ENUM_STORE (model), stock_prefix);
+ gimp_enum_store_set_icon_prefix (GIMP_ENUM_STORE (model), icon_prefix);
}
diff --git a/libgimpwidgets/gimpenumcombobox.h b/libgimpwidgets/gimpenumcombobox.h
index 62379b8..a729952 100644
--- a/libgimpwidgets/gimpenumcombobox.h
+++ b/libgimpwidgets/gimpenumcombobox.h
@@ -62,9 +62,13 @@ GType gimp_enum_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_combo_box_new (GType enum_type);
GtkWidget * gimp_enum_combo_box_new_with_model (GimpEnumStore *enum_store);
+GIMP_DEPRECATED_FOR(gimp_enum_combo_box_set_icon_prefix)
void gimp_enum_combo_box_set_stock_prefix (GimpEnumComboBox *combo_box,
const gchar *stock_prefix);
+void gimp_enum_combo_box_set_icon_prefix (GimpEnumComboBox *combo_box,
+ const gchar *icon_prefix);
+
G_END_DECLS
#endif /* __GIMP_ENUM_COMBO_BOX_H__ */
diff --git a/libgimpwidgets/gimpenumstore.c b/libgimpwidgets/gimpenumstore.c
index 07ff090..6ea0146 100644
--- a/libgimpwidgets/gimpenumstore.c
+++ b/libgimpwidgets/gimpenumstore.c
@@ -318,11 +318,32 @@ gimp_enum_store_new_with_values_valist (GType enum_type,
* See also: gimp_enum_combo_box_set_stock_prefix().
*
* Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
**/
void
gimp_enum_store_set_stock_prefix (GimpEnumStore *store,
const gchar *stock_prefix)
{
+ gimp_enum_store_set_icon_prefix (store, stock_prefix);
+}
+
+/**
+ * gimp_enum_store_set_icon_prefix:
+ * @store: a #GimpEnumStore
+ * @icon_prefix: a prefix to create icon names from enum values
+ *
+ * Creates an icon name for each enum value in the @store by appending
+ * the value's nick to the given @icon_prefix, separated by a hyphen.
+ *
+ * See also: gimp_enum_combo_box_set_icon_prefix().
+ *
+ * Since: GIMP 2.10
+ **/
+void
+gimp_enum_store_set_icon_prefix (GimpEnumStore *store,
+ const gchar *icon_prefix)
+{
GtkTreeModel *model;
GtkTreeIter iter;
gboolean iter_valid;
@@ -335,9 +356,9 @@ gimp_enum_store_set_stock_prefix (GimpEnumStore *store,
iter_valid;
iter_valid = gtk_tree_model_iter_next (model, &iter))
{
- gchar *stock_id = NULL;
+ gchar *icon_name = NULL;
- if (stock_prefix)
+ if (icon_prefix)
{
GEnumValue *enum_value;
gint value;
@@ -348,16 +369,16 @@ gimp_enum_store_set_stock_prefix (GimpEnumStore *store,
enum_value = g_enum_get_value (store->enum_class, value);
- stock_id = g_strconcat (stock_prefix, "-",
- enum_value->value_nick,
- NULL);
+ icon_name = g_strconcat (icon_prefix, "-",
+ enum_value->value_nick,
+ NULL);
}
gtk_list_store_set (GTK_LIST_STORE (store), &iter,
- GIMP_INT_STORE_STOCK_ID, stock_id,
+ GIMP_INT_STORE_ICON_NAME, icon_name,
-1);
- if (stock_id)
- g_free (stock_id);
+ if (icon_name)
+ g_free (icon_name);
}
}
diff --git a/libgimpwidgets/gimpenumstore.h b/libgimpwidgets/gimpenumstore.h
index bd7dfe0..176af6f 100644
--- a/libgimpwidgets/gimpenumstore.h
+++ b/libgimpwidgets/gimpenumstore.h
@@ -72,9 +72,13 @@ GtkListStore * gimp_enum_store_new_with_values_valist (GType enum_type,
gint n_values,
va_list args);
+GIMP_DEPRECATED_FOR(gimp_enum_store_set_icon_prefix)
void gimp_enum_store_set_stock_prefix (GimpEnumStore *store,
const gchar *stock_prefix);
+void gimp_enum_store_set_icon_prefix (GimpEnumStore *store,
+ const gchar *icon_prefix);
+
G_END_DECLS
diff --git a/libgimpwidgets/gimpenumwidgets.c b/libgimpwidgets/gimpenumwidgets.c
index 2021f4c..f311123 100644
--- a/libgimpwidgets/gimpenumwidgets.c
+++ b/libgimpwidgets/gimpenumwidgets.c
@@ -276,6 +276,8 @@ gimp_enum_radio_frame_new_with_range (GType enum_type,
* Return value: a new #GtkHBox holding a group of #GtkRadioButtons.
*
* Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
**/
GtkWidget *
gimp_enum_stock_box_new (GType enum_type,
@@ -285,23 +287,9 @@ gimp_enum_stock_box_new (GType enum_type,
gpointer callback_data,
GtkWidget **first_button)
{
- GEnumClass *enum_class;
- GtkWidget *box;
-
- g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
-
- enum_class = g_type_class_ref (enum_type);
-
- box = gimp_enum_stock_box_new_with_range (enum_type,
- enum_class->minimum,
- enum_class->maximum,
- stock_prefix, icon_size,
- callback, callback_data,
- first_button);
-
- g_type_class_unref (enum_class);
-
- return box;
+ return gimp_enum_icon_box_new (enum_type, stock_prefix, icon_size,
+ callback, callback_data,
+ first_button);
}
/**
@@ -323,6 +311,8 @@ gimp_enum_stock_box_new (GType enum_type,
* Return value: a new #GtkHBox holding a group of #GtkRadioButtons.
*
* Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
**/
GtkWidget *
gimp_enum_stock_box_new_with_range (GType enum_type,
@@ -334,16 +324,118 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
gpointer callback_data,
GtkWidget **first_button)
{
+ return gimp_enum_icon_box_new_with_range (enum_type, minimum, maximum,
+ stock_prefix, icon_size,
+ callback, callback_data,
+ first_button);
+}
+
+/**
+ * gimp_enum_stock_box_set_child_padding:
+ * @stock_box: a stock box widget
+ * @xpad: horizontal padding
+ * @ypad: vertical padding
+ *
+ * Sets the padding of all buttons in a box created by
+ * gimp_enum_stock_box_new().
+ *
+ * Since: GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
+ **/
+void
+gimp_enum_stock_box_set_child_padding (GtkWidget *stock_box,
+ gint xpad,
+ gint ypad)
+{
+ gimp_enum_icon_box_set_child_padding (stock_box, xpad, ypad);
+}
+
+/**
+ * gimp_enum_icon_box_new:
+ * @enum_type: the #GType of an enum.
+ * @icon_prefix: the prefix of the group of icon names to use.
+ * @icon_size: the icon size for the icons
+ * @callback: a callback to connect to the "toggled" signal of each
+ * #GtkRadioButton that is created.
+ * @callback_data: data to pass to the @callback.
+ * @first_button: returns the first button in the created group.
+ *
+ * Creates a horizontal box of radio buttons with named icons. The
+ * icon name for each icon is created by appending the enum_value's
+ * nick to the given @icon_prefix.
+ *
+ * Return value: a new #GtkHBox holding a group of #GtkRadioButtons.
+ *
+ * Since: GIMP 2.10
+ **/
+GtkWidget *
+gimp_enum_icon_box_new (GType enum_type,
+ const gchar *icon_prefix,
+ GtkIconSize icon_size,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget **first_button)
+{
+ GEnumClass *enum_class;
+ GtkWidget *box;
+
+ g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
+
+ enum_class = g_type_class_ref (enum_type);
+
+ box = gimp_enum_icon_box_new_with_range (enum_type,
+ enum_class->minimum,
+ enum_class->maximum,
+ icon_prefix, icon_size,
+ callback, callback_data,
+ first_button);
+
+ g_type_class_unref (enum_class);
+
+ return box;
+}
+
+/**
+ * gimp_enum_icon_box_new_with_range:
+ * @enum_type: the #GType of an enum.
+ * @minimum: the minumim enum value
+ * @maximum: the maximum enum value
+ * @icon_prefix: the prefix of the group of icon names to use.
+ * @icon_size: the icon size for the icons
+ * @callback: a callback to connect to the "toggled" signal of each
+ * #GtkRadioButton that is created.
+ * @callback_data: data to pass to the @callback.
+ * @first_button: returns the first button in the created group.
+ *
+ * Just like gimp_enum_icon_box_new(), this function creates a group
+ * of radio buttons, but additionally it supports limiting the range
+ * of available enum values.
+ *
+ * Return value: a new #GtkHBox holding a group of #GtkRadioButtons.
+ *
+ * Since: GIMP 2.10
+ **/
+GtkWidget *
+gimp_enum_icon_box_new_with_range (GType enum_type,
+ gint minimum,
+ gint maximum,
+ const gchar *icon_prefix,
+ GtkIconSize icon_size,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget **first_button)
+{
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *image;
GEnumClass *enum_class;
GEnumValue *value;
- gchar *stock_id;
+ gchar *icon_name;
GSList *group = NULL;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
- g_return_val_if_fail (stock_prefix != NULL, NULL);
+ g_return_val_if_fail (icon_prefix != NULL, NULL);
enum_class = g_type_class_ref (enum_type);
@@ -367,14 +459,11 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
if (first_button && *first_button == NULL)
*first_button = button;
- stock_id = g_strconcat (stock_prefix, "-", value->value_nick, NULL);
+ icon_name = g_strconcat (icon_prefix, "-", value->value_nick, NULL);
- if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), stock_id))
- image = gtk_image_new_from_icon_name (stock_id, icon_size);
- else
- image = gtk_image_new_from_stock (stock_id, icon_size);
+ image = gtk_image_new_from_icon_name (icon_name, icon_size);
- g_free (stock_id);
+ g_free (icon_name);
if (image)
{
@@ -403,27 +492,27 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
}
/**
- * gimp_enum_stock_box_set_child_padding:
- * @stock_box: a stock box widget
- * @xpad: horizontal padding
- * @ypad: vertical padding
+ * gimp_enum_icon_box_set_child_padding:
+ * @icon_box: an icon box widget
+ * @xpad: horizontal padding
+ * @ypad: vertical padding
*
* Sets the padding of all buttons in a box created by
- * gimp_enum_stock_box_new().
+ * gimp_enum_icon_box_new().
*
- * Since: GIMP 2.4
+ * Since: GIMP 2.10
**/
void
-gimp_enum_stock_box_set_child_padding (GtkWidget *stock_box,
- gint xpad,
- gint ypad)
+gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
+ gint xpad,
+ gint ypad)
{
GList *children;
GList *list;
- g_return_if_fail (GTK_IS_CONTAINER (stock_box));
+ g_return_if_fail (GTK_IS_CONTAINER (icon_box));
- children = gtk_container_get_children (GTK_CONTAINER (stock_box));
+ children = gtk_container_get_children (GTK_CONTAINER (icon_box));
for (list = children; list; list = g_list_next (list))
{
diff --git a/libgimpwidgets/gimpenumwidgets.h b/libgimpwidgets/gimpenumwidgets.h
index 962c696..a31c673 100644
--- a/libgimpwidgets/gimpenumwidgets.h
+++ b/libgimpwidgets/gimpenumwidgets.h
@@ -53,12 +53,14 @@ GtkWidget * gimp_enum_radio_frame_new_with_range (GType enum_type,
gpointer callback_data,
GtkWidget **first_button);
+GIMP_DEPRECATED_FOR(gimp_enum_icon_box_new)
GtkWidget * gimp_enum_stock_box_new (GType enum_type,
const gchar *stock_prefix,
GtkIconSize icon_size,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
+GIMP_DEPRECATED_FOR(gimp_enum_icon_box_new_with_range)
GtkWidget * gimp_enum_stock_box_new_with_range (GType enum_type,
gint minimum,
gint maximum,
@@ -67,11 +69,28 @@ GtkWidget * gimp_enum_stock_box_new_with_range (GType enum_type,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
-
+GIMP_DEPRECATED_FOR(gimp_enum_icon_box_set_child_padding)
void gimp_enum_stock_box_set_child_padding (GtkWidget *stock_box,
gint xpad,
gint ypad);
+GtkWidget * gimp_enum_icon_box_new (GType enum_type,
+ const gchar *icon_prefix,
+ GtkIconSize icon_size,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget **first_button);
+GtkWidget * gimp_enum_icon_box_new_with_range (GType enum_type,
+ gint minimum,
+ gint maximum,
+ const gchar *icon_prefix,
+ GtkIconSize icon_size,
+ GCallback callback,
+ gpointer callback_data,
+ GtkWidget **first_button);
+void gimp_enum_icon_box_set_child_padding (GtkWidget *icon_box,
+ gint xpad,
+ gint ypad);
G_END_DECLS
diff --git a/libgimpwidgets/gimpfileentry.c b/libgimpwidgets/gimpfileentry.c
index 93a33bd..437f2e3 100644
--- a/libgimpwidgets/gimpfileentry.c
+++ b/libgimpwidgets/gimpfileentry.c
@@ -129,7 +129,7 @@ gimp_file_entry_init (GimpFileEntry *entry)
gtk_box_pack_end (GTK_BOX (entry), entry->browse_button, FALSE, FALSE, 0);
gtk_widget_show (entry->browse_button);
- image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
+ image = gtk_image_new_from_icon_name (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (entry->browse_button), image);
gtk_widget_show (image);
@@ -203,8 +203,8 @@ gimp_file_entry_new (const gchar *title,
if (check_valid)
{
- entry->file_exists = gtk_image_new_from_stock (GTK_STOCK_NO,
- GTK_ICON_SIZE_BUTTON);
+ entry->file_exists = gtk_image_new_from_icon_name (GTK_STOCK_NO,
+ GTK_ICON_SIZE_BUTTON);
gtk_box_pack_start (GTK_BOX (entry), entry->file_exists, FALSE, FALSE, 0);
gtk_widget_show (entry->file_exists);
}
@@ -430,7 +430,7 @@ gimp_file_entry_check_filename (GimpFileEntry *entry)
g_free (filename);
- gtk_image_set_from_stock (GTK_IMAGE (entry->file_exists),
- exists ? GTK_STOCK_YES : GTK_STOCK_NO,
- GTK_ICON_SIZE_BUTTON);
+ gtk_image_set_from_icon_name (GTK_IMAGE (entry->file_exists),
+ exists ? GTK_STOCK_YES : GTK_STOCK_NO,
+ GTK_ICON_SIZE_BUTTON);
}
diff --git a/libgimpwidgets/gimphintbox.c b/libgimpwidgets/gimphintbox.c
index ae20e05..58f6387 100644
--- a/libgimpwidgets/gimphintbox.c
+++ b/libgimpwidgets/gimphintbox.c
@@ -42,6 +42,7 @@ typedef struct
{
GtkBox parent_instance;
+ gchar *icon_name;
gchar *stock_id;
gchar *hint;
} GimpHintBox;
@@ -52,6 +53,7 @@ typedef struct
enum
{
PROP_0,
+ PROP_ICON_NAME,
PROP_STOCK_ID,
PROP_HINT
};
@@ -84,6 +86,11 @@ gimp_hint_box_class_init (GimpHintBoxClass *klass)
object_class->set_property = gimp_hint_box_set_property;
object_class->get_property = gimp_hint_box_get_property;
+ g_object_class_install_property (object_class, PROP_ICON_NAME,
+ g_param_spec_string ("icon-name", NULL, NULL,
+ GIMP_STOCK_INFO,
+ G_PARAM_CONSTRUCT_ONLY |
+ GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_STOCK_ID,
g_param_spec_string ("stock-id", NULL, NULL,
GIMP_STOCK_INFO,
@@ -101,26 +108,32 @@ gimp_hint_box_init (GimpHintBox *box)
{
gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
GTK_ORIENTATION_HORIZONTAL);
-
- box->stock_id = NULL;
- box->hint = NULL;
}
static void
gimp_hint_box_constructed (GObject *object)
{
- GimpHintBox *box = GIMP_HINT_BOX (object);
+ GimpHintBox *box = GIMP_HINT_BOX (object);
+ GtkImage *image = NULL;
GtkWidget *label;
G_OBJECT_CLASS (parent_class)->constructed (object);
gtk_box_set_spacing (GTK_BOX (box), 12);
- if (box->stock_id)
+ if (box->icon_name)
+ {
+ image = gtk_image_new_from_icon_name (box->icon_name,
+ GTK_ICON_SIZE_DIALOG);
+ }
+ else if (box->stock_id)
{
- GtkWidget *image = gtk_image_new_from_stock (box->stock_id,
- GTK_ICON_SIZE_DIALOG);
+ image = gtk_image_new_from_stock (box->stock_id,
+ GTK_ICON_SIZE_DIALOG);
+ }
+ if (image)
+ {
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
gtk_widget_show (image);
}
@@ -145,6 +158,12 @@ gimp_hint_box_finalize (GObject *object)
{
GimpHintBox *box = GIMP_HINT_BOX (object);
+ if (box->icon_name)
+ {
+ g_free (box->icon_name);
+ box->icon_name = NULL;
+ }
+
if (box->stock_id)
{
g_free (box->stock_id);
@@ -170,6 +189,10 @@ gimp_hint_box_set_property (GObject *object,
switch (property_id)
{
+ case PROP_ICON_NAME:
+ box->icon_name = g_value_dup_string (value);
+ break;
+
case PROP_STOCK_ID:
box->stock_id = g_value_dup_string (value);
break;
@@ -194,6 +217,10 @@ gimp_hint_box_get_property (GObject *object,
switch (property_id)
{
+ case PROP_ICON_NAME:
+ g_value_set_string (value, box->icon_name);
+ break;
+
case PROP_STOCK_ID:
g_value_set_string (value, box->stock_id);
break;
diff --git a/libgimpwidgets/gimpintstore.c b/libgimpwidgets/gimpintstore.c
index d72e129..573edfa 100644
--- a/libgimpwidgets/gimpintstore.c
+++ b/libgimpwidgets/gimpintstore.c
@@ -145,7 +145,7 @@ gimp_int_store_constructed (GObject *object)
types[GIMP_INT_STORE_VALUE] = G_TYPE_INT;
types[GIMP_INT_STORE_LABEL] = G_TYPE_STRING;
- types[GIMP_INT_STORE_STOCK_ID] = G_TYPE_STRING;
+ types[GIMP_INT_STORE_ICON_NAME] = G_TYPE_STRING;
types[GIMP_INT_STORE_PIXBUF] = GDK_TYPE_PIXBUF;
types[GIMP_INT_STORE_USER_DATA] = (priv->user_data_type != G_TYPE_NONE ?
priv->user_data_type : G_TYPE_POINTER);
diff --git a/libgimpwidgets/gimpintstore.h b/libgimpwidgets/gimpintstore.h
index 9cdec4c..d819893 100644
--- a/libgimpwidgets/gimpintstore.h
+++ b/libgimpwidgets/gimpintstore.h
@@ -33,10 +33,11 @@ G_BEGIN_DECLS
* GimpIntStoreColumns:
* @GIMP_INT_STORE_VALUE: the integer value
* @GIMP_INT_STORE_LABEL: a human-readable label
- * @GIMP_INT_STORE_STOCK_ID: a stock ID
+ * @GIMP_INT_STORE_ICON_NAME: an icon name
* @GIMP_INT_STORE_PIXBUF: a #GdkPixbuf
* @GIMP_INT_STORE_USER_DATA: arbitrary user data
* @GIMP_INT_STORE_NUM_COLUMNS: the number of columns
+ * @GIMP_INT_STORE_STOCK_ID: compat alias for @GIMP_INT_STORE_ICON_NAME
*
* The column types of #GimpIntStore.
**/
@@ -44,10 +45,13 @@ typedef enum
{
GIMP_INT_STORE_VALUE,
GIMP_INT_STORE_LABEL,
- GIMP_INT_STORE_STOCK_ID,
+ GIMP_INT_STORE_ICON_NAME,
GIMP_INT_STORE_PIXBUF,
GIMP_INT_STORE_USER_DATA,
- GIMP_INT_STORE_NUM_COLUMNS
+ GIMP_INT_STORE_NUM_COLUMNS,
+
+ /* deprecated */
+ GIMP_INT_STORE_STOCK_ID = GIMP_INT_STORE_ICON_NAME
} GimpIntStoreColumns;
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 58cf188..7a47c2e 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -122,8 +122,8 @@ gimp_pick_button_init (GimpPickButton *button)
{
GtkWidget *image;
- image = gtk_image_new_from_stock (GIMP_STOCK_COLOR_PICK_FROM_SCREEN,
- GTK_ICON_SIZE_BUTTON);
+ image = gtk_image_new_from_icon_name (GIMP_STOCK_COLOR_PICK_FROM_SCREEN,
+ GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), image);
gtk_widget_show (image);
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index 1a19c69..7b93bdf 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -915,6 +915,8 @@ gimp_prop_boolean_radio_frame_new (GObject *config,
* Return value: A #libgimpwidgets-gimpenumstockbox containing the radio buttons.
*
* Since GIMP 2.4
+ *
+ * Deprecated: GIMP 2.10
*/
GtkWidget *
gimp_prop_enum_stock_box_new (GObject *config,
@@ -923,6 +925,35 @@ gimp_prop_enum_stock_box_new (GObject *config,
gint minimum,
gint maximum)
{
+ return gimp_prop_enum_icon_box_new (config, property_name,
+ stock_prefix, minimum, maximum);
+}
+
+/**
+ * gimp_prop_enum_icon_box_new:
+ * @config: Object to which property is attached.
+ * @property_name: Name of enum property controlled by the radio buttons.
+ * @icon_prefix: The prefix of the group of icon names to use.
+ * @minimum: Smallest value of enum to be included.
+ * @maximum: Largest value of enum to be included.
+ *
+ * Creates a horizontal box of radio buttons with named icons, which
+ * function to set and display the value of the specified Enum
+ * property. The icon name for each icon is created by appending the
+ * enum_value's nick to the given @icon_prefix. See
+ * gimp_enum_icon_box_new() for more information.
+ *
+ * Return value: A #libgimpwidgets-gimpenumiconbox containing the radio buttons.
+ *
+ * Since GIMP 2.10
+ */
+GtkWidget *
+gimp_prop_enum_icon_box_new (GObject *config,
+ const gchar *property_name,
+ const gchar *icon_prefix,
+ gint minimum,
+ gint maximum)
+{
GParamSpec *param_spec;
GtkWidget *box;
GtkWidget *button;
@@ -942,22 +973,22 @@ gimp_prop_enum_stock_box_new (GObject *config,
if (minimum != maximum)
{
- box = gimp_enum_stock_box_new_with_range (param_spec->value_type,
- minimum, maximum,
- stock_prefix,
- GTK_ICON_SIZE_MENU,
- G_CALLBACK (gimp_prop_radio_button_callback),
- config,
- &button);
+ box = gimp_enum_icon_box_new_with_range (param_spec->value_type,
+ minimum, maximum,
+ icon_prefix,
+ GTK_ICON_SIZE_MENU,
+ G_CALLBACK (gimp_prop_radio_button_callback),
+ config,
+ &button);
}
else
{
- box = gimp_enum_stock_box_new (param_spec->value_type,
- stock_prefix,
- GTK_ICON_SIZE_MENU,
- G_CALLBACK (gimp_prop_radio_button_callback),
- config,
- &button);
+ box = gimp_enum_icon_box_new (param_spec->value_type,
+ icon_prefix,
+ GTK_ICON_SIZE_MENU,
+ G_CALLBACK (gimp_prop_radio_button_callback),
+ config,
+ &button);
}
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), value);
diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h
index afff4b5..66a6ee2 100644
--- a/libgimpwidgets/gimppropwidgets.h
+++ b/libgimpwidgets/gimppropwidgets.h
@@ -78,12 +78,20 @@ GtkWidget * gimp_prop_enum_radio_box_new (GObject *config,
const gchar *property_name,
gint minimum,
gint maximum);
+
+GIMP_DEPRECATED_FOR(gimp_prop_enum_icon_box_new)
GtkWidget * gimp_prop_enum_stock_box_new (GObject *config,
const gchar *property_name,
const gchar *stock_prefix,
gint minimum,
gint maximum);
+GtkWidget * gimp_prop_enum_icon_box_new (GObject *config,
+ const gchar *property_name,
+ const gchar *stock_prefix,
+ gint minimum,
+ gint maximum);
+
GtkWidget * gimp_prop_enum_label_new (GObject *config,
const gchar *property_name);
diff --git a/libgimpwidgets/gimpquerybox.c b/libgimpwidgets/gimpquerybox.c
index a391315..c8a4a86 100644
--- a/libgimpwidgets/gimpquerybox.c
+++ b/libgimpwidgets/gimpquerybox.c
@@ -81,7 +81,7 @@ static QueryBox * create_query_box (const gchar *title,
GimpHelpFunc help_func,
const gchar *help_id,
GCallback response_callback,
- const gchar *stock_id,
+ const gchar *icon_name,
const gchar *message,
const gchar *ok_button,
const gchar *cancel_button,
@@ -121,7 +121,7 @@ create_query_box (const gchar *title,
GimpHelpFunc help_func,
const gchar *help_id,
GCallback response_callback,
- const gchar *stock_id,
+ const gchar *icon_name,
const gchar *message,
const gchar *ok_button,
const gchar *cancel_button,
@@ -178,7 +178,7 @@ create_query_box (const gchar *title,
g_signal_connect_closure (object, signal, closure, FALSE);
}
- if (stock_id)
+ if (icon_name)
{
GtkWidget *content_area;
GtkWidget *image;
@@ -190,7 +190,7 @@ create_query_box (const gchar *title,
gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);
+ image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
gtk_widget_show (image);
@@ -503,7 +503,7 @@ gimp_query_size_box (const gchar *title,
* @parent: The dialog's parent widget.
* @help_func: The help function to show this dialog's help page.
* @help_id: A string identifying this dialog's help page.
- * @stock_id: A stock_id to specify an icon to appear on the left
+ * @icon_name: An icon name to specify an icon to appear on the left
* on the dialog's message.
* @message: A string which will be shown in the query box.
* @true_button: The string to be shown in the dialog's left button.
@@ -524,7 +524,7 @@ gimp_query_boolean_box (const gchar *title,
GtkWidget *parent,
GimpHelpFunc help_func,
const gchar *help_id,
- const gchar *stock_id,
+ const gchar *icon_name,
const gchar *message,
const gchar *true_button,
const gchar *false_button,
@@ -537,7 +537,7 @@ gimp_query_boolean_box (const gchar *title,
query_box = create_query_box (title, parent, help_func, help_id,
G_CALLBACK (boolean_query_box_response),
- stock_id,
+ icon_name,
message,
true_button, false_button,
object, signal,
diff --git a/libgimpwidgets/gimpquerybox.h b/libgimpwidgets/gimpquerybox.h
index a62a241..7eee5b2 100644
--- a/libgimpwidgets/gimpquerybox.h
+++ b/libgimpwidgets/gimpquerybox.h
@@ -165,7 +165,7 @@ GtkWidget * gimp_query_boolean_box (const gchar *title,
GtkWidget *parent,
GimpHelpFunc help_func,
const gchar *help_id,
- const gchar *stock_id,
+ const gchar *icon_name,
const gchar *message,
const gchar *true_button,
const gchar *false_button,
diff --git a/libgimpwidgets/gimpscrolledpreview.c b/libgimpwidgets/gimpscrolledpreview.c
index b0097db..900a9cd 100644
--- a/libgimpwidgets/gimpscrolledpreview.c
+++ b/libgimpwidgets/gimpscrolledpreview.c
@@ -216,7 +216,8 @@ gimp_scrolled_preview_init (GimpScrolledPreview *preview)
preview->nav_icon, 1,2, 1,2,
GTK_SHRINK, GTK_SHRINK, 0, 0);
- image = gtk_image_new_from_stock (GIMP_STOCK_NAVIGATION, GTK_ICON_SIZE_MENU);
+ image = gtk_image_new_from_icon_name (GIMP_STOCK_NAVIGATION,
+ GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (preview->nav_icon), image);
gtk_widget_show (image);
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index f34ad9e..b8f005e 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -136,7 +136,11 @@ EXPORTS
gimp_enum_combo_box_get_type
gimp_enum_combo_box_new
gimp_enum_combo_box_new_with_model
+ gimp_enum_combo_box_set_icon_prefix
gimp_enum_combo_box_set_stock_prefix
+ gimp_enum_icon_box_new
+ gimp_enum_icon_box_new_with_range
+ gimp_enum_icon_box_set_child_padding
gimp_enum_label_get_type
gimp_enum_label_new
gimp_enum_label_set_value
@@ -152,6 +156,7 @@ EXPORTS
gimp_enum_store_new_with_range
gimp_enum_store_new_with_values
gimp_enum_store_new_with_values_valist
+ gimp_enum_store_set_icon_prefix
gimp_enum_store_set_stock_prefix
gimp_file_entry_get_filename
gimp_file_entry_get_type
@@ -284,6 +289,7 @@ EXPORTS
gimp_prop_entry_new
gimp_prop_enum_check_button_new
gimp_prop_enum_combo_box_new
+ gimp_prop_enum_icon_box_new
gimp_prop_enum_label_new
gimp_prop_enum_radio_box_new
gimp_prop_enum_radio_frame_new
diff --git a/libgimpwidgets/gimpzoommodel.c b/libgimpwidgets/gimpzoommodel.c
index caa557d..efcb33d 100644
--- a/libgimpwidgets/gimpzoommodel.c
+++ b/libgimpwidgets/gimpzoommodel.c
@@ -465,23 +465,19 @@ gimp_zoom_model_get_fraction (GimpZoomModel *model,
}
static GtkWidget *
-zoom_button_new (const gchar *stock_id,
+zoom_button_new (const gchar *icon_name,
GtkIconSize icon_size)
{
GtkWidget *button;
+ GtkWidget *image;
- if (icon_size > 0)
- {
- GtkWidget *image = gtk_image_new_from_stock (stock_id, icon_size);
+ image = gtk_image_new_from_icon_name (icon_name,
+ icon_size > 0 ?
+ icon_size : GTK_ICON_SIZE_BUTTON);
- button = gtk_button_new ();
- gtk_container_add (GTK_CONTAINER (button), image);
- gtk_widget_show (image);
- }
- else
- {
- button = gtk_button_new_from_stock (stock_id);
- }
+ button = gtk_button_new ();
+ gtk_container_add (GTK_CONTAINER (button), image);
+ gtk_widget_show (image);
return button;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]