app: don't hardcode the prefs icon sizes n_categories times

Remove the parameters from gimp_prefs_box_add_page() and instead
hardcode them once in GimpPrefsBox. This way they can also easily be
made configurable in the future.
This commit is contained in:
Michael Natterer 2015-12-13 13:33:55 +01:00
parent 8619852a6c
commit f7d33ac18f
3 changed files with 12 additions and 75 deletions

View File

@ -1359,10 +1359,7 @@ prefs_dialog_new (Gimp *gimp,
/**********************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-system-resources",
GTK_ICON_SIZE_DIALOG,
_("System Resources"),
"gimp-prefs-system-resources",
GTK_ICON_SIZE_BUTTON,
_("System Resources"),
GIMP_HELP_PREFS_SYSTEM_RESOURCES,
NULL,
@ -1435,10 +1432,7 @@ prefs_dialog_new (Gimp *gimp,
/**********************/
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"),
GIMP_HELP_PREFS_COLOR_MANAGEMENT,
NULL,
@ -1589,10 +1583,7 @@ prefs_dialog_new (Gimp *gimp,
{
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-playground",
GTK_ICON_SIZE_DIALOG,
_("Experimental Playground"),
"gimp-prefs-playground",
GTK_ICON_SIZE_BUTTON,
_("Playground"),
GIMP_HELP_PREFS_DIALOG,
NULL,
@ -1624,10 +1615,7 @@ prefs_dialog_new (Gimp *gimp,
/******************/
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"),
GIMP_HELP_PREFS_TOOL_OPTIONS,
NULL,
@ -1714,10 +1702,7 @@ prefs_dialog_new (Gimp *gimp,
/*******************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-new-image",
GTK_ICON_SIZE_DIALOG,
_("Default New Image"),
"gimp-prefs-new-image",
GTK_ICON_SIZE_BUTTON,
_("Default Image"),
GIMP_HELP_PREFS_NEW_IMAGE,
NULL,
@ -1767,10 +1752,7 @@ prefs_dialog_new (Gimp *gimp,
/**********************************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-default-grid",
GTK_ICON_SIZE_DIALOG,
_("Default Image Grid"),
"gimp-prefs-default-grid",
GTK_ICON_SIZE_BUTTON,
_("Default Grid"),
GIMP_HELP_PREFS_DEFAULT_GRID,
&top_iter,
@ -1790,10 +1772,7 @@ prefs_dialog_new (Gimp *gimp,
/***************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-interface",
GTK_ICON_SIZE_DIALOG,
_("User Interface"),
"gimp-prefs-interface",
GTK_ICON_SIZE_BUTTON,
_("Interface"),
GIMP_HELP_PREFS_INTERFACE,
NULL,
@ -1872,10 +1851,7 @@ prefs_dialog_new (Gimp *gimp,
/***********************/
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"),
GIMP_HELP_PREFS_THEME,
&top_iter,
@ -1975,10 +1951,7 @@ prefs_dialog_new (Gimp *gimp,
/****************************/
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"),
GIMP_HELP_PREFS_ICON_THEME,
&top_iter,
@ -2067,10 +2040,7 @@ prefs_dialog_new (Gimp *gimp,
/*************************/
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"),
GIMP_HELP_PREFS_TOOLBOX,
&top_iter,
@ -2114,10 +2084,7 @@ prefs_dialog_new (Gimp *gimp,
/*****************************/
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"),
GIMP_HELP_PREFS_HELP,
&top_iter,
@ -2216,10 +2183,7 @@ prefs_dialog_new (Gimp *gimp,
/*************************/
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"),
GIMP_HELP_PREFS_DISPLAY,
&top_iter,
@ -2343,10 +2307,7 @@ prefs_dialog_new (Gimp *gimp,
/***********************************/
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"),
GIMP_HELP_PREFS_WINDOW_MANAGEMENT,
&top_iter,
@ -2401,10 +2362,7 @@ prefs_dialog_new (Gimp *gimp,
/*******************/
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"),
GIMP_HELP_PREFS_IMAGE_WINDOW,
NULL,
@ -2483,10 +2441,7 @@ prefs_dialog_new (Gimp *gimp,
/********************************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-image-windows",
GTK_ICON_SIZE_DIALOG,
_("Image Window Appearance"),
"gimp-prefs-image-windows",
GTK_ICON_SIZE_BUTTON,
_("Appearance"),
GIMP_HELP_PREFS_IMAGE_WINDOW_APPEARANCE,
&top_iter,
@ -2508,10 +2463,7 @@ prefs_dialog_new (Gimp *gimp,
/****************************************************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-image-title",
GTK_ICON_SIZE_DIALOG,
_("Image Title & Statusbar Format"),
"gimp-prefs-image-title",
GTK_ICON_SIZE_BUTTON,
_("Title & Status"),
GIMP_HELP_PREFS_IMAGE_WINDOW_TITLE,
&top_iter,
@ -2634,10 +2586,7 @@ prefs_dialog_new (Gimp *gimp,
/******************************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-tool-options",
GTK_ICON_SIZE_DIALOG,
_("Image Window Snapping Behavior"),
"gimp-prefs-tool-options",
GTK_ICON_SIZE_BUTTON,
_("Snapping"),
GIMP_HELP_PREFS_IMAGE_WINDOW_APPEARANCE,
&top_iter,
@ -2658,10 +2607,7 @@ prefs_dialog_new (Gimp *gimp,
/*******************/
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"),
GIMP_HELP_PREFS_INPUT_DEVICES,
NULL,
@ -2705,10 +2651,7 @@ prefs_dialog_new (Gimp *gimp,
/****************************/
vbox = gimp_prefs_box_add_page (GIMP_PREFS_BOX (prefs_box),
"gimp-prefs-controllers",
GTK_ICON_SIZE_DIALOG,
_("Additional Input Controllers"),
"gimp-prefs-controllers",
GTK_ICON_SIZE_BUTTON,
_("Input Controllers"),
GIMP_HELP_PREFS_INPUT_CONTROLLERS,
&top_iter,
@ -2724,10 +2667,7 @@ prefs_dialog_new (Gimp *gimp,
/*************/
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"),
GIMP_HELP_PREFS_FOLDERS,
NULL,
@ -2865,10 +2805,7 @@ prefs_dialog_new (Gimp *gimp,
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),
icon_name,
GTK_ICON_SIZE_BUTTON,
gettext (paths[i].tree_label),
paths[i].help_data,
&top_iter,

View File

@ -53,6 +53,9 @@ struct _GimpPrefsBoxPrivate
GtkWidget *label;
GtkWidget *image;
gint tree_icon_size;
gint notebook_icon_size;
gint page_index;
};
@ -92,6 +95,9 @@ gimp_prefs_box_init (GimpPrefsBox *box)
GtkWidget *ebox;
GtkWidget *vbox;
private->tree_icon_size = GTK_ICON_SIZE_BUTTON;
private->notebook_icon_size = GTK_ICON_SIZE_DIALOG;
gtk_orientable_set_orientation (GTK_ORIENTABLE (box),
GTK_ORIENTATION_HORIZONTAL);
gtk_box_set_spacing (GTK_BOX (box), 12);
@ -302,11 +308,8 @@ gimp_prefs_box_new (void)
GtkWidget *
gimp_prefs_box_add_page (GimpPrefsBox *box,
const gchar *notebook_icon_name,
const GtkIconSize notebook_icon_size,
const gchar *icon_name,
const gchar *notebook_label,
const gchar *tree_icon_name,
const GtkIconSize tree_icon_size,
const gchar *tree_label,
const gchar *help_id,
GtkTreeIter *parent,
@ -333,11 +336,11 @@ gimp_prefs_box_add_page (GimpPrefsBox *box,
gtk_tree_store_append (private->store, iter, parent);
gtk_tree_store_set (private->store, iter,
COLUMN_TREE_ICON_NAME, tree_icon_name,
COLUMN_TREE_ICON_SIZE, tree_icon_size,
COLUMN_TREE_ICON_NAME, icon_name,
COLUMN_TREE_ICON_SIZE, private->tree_icon_size,
COLUMN_TREE_LABEL, tree_label,
COLUMN_NOTEBOOK_ICON_NAME, notebook_icon_name,
COLUMN_NOTEBOOK_ICON_SIZE, notebook_icon_size,
COLUMN_NOTEBOOK_ICON_NAME, icon_name,
COLUMN_NOTEBOOK_ICON_SIZE, private->notebook_icon_size,
COLUMN_NOTEBOOK_LABEL , notebook_label,
COLUMN_PAGE_INDEX, private->page_index++,
-1);

View File

@ -48,11 +48,8 @@ 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_icon_name,
const GtkIconSize notebook_icon_size,
const gchar *icon_name,
const gchar *notebook_label,
const gchar *tree_icon_name,
const GtkIconSize tree_icon_size,
const gchar *tree_label,
const gchar *help_id,
GtkTreeIter *parent,