[gtk+/wip/otte/gtk4: 112/127] widget-factory: Stop using custom icon sizes
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/gtk4: 112/127] widget-factory: Stop using custom icon sizes
- Date: Sat, 8 Oct 2016 03:19:38 +0000 (UTC)
commit 82c76826c15c4b205363de88f6a34b3978751a55
Author: Timm Bäder <mail baedert org>
Date: Wed Oct 5 19:41:07 2016 +0200
widget-factory: Stop using custom icon sizes
demos/widget-factory/widget-factory.c | 61 +++----------------------------
demos/widget-factory/widget-factory.ui | 2 +-
2 files changed, 7 insertions(+), 56 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index d972f32..3de5fb6 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1507,45 +1507,7 @@ g_test_permission_class_init (GTestPermissionClass *class)
permission_class->release_finish = release_finish;
}
-static int icon_sizes[5];
-
-static void
-register_icon_sizes (void)
-{
- static gboolean registered;
-
- if (registered)
- return;
-
- registered = TRUE;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- icon_sizes[0] = gtk_icon_size_register ("a", 16, 16);
- icon_sizes[1] = gtk_icon_size_register ("b", 24, 24);
- icon_sizes[2] = gtk_icon_size_register ("c", 32, 32);
- icon_sizes[3] = gtk_icon_size_register ("d", 48, 48);
- icon_sizes[4] = gtk_icon_size_register ("e", 64, 64);
-G_GNUC_END_IGNORE_DEPRECATIONS
-}
-
-static int
-find_icon_size (GtkIconSize size)
-{
- gint w, h, w2, h2;
- gint i;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_icon_size_lookup (size, &w, &h);
- for (i = 0; i < G_N_ELEMENTS (icon_sizes); i++)
- {
- gtk_icon_size_lookup (icon_sizes[i], &w2, &h2);
- if (w == w2)
- return i;
- }
-G_GNUC_END_IGNORE_DEPRECATIONS
-
- return 2;
-}
+static int icon_sizes[] = {0, 1, 2, 3, 4, 5, 6};
static void
update_buttons (GtkWidget *iv, int pos)
@@ -1564,21 +1526,16 @@ increase_icon_size (GtkWidget *iv)
GList *cells;
GtkCellRendererPixbuf *cell;
GtkIconSize size;
- int i;
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (iv));
cell = cells->data;
g_list_free (cells);
g_object_get (cell, "stock-size", &size, NULL);
-
- i = find_icon_size (size);
- i = CLAMP (i + 1, 0, G_N_ELEMENTS (icon_sizes) - 1);
- size = icon_sizes[i];
-
+ size = MIN (size + 1, G_N_ELEMENTS (icon_sizes) - 1);
g_object_set (cell, "stock-size", size, NULL);
- update_buttons (iv, i);
+ update_buttons (iv, size);
gtk_widget_queue_resize (iv);
}
@@ -1589,21 +1546,16 @@ decrease_icon_size (GtkWidget *iv)
GList *cells;
GtkCellRendererPixbuf *cell;
GtkIconSize size;
- int i;
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (iv));
cell = cells->data;
g_list_free (cells);
g_object_get (cell, "stock-size", &size, NULL);
-
- i = find_icon_size (size);
- i = CLAMP (i - 1, 0, G_N_ELEMENTS (icon_sizes) - 1);
- size = icon_sizes[i];
-
+ size = MAX (size - 1, 1);
g_object_set (cell, "stock-size", size, NULL);
- update_buttons (iv, i);
+ update_buttons (iv, size);
gtk_widget_queue_resize (iv);
}
@@ -1618,7 +1570,7 @@ reset_icon_size (GtkWidget *iv)
cell = cells->data;
g_list_free (cells);
- g_object_set (cell, "stock-size", icon_sizes[2], NULL);
+ g_object_set (cell, "stock-size", 2, NULL);
update_buttons (iv, 2);
@@ -1680,7 +1632,6 @@ activate (GApplication *app)
GAction *action;
g_type_ensure (my_text_view_get_type ());
- register_icon_sizes ();
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/WidgetFactory/widget-factory.css");
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 58f1e26..c7d80a6 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -2778,7 +2778,7 @@ microphone-sensitivity-medium-symbolic</property>
<property name="model">iconsmodel</property>
<child>
<object class="GtkCellRendererPixbuf" id="iconviewcell">
- <property name="stock-size">5</property>
+ <property name="stock-size">2</property>
</object>
<attributes>
<attribute name="icon-name">0</attribute>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]