[gimp/wip/jehan/icons: 3/3] app: use gimp_icon_get_image() for dock tab icons.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/jehan/icons: 3/3] app: use gimp_icon_get_image() for dock tab icons.
- Date: Tue, 22 May 2018 14:39:27 +0000 (UTC)
commit 5993d0cbb7001f3da0e560058a01acdb92d12f70
Author: Jehan <jehan girinstud io>
Date: Mon May 21 05:59:27 2018 +0200
app: use gimp_icon_get_image() for dock tab icons.
app/widgets/gimpcoloreditor.c | 10 +--
app/widgets/gimpcontainerbox.c | 12 +---
app/widgets/gimpcontainereditor.c | 4 +-
app/widgets/gimpdockable.c | 28 +++++-----
app/widgets/gimpdockable.h | 4 +-
app/widgets/gimpdockbook.c | 112 ++++++++++++++++++++++++++++++++-----
app/widgets/gimpdocked.c | 2 +-
app/widgets/gimpdocked.h | 4 +-
8 files changed, 125 insertions(+), 51 deletions(-)
---
diff --git a/app/widgets/gimpcoloreditor.c b/app/widgets/gimpcoloreditor.c
index cfe3121..f04a378 100644
--- a/app/widgets/gimpcoloreditor.c
+++ b/app/widgets/gimpcoloreditor.c
@@ -72,7 +72,7 @@ static void gimp_color_editor_set_aux_info (GimpDocked *docked,
static GList *gimp_color_editor_get_aux_info (GimpDocked *docked);
static GtkWidget *gimp_color_editor_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size);
+ gint size);
static void gimp_color_editor_set_context (GimpDocked *docked,
GimpContext *context);
@@ -344,16 +344,12 @@ gimp_color_editor_get_property (GObject *object,
static GtkWidget *
gimp_color_editor_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size)
+ gint size)
{
GtkWidget *preview;
- gint width;
- gint height;
preview = gimp_fg_bg_view_new (context);
-
- if (gtk_icon_size_lookup (size, &width, &height))
- gtk_widget_set_size_request (preview, width, height);
+ gtk_widget_set_size_request (preview, size, size);
return preview;
}
diff --git a/app/widgets/gimpcontainerbox.c b/app/widgets/gimpcontainerbox.c
index d1faeee..1f60a2a 100644
--- a/app/widgets/gimpcontainerbox.c
+++ b/app/widgets/gimpcontainerbox.c
@@ -48,7 +48,7 @@ static void gimp_container_box_constructed (GObject *object);
static GtkWidget * gimp_container_box_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size);
+ gint size);
static void gimp_container_box_set_context (GimpDocked *docked,
GimpContext *context);
@@ -187,13 +187,11 @@ gimp_container_box_set_context (GimpDocked *docked,
static GtkWidget *
gimp_container_box_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size)
+ gint size)
{
GimpContainerView *view = GIMP_CONTAINER_VIEW (docked);
GimpContainer *container;
GtkWidget *preview;
- gint width;
- gint height;
gint border_width = 1;
const gchar *prop_name;
@@ -201,12 +199,10 @@ gimp_container_box_get_preview (GimpDocked *docked,
g_return_val_if_fail (container != NULL, NULL);
- gtk_icon_size_lookup (size, &width, &height);
-
prop_name = gimp_context_type_to_prop_name (gimp_container_get_children_type (container));
preview = gimp_prop_view_new (G_OBJECT (context), prop_name,
- context, height);
+ context, size);
GIMP_VIEW (preview)->renderer->size = -1;
gimp_container_view_get_view_size (view, &border_width);
@@ -214,7 +210,7 @@ gimp_container_box_get_preview (GimpDocked *docked,
border_width = MIN (1, border_width);
gimp_view_renderer_set_size_full (GIMP_VIEW (preview)->renderer,
- width, height, border_width);
+ size, size, border_width);
return preview;
}
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index d3554af..23be862 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -98,7 +98,7 @@ static void gimp_container_editor_real_context_item(GimpContainerEditor *edito
static GtkWidget * gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size);
+ gint size);
static void gimp_container_editor_set_context (GimpDocked *docked,
GimpContext *context);
static GimpUIManager * gimp_container_editor_get_menu(GimpDocked *docked,
@@ -478,7 +478,7 @@ gimp_container_editor_real_context_item (GimpContainerEditor *editor,
static GtkWidget *
gimp_container_editor_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size)
+ gint size)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (docked);
diff --git a/app/widgets/gimpdockable.c b/app/widgets/gimpdockable.c
index 0927a1c..a670fc1 100644
--- a/app/widgets/gimpdockable.c
+++ b/app/widgets/gimpdockable.c
@@ -447,7 +447,7 @@ static GtkWidget *
gimp_dockable_new_tab_widget_internal (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
- GtkIconSize size,
+ gint size,
gboolean dnd)
{
GtkWidget *tab_widget = NULL;
@@ -477,7 +477,10 @@ gimp_dockable_new_tab_widget_internal (GimpDockable *dockable,
case GIMP_TAB_STYLE_ICON:
case GIMP_TAB_STYLE_ICON_NAME:
case GIMP_TAB_STYLE_ICON_BLURB:
- icon = gimp_dockable_get_icon (dockable, size);
+ icon = gimp_icon_get_image (dockable->p->icon_name,
+ GTK_WIDGET (dockable), size,
+ G_OBJECT (dockable->p->dockbook),
+ "tab-icon-size");
break;
case GIMP_TAB_STYLE_PREVIEW:
@@ -491,7 +494,10 @@ gimp_dockable_new_tab_widget_internal (GimpDockable *dockable,
context, size);
if (! icon)
- icon = gimp_dockable_get_icon (dockable, size);
+ icon = gimp_icon_get_image (dockable->p->icon_name,
+ GTK_WIDGET (dockable), size,
+ G_OBJECT (dockable->p->dockbook),
+ "tab-icon-size");
}
break;
@@ -643,15 +649,6 @@ gimp_dockable_get_icon_name (GimpDockable *dockable)
return dockable->p->icon_name;
}
-GtkWidget *
-gimp_dockable_get_icon (GimpDockable *dockable,
- GtkIconSize size)
-{
- g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
-
- return gtk_image_new_from_icon_name (dockable->p->icon_name, size);
-}
-
gboolean
gimp_dockable_get_locked (GimpDockable *dockable)
{
@@ -761,7 +758,7 @@ GtkWidget *
gimp_dockable_create_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
- GtkIconSize size)
+ gint size)
{
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@@ -775,16 +772,19 @@ gimp_dockable_create_drag_widget (GimpDockable *dockable)
{
GtkWidget *frame;
GtkWidget *widget;
+ gint icon_width;
+ gint icon_height;
g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
+ gtk_icon_size_lookup (GTK_ICON_SIZE_DND, &icon_width, &icon_height);
widget = gimp_dockable_new_tab_widget_internal (dockable,
dockable->p->context,
GIMP_TAB_STYLE_ICON_BLURB,
- GTK_ICON_SIZE_DND,
+ MAX (icon_width, icon_height),
TRUE);
gtk_container_set_border_width (GTK_CONTAINER (widget), 6);
gtk_container_add (GTK_CONTAINER (frame), widget);
diff --git a/app/widgets/gimpdockable.h b/app/widgets/gimpdockable.h
index c3a0819..fc16e0a 100644
--- a/app/widgets/gimpdockable.h
+++ b/app/widgets/gimpdockable.h
@@ -70,8 +70,6 @@ const gchar * gimp_dockable_get_name (GimpDockable *dockable);
const gchar * gimp_dockable_get_blurb (GimpDockable *dockable);
const gchar * gimp_dockable_get_help_id (GimpDockable *dockable);
const gchar * gimp_dockable_get_icon_name (GimpDockable *dockable);
-GtkWidget * gimp_dockable_get_icon (GimpDockable *dockable,
- GtkIconSize size);
gboolean gimp_dockable_get_locked (GimpDockable *dockable);
void gimp_dockable_set_drag_pos (GimpDockable *dockable,
@@ -94,7 +92,7 @@ GimpTabStyle gimp_dockable_get_actual_tab_style (GimpDockable *dockable);
GtkWidget * gimp_dockable_create_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
- GtkIconSize size);
+ gint size);
GtkWidget * gimp_dockable_create_drag_widget (GimpDockable *dockable);
void gimp_dockable_set_context (GimpDockable *dockable,
GimpContext *context);
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 38eee6b..b4c5615 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -72,6 +72,12 @@ enum
LAST_SIGNAL
};
+enum
+{
+ PROP_0,
+ PROP_TAB_ICON_SIZE
+};
+
/* List of candidates for the automatic style, starting with the
* biggest first
*/
@@ -105,11 +111,22 @@ struct _GimpDockbookPrivate
GList *dockables;
GtkWidget *menu_button;
+
+ gint tab_icon_size;
};
static void gimp_dockbook_dispose (GObject *object);
static void gimp_dockbook_finalize (GObject *object);
+
+static void gimp_dockbook_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_dockbook_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void gimp_dockbook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gimp_dockbook_style_updated (GtkWidget *widget);
@@ -168,8 +185,8 @@ static void gimp_dockbook_update_automatic_tab_style (GimpDockbook *d
static GtkWidget * gimp_dockable_create_event_box_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
- GtkIconSize size);
-static GtkIconSize gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook);
+ gint size);
+static gint gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook);
static void gimp_dockbook_add_tab_timeout (GimpDockbook *dockbook,
GimpDockable *dockable);
static void gimp_dockbook_remove_tab_timeout (GimpDockbook *dockbook);
@@ -230,8 +247,10 @@ gimp_dockbook_class_init (GimpDockbookClass *klass)
G_TYPE_NONE, 1,
GIMP_TYPE_DOCKABLE);
- object_class->dispose = gimp_dockbook_dispose;
- object_class->finalize = gimp_dockbook_finalize;
+ object_class->dispose = gimp_dockbook_dispose;
+ object_class->finalize = gimp_dockbook_finalize;
+ object_class->set_property = gimp_dockbook_set_property;
+ object_class->get_property = gimp_dockbook_get_property;
widget_class->size_allocate = gimp_dockbook_size_allocate;
widget_class->style_updated = gimp_dockbook_style_updated;
@@ -244,6 +263,11 @@ gimp_dockbook_class_init (GimpDockbookClass *klass)
klass->dockable_removed = gimp_dockbook_dockable_removed;
klass->dockable_reordered = NULL;
+ g_object_class_install_property (object_class, PROP_TAB_ICON_SIZE,
+ g_param_spec_int ("tab-icon-size", NULL, NULL,
+ 16, 200, 16,
+ GIMP_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_enum ("tab-icon-size",
NULL, NULL,
@@ -340,6 +364,46 @@ gimp_dockbook_finalize (GObject *object)
}
static void
+gimp_dockbook_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
+
+ switch (property_id)
+ {
+ case PROP_TAB_ICON_SIZE:
+ dockbook->p->tab_icon_size = g_value_get_int (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_dockbook_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDockbook *dockbook = GIMP_DOCKBOOK (object);
+
+ switch (property_id)
+ {
+ case PROP_TAB_ICON_SIZE:
+ g_value_set_int (value, dockbook->p->tab_icon_size);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
gimp_dockbook_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -537,8 +601,9 @@ gimp_dockbook_show_menu (GimpDockbook *dockbook)
}
{
- GtkWidget *image = gimp_dockable_get_icon (dockable,
- GTK_ICON_SIZE_MENU);
+ GtkWidget *image = gimp_icon_get_image (gimp_dockable_get_icon_name (dockable),
+ GTK_WIDGET (dockable), -1,
+ G_OBJECT (dockbook), "tab-icon-size");
gimp_menu_item_set_image (GTK_MENU_ITEM (parent_menu_widget), image);
gtk_widget_show (image);
}
@@ -893,10 +958,18 @@ gimp_dockbook_set_dock (GimpDockbook *dockbook,
dockbook);
dockbook->p->dock = dock;
if (dock)
- g_signal_connect (gimp_dock_get_context (dockbook->p->dock)->gimp->config,
- "size-changed",
- G_CALLBACK (gimp_dockbook_config_size_changed),
- dockbook);
+ {
+ g_signal_connect (gimp_dock_get_context (dockbook->p->dock)->gimp->config,
+ "size-changed",
+ G_CALLBACK (gimp_dockbook_config_size_changed),
+ dockbook);
+
+ /* Set current tab icon size. */
+ g_object_set (dockbook,
+ "tab-icon-size",
+ gimp_dockbook_get_tab_icon_size (dockbook),
+ NULL);
+ }
}
GimpUIManager *
@@ -914,6 +987,8 @@ gimp_dockbook_add (GimpDockbook *dockbook,
{
GtkWidget *tab_widget;
GtkWidget *menu_widget;
+ gint icon_width;
+ gint icon_height;
g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook));
g_return_if_fail (dockbook->p->dock != NULL);
@@ -939,11 +1014,12 @@ gimp_dockbook_add (GimpDockbook *dockbook,
gimp_dockable_set_drag_handler (dockable, dockbook->p->drag_handler);
/* For the notebook right-click menu, always use the icon style */
+ gtk_icon_size_lookup (MENU_WIDGET_ICON_SIZE, &icon_width, &icon_height);
menu_widget =
gimp_dockable_create_tab_widget (dockable,
gimp_dock_get_context (dockbook->p->dock),
GIMP_TAB_STYLE_ICON_BLURB,
- MENU_WIDGET_ICON_SIZE);
+ MAX (icon_width, icon_height));
g_return_if_fail (GTK_IS_WIDGET (menu_widget));
@@ -1552,7 +1628,7 @@ static GtkWidget *
gimp_dockable_create_event_box_tab_widget (GimpDockable *dockable,
GimpContext *context,
GimpTabStyle tab_style,
- GtkIconSize size)
+ gint size)
{
GtkWidget *tab_widget;
@@ -1578,12 +1654,14 @@ gimp_dockable_create_event_box_tab_widget (GimpDockable *dockable,
return tab_widget;
}
-static GtkIconSize
+static gint
gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook)
{
Gimp *gimp;
GimpIconSize size;
GtkIconSize tab_size = DEFAULT_TAB_ICON_SIZE;
+ gint icon_width;
+ gint icon_height;
gimp = gimp_dock_get_context (dockbook->p->dock)->gimp;
@@ -1610,7 +1688,9 @@ gimp_dockbook_get_tab_icon_size (GimpDockbook *dockbook)
break;
}
- return tab_size;
+ gtk_icon_size_lookup (tab_size, &icon_width, &icon_height);
+
+ return MAX (icon_width, icon_height);
}
static void
@@ -1694,5 +1774,9 @@ static void
gimp_dockbook_config_size_changed (GimpGuiConfig *config,
GimpDockbook *dockbook)
{
+ g_object_set (dockbook,
+ "tab-icon-size",
+ gimp_dockbook_get_tab_icon_size (dockbook),
+ NULL);
gimp_dockbook_recreate_tab_widgets (dockbook, TRUE);
}
diff --git a/app/widgets/gimpdocked.c b/app/widgets/gimpdocked.c
index 5c3d581..3338624 100644
--- a/app/widgets/gimpdocked.c
+++ b/app/widgets/gimpdocked.c
@@ -179,7 +179,7 @@ gimp_docked_get_aux_info (GimpDocked *docked)
GtkWidget *
gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size)
+ gint size)
{
GimpDockedInterface *docked_iface;
diff --git a/app/widgets/gimpdocked.h b/app/widgets/gimpdocked.h
index fe9e269..ac55cdc 100644
--- a/app/widgets/gimpdocked.h
+++ b/app/widgets/gimpdocked.h
@@ -49,7 +49,7 @@ struct _GimpDockedInterface
GtkWidget * (* get_preview) (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size);
+ gint size);
gboolean (* get_prefer_icon) (GimpDocked *docked);
GimpUIManager * (* get_menu) (GimpDocked *docked,
const gchar **ui_path,
@@ -76,7 +76,7 @@ GList * gimp_docked_get_aux_info (GimpDocked *docked);
GtkWidget * gimp_docked_get_preview (GimpDocked *docked,
GimpContext *context,
- GtkIconSize size);
+ gint size);
gboolean gimp_docked_get_prefer_icon (GimpDocked *docked);
GimpUIManager * gimp_docked_get_menu (GimpDocked *docked,
const gchar **ui_path,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]