예제 #1
0
int
main (int argc,
      char **argv)
{
  GdkPixbuf *pixbuf, *otherpix;
  GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
  GIcon *emblemed;
  GEmblem *emblem;
  gchar *str;

  gtk_init (&argc, &argv);

  pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
  toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_container_add (GTK_CONTAINER (toplevel), hbox);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);

  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);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  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);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  
  image2 = gtk_image_new_from_gicon (emblemed, GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (vbox), image2, FALSE, FALSE, 0);

  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);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  gtk_widget_show_all (toplevel);

  g_signal_connect (toplevel, "delete-event",
		    G_CALLBACK (gtk_main_quit), NULL);

  gtk_main ();

  return 0;
}
예제 #2
0
static void
pack_numerable (GtkWidget *parent,
                GtkIconSize size)
{
  PackData *d;
  GtkWidget *vbox, *label, *image, *button;
  gchar *str;
  GIcon *icon, *numerable;

  d = g_slice_new0 (PackData);

  image = gtk_image_new ();
  icon = g_themed_icon_new ("system-file-manager");
  numerable = gtk_numerable_icon_new (icon);

  d->image = image;
  d->numerable = numerable;
  d->odd = FALSE;
  d->size = size;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (parent), vbox, FALSE, FALSE, 0);

  gtk_numerable_icon_set_count (GTK_NUMERABLE_ICON (numerable), 42);
  gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
  gtk_numerable_icon_set_style_context (GTK_NUMERABLE_ICON (numerable),
                                        gtk_widget_get_style_context (image));
  gtk_image_set_from_gicon (GTK_IMAGE (image), numerable, size);

  label = gtk_label_new (NULL);
  str = g_strdup_printf ("Numerable icon, hash %u", g_icon_hash (numerable));
  gtk_label_set_label (GTK_LABEL (label), str);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  button = gtk_button_new_with_label ("Change icon number");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "clicked",
                    G_CALLBACK (button_clicked_cb), d);

  button = gtk_button_new_with_label ("Properties");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "clicked",
                    G_CALLBACK (properties_cb), numerable);

  button = gtk_button_new_with_label ("Refresh");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "clicked",
                    G_CALLBACK (refresh_cb), d);
}
예제 #3
0
static guint
loadable_icon_key_hash (LoadableIconKey *key)
{
	return g_icon_hash (key->icon) ^ key->size;
}
예제 #4
0
파일: gicon.c 프로젝트: taf2/ruby-gnome2
static VALUE
icon_hash(VALUE self)
{
        return UINT2NUM(g_icon_hash(_SELF(self)));
}