コード例 #1
0
ファイル: ar-stock.c プロジェクト: Bob131/aisleriot
static void
register_stock_icon_bidi (GtkIconFactory * icon_factory,
                          const char * stock_id,
                          const char * icon_name_ltr,
                          const char * icon_name_rtl)
{
  GtkIconSource *source;
  GtkIconSet *set;

  set = gtk_icon_set_new ();

  source = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (source, icon_name_ltr);
  gtk_icon_source_set_direction (source, GTK_TEXT_DIR_LTR);
  gtk_icon_source_set_direction_wildcarded (source, FALSE);
  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  source = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (source, icon_name_rtl);
  gtk_icon_source_set_direction (source, GTK_TEXT_DIR_RTL);
  gtk_icon_source_set_direction_wildcarded (source, FALSE);
  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  gtk_icon_factory_add (icon_factory, stock_id, set);
  gtk_icon_set_unref (set);
}
コード例 #2
0
static void
add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme,
		const char *size, SizedStockIcon sized_icon, gboolean translucent)
{
	char *filename;
	GtkIconSource *source;
	GdkPixbuf *pixbuf;

	filename = find_icon_file(theme, size, sized_icon, FALSE);
	g_return_if_fail(filename != NULL);
	pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
	if (translucent)
		do_alphashift(pixbuf, pixbuf);

	source = gtk_icon_source_new();
	gtk_icon_source_set_pixbuf(source, pixbuf);
	gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR);
	gtk_icon_source_set_direction_wildcarded(source, !sized_icon.rtl);
	gtk_icon_source_set_size(source, sizeid);
	gtk_icon_source_set_size_wildcarded(source, FALSE);
	gtk_icon_source_set_state_wildcarded(source, TRUE);
	gtk_icon_set_add_source(iconset, source);
	gtk_icon_source_free(source);

	if (sizeid == gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)) {
		source = gtk_icon_source_new();
		gtk_icon_source_set_pixbuf(source, pixbuf);
		gtk_icon_source_set_direction_wildcarded(source, TRUE);
		gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU);
		gtk_icon_source_set_size_wildcarded(source, FALSE);
		gtk_icon_source_set_state_wildcarded(source, TRUE);
		gtk_icon_set_add_source(iconset, source);
		gtk_icon_source_free(source);
	}
	g_free(filename);
	g_object_unref(pixbuf);

	if (sized_icon.rtl) {
		filename = find_icon_file(theme, size, sized_icon, TRUE);
		g_return_if_fail(filename != NULL);
		pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
		if (translucent)
			do_alphashift(pixbuf, pixbuf);

		source = gtk_icon_source_new();
		gtk_icon_source_set_pixbuf(source, pixbuf);
		gtk_icon_source_set_filename(source, filename);
		gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL);
		gtk_icon_source_set_size(source, sizeid);
		gtk_icon_source_set_size_wildcarded(source, FALSE);
		gtk_icon_source_set_state_wildcarded(source, TRUE);
		gtk_icon_set_add_source(iconset, source);
		g_free(filename);
		g_object_unref(pixbuf);
		gtk_icon_source_free(source);
	}
}
コード例 #3
0
ファイル: page-holder.c プロジェクト: garfieldwtf/midori
MidoriExtension*
extension_init (void)
{
    GtkIconFactory* factory;
    GtkIconSource* icon_source;
    GtkIconSet* icon_set;
    static GtkStockItem items[] =
    {
        { STOCK_PAGE_HOLDER, N_("_Pageholder"), 0, 0, NULL },
    };

    factory = gtk_icon_factory_new ();
    gtk_stock_add (items, G_N_ELEMENTS (items));
    icon_set = gtk_icon_set_new ();
    icon_source = gtk_icon_source_new ();
    gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_ORIENTATION_PORTRAIT);
    gtk_icon_set_add_source (icon_set, icon_source);
    gtk_icon_source_free (icon_source);
    gtk_icon_factory_add (factory, STOCK_PAGE_HOLDER, icon_set);
    gtk_icon_set_unref (icon_set);
    gtk_icon_factory_add_default (factory);
    g_object_unref (factory);

    MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
                                 "name", _("Pageholder"),
                                 "description", "",
                                 "version", "0.1",
                                 "authors", "Christian Dywan <*****@*****.**>",
                                 NULL);

    g_signal_connect (extension, "activate",
                      G_CALLBACK (page_holder_activate_cb), NULL);

    return extension;
}
コード例 #4
0
void
camorama_stock_init(void) {
    GtkIconFactory* factory = gtk_icon_factory_new();
    GtkIconSet    * set = gtk_icon_set_new ();
    GtkIconSource * source = gtk_icon_source_new();

    gtk_stock_add_static(camorama_items, G_N_ELEMENTS(camorama_items));

    gtk_icon_source_set_size_wildcarded(source, TRUE);
    gtk_icon_source_set_direction_wildcarded(source, TRUE);
    gtk_icon_source_set_state_wildcarded(source, TRUE);

    gtk_icon_source_set_icon_name(source, CAMORAMA_STOCK_WEBCAM);
    gtk_icon_set_add_source(set, source);

    gtk_icon_factory_add(factory, CAMORAMA_STOCK_WEBCAM, set);

    add_default_image(CAMORAMA_STOCK_WEBCAM, 16, camorama_webcam_16);
    add_default_image(CAMORAMA_STOCK_WEBCAM, 24, camorama_webcam_24);

    gtk_icon_factory_add_default(factory);

    gtk_icon_set_unref(set);
    gtk_icon_source_free(source);
}
コード例 #5
0
ファイル: RenderThemeGtk.cpp プロジェクト: Wrichik1999/webkit
void RenderThemeGtk::initMediaButtons()
{
    static bool iconsInitialized = false;

    if (iconsInitialized)
        return;

    GRefPtr<GtkIconFactory> iconFactory = adoptGRef(gtk_icon_factory_new());
    GtkIconSource* iconSource = gtk_icon_source_new();
    const char* icons[] = { "audio-volume-high", "audio-volume-muted" };

    gtk_icon_factory_add_default(iconFactory.get());

    for (size_t i = 0; i < G_N_ELEMENTS(icons); ++i) {
        gtk_icon_source_set_icon_name(iconSource, icons[i]);
        GtkIconSet* iconSet = gtk_icon_set_new();
        gtk_icon_set_add_source(iconSet, iconSource);
        gtk_icon_factory_add(iconFactory.get(), icons[i], iconSet);
        gtk_icon_set_unref(iconSet);
    }

    gtk_icon_source_free(iconSource);

    iconsInitialized = true;
}
コード例 #6
0
ファイル: sendmail.c プロジェクト: DaveMDS/geany-plugins
static void add_stock_item(void)
{
	GtkIconSet *icon_set;
	GtkIconFactory *factory = gtk_icon_factory_new();
	GtkIconTheme *theme = gtk_icon_theme_get_default();
	GtkStockItem item = { (gchar*)(GEANYSENDMAIL_STOCK_MAIL), (gchar*)(N_("Mail")), 0, 0, (gchar*)(GETTEXT_PACKAGE) };

	if (gtk_icon_theme_has_icon(theme, "mail-message-new"))
	{
		GtkIconSource *icon_source = gtk_icon_source_new();
		icon_set = gtk_icon_set_new();
		gtk_icon_source_set_icon_name(icon_source, "mail-message-new");
		gtk_icon_set_add_source(icon_set, icon_source);
		gtk_icon_source_free(icon_source);
	}
	else
	{
		GdkPixbuf *pb = gdk_pixbuf_new_from_xpm_data(mail_icon);
		icon_set = gtk_icon_set_new_from_pixbuf(pb);
		g_object_unref(pb);
	}
	gtk_icon_factory_add(factory, item.stock_id, icon_set);
	gtk_stock_add(&item, 1);
	gtk_icon_factory_add_default(factory);

	g_object_unref(factory);
	gtk_icon_set_unref(icon_set);
}
コード例 #7
0
static void
add_stock_icon (const gchar  *stock_id,
                GtkIconSize   size,
                const guint8 *inline_data)
{
  GtkIconSource *source;
  GtkIconSet    *set;
  GdkPixbuf     *pixbuf;

  source = gtk_icon_source_new ();

  gtk_icon_source_set_size (source, size);
  gtk_icon_source_set_size_wildcarded (source, FALSE);

  pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);

  gtk_icon_source_set_pixbuf (source, pixbuf);
  g_object_unref (pixbuf);

  set = gtk_icon_set_new ();

  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  gtk_icon_factory_add (mapobject_icon_factory, stock_id, set);

  gtk_icon_set_unref (set);
}
コード例 #8
0
ファイル: thunar-stock.c プロジェクト: flipcoder/thunar
/**
 * thunar_stock_init:
 *
 * Initializes the stock icons used by the Thunar
 * file manager.
 **/
void
thunar_stock_init (void)
{
  GtkIconFactory *icon_factory;
  GtkIconSource  *icon_source;
  GtkIconSet     *icon_set;
  guint           n;

  /* allocate a new icon factory for the thunar stock icons */
  icon_factory = gtk_icon_factory_new ();

  /* allocate an icon source */
  icon_source = gtk_icon_source_new ();

  /* register our stock icons */
  for (n = 0; n < G_N_ELEMENTS (thunar_stock_icons); ++n)
    {
      /* setup the icon set */
      icon_set = gtk_icon_set_new ();
      gtk_icon_source_set_icon_name (icon_source, thunar_stock_icons[n].icon);
      gtk_icon_set_add_source (icon_set, icon_source);
      gtk_icon_factory_add (icon_factory, thunar_stock_icons[n].name, icon_set);
      gtk_icon_set_unref (icon_set);
    }

  /* register our icon factory as default */
  gtk_icon_factory_add_default (icon_factory);

  /* cleanup */
  g_object_unref (G_OBJECT (icon_factory));
  gtk_icon_source_free (icon_source);
}
コード例 #9
0
ファイル: ev-stock-icons.c プロジェクト: monsta/atril
/**
 * ev_stock_icons_init:
 *
 * Creates a new icon factory, adding the base stock icons to it.
 */
void
ev_stock_icons_init (void)
{
	GtkIconFactory *factory;
	GtkIconSource *source;
	gint i;

	ev_icons_path = g_build_filename (ATRILDATADIR, "icons", NULL);

        factory = gtk_icon_factory_new ();
        gtk_icon_factory_add_default (factory);

	source = gtk_icon_source_new ();

	for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) {
		GtkIconSet *set;

		gtk_icon_source_set_icon_name (source, stock_icons [i].icon);

		set = gtk_icon_set_new ();
		gtk_icon_set_add_source (set, source);

		gtk_icon_factory_add (factory, stock_icons [i].stock_id, set);
		gtk_icon_set_unref (set);
	}

	gtk_icon_source_free (source);

	g_object_unref (G_OBJECT (factory));

	ev_stock_icons_add_icons_path_for_screen (gdk_screen_get_default ());
}
コード例 #10
0
ファイル: fr-stock.c プロジェクト: City-busz/engrampa
void
fr_stock_init (void)
{        
	GtkIconFactory *factory;
        GtkIconSource  *source;
        int             i;
	
	if (stock_initialized)
		return;
	stock_initialized = TRUE;

	gtk_stock_add_static (stock_items, G_N_ELEMENTS (stock_items));

        factory = gtk_icon_factory_new ();
        gtk_icon_factory_add_default (factory);

        source = gtk_icon_source_new ();

        for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) {
                GtkIconSet *set;

                gtk_icon_source_set_icon_name (source, stock_icons [i].icon);

                set = gtk_icon_set_new ();
                gtk_icon_set_add_source (set, source);

                gtk_icon_factory_add (factory, stock_icons [i].stock_id, set);
                gtk_icon_set_unref (set);
        }

        gtk_icon_source_free (source);

        g_object_unref (factory);
}
コード例 #11
0
nsresult
nsIconChannel::Init(nsIURI* aURI)
{
  nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI);
  NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI");

  nsCAutoString stockIcon;
  iconURI->GetStockIcon(stockIcon);
  if (stockIcon.IsEmpty()) {
#ifdef MOZ_ENABLE_GNOMEUI
    return InitWithGnome(iconURI);
#else
    return NS_ERROR_NOT_AVAILABLE;
#endif
  }

  nsCAutoString iconSizeString;
  iconURI->GetIconSize(iconSizeString);

  nsCAutoString iconStateString;
  iconURI->GetIconState(iconStateString);

  GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
   
  ensure_stock_image_widget();

  gboolean sensitive = strcmp(iconStateString.get(), "disabled");
  gtk_widget_set_sensitive (gStockImageWidget, sensitive);

  GdkPixbuf *icon = gtk_widget_render_icon(gStockImageWidget, stockIcon.get(),
                                           icon_size, NULL);
#if GTK_CHECK_VERSION(2,4,0)
  if (!icon) {
    ensure_icon_factory();
      
    GtkIconSet *icon_set = gtk_icon_set_new();
    GtkIconSource *icon_source = gtk_icon_source_new();
    
    gtk_icon_source_set_icon_name(icon_source, stockIcon.get());
    gtk_icon_set_add_source(icon_set, icon_source);
    gtk_icon_factory_add(gIconFactory, stockIcon.get(), icon_set);
    gtk_icon_set_unref(icon_set);
    gtk_icon_source_free(icon_source);

    icon = gtk_widget_render_icon(gStockImageWidget, stockIcon.get(),
                                  icon_size, NULL);
  }
#endif

  if (!icon)
    return NS_ERROR_NOT_AVAILABLE;
  
  nsresult rv = moz_gdk_pixbuf_to_channel(icon, iconURI,
                                          getter_AddRefs(mRealChannel));

  g_object_unref(icon);

  return rv;
}
コード例 #12
0
ファイル: application.c プロジェクト: UIKit0/gnumeric
static void
add_icon (GtkIconFactory *factory,
	  const char *scalable_filename,
	  const char *sized_filename,
	  const char *stock_id)
{
	GtkIconSet *set = gtk_icon_set_new ();
	GtkIconSource *src = gtk_icon_source_new ();

	if (scalable_filename) {
		char *res = g_strconcat ("res:gnm:pixmaps/",
					 scalable_filename,
					 NULL);
		GdkPixbuf *pix = go_gdk_pixbuf_load_from_file (res);
		if (pix) {
			gtk_icon_source_set_size_wildcarded (src, TRUE);
			gtk_icon_source_set_pixbuf (src, pix);
			gtk_icon_set_add_source (set, src);
			g_object_unref (pix);
		} else {
			g_warning ("Missing resource %s\n", res);
		}
		g_free (res);
	}

	/*
	 * For now, don't register a fixed-sized icon as doing so without
	 * catching style changes kills things like bug 302902.
	 */
	if (sized_filename && !scalable_filename) {
		char *res = g_strconcat ("res:gnm:pixmaps/",
					 sized_filename,
					 NULL);
		GdkPixbuf *pix = go_gdk_pixbuf_load_from_file (res);
		gtk_icon_source_set_size (src, GTK_ICON_SIZE_MENU);
		gtk_icon_source_set_size_wildcarded (src, FALSE);
		gtk_icon_source_set_pixbuf (src, pix);
		gtk_icon_set_add_source (set, src);
		g_object_unref (pix);
		g_free (res);
	}

	gtk_icon_factory_add (factory, stock_id, set);
	gtk_icon_set_unref (set);
	gtk_icon_source_free (src);
}
コード例 #13
0
ファイル: gul-gui.c プロジェクト: GNOME/galeon
/**
 * gul_gui_image_set_from_mime_type:
 * @image: a #GtkImage
 * @mime_type: a MIME type
 * @icon_size: a stock icon size
 *
 * Set the @image to display the icon for MIME type @mime_type.  Sample MIME
 * types are "text/plain", "application/ogg".  Sample stock sizes are
 * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_DIALOG.
 */
void
gul_gui_image_set_from_mime_type (GtkWidget  *image,
		                  const char *mime_type,
				  GtkIconSize icon_size)
{
	GtkIconTheme *theme;
	char           *icon;
	GtkIconSource  *source;
	GtkIconSet     *icon_set;

	g_return_if_fail (GTK_IS_IMAGE(image));
	g_return_if_fail (mime_type != NULL);

	theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (image));

	icon = gnome_icon_lookup (theme, NULL, NULL, NULL, NULL,
				  mime_type,
				  GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);

	if (!g_path_is_absolute (icon))
	{
		int   width, height;
		GtkIconInfo *icon_info;

		if (!gtk_icon_size_lookup_for_settings 
			(gtk_widget_get_settings (GTK_WIDGET(image)),
			 icon_size, &width, &height))
		{
			width = height = -1;
		}

		icon_info = gtk_icon_theme_lookup_icon (theme, icon, height,0);
		g_free (icon);

		g_return_if_fail (icon_info != NULL);

		icon = g_strdup (gtk_icon_info_get_filename (icon_info));
		gtk_icon_info_free (icon_info);
	}

	/* Now that we have the icon filename, wrap it into an GtkIconSet so
	 * that we really get the desired size; the icon size in the file may
	 * still be arbitrary, in case of SVG themes, for example.
	 */

	source = gtk_icon_source_new ();
	gtk_icon_source_set_filename (source, icon);
	g_free (icon);

	icon_set = gtk_icon_set_new ();
	gtk_icon_set_add_source (icon_set, source);
	gtk_icon_source_free (source);

	gtk_image_set_from_icon_set (GTK_IMAGE(image), icon_set, icon_size);

	gtk_icon_set_unref (icon_set);
}
コード例 #14
0
ファイル: gimpstock.c プロジェクト: jdburton/gimp-osx
static void
icon_set_from_inline (GtkIconSet       *set,
                      const guchar     *inline_data,
                      GtkIconSize       size,
                      GtkTextDirection  direction,
                      gboolean          fallback)
{
  GtkIconSource *source;
  GdkPixbuf     *pixbuf;

  source = gtk_icon_source_new ();

  if (direction != GTK_TEXT_DIR_NONE)
    {
      gtk_icon_source_set_direction (source, direction);
      gtk_icon_source_set_direction_wildcarded (source, FALSE);
    }

  gtk_icon_source_set_size (source, size);
  gtk_icon_source_set_size_wildcarded (source, FALSE);

  pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);

  g_assert (pixbuf);

  gtk_icon_source_set_pixbuf (source, pixbuf);

  g_object_unref (pixbuf);

  gtk_icon_set_add_source (set, source);

  if (fallback)
    {
      gtk_icon_source_set_size_wildcarded (source, TRUE);
      gtk_icon_set_add_source (set, source);
    }

  gtk_icon_source_free (source);
}
コード例 #15
0
ファイル: gdl-stock.c プロジェクト: wdmchaft/DoonSketch
static void
icon_set_from_data (GtkIconSet       *set,
		    const guint8     *icon_data,
		    const guint       data_size,
		    GtkIconSize       size,
		    gboolean          fallback)
{
	GtkIconSource *source;
	GdkPixbuf     *pixbuf;
	GError        *err = NULL;

	source = gtk_icon_source_new ();

	gtk_icon_source_set_size (source, size);
	gtk_icon_source_set_size_wildcarded (source, FALSE);
	
	pixbuf = gdk_pixbuf_new_from_inline (data_size, icon_data, FALSE, &err);
	if (err) {
	    g_warning ("%s",err->message);
	    g_error_free (err);
	    err = NULL;
	    g_object_unref (source);
	    return;
	}
	
	gtk_icon_source_set_pixbuf (source, pixbuf);
	
	g_object_unref (pixbuf);
	
	gtk_icon_set_add_source (set, source);
	
	if (fallback) {
		gtk_icon_source_set_size_wildcarded (source, TRUE);
		gtk_icon_set_add_source (set, source);
	}
	
	gtk_icon_source_free (source);
}
コード例 #16
0
ファイル: icons.c プロジェクト: gpg/gpa
static void
register_stock_icons (void)
{
  GdkPixbuf *pixbuf;
  GtkIconFactory *icon_factory;
  GtkIconSet *icon_set;
  GtkIconSource *icon_source;
  gint i;

  icon_factory = gtk_icon_factory_new ();

  for (i = 0; xpms[i].name; i++)
    {
      icon_set = gtk_icon_set_new ();
      icon_source = gtk_icon_source_new ();

      pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) xpms[i].xpm);
      gtk_icon_source_set_pixbuf (icon_source, pixbuf);
      gtk_icon_source_set_direction_wildcarded (icon_source, TRUE);
      gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
      if (! strcmp (xpms[i].name, GPA_STOCK_PUBLIC_KEY)
	  || ! strcmp (xpms[i].name, GPA_STOCK_SECRET_KEY))
	{
	  /* FIXME: For the keylist icons, we disable scaling for now
	     for best visual results.  */
	  gtk_icon_source_set_size_wildcarded (icon_source, FALSE);
	  gtk_icon_source_set_size (icon_source, GTK_ICON_SIZE_LARGE_TOOLBAR);
	}

      gtk_icon_set_add_source (icon_set, icon_source);
      gtk_icon_source_free (icon_source);
      gtk_icon_factory_add (icon_factory, xpms[i].name, icon_set);
      gtk_icon_set_unref (icon_set);
    }

  /* Add a fake stock icon for the clipboard window.  */
  icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_PASTE);
  icon_set = gtk_icon_set_copy (icon_set);
  gtk_icon_factory_add (icon_factory, GPA_STOCK_CLIPBOARD, icon_set);

  /* Add a fake stock icon for the file manager window.  */
  icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_DIRECTORY);
  icon_set = gtk_icon_set_copy (icon_set);
  gtk_icon_factory_add (icon_factory, GPA_STOCK_FILEMAN, icon_set);

  gtk_icon_factory_add_default (icon_factory);

  g_object_unref (icon_factory);
}
コード例 #17
0
ファイル: stock.c プロジェクト: BackupTheBerlios/hardinfo-svn
void stock_icon_register_pixbuf(GdkPixbuf * pixbuf, gchar * stock_id)
{
    GtkIconSet *icon_set;
    GtkIconSource *icon_source;

    icon_set = gtk_icon_set_new();
    icon_source = gtk_icon_source_new();

    gtk_icon_source_set_pixbuf(icon_source, pixbuf);
    gtk_icon_set_add_source(icon_set, icon_source);
    gtk_icon_source_free(icon_source);

    gtk_icon_factory_add(icon_factory, stock_id, icon_set);

    gtk_icon_set_unref(icon_set);
}
コード例 #18
0
static void
register_screenshooter_icon (GtkIconFactory * factory)
{
  GtkIconSource *source;
  GtkIconSet *icon_set;

  source = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (source, SCREENSHOOTER_ICON);

  icon_set = gtk_icon_set_new ();
  gtk_icon_set_add_source (icon_set, source);

  gtk_icon_factory_add (factory, SCREENSHOOTER_ICON, icon_set);
  gtk_icon_set_unref (icon_set);
  gtk_icon_source_free (source);
}
コード例 #19
0
ファイル: stock.c プロジェクト: BackupTheBerlios/hardinfo-svn
void stock_icon_register(gchar * filename, gchar * stock_id)
{
    GtkIconSet *icon_set;
    GtkIconSource *icon_source;

    icon_set = gtk_icon_set_new();
    icon_source = gtk_icon_source_new();

    gtk_icon_source_set_pixbuf(icon_source,
			       icon_cache_get_pixbuf(filename));
    gtk_icon_set_add_source(icon_set, icon_source);
    gtk_icon_source_free(icon_source);

    gtk_icon_factory_add(icon_factory, stock_id, icon_set);

    gtk_icon_set_unref(icon_set);
}
コード例 #20
0
ファイル: ar-stock.c プロジェクト: Bob131/aisleriot
static void
register_stock_icon (GtkIconFactory * icon_factory,
                     const char * stock_id,
                     const char * icon_name)
{
  GtkIconSource *source;
  GtkIconSet *set;

  set = gtk_icon_set_new ();

  source = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (source, icon_name);
  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  gtk_icon_factory_add (icon_factory, stock_id, set);
  gtk_icon_set_unref (set);
}
コード例 #21
0
ファイル: applet.c プロジェクト: City-busz/mate-applets
static void accessx_applet_add_stock_icons(AccessxStatusApplet* sapplet, GtkWidget* widget)
{
    GtkIconFactory* factory = gtk_icon_factory_new();
    gint i = 0;
    GtkIconSet* icon_set;

    gtk_icon_factory_add_default(factory);

    while (i <  G_N_ELEMENTS(stock_icons))
    {
        gchar* set_name = stock_icons[i].stock_id;
        icon_set = gtk_icon_set_new();

        do {
            char* filename;
            GtkIconSource* source = gtk_icon_source_new();
            filename = g_build_filename(ACCESSX_PIXMAPS_DIR, stock_icons[i].name, NULL);

            if (g_file_test(filename, G_FILE_TEST_EXISTS) && g_file_test(filename, G_FILE_TEST_IS_REGULAR))
            {
                gtk_icon_source_set_filename(source, filename);
            }
            else
            {
                GtkIconSet* default_set = gtk_icon_factory_lookup_default(GTK_STOCK_MISSING_IMAGE);
                gtk_icon_source_set_pixbuf(source, gtk_icon_set_render_icon(default_set, gtk_widget_get_style(widget), GTK_TEXT_DIR_NONE, GTK_STATE_NORMAL, icon_size_spec, widget, NULL));
            }
            g_free(filename);
            gtk_icon_source_set_state(source, stock_icons[i].state);
            gtk_icon_source_set_state_wildcarded(source, stock_icons[i].wildcarded);
            gtk_icon_set_add_source(icon_set, source);
            gtk_icon_source_free(source);
            ++i;
        } while (set_name == stock_icons[i].stock_id);
        gtk_icon_factory_add(factory, set_name, icon_set);
        gtk_icon_set_unref(icon_set);
    }
    /* now create the stock icons for AltGr, which are internationalized */
    icon_set = accessx_status_applet_altgraph_icon_set (sapplet, widget);
    gtk_icon_factory_add(factory, ALTGRAPH_KEY_ICON, icon_set);
    gtk_icon_set_unref(icon_set);
    sapplet->icon_factory = factory;
}
コード例 #22
0
ファイル: gimpicons.c プロジェクト: LebedevRI/gimp
static void
register_stock_icon (GtkIconFactory *factory,
		     const gchar    *stock_id,
                     const gchar    *icon_name)
{
  GtkIconSet    *set    = gtk_icon_set_new ();
  GtkIconSource *source = gtk_icon_source_new ();

  gtk_icon_source_set_direction_wildcarded (source, TRUE);
  gtk_icon_source_set_size_wildcarded (source, TRUE);
  gtk_icon_source_set_state_wildcarded (source, TRUE);
  gtk_icon_source_set_icon_name (source, icon_name);

  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  gtk_icon_factory_add (factory, stock_id, set);
  gtk_icon_set_unref (set);
}
コード例 #23
0
ファイル: glade-gtk-icon-factory.c プロジェクト: GNOME/glade
static void
apply_icon_sources (gchar *icon_name, GList *sources, GtkIconFactory *factory)
{
  GtkIconSource *source;
  GtkIconSet *set;
  GList *l;

G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  set = gtk_icon_set_new ();

  for (l = sources; l; l = l->next)
    {
      source = gtk_icon_source_copy ((GtkIconSource *) l->data);
      gtk_icon_set_add_source (set, source);
    }

  gtk_icon_factory_add (factory, icon_name, set);
G_GNUC_END_IGNORE_DEPRECATIONS
}
コード例 #24
0
void add_stock_icon (const gchar *filename, const gchar *stock_id)
  {
  GtkIconSource *icon_source = NULL ;
  GtkIconSet *icon_set = NULL ;
  static GtkIconFactory *icon_factory = NULL ;
  char *psz = NULL ;

  if (NULL == icon_factory)
    gtk_icon_factory_add_default (icon_factory = gtk_icon_factory_new ()) ;

  if (NULL != (icon_source = gtk_icon_source_new ()))
    {
    gtk_icon_source_set_filename (icon_source, psz = find_pixmap_file (filename)) ;
    if (NULL == (icon_set = gtk_icon_factory_lookup (icon_factory, stock_id)))
      {
      icon_set = gtk_icon_set_new () ;
      gtk_icon_factory_add (icon_factory, stock_id, icon_set) ;
      }
    gtk_icon_set_add_source (icon_set, icon_source) ;
    }
  }
コード例 #25
0
/* Initialize Sticky Notes Icons */
void stickynotes_applet_init_icons(void)
{
	GtkIconFactory *icon_factory = gtk_icon_factory_new();

	gint i;
	for (i = 0; i < G_N_ELEMENTS(stickynotes_icons); i++) {
		StickyNotesStockIcon icon = stickynotes_icons[i];
		GtkIconSource *icon_source = gtk_icon_source_new();
		GtkIconSet *icon_set = gtk_icon_set_new();

		gtk_icon_source_set_filename(icon_source, icon.filename);
		gtk_icon_set_add_source(icon_set, icon_source);
		gtk_icon_factory_add(icon_factory, icon.stock_id, icon_set);

		gtk_icon_source_free(icon_source);
		gtk_icon_set_unref(icon_set);
	}

	gtk_icon_factory_add_default(icon_factory);

	g_object_unref(G_OBJECT(icon_factory));
}
コード例 #26
0
ファイル: gap_stock.c プロジェクト: nhorman/gimp-gap
static void
add_stock_icon (const gchar  *stock_id,
                GtkIconSize   size,
                const guint8 *inline_data)
{
  GtkIconSource *source;
  GtkIconSet    *set;
  GdkPixbuf     *pixbuf;
  
  source = gtk_icon_source_new ();

  gtk_icon_source_set_size (source, size);
  gtk_icon_source_set_size_wildcarded (source, FALSE);

  pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);

  if(gap_debug)
  {
    printf("add_stock_icon stock_id:%s size:%d inline_data:%d pixbuf:%d\n"
       ,stock_id
       ,(int)size
       ,(int)inline_data
       ,(int)pixbuf
       );
  }

  gtk_icon_source_set_pixbuf (source, pixbuf);
  g_object_unref (pixbuf);

  set = gtk_icon_set_new ();

  gtk_icon_set_add_source (set, source);
  gtk_icon_source_free (source);

  gtk_icon_factory_add (gap_icon_factory, stock_id, set);

  gtk_icon_set_unref (set);
}
コード例 #27
0
static void
panel_init_stock_icons (GtkIconFactory *factory)
{
	GtkIconSource *source;
	int            i;


	source = gtk_icon_source_new ();

	for (i = 0; i < G_N_ELEMENTS (stock_icons); i++) {
		GtkIconSet *set;

		gtk_icon_source_set_icon_name (source, stock_icons [i].icon);

		set = gtk_icon_set_new ();
		gtk_icon_set_add_source (set, source);

		gtk_icon_factory_add (factory, stock_icons [i].stock_id, set);
		gtk_icon_set_unref (set);
	}

	gtk_icon_source_free (source);

}
コード例 #28
0
ファイル: tab-panel.c プロジェクト: OoberMick/Midori
MidoriExtension*
extension_init (void)
{
    GtkIconFactory* factory;
    GtkIconSource* icon_source;
    GtkIconSet* icon_set;
    static GtkStockItem items[] =
    {
        { STOCK_TAB_PANEL, N_("T_ab Panel"), 0, 0, NULL },
    };
    MidoriExtension* extension;

    factory = gtk_icon_factory_new ();
    gtk_stock_add (items, G_N_ELEMENTS (items));
    icon_set = gtk_icon_set_new ();
    icon_source = gtk_icon_source_new ();
    gtk_icon_source_set_icon_name (icon_source, GTK_STOCK_INDEX);
    gtk_icon_set_add_source (icon_set, icon_source);
    gtk_icon_source_free (icon_source);
    gtk_icon_factory_add (factory, STOCK_TAB_PANEL, icon_set);
    gtk_icon_set_unref (icon_set);
    gtk_icon_factory_add_default (factory);
    g_object_unref (factory);

    extension = g_object_new (MIDORI_TYPE_EXTENSION,
        "name", _("Tab Panel"),
        "description", _("Show tabs in a vertical panel"),
        "version", "0.1",
        "authors", "Christian Dywan <*****@*****.**>",
        NULL);

    g_signal_connect (extension, "activate",
        G_CALLBACK (tab_panel_activate_cb), NULL);

    return extension;
}
コード例 #29
0
ファイル: testimage.c プロジェクト: Pfiver/gtk
int
main (int argc, char **argv)
{
  GtkWidget *window, *grid;
  GtkWidget *label, *image, *box;
  GtkIconTheme *theme;
  GdkPixbuf *pixbuf;
  GtkIconSet *iconset;
  GtkIconSource *iconsource;
  gchar *icon_name = "gnome-terminal";
  gchar *anim_filename = NULL;
  GIcon *icon;
  GFile *file;

  gtk_init (&argc, &argv);

  if (argc > 1)
    icon_name = argv[1];

  if (argc > 2)
    anim_filename = argv[2];

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  label = gtk_label_new ("symbolic size");
  gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
  label = gtk_label_new ("fixed size");
  gtk_grid_attach (GTK_GRID (grid), label, 2, 0, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_PIXBUF");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  theme = gtk_icon_theme_get_default ();
  pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 48, 0, NULL);
  image = gtk_image_new_from_pixbuf (pixbuf);
  box = gtk_event_box_new ();
  gtk_container_add (GTK_CONTAINER (box), image);
  gtk_grid_attach (GTK_GRID (grid), box, 2, 1, 1, 1);

  gtk_drag_source_set (box, GDK_BUTTON1_MASK, 
		       NULL, 0,
		       GDK_ACTION_COPY);
  gtk_drag_source_add_image_targets (box);
  g_signal_connect (box, "drag_begin", G_CALLBACK (drag_begin), image);
  g_signal_connect (box, "drag_data_get", G_CALLBACK (drag_data_get), image);

  gtk_drag_dest_set (box,
                     GTK_DEST_DEFAULT_MOTION |
                     GTK_DEST_DEFAULT_HIGHLIGHT |
                     GTK_DEST_DEFAULT_DROP,
                     NULL, 0, GDK_ACTION_COPY);
  gtk_drag_dest_add_image_targets (box);
  g_signal_connect (box, "drag_data_received", 
		    G_CALLBACK (drag_data_received), image);

  label = gtk_label_new ("GTK_IMAGE_STOCK");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

  image = gtk_image_new_from_stock (GTK_STOCK_REDO, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 2, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_ICON_SET");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);

  iconsource = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (iconsource, icon_name);
  iconset = gtk_icon_set_new ();
  gtk_icon_set_add_source (iconset, iconsource);
  image = gtk_image_new_from_icon_set (iconset, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 3, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_ICON_NAME");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1);
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 4, 1, 1);
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
  gtk_grid_attach (GTK_GRID (grid), image, 2, 4, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_GICON");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1);
  icon = g_themed_icon_new_with_default_fallbacks ("folder-remote");
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 5, 1, 1);
  file = g_file_new_for_path ("apple-red.png");
  icon = g_file_icon_new (file);
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
  gtk_grid_attach (GTK_GRID (grid), image, 2, 5, 1, 1);

  
  if (anim_filename)
    {
      label = gtk_label_new ("GTK_IMAGE_ANIMATION (from file)");
      gtk_grid_attach (GTK_GRID (grid), label, 0, 6, 1, 1);
      image = gtk_image_new_from_file (anim_filename);
      gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
      gtk_grid_attach (GTK_GRID (grid), image, 2, 6, 1, 1);

      /* produce high load */
      g_signal_connect_after (image, "draw",
                              G_CALLBACK (anim_image_draw),
                              NULL);
    }

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
コード例 #30
0
nsresult
nsIconChannel::Init(nsIURI* aURI)
{
    nsCOMPtr<nsIMozIconURI> iconURI = do_QueryInterface(aURI);
    NS_ASSERTION(iconURI, "URI is not an nsIMozIconURI");

    nsAutoCString stockIcon;
    iconURI->GetStockIcon(stockIcon);
    if (stockIcon.IsEmpty()) {
#ifdef MOZ_ENABLE_GNOMEUI
        return InitWithGnome(iconURI);
#else
#ifdef MOZ_ENABLE_GIO
        return InitWithGIO(iconURI);
#else
        return NS_ERROR_NOT_AVAILABLE;
#endif
#endif
    }

    // Search for stockIcon
    nsAutoCString iconSizeString;
    iconURI->GetIconSize(iconSizeString);

    nsAutoCString iconStateString;
    iconURI->GetIconState(iconStateString);

    GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
    GtkStateType state = iconStateString.EqualsLiteral("disabled") ?
                         GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;

    // First lookup the icon by stock id and text direction.
    GtkTextDirection direction = GTK_TEXT_DIR_NONE;
    if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-ltr"))) {
        direction = GTK_TEXT_DIR_LTR;
    } else if (StringEndsWith(stockIcon, NS_LITERAL_CSTRING("-rtl"))) {
        direction = GTK_TEXT_DIR_RTL;
    }

    bool forceDirection = direction != GTK_TEXT_DIR_NONE;
    nsAutoCString stockID;
    bool useIconName = false;
    if (!forceDirection) {
        direction = gtk_widget_get_default_direction();
        stockID = stockIcon;
    } else {
        // GTK versions < 2.22 use icon names from concatenating stock id with
        // -(rtl|ltr), which is how the moz-icon stock name is interpreted here.
        stockID = Substring(stockIcon, 0, stockIcon.Length() - 4);
        // However, if we lookup bidi icons by the stock name, then GTK versions
        // >= 2.22 will use a bidi lookup convention that most icon themes do not
        // yet follow.  Therefore, we first check to see if the theme supports the
        // old icon name as this will have bidi support (if found).
        GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
        // Micking what gtk_icon_set_render_icon does with sizes, though it's not
        // critical as icons will be scaled to suit size.  It just means we follow
        // the same pathes and so share caches.
        gint width, height;
        if (gtk_icon_size_lookup(icon_size, &width, &height)) {
            gint size = NS_MIN(width, height);
            // We use gtk_icon_theme_lookup_icon() without
            // GTK_ICON_LOOKUP_USE_BUILTIN instead of gtk_icon_theme_has_icon() so
            // we don't pick up fallback icons added by distributions for backward
            // compatibility.
            GtkIconInfo *icon =
                gtk_icon_theme_lookup_icon(icon_theme, stockIcon.get(),
                                           size, (GtkIconLookupFlags)0);
            if (icon) {
                useIconName = true;
                gtk_icon_info_free(icon);
            }
        }
    }

    ensure_stock_image_widget();
    GtkStyle *style = gtk_widget_get_style(gStockImageWidget);
    GtkIconSet *icon_set = NULL;
    if (!useIconName) {
        icon_set = gtk_style_lookup_icon_set(style, stockID.get());
    }

    if (!icon_set) {
        // Either we have choosen icon-name lookup for a bidi icon, or stockIcon is
        // not a stock id so we assume it is an icon name.
        useIconName = true;
        // Creating a GtkIconSet is a convenient way to allow the style to
        // render the icon, possibly with variations suitable for insensitive
        // states.
        icon_set = gtk_icon_set_new();
        GtkIconSource *icon_source = gtk_icon_source_new();

        gtk_icon_source_set_icon_name(icon_source, stockIcon.get());
        gtk_icon_set_add_source(icon_set, icon_source);
        gtk_icon_source_free(icon_source);
    }

    GdkPixbuf *icon =
        gtk_icon_set_render_icon (icon_set, style, direction, state,
                                  icon_size, gStockImageWidget, NULL);
    if (useIconName) {
        gtk_icon_set_unref(icon_set);
    }

    // According to documentation, gtk_icon_set_render_icon() never returns
    // NULL, but it does return NULL when we have the problem reported here:
    // https://bugzilla.gnome.org/show_bug.cgi?id=629878#c13
    if (!icon)
        return NS_ERROR_NOT_AVAILABLE;

    nsresult rv = moz_gdk_pixbuf_to_channel(icon, iconURI,
                                            getter_AddRefs(mRealChannel));

    g_object_unref(icon);

    return rv;
}