Commit d1372c6c authored by Jehan's avatar Jehan

libgimpwidgets, app: change "stock-size" property of...

... GimpCellRendererToggle into "icon-size".

In particular making it a pixel size instead of a GtkIconSize. This enum
is limited to a few presets (registering new values is deprecated since
GTK+ 3.10), with names completely semantically wrong. It is better to
specify icon sizes (before scaling) in pixels directly, which goes also
with named icons instead of stock ones.
parent 343bfbf2
......@@ -288,9 +288,9 @@ gimp_component_editor_set_view_size (GimpComponentEditor *editor,
GtkWidget *tree_widget;
GtkStyleContext *tree_style;
GtkBorder border;
GtkIconSize icon_size;
GtkTreeIter iter;
gboolean iter_valid;
gint icon_size;
g_return_if_fail (GIMP_IS_COMPONENT_EDITOR (editor));
g_return_if_fail (view_size > 0 &&
......@@ -304,17 +304,10 @@ gimp_component_editor_set_view_size (GimpComponentEditor *editor,
gtk_style_context_get_border (tree_style, 0, &border);
gtk_style_context_restore (tree_style);
icon_size = gimp_get_icon_size (tree_widget,
GIMP_ICON_VISIBLE,
GTK_ICON_SIZE_BUTTON,
view_size -
(border.left + border.right),
view_size -
(border.top + border.bottom));
g_object_set (editor->eye_cell,
"stock-size", icon_size,
NULL);
g_object_get (editor->eye_cell, "icon-size", &icon_size, NULL);
icon_size = MIN (icon_size, MAX (view_size - (border.left + border.right),
view_size - (border.top + border.bottom)));
g_object_set (editor->eye_cell, "icon-size", icon_size, NULL);
for (iter_valid = gtk_tree_model_get_iter_first (editor->model, &iter);
iter_valid;
......
......@@ -959,8 +959,8 @@ gimp_container_tree_view_set_view_size (GimpContainerView *view)
for (list = tree_view->priv->toggle_cells; list; list = g_list_next (list))
{
gchar *icon_name;
GtkIconSize icon_size;
gchar *icon_name;
gint icon_size;
g_object_get (list->data, "icon-name", &icon_name, NULL);
......@@ -974,15 +974,10 @@ gimp_container_tree_view_set_view_size (GimpContainerView *view)
gtk_style_context_get_border (style, 0, &border);
gtk_style_context_restore (style);
icon_size = gimp_get_icon_size (tree_widget,
icon_name,
GTK_ICON_SIZE_BUTTON,
view_size -
(border.left + border.right),
view_size -
(border.top + border.bottom));
g_object_set (list->data, "stock-size", icon_size, NULL);
g_object_get (list->data, "icon-size", &icon_size, NULL);
icon_size = MIN (icon_size, MAX (view_size - (border.left + border.right),
view_size - (border.top + border.bottom)));
g_object_set (list->data, "icon-size", icon_size, NULL);
g_free (icon_name);
}
......
......@@ -259,7 +259,7 @@ gimp_tool_editor_new (GimpContainer *container,
GtkTreeViewColumn *column;
GtkCellRenderer *eye_cell;
GtkBorder border;
GtkIconSize icon_size;
gint icon_size;
tree_style = gtk_widget_get_style_context (tree_widget);
gtk_style_context_get_border (tree_style, 0, &border);
......@@ -269,13 +269,11 @@ gimp_tool_editor_new (GimpContainer *container,
eye_cell = gimp_cell_renderer_toggle_new (GIMP_ICON_VISIBLE);
icon_size = gimp_get_icon_size (GTK_WIDGET (tool_editor),
GIMP_ICON_VISIBLE,
GTK_ICON_SIZE_BUTTON,
view_size - (border.left + border.right),
view_size - (border.top + border.bottom));
g_object_get (eye_cell, "icon-size", &icon_size, NULL);
icon_size = MIN (icon_size, MAX (view_size - (border.left + border.right),
view_size - (border.top + border.bottom)));
g_object_set (eye_cell, "icon-size", icon_size, NULL);
g_object_set (eye_cell, "stock-size", icon_size, NULL);
gtk_tree_view_column_pack_start (column, eye_cell, FALSE);
gtk_tree_view_column_set_cell_data_func (column, eye_cell,
gimp_tool_editor_eye_data_func,
......
......@@ -39,7 +39,7 @@
**/
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_BUTTON
#define DEFAULT_ICON_SIZE 16
enum
......@@ -52,7 +52,7 @@ enum
{
PROP_0,
PROP_ICON_NAME,
PROP_STOCK_SIZE,
PROP_ICON_SIZE,
PROP_OVERRIDE_BACKGROUND
};
......@@ -60,7 +60,7 @@ enum
struct _GimpCellRendererTogglePrivate
{
gchar *icon_name;
GtkIconSize stock_size;
gint icon_size;
gboolean override_background;
GdkPixbuf *pixbuf;
......@@ -143,10 +143,10 @@ gimp_cell_renderer_toggle_class_init (GimpCellRendererToggleClass *klass)
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_STOCK_SIZE,
g_param_spec_int ("stock-size",
"Stock Size",
"The icon size to use",
g_object_class_install_property (object_class, PROP_ICON_SIZE,
g_param_spec_int ("icon-size",
"Icon Size",
"The desired icon size to use in pixel (before applying scaling factor)",
0, G_MAXINT,
DEFAULT_ICON_SIZE,
GIMP_PARAM_READWRITE |
......@@ -196,8 +196,8 @@ gimp_cell_renderer_toggle_get_property (GObject *object,
g_value_set_string (value, priv->icon_name);
break;
case PROP_STOCK_SIZE:
g_value_set_int (value, priv->stock_size);
case PROP_ICON_SIZE:
g_value_set_int (value, priv->icon_size);
break;
case PROP_OVERRIDE_BACKGROUND:
......@@ -226,8 +226,8 @@ gimp_cell_renderer_toggle_set_property (GObject *object,
priv->icon_name = g_value_dup_string (value);
break;
case PROP_STOCK_SIZE:
priv->stock_size = g_value_get_int (value);
case PROP_ICON_SIZE:
priv->icon_size = g_value_get_int (value);
break;
case PROP_OVERRIDE_BACKGROUND:
......@@ -499,10 +499,6 @@ gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
GtkIconInfo *icon_info;
gchar *icon_name;
gint scale_factor;
gint width, height;
if (! gtk_icon_size_lookup (priv->stock_size, &width, &height))
gtk_icon_size_lookup (DEFAULT_ICON_SIZE, &width, &height);
scale_factor = gtk_widget_get_scale_factor (widget);
screen = gtk_widget_get_screen (widget);
......@@ -511,7 +507,7 @@ gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
/* Look for symbolic and fallback to color icon. */
icon_name = g_strdup_printf ("%s-symbolic", priv->icon_name);
icon_info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, icon_name,
MIN (width, height), scale_factor,
priv->icon_size, scale_factor,
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
g_free (icon_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment