summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-12-01 09:25:13 -0500
committerMatthias Clasen <mclasen@redhat.com>2017-12-01 10:29:53 -0500
commitb9035fc3a69f3a03a45647401f5cf7603c67dfa8 (patch)
treef5f406075d3a1a0068ba065f312706370f2444a7 /demos
parent478b1d56f88fdfeeaae6c2efac5be441eb3b5e57 (diff)
downloadgtk+-b9035fc3a69f3a03a45647401f5cf7603c67dfa8.tar.gz
widget-factory: Fix up icon size handling
Make the icon grid on page 2 work with our new approach to icon sizes.
Diffstat (limited to 'demos')
-rw-r--r--demos/widget-factory/widget-factory.c31
-rw-r--r--demos/widget-factory/widget-factory.ui7
2 files changed, 17 insertions, 21 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 9ad481d189..016ee9d39a 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -1523,17 +1523,17 @@ g_test_permission_class_init (GTestPermissionClass *class)
permission_class->release_finish = release_finish;
}
-static int icon_sizes[] = {0, 1, 2, 3, 4, 5, 6};
-
static void
-update_buttons (GtkWidget *iv, int pos)
+update_buttons (GtkWidget *iv, GtkIconSize size)
{
GtkWidget *button;
button = GTK_WIDGET (g_object_get_data (G_OBJECT (iv), "increase_button"));
- gtk_widget_set_sensitive (button, pos + 1 < G_N_ELEMENTS (icon_sizes));
+ gtk_widget_set_sensitive (button, size != GTK_ICON_SIZE_LARGE);
button = GTK_WIDGET (g_object_get_data (G_OBJECT (iv), "decrease_button"));
- gtk_widget_set_sensitive (button, pos > 0);
+ gtk_widget_set_sensitive (button, size != GTK_ICON_SIZE_NORMAL);
+ button = GTK_WIDGET (g_object_get_data (G_OBJECT (iv), "reset_button"));
+ gtk_widget_set_sensitive (button, size != GTK_ICON_SIZE_INHERIT);
}
static void
@@ -1541,17 +1541,14 @@ increase_icon_size (GtkWidget *iv)
{
GList *cells;
GtkCellRendererPixbuf *cell;
- GtkIconSize size;
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);
- size = MIN (size + 1, G_N_ELEMENTS (icon_sizes) - 1);
- g_object_set (cell, "stock-size", size, NULL);
+ g_object_set (cell, "stock-size", GTK_ICON_SIZE_LARGE, NULL);
- update_buttons (iv, size);
+ update_buttons (iv, GTK_ICON_SIZE_LARGE);
gtk_widget_queue_resize (iv);
}
@@ -1561,17 +1558,14 @@ decrease_icon_size (GtkWidget *iv)
{
GList *cells;
GtkCellRendererPixbuf *cell;
- GtkIconSize size;
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);
- size = MAX (size - 1, 1);
- g_object_set (cell, "stock-size", size, NULL);
+ g_object_set (cell, "stock-size", GTK_ICON_SIZE_NORMAL, NULL);
- update_buttons (iv, size);
+ update_buttons (iv, GTK_ICON_SIZE_NORMAL);
gtk_widget_queue_resize (iv);
}
@@ -1586,9 +1580,9 @@ reset_icon_size (GtkWidget *iv)
cell = cells->data;
g_list_free (cells);
- g_object_set (cell, "stock-size", 2, NULL);
+ g_object_set (cell, "stock-size", GTK_ICON_SIZE_INHERIT, NULL);
- update_buttons (iv, 2);
+ update_buttons (iv, GTK_ICON_SIZE_INHERIT);
gtk_widget_queue_resize (iv);
}
@@ -1888,6 +1882,9 @@ activate (GApplication *app)
g_object_set_data (G_OBJECT (widget), "increase_button", widget2);
widget2 = (GtkWidget *)gtk_builder_get_object (builder, "decrease_button");
g_object_set_data (G_OBJECT (widget), "decrease_button", widget2);
+ widget2 = (GtkWidget *)gtk_builder_get_object (builder, "reset_button");
+ g_object_set_data (G_OBJECT (widget), "reset_button", widget2);
+ reset_icon_size (widget);
adj = (GtkAdjustment *)gtk_builder_get_object (builder, "adjustment3");
widget = (GtkWidget *)gtk_builder_get_object (builder, "progressbar1");
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index f533937b2e..b6d24cb998 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -2400,7 +2400,6 @@ microphone-sensitivity-medium-symbolic</property>
<property name="model">iconsmodel</property>
<child>
<object class="GtkCellRendererPixbuf" id="iconviewcell">
- <property name="stock-size">2</property>
</object>
<attributes>
<attribute name="icon-name">0</attribute>
@@ -2419,21 +2418,21 @@ microphone-sensitivity-medium-symbolic</property>
<child>
<object class="GtkToolButton" id="decrease_button">
<property name="icon-name">zoom-out-symbolic</property>
- <property name="label">Remove item</property>
+ <property name="tooltip-text">Normal icons</property>
<signal name="clicked" handler="decrease_icon_size" object="iconview1" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkToolButton" id="increase_button">
<property name="icon-name">zoom-in-symbolic</property>
- <property name="label">Add item</property>
+ <property name="tooltip-text">Large icons</property>
<signal name="clicked" handler="increase_icon_size" object="iconview1" swapped="yes"/>
</object>
</child>
<child>
<object class="GtkToolButton" id="reset_button">
<property name="icon-name">zoom-original-symbolic</property>
- <property name="label">Refresh</property>
+ <property name="tooltip-text">Inherited icon size</property>
<signal name="clicked" handler="reset_icon_size" object="iconview1" swapped="yes"/>
</object>
</child>