forked from AuroraMiddleware/gtk
Add more icon entry tests
This test shows that changing icon types works.
This commit is contained in:
parent
18e8842a7e
commit
7acb670e70
@ -49,6 +49,50 @@ drag_data_get_cb (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_blank (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_icon_name (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "media-floppy");
|
||||
}
|
||||
|
||||
static void
|
||||
set_gicon (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
GIcon *icon;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
{
|
||||
icon = g_themed_icon_new ("gtk-yes");
|
||||
gtk_entry_set_icon_from_gicon (entry, GTK_ENTRY_ICON_SECONDARY, icon);
|
||||
g_object_unref (icon);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_pixbuf (GtkWidget *button,
|
||||
GtkEntry *entry)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
||||
{
|
||||
pixbuf = gdk_pixbuf_new_from_resource ("/org/gtk/libgtk/inspector/logo.png", NULL);
|
||||
gtk_entry_set_icon_from_pixbuf (entry, GTK_ENTRY_ICON_SECONDARY, pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -56,6 +100,11 @@ main (int argc, char **argv)
|
||||
GtkWidget *grid;
|
||||
GtkWidget *label;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *box;
|
||||
GtkWidget *button1;
|
||||
GtkWidget *button2;
|
||||
GtkWidget *button3;
|
||||
GtkWidget *button4;
|
||||
GIcon *icon;
|
||||
GtkTargetList *tlist;
|
||||
|
||||
@ -183,6 +232,25 @@ main (int argc, char **argv)
|
||||
gtk_widget_set_hexpand (entry, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), entry, 1, 4, 1, 1);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_grid_attach (GTK_GRID (grid), box, 0, 5, 3, 1);
|
||||
|
||||
button1 = gtk_radio_button_new_with_label (NULL, "Blank");
|
||||
g_signal_connect (button1, "toggled", G_CALLBACK (set_blank), entry);
|
||||
gtk_container_add (GTK_CONTAINER (box), button1);
|
||||
button2 = gtk_radio_button_new_with_label (NULL, "Icon Name");
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button2), GTK_RADIO_BUTTON (button1));
|
||||
g_signal_connect (button2, "toggled", G_CALLBACK (set_icon_name), entry);
|
||||
gtk_container_add (GTK_CONTAINER (box), button2);
|
||||
button3 = gtk_radio_button_new_with_label (NULL, "GIcon");
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button3), GTK_RADIO_BUTTON (button1));
|
||||
g_signal_connect (button3, "toggled", G_CALLBACK (set_gicon), entry);
|
||||
gtk_container_add (GTK_CONTAINER (box), button3);
|
||||
button4 = gtk_radio_button_new_with_label (NULL, "Pixbuf");
|
||||
gtk_radio_button_join_group (GTK_RADIO_BUTTON (button4), GTK_RADIO_BUTTON (button1));
|
||||
g_signal_connect (button4, "toggled", G_CALLBACK (set_pixbuf), entry);
|
||||
gtk_container_add (GTK_CONTAINER (box), button4);
|
||||
|
||||
gtk_widget_show_all (window);
|
||||
|
||||
gtk_main();
|
||||
|
Loading…
Reference in New Issue
Block a user