Bug 759345 - Fix for prefs dialog to add icon theme support

Change GimpPrefsBox to use icon names instead of pixbufs, and change
preferences-dialog.c accordingly.
This commit is contained in:
Benoit Touchette 2015-12-11 06:29:50 -05:00 committed by Michael Natterer
parent d1e5d719de
commit 55270366d7
3 changed files with 163 additions and 163 deletions

View File

@ -745,8 +745,7 @@ prefs_icon_theme_select_callback (GtkTreeSelection *sel,
if (gtk_tree_selection_get_selected (sel, &model, &iter))
{
GtkWidget *dialog;
GValue val = { 0, };
GValue val = { 0, };
gtk_tree_model_get_value (model, &iter, 0, &val);
g_object_set_property (G_OBJECT (gimp->config), "icon-theme", &val);
@ -1288,35 +1287,6 @@ prefs_message (GtkMessageType type,
gtk_widget_show (dialog);
}
static gboolean
prefs_idle_unref (gpointer data)
{
g_object_unref (data);
return FALSE;
}
static GdkPixbuf *
prefs_get_pixbufs (GtkWidget *widget,
const gchar *name,
GdkPixbuf **small_pixbuf)
{
GdkPixbuf *pixbuf = NULL;
gchar *icon_name;
icon_name = g_strconcat ("gimp-prefs-", name, NULL);
pixbuf = gimp_widget_load_icon (widget, icon_name, 48);
g_idle_add (prefs_idle_unref, pixbuf);
*small_pixbuf = gimp_widget_load_icon (widget, icon_name, 22);
g_idle_add (prefs_idle_unref, *small_pixbuf);
g_free (icon_name);
return pixbuf;
}
static GtkWidget *
prefs_dialog_new (Gimp *gimp,
GimpConfig *config)
@ -1325,10 +1295,8 @@ prefs_dialog_new (Gimp *gimp,
GtkTreeIter top_iter;
GtkTreeIter child_iter;
GtkSizeGroup *size_group = NULL;
GdkPixbuf *pixbuf;
GdkPixbuf *small_pixbuf = NULL;
GtkWidget *prefs_box;
GtkSizeGroup *size_group = NULL;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *vbox2;
@ -1389,12 +1357,13 @@ prefs_dialog_new (Gimp *gimp,
/*****************/
/* Environment */
/*****************/
pixbuf = prefs_get_pixbufs (dialog, "environment", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-environment",
GTK_ICON_SIZE_DIALOG,
_("Environment"),
"gimp-prefs-environment",
GTK_ICON_SIZE_BUTTON,
_("Environment"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_ENVIRONMENT,
NULL,
&top_iter);
@ -1464,12 +1433,13 @@ prefs_dialog_new (Gimp *gimp,
/***************/
/* Interface */
/***************/
pixbuf = prefs_get_pixbufs (dialog, "interface", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-interface",
GTK_ICON_SIZE_DIALOG,
_("User Interface"),
pixbuf,
"gimp-prefs-interface",
GTK_ICON_SIZE_BUTTON,
_("Interface"),
small_pixbuf,
GIMP_HELP_PREFS_INTERFACE,
NULL,
&top_iter);
@ -1547,12 +1517,13 @@ prefs_dialog_new (Gimp *gimp,
/****************/
if (gimp->show_playground)
{
pixbuf = prefs_get_pixbufs (dialog, "playground", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-playground",
GTK_ICON_SIZE_DIALOG,
_("Experimental Playground"),
pixbuf,
"gimp-prefs-playground",
GTK_ICON_SIZE_BUTTON,
_("Playground"),
small_pixbuf,
GIMP_HELP_PREFS_DIALOG,
NULL,
&top_iter);
@ -1581,12 +1552,13 @@ prefs_dialog_new (Gimp *gimp,
/***********/
/* Theme */
/***********/
pixbuf = prefs_get_pixbufs (dialog, "theme", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-theme",
GTK_ICON_SIZE_DIALOG,
_("Theme"),
"gimp-prefs-theme",
GTK_ICON_SIZE_BUTTON,
_("Theme"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_THEME,
NULL,
&top_iter);
@ -1683,12 +1655,13 @@ prefs_dialog_new (Gimp *gimp,
/****************/
/* Icon Theme */
/****************/
pixbuf = prefs_get_pixbufs (dialog, "icon-theme", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-icon-theme",
GTK_ICON_SIZE_DIALOG,
_("Icon Theme"),
"gimp-prefs-icon-theme",
GTK_ICON_SIZE_BUTTON,
_("Icon Theme"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_ICON_THEME,
NULL,
&top_iter);
@ -1774,12 +1747,13 @@ prefs_dialog_new (Gimp *gimp,
/*****************/
/* Help System */
/*****************/
pixbuf = prefs_get_pixbufs (dialog, "help-system", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-help-system",
GTK_ICON_SIZE_DIALOG,
_("Help System"),
"gimp-prefs-help-system",
GTK_ICON_SIZE_BUTTON,
_("Help System"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_HELP,
NULL,
&top_iter);
@ -1875,12 +1849,13 @@ prefs_dialog_new (Gimp *gimp,
/******************/
/* Tool Options */
/******************/
pixbuf = prefs_get_pixbufs (dialog, "tool-options", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-tool-options",
GTK_ICON_SIZE_DIALOG,
C_("preferences", "Tool Options"),
"gimp-prefs-tool-options",
GTK_ICON_SIZE_BUTTON,
C_("preferences", "Tool Options"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_TOOL_OPTIONS,
NULL,
&top_iter);
@ -1964,12 +1939,13 @@ prefs_dialog_new (Gimp *gimp,
/*************/
/* Toolbox */
/*************/
pixbuf = prefs_get_pixbufs (dialog, "toolbox", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-toolbox",
GTK_ICON_SIZE_DIALOG,
_("Toolbox"),
"gimp-prefs-toolbox",
GTK_ICON_SIZE_BUTTON,
_("Toolbox"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_TOOLBOX,
NULL,
&top_iter);
@ -2010,12 +1986,13 @@ prefs_dialog_new (Gimp *gimp,
/***********************/
/* Default New Image */
/***********************/
pixbuf = prefs_get_pixbufs (dialog, "new-image", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-new-image",
GTK_ICON_SIZE_DIALOG,
_("Default New Image"),
pixbuf,
"gimp-prefs-new-image",
GTK_ICON_SIZE_BUTTON,
_("Default Image"),
small_pixbuf,
GIMP_HELP_PREFS_NEW_IMAGE,
NULL,
&top_iter);
@ -2062,12 +2039,13 @@ prefs_dialog_new (Gimp *gimp,
/******************/
/* Default Grid */
/******************/
pixbuf = prefs_get_pixbufs (dialog, "default-grid", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-default-grid",
GTK_ICON_SIZE_DIALOG,
_("Default Image Grid"),
pixbuf,
"gimp-prefs-default-grid",
GTK_ICON_SIZE_BUTTON,
_("Default Grid"),
small_pixbuf,
GIMP_HELP_PREFS_DEFAULT_GRID,
NULL,
&top_iter);
@ -2084,12 +2062,13 @@ prefs_dialog_new (Gimp *gimp,
/*******************/
/* Image Windows */
/*******************/
pixbuf = prefs_get_pixbufs (dialog, "image-windows", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-image-windows",
GTK_ICON_SIZE_DIALOG,
_("Image Windows"),
"gimp-prefs-image-windows",
GTK_ICON_SIZE_BUTTON,
_("Image Windows"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_IMAGE_WINDOW,
NULL,
&top_iter);
@ -2165,12 +2144,13 @@ prefs_dialog_new (Gimp *gimp,
/********************************/
/* Image Windows / Appearance */
/********************************/
pixbuf = prefs_get_pixbufs (dialog, "image-windows", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-image-windows",
GTK_ICON_SIZE_DIALOG,
_("Image Window Appearance"),
pixbuf,
"gimp-prefs-image-windows",
GTK_ICON_SIZE_BUTTON,
_("Appearance"),
small_pixbuf,
GIMP_HELP_PREFS_IMAGE_WINDOW_APPEARANCE,
&top_iter,
&child_iter);
@ -2189,12 +2169,13 @@ prefs_dialog_new (Gimp *gimp,
/****************************************************/
/* Image Windows / Image Title & Statusbar Format */
/****************************************************/
pixbuf = prefs_get_pixbufs (dialog, "image-title", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-image-title",
GTK_ICON_SIZE_DIALOG,
_("Image Title & Statusbar Format"),
pixbuf,
"gimp-prefs-image-title",
GTK_ICON_SIZE_BUTTON,
_("Title & Status"),
small_pixbuf,
GIMP_HELP_PREFS_IMAGE_WINDOW_TITLE,
&top_iter,
&child_iter);
@ -2314,12 +2295,13 @@ prefs_dialog_new (Gimp *gimp,
/********************************/
/* Image Windows / Behavior */
/********************************/
pixbuf = prefs_get_pixbufs (dialog, "tool-options", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-tool-options",
GTK_ICON_SIZE_DIALOG,
_("Image Window Drawing Behavior"),
pixbuf,
"gimp-prefs-tool-options",
GTK_ICON_SIZE_BUTTON,
_("Behavior"),
small_pixbuf,
GIMP_HELP_PREFS_IMAGE_WINDOW_APPEARANCE,
&top_iter,
&child_iter);
@ -2337,12 +2319,13 @@ prefs_dialog_new (Gimp *gimp,
/*************/
/* Display */
/*************/
pixbuf = prefs_get_pixbufs (dialog, "display", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-display",
GTK_ICON_SIZE_DIALOG,
_("Display"),
"gimp-prefs-display",
GTK_ICON_SIZE_BUTTON,
_("Display"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_DISPLAY,
NULL,
&top_iter);
@ -2463,12 +2446,13 @@ prefs_dialog_new (Gimp *gimp,
/**********************/
/* Color Management */
/**********************/
pixbuf = prefs_get_pixbufs (dialog, "color-management", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-color-management",
GTK_ICON_SIZE_DIALOG,
_("Color Management"),
"gimp-prefs-color-management",
GTK_ICON_SIZE_BUTTON,
_("Color Management"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_COLOR_MANAGEMENT,
NULL,
&top_iter);
@ -2614,12 +2598,13 @@ prefs_dialog_new (Gimp *gimp,
/*******************/
/* Input Devices */
/*******************/
pixbuf = prefs_get_pixbufs (dialog, "input-devices", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-input-devices",
GTK_ICON_SIZE_DIALOG,
_("Input Devices"),
"gimp-prefs-input-devices",
GTK_ICON_SIZE_BUTTON,
_("Input Devices"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_INPUT_DEVICES,
NULL,
&top_iter);
@ -2660,12 +2645,13 @@ prefs_dialog_new (Gimp *gimp,
/****************************/
/* Additional Controllers */
/****************************/
pixbuf = prefs_get_pixbufs (dialog, "controllers", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-controllers",
GTK_ICON_SIZE_DIALOG,
_("Additional Input Controllers"),
pixbuf,
"gimp-prefs-controllers",
GTK_ICON_SIZE_BUTTON,
_("Input Controllers"),
small_pixbuf,
GIMP_HELP_PREFS_INPUT_CONTROLLERS,
&top_iter,
&child_iter);
@ -2678,12 +2664,13 @@ prefs_dialog_new (Gimp *gimp,
/***********************/
/* Window Management */
/***********************/
pixbuf = prefs_get_pixbufs (dialog, "window-management", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-window-management",
GTK_ICON_SIZE_DIALOG,
_("Window Management"),
"gimp-prefs-window-management",
GTK_ICON_SIZE_BUTTON,
_("Window Management"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_WINDOW_MANAGEMENT,
NULL,
&top_iter);
@ -2735,12 +2722,13 @@ prefs_dialog_new (Gimp *gimp,
/*************/
/* Folders */
/*************/
pixbuf = prefs_get_pixbufs (dialog, "folders", &small_pixbuf);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-folders",
GTK_ICON_SIZE_DIALOG,
_("Folders"),
"gimp-prefs-folders",
GTK_ICON_SIZE_BUTTON,
_("Folders"),
pixbuf,
NULL,
small_pixbuf,
GIMP_HELP_PREFS_FOLDERS,
NULL,
&top_iter);
@ -2860,6 +2848,7 @@ prefs_dialog_new (Gimp *gimp,
for (i = 0; i < G_N_ELEMENTS (paths); i++)
{
GtkWidget *editor;
gchar *icon_name;
#ifdef HAVE_LIBMYPAINT
if (! gui_config->playground_mybrush_tool &&
@ -2869,15 +2858,18 @@ prefs_dialog_new (Gimp *gimp,
}
#endif
pixbuf = prefs_get_pixbufs (dialog, paths[i].icon, &small_pixbuf);
icon_name = g_strconcat ("gimp-prefs-", paths[i].icon, NULL);
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
icon_name,
GTK_ICON_SIZE_DIALOG,
gettext (paths[i].label),
pixbuf,
icon_name,
GTK_ICON_SIZE_BUTTON,
gettext (paths[i].tree_label),
small_pixbuf,
paths[i].help_data,
&top_iter,
&child_iter);
g_free (icon_name);
editor = gimp_prop_path_editor_new (object,
paths[i].path_property_name,

View File

@ -34,9 +34,11 @@
enum
{
COLUMN_TREE_PIXBUF,
COLUMN_TREE_ICON_NAME,
COLUMN_TREE_ICON_SIZE,
COLUMN_TREE_LABEL,
COLUMN_NOTEBOOK_PIXBUF,
COLUMN_NOTEBOOK_ICON_NAME,
COLUMN_NOTEBOOK_ICON_SIZE,
COLUMN_NOTEBOOK_LABEL,
COLUMN_PAGE_INDEX
};
@ -105,10 +107,12 @@ gimp_prefs_box_init (GimpPrefsBox *box)
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
private->store = gtk_tree_store_new (5,
GDK_TYPE_PIXBUF,
private->store = gtk_tree_store_new (7,
G_TYPE_STRING,
GDK_TYPE_PIXBUF,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_INT,
G_TYPE_STRING,
G_TYPE_INT);
private->tree_view =
@ -121,13 +125,16 @@ gimp_prefs_box_init (GimpPrefsBox *box)
cell = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, cell, FALSE);
gtk_tree_view_column_set_attributes (column, cell, "pixbuf",
COLUMN_TREE_PIXBUF, NULL);
gtk_tree_view_column_set_attributes (column, cell,
"icon-name", COLUMN_TREE_ICON_NAME,
"stock-size", COLUMN_TREE_ICON_SIZE,
NULL);
cell = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_attributes (column, cell, "text",
COLUMN_TREE_LABEL, NULL);
gtk_tree_view_column_set_attributes (column, cell,
"text", COLUMN_TREE_LABEL,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (private->tree_view), column);
@ -187,31 +194,35 @@ gimp_prefs_box_tree_select_callback (GtkTreeSelection *sel,
GimpPrefsBoxPrivate *private = GET_PRIVATE (box);
GtkTreeModel *model;
GtkTreeIter iter;
gchar *text;
GdkPixbuf *pixbuf;
gint index;
gchar *notebook_text;
gchar *notebook_icon_name;
gint notebook_icon_size;
gint notebook_index;
if (! gtk_tree_selection_get_selected (sel, &model, &iter))
return;
gtk_tree_model_get (model, &iter,
COLUMN_NOTEBOOK_LABEL, &text,
COLUMN_NOTEBOOK_PIXBUF, &pixbuf,
COLUMN_PAGE_INDEX, &index,
COLUMN_NOTEBOOK_ICON_NAME, &notebook_icon_name,
COLUMN_NOTEBOOK_ICON_SIZE, &notebook_icon_size,
COLUMN_NOTEBOOK_LABEL, &notebook_text,
COLUMN_PAGE_INDEX, &notebook_index,
-1);
gtk_label_set_text (GTK_LABEL (private->label), text);
g_free (text);
gtk_label_set_text (GTK_LABEL (private->label), notebook_text);
g_free (notebook_text);
gtk_image_set_from_pixbuf (GTK_IMAGE (private->image), pixbuf);
if (pixbuf)
g_object_unref (pixbuf);
gtk_image_set_from_icon_name (GTK_IMAGE (private->image),
notebook_icon_name,
notebook_icon_size);
g_free (notebook_icon_name);
g_signal_handlers_block_by_func (private->notebook,
gimp_prefs_box_notebook_page_callback,
sel);
gtk_notebook_set_current_page (GTK_NOTEBOOK (private->notebook), index);
gtk_notebook_set_current_page (GTK_NOTEBOOK (private->notebook),
notebook_index);
g_signal_handlers_unblock_by_func (private->notebook,
gimp_prefs_box_notebook_page_callback,
@ -290,14 +301,16 @@ gimp_prefs_box_new (void)
}
GtkWidget *
gimp_prefs_box_add_page (GimpPrefsBox *box,
const gchar *notebook_label,
GdkPixbuf *notebook_icon,
const gchar *tree_label,
GdkPixbuf *tree_icon,
const gchar *help_id,
GtkTreeIter *parent,
GtkTreeIter *iter)
gimp_prefs_box_add_page (GimpPrefsBox *box,
const gchar *notebook_icon_name,
const GtkIconSize notebook_icon_size,
const gchar *notebook_label,
const gchar *tree_icon_name,
const GtkIconSize tree_icon_size,
const gchar *tree_label,
const gchar *help_id,
GtkTreeIter *parent,
GtkTreeIter *iter)
{
GimpPrefsBoxPrivate *private;
GtkWidget *event_box;
@ -318,22 +331,15 @@ gimp_prefs_box_add_page (GimpPrefsBox *box,
gtk_container_add (GTK_CONTAINER (event_box), vbox);
gtk_widget_show (vbox);
if (! notebook_icon)
notebook_icon = tree_icon;
if (! tree_icon)
tree_icon = notebook_icon;
if (! tree_label)
tree_label = notebook_label;
gtk_tree_store_append (private->store, iter, parent);
gtk_tree_store_set (private->store, iter,
COLUMN_TREE_PIXBUF, tree_icon,
COLUMN_TREE_LABEL, tree_label,
COLUMN_NOTEBOOK_PIXBUF, notebook_icon,
COLUMN_NOTEBOOK_LABEL , notebook_label,
COLUMN_PAGE_INDEX, private->page_index++,
COLUMN_TREE_ICON_NAME, tree_icon_name,
COLUMN_TREE_ICON_SIZE, tree_icon_size,
COLUMN_TREE_LABEL, tree_label,
COLUMN_NOTEBOOK_ICON_NAME, notebook_icon_name,
COLUMN_NOTEBOOK_ICON_SIZE, notebook_icon_size,
COLUMN_NOTEBOOK_LABEL , notebook_label,
COLUMN_PAGE_INDEX, private->page_index++,
-1);
return vbox;

View File

@ -47,18 +47,20 @@ GType gimp_prefs_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_prefs_box_new (void);
GtkWidget * gimp_prefs_box_add_page (GimpPrefsBox *box,
const gchar *notebook_label,
GdkPixbuf *notebook_icon,
const gchar *tree_label,
GdkPixbuf *tree_icon,
const gchar *help_id,
GtkTreeIter *parent,
GtkTreeIter *iter);
GtkWidget * gimp_prefs_box_add_page (GimpPrefsBox *box,
const gchar *notebook_icon_name,
const GtkIconSize notebook_icon_size,
const gchar *notebook_label,
const gchar *tree_icon_name,
const GtkIconSize tree_icon_size,
const gchar *tree_label,
const gchar *help_id,
GtkTreeIter *parent,
GtkTreeIter *iter);
GtkWidget * gimp_prefs_box_get_tree_view (GimpPrefsBox *box);
GtkWidget * gimp_prefs_box_get_notebook (GimpPrefsBox *box);
GtkWidget * gimp_prefs_box_get_image (GimpPrefsBox *box);
GtkWidget * gimp_prefs_box_get_tree_view (GimpPrefsBox *box);
GtkWidget * gimp_prefs_box_get_notebook (GimpPrefsBox *box);
GtkWidget * gimp_prefs_box_get_image (GimpPrefsBox *box);
#endif /* __GIMP_PREFS_BOX_H__ */