2010-11-05 09:33:50 +00:00
|
|
|
/* testgiconpixbuf.c
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
* Authors: Cosimo Cecchi
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-11-05 09:33:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
2017-03-12 18:36:21 +00:00
|
|
|
#include <glib/gstdio.h>
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
static void
|
|
|
|
quit_cb (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gboolean *done = data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
|
|
|
|
g_main_context_wakeup (NULL);
|
|
|
|
}
|
|
|
|
|
2010-11-05 09:33:50 +00:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char **argv)
|
|
|
|
{
|
|
|
|
GdkPixbuf *pixbuf, *otherpix;
|
|
|
|
GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
|
|
|
|
GIcon *emblemed;
|
|
|
|
GEmblem *emblem;
|
|
|
|
gchar *str;
|
2020-02-10 03:24:47 +00:00
|
|
|
gboolean done = FALSE;
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2017-03-12 18:36:21 +00:00
|
|
|
#ifdef GTK_SRCDIR
|
|
|
|
g_chdir (GTK_SRCDIR);
|
|
|
|
#endif
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2010-11-05 09:33:50 +00:00
|
|
|
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
|
2020-02-14 19:55:36 +00:00
|
|
|
toplevel = gtk_window_new ();
|
2010-11-05 16:01:34 +00:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2020-05-10 23:55:22 +00:00
|
|
|
gtk_window_set_child (GTK_WINDOW (toplevel), hbox);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2010-11-05 16:01:34 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), vbox);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
image = gtk_image_new_from_gicon (G_ICON (pixbuf));
|
2017-11-15 02:14:47 +00:00
|
|
|
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), image);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
str = g_strdup_printf ("Normal icon, hash %u", g_icon_hash (G_ICON (pixbuf)));
|
|
|
|
gtk_label_set_label (GTK_LABEL (label), str);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), label);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
|
|
|
otherpix = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
|
|
|
|
emblem = g_emblem_new (G_ICON (otherpix));
|
|
|
|
emblemed = g_emblemed_icon_new (G_ICON (pixbuf), emblem);
|
|
|
|
|
2010-11-05 16:01:34 +00:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), vbox);
|
2016-10-02 15:37:22 +00:00
|
|
|
|
2017-11-15 00:43:13 +00:00
|
|
|
image2 = gtk_image_new_from_gicon (emblemed);
|
2017-11-15 02:14:47 +00:00
|
|
|
gtk_image_set_icon_size (GTK_IMAGE (image2), GTK_ICON_SIZE_LARGE);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), image2);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
str = g_strdup_printf ("Emblemed icon, hash %u", g_icon_hash (emblemed));
|
|
|
|
gtk_label_set_label (GTK_LABEL (label), str);
|
2018-12-26 07:20:34 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (vbox), label);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (toplevel);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
while (!done)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2010-11-05 09:33:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|