mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 09:53:25 +00:00
libgimpwidgets: mostly port from stock IDs to icon names
Add some new API and deprecate old one.
This commit is contained in:
parent
233b86b32d
commit
79bd9c60de
22 changed files with 346 additions and 114 deletions
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -192,10 +192,32 @@ 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;
|
||||
|
||||
|
@ -203,5 +225,5 @@ gimp_enum_combo_box_set_stock_prefix (GimpEnumComboBox *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);
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -318,10 +318,31 @@ 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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
@ -333,17 +323,119 @@ gimp_enum_stock_box_new_with_range (GType enum_type,
|
|||
GCallback callback,
|
||||
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))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
GtkWidget *image = gtk_image_new_from_stock (box->stock_id,
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
image = gtk_image_new_from_icon_name (box->icon_name,
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
}
|
||||
else if (box->stock_id)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
@ -922,6 +924,35 @@ gimp_prop_enum_stock_box_new (GObject *config,
|
|||
const gchar *stock_prefix,
|
||||
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;
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue