summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTimm Bäder <mail@baedert.org>2016-10-14 16:01:56 +0200
committerBenjamin Otte <otte@redhat.com>2016-10-18 00:29:19 +0200
commitbe2f19663bf9c1ead35fa69aee0292842ceada97 (patch)
treed01d19b069b1823bb124847ad1feba82d1cb43b9 /tests
parent37c728be12fd4c5664ca2c5ee9abd5c6c9973d0c (diff)
downloadgtk+-be2f19663bf9c1ead35fa69aee0292842ceada97.tar.gz
button: Add icon-name property
Remove the old-style button construction that allowed to show both an icon and a label and change visibility based on a GtkSetting.
Diffstat (limited to 'tests')
-rw-r--r--tests/testbaseline.c33
-rw-r--r--tests/testbuttons.c32
2 files changed, 36 insertions, 29 deletions
diff --git a/tests/testbaseline.c b/tests/testbaseline.c
index 2ae81c5ac3..30f4a1924a 100644
--- a/tests/testbaseline.c
+++ b/tests/testbaseline.c
@@ -173,11 +173,13 @@ main (int argc,
for (i = 0; i < 3; i++)
{
- button = gtk_button_new_with_label ("│Xyj,Ö");
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
- gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
+ gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("│Xyj,Ö"));
+ gtk_container_add (GTK_CONTAINER (box),
+ gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
+ gtk_container_add (GTK_CONTAINER (button), box);
set_font_size (button, i);
@@ -270,11 +272,13 @@ main (int argc,
for (i = 0; i < 3; i++)
{
- button = gtk_button_new_with_label ("│Xyj,Ö");
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ button = gtk_button_new ();
- gtk_button_set_image (GTK_BUTTON (button),
- gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
- gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
+ gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("│Xyj,Ö"));
+ gtk_container_add (GTK_CONTAINER (box),
+ gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON));
+ gtk_container_add (GTK_CONTAINER (button), box);
set_font_size (button, i);
@@ -358,14 +362,17 @@ main (int argc,
for (i = 0; i < 3; i++)
{
- button = gtk_button_new_with_label ("│Xyj,Ö");
+ GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ button = gtk_button_new ();
+
+ gtk_container_add (GTK_CONTAINER (box), gtk_label_new ("│Xyj,Ö"));
+ image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
+ gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
+ gtk_container_add (GTK_CONTAINER (box), image);
+ gtk_container_add (GTK_CONTAINER (button), box);
- image = gtk_image_new_from_icon_name ("face-sad", GTK_ICON_SIZE_BUTTON);
- gtk_image_set_pixel_size (GTK_IMAGE (image), 16);
- gtk_button_set_image (GTK_BUTTON (button), image);
if (i == 0)
g_signal_connect (spin2, "value-changed", (GCallback)image_size_value_changed, image);
- gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
set_font_size (button, i);
diff --git a/tests/testbuttons.c b/tests/testbuttons.c
index 6046b73189..7217311b00 100644
--- a/tests/testbuttons.c
+++ b/tests/testbuttons.c
@@ -23,8 +23,9 @@ int main (int argc, char *argv[])
{
GtkWidget *window, *box, *button, *hbox;
gchar *text;
+ const char *icon_name;
gboolean use_underline;
- GtkWidget *image, *label;
+ GtkWidget *label;
gtk_init (&argc, &argv);
@@ -44,9 +45,9 @@ int main (int argc, char *argv[])
g_object_get (button,
"label", &text,
"use-underline", &use_underline,
- "image", &image,
+ "icon-name", &icon_name,
NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-underline: %s\n", text, image, use_underline ? "TRUE" : "FALSE");
+ text = g_strdup_printf ("label: \"%s\" icon-name: \"%s\" use-underline: %s\n", text, icon_name, use_underline ? "TRUE" : "FALSE");
label = gtk_label_new (text);
g_free (text);
gtk_container_add (GTK_CONTAINER (hbox), label);
@@ -59,9 +60,9 @@ int main (int argc, char *argv[])
g_object_get (button,
"label", &text,
"use-underline", &use_underline,
- "image", &image,
+ "icon-name", &icon_name,
NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-underline: %s\n", text, image, use_underline ? "TRUE" : "FALSE");
+ text = g_strdup_printf ("label: \"%s\" icon-name: \"%s\" use-underline: %s\n", text, icon_name, use_underline ? "TRUE" : "FALSE");
label = gtk_label_new (text);
g_free (text);
gtk_container_add (GTK_CONTAINER (hbox), label);
@@ -74,41 +75,40 @@ int main (int argc, char *argv[])
g_object_get (button,
"label", &text,
"use-underline", &use_underline,
- "image", &image,
+ "icon-name", &icon_name,
NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-underline: %s\n", text, image, use_underline ? "TRUE" : "FALSE");
+ text = g_strdup_printf ("label: \"%s\" icon-name: \"%s\" use-underline: %s\n", text, icon_name, use_underline ? "TRUE" : "FALSE");
label = gtk_label_new (text);
g_free (text);
gtk_container_add (GTK_CONTAINER (hbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (box), hbox);
- button = gtk_button_new_with_label ("_Save");
- gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_BUTTON));
- gtk_button_set_always_show_image (GTK_BUTTON (button), TRUE);
+ button = gtk_button_new_from_icon_name ("help-about", GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (hbox), button);
g_object_get (button,
"label", &text,
"use-underline", &use_underline,
- "image", &image,
+ "icon-name", &icon_name,
NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-underline: %s\n", text, image, use_underline ? "TRUE" : "FALSE");
+ text = g_strdup_printf ("label: \"%s\" icon-name: \"%s\" use-underline: %s\n", text, icon_name, use_underline ? "TRUE" : "FALSE");
label = gtk_label_new (text);
g_free (text);
gtk_container_add (GTK_CONTAINER (hbox), label);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_add (GTK_CONTAINER (box), hbox);
- button = gtk_button_new_with_mnemonic ("_Save");
- gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_BUTTON));
+ button = gtk_button_new ();
+ gtk_button_set_icon_name (GTK_BUTTON (button), "help-about");
+ gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
gtk_container_add (GTK_CONTAINER (hbox), button);
g_object_get (button,
"label", &text,
"use-underline", &use_underline,
- "image", &image,
+ "icon-name", &icon_name,
NULL);
- text = g_strdup_printf ("label: \"%s\" image: %p use-underline: %s\n", text, image, use_underline ? "TRUE" : "FALSE");
+ text = g_strdup_printf ("label: \"%s\" icon-name: \"%s\" use-underline: %s\n", text, icon_name, use_underline ? "TRUE" : "FALSE");
label = gtk_label_new (text);
g_free (text);
gtk_container_add (GTK_CONTAINER (hbox), label);