示例#1
0
文件: gtkstock.c 项目: BYC/gtk
static void
init_stock_hash (void)
{
  if (stock_hash == NULL)
    {
      stock_hash = g_hash_table_new (g_str_hash, g_str_equal);

      gtk_stock_add_static (builtin_items, G_N_ELEMENTS (builtin_items));
    }

  if (translate_hash == NULL)
    {
      translate_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
	                                      g_free, NULL);

      gtk_stock_set_translate_func (GETTEXT_PACKAGE, 
				    sgettext_swapped,
				    "Stock label",
				    NULL);
      gtk_stock_set_translate_func (GETTEXT_PACKAGE "-navigation", 
				    sgettext_swapped,
				    "Stock label, navigation",
				    NULL);
      gtk_stock_set_translate_func (GETTEXT_PACKAGE "-media", 
				    sgettext_swapped,
				    "Stock label, media",
				    NULL);
    }
}
示例#2
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);
}
示例#3
0
文件: gfig-stock.c 项目: Minoos/gimp
void
gfig_stock_init (void)
{
  static gboolean initialized = FALSE;

  if (initialized)
    return;

  gfig_icon_factory = gtk_icon_factory_new ();

  add_stock_icon (GFIG_STOCK_BEZIER,        GTK_ICON_SIZE_BUTTON, stock_bezier);
  add_stock_icon (GFIG_STOCK_CIRCLE,        GTK_ICON_SIZE_BUTTON, stock_circle);
  add_stock_icon (GFIG_STOCK_COPY_OBJECT,   GTK_ICON_SIZE_BUTTON, stock_copy_object);
  add_stock_icon (GFIG_STOCK_CURVE,         GTK_ICON_SIZE_BUTTON, stock_curve);
  add_stock_icon (GFIG_STOCK_DELETE_OBJECT, GTK_ICON_SIZE_BUTTON, stock_delete_object);
  add_stock_icon (GFIG_STOCK_ELLIPSE,       GTK_ICON_SIZE_BUTTON, stock_ellipse);
  add_stock_icon (GFIG_STOCK_LINE,          GTK_ICON_SIZE_BUTTON, stock_line);
  add_stock_icon (GFIG_STOCK_MOVE_OBJECT,   GTK_ICON_SIZE_BUTTON, stock_move_object);
  add_stock_icon (GFIG_STOCK_MOVE_POINT,    GTK_ICON_SIZE_BUTTON, stock_move_point);
  add_stock_icon (GFIG_STOCK_POLYGON,       GTK_ICON_SIZE_BUTTON, stock_polygon);
  add_stock_icon (GFIG_STOCK_RECTANGLE,     GTK_ICON_SIZE_BUTTON, stock_rectangle);
  add_stock_icon (GFIG_STOCK_SELECT_OBJECT, GTK_ICON_SIZE_BUTTON, stock_select_object);
  add_stock_icon (GFIG_STOCK_SHOW_ALL,      GTK_ICON_SIZE_BUTTON, stock_show_all);
  add_stock_icon (GFIG_STOCK_SPIRAL,        GTK_ICON_SIZE_BUTTON, stock_spiral);
  add_stock_icon (GFIG_STOCK_STAR,          GTK_ICON_SIZE_BUTTON, stock_star);

  gtk_icon_factory_add_default (gfig_icon_factory);

  gtk_stock_add_static (gfig_stock_items, G_N_ELEMENTS (gfig_stock_items));

  initialized = TRUE;
}
示例#4
0
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);
}
示例#5
0
void
gap_stock_init (void)
{
  static gboolean initialized = FALSE;

  if(gap_debug)
  {
    printf("gap_stock_init START\n");
  }

  if (initialized)
    return;

  gap_icon_factory = gtk_icon_factory_new ();
  
  add_stock_icon (GAP_STOCK_ADD_POINT          , GTK_ICON_SIZE_BUTTON, gap_add_point);
  add_stock_icon (GAP_STOCK_ANIM_PREVIEW       , GTK_ICON_SIZE_BUTTON, gap_anim_preview);
  add_stock_icon (GAP_STOCK_DELETE_ALL_POINTS  , GTK_ICON_SIZE_BUTTON, gap_delete_all_points);
  add_stock_icon (GAP_STOCK_DELETE_POINT       , GTK_ICON_SIZE_BUTTON, gap_delete_point);
  add_stock_icon (GAP_STOCK_FIRST_POINT        , GTK_ICON_SIZE_BUTTON, gap_first_point);
  add_stock_icon (GAP_STOCK_GRAB_POINTS        , GTK_ICON_SIZE_BUTTON, gap_grab_points);
  add_stock_icon (GAP_STOCK_INSERT_POINT       , GTK_ICON_SIZE_BUTTON, gap_insert_point);
  add_stock_icon (GAP_STOCK_LAST_POINT         , GTK_ICON_SIZE_BUTTON, gap_last_point);
  add_stock_icon (GAP_STOCK_NEXT_POINT         , GTK_ICON_SIZE_BUTTON, gap_next_point);
  add_stock_icon (GAP_STOCK_PAUSE              , GTK_ICON_SIZE_BUTTON, gap_pause);
  add_stock_icon (GAP_STOCK_PLAY               , GTK_ICON_SIZE_BUTTON, gap_play);
  add_stock_icon (GAP_STOCK_PLAY_REVERSE       , GTK_ICON_SIZE_BUTTON, gap_play_reverse);
  add_stock_icon (GAP_STOCK_PREV_POINT         , GTK_ICON_SIZE_BUTTON, gap_prev_point);
  add_stock_icon (GAP_STOCK_RESET_ALL_POINTS   , GTK_ICON_SIZE_BUTTON, gap_reset_all_points);
  add_stock_icon (GAP_STOCK_RESET_POINT        , GTK_ICON_SIZE_BUTTON, gap_reset_point);
  add_stock_icon (GAP_STOCK_ROTATE_FOLLOW      , GTK_ICON_SIZE_BUTTON, gap_rotate_follow);
  add_stock_icon (GAP_STOCK_SOURCE_IMAGE       , GTK_ICON_SIZE_BUTTON, gap_source_image);
  add_stock_icon (GAP_STOCK_STEPMODE           , GTK_ICON_SIZE_BUTTON, gap_stepmode);
  add_stock_icon (GAP_STOCK_UPDATE             , GTK_ICON_SIZE_BUTTON, gap_update);

  add_stock_icon ( GAP_STOCK_RANGE_END         , GTK_ICON_SIZE_BUTTON, gap_range_end);
  add_stock_icon ( GAP_STOCK_RANGE_START       , GTK_ICON_SIZE_BUTTON, gap_range_start);
  add_stock_icon ( GAP_STOCK_SET_RANGE_END     , GTK_ICON_SIZE_BUTTON, gap_set_range_end);
  add_stock_icon ( GAP_STOCK_SET_RANGE_START   , GTK_ICON_SIZE_BUTTON, gap_set_range_start);
  add_stock_icon ( GAP_STOCK_SPEED             , GTK_ICON_SIZE_BUTTON, gap_speed);

  gtk_icon_factory_add_default (gap_icon_factory);

  gtk_stock_add_static (gap_stock_items, G_N_ELEMENTS (gap_stock_items));

  initialized = TRUE;

  if(gap_debug)
  {
    printf("gap_stock_init DONE\n");
  }
}
示例#6
0
void
pidgin_stock_init(void)
{
	PidginIconThemeLoader *loader, *stockloader;
	const gchar *path = NULL;

	if (stock_initted)
		return;

	stock_initted = TRUE;

	/* Setup the status icon theme */
	loader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "status-icon", NULL);
	purple_theme_manager_register_type(PURPLE_THEME_LOADER(loader));
	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/status");
	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/status/icon-theme", "");
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", "");

	stockloader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "stock-icon", NULL);
	purple_theme_manager_register_type(PURPLE_THEME_LOADER(stockloader));
	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/stock");
	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", "");
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", "");

	/* register custom icon sizes */
	microscopic =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC, 11, 11);
	extra_small =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16);
	small       =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22);
	medium      =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32);
	large       =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48);
	huge        =  gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64);

	pidgin_stock_load_stock_icon_theme(NULL);

	/* Pre-load Status icon theme - this avoids a bug with displaying the correct icon in the tray, theme is destroyed after*/
	if (purple_prefs_get_string(PIDGIN_PREFS_ROOT "/status/icon-theme") &&
	   (path = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir"))) {

		PidginStatusIconTheme *theme = PIDGIN_STATUS_ICON_THEME(purple_theme_loader_build(PURPLE_THEME_LOADER(loader), path));
		pidgin_stock_load_status_icon_theme(theme);
		if (theme)
			g_object_unref(G_OBJECT(theme));

	}
	else
		pidgin_stock_load_status_icon_theme(NULL);

	/* Register the stock items. */
	gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items));
}
示例#7
0
static void
application_class_init (PlannerApplicationClass *klass)
{
	GObjectClass *o_class;

	parent_class = g_type_class_peek_parent (klass);

	o_class = (GObjectClass *) klass;

	/* GObject signals */
	o_class->finalize = application_finalize;

	gtk_stock_add_static (stock_items, G_N_ELEMENTS (stock_items));

}
示例#8
0
文件: icons.c 项目: gpg/gpa
void
gpa_register_stock_items (void)
{
  static const GtkStockItem items[] =
    {
      { GPA_STOCK_SIGN, N_("_Sign"), 0, 0, PACKAGE },
      { GPA_STOCK_VERIFY, N_("_Verify"), 0, 0, PACKAGE },
      { GPA_STOCK_ENCRYPT, N_("_Encrypt"), 0, 0, PACKAGE },
      { GPA_STOCK_DECRYPT, N_("_Decrypt"), 0, 0, PACKAGE },
      { GPA_STOCK_BRIEF, N_("_Brief"), 0, 0, PACKAGE },
      { GPA_STOCK_DETAILED, N_("_Detailed"), 0, 0, PACKAGE },
      { GPA_STOCK_KEYMAN,   N_("_Keyring Manager"), 0, 0, PACKAGE },
      { GPA_STOCK_CLIPBOARD, N_("_Clipboard"), 0, 0, PACKAGE },
      { GPA_STOCK_FILEMAN, N_("_File Manager"), 0, 0, PACKAGE },
      { GPA_STOCK_CARDMAN, N_("_Card Manager"), 0, 0, PACKAGE }
    };

  register_stock_icons ();

  gtk_stock_add_static (items, G_N_ELEMENTS (items));
}
示例#9
0
void
mapobject_stock_init (void)
{
  static gboolean initialized = FALSE;

  if (initialized)
    return;

  mapobject_icon_factory = gtk_icon_factory_new ();

  add_stock_icon (STOCK_INTENSITY_AMBIENT_LOW,       GTK_ICON_SIZE_BUTTON,
                  stock_intensity_ambient_low);
  add_stock_icon (STOCK_INTENSITY_AMBIENT_HIGH,      GTK_ICON_SIZE_BUTTON,
                  stock_intensity_ambient_high);
  add_stock_icon (STOCK_INTENSITY_DIFFUSE_LOW,       GTK_ICON_SIZE_BUTTON,
                  stock_intensity_diffuse_low);
  add_stock_icon (STOCK_INTENSITY_DIFFUSE_HIGH,      GTK_ICON_SIZE_BUTTON,
                  stock_intensity_diffuse_high);
  add_stock_icon (STOCK_REFLECTIVITY_DIFFUSE_LOW,    GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_diffuse_low);
  add_stock_icon (STOCK_REFLECTIVITY_DIFFUSE_HIGH,   GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_diffuse_high);
  add_stock_icon (STOCK_REFLECTIVITY_SPECULAR_LOW,   GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_specular_low);
  add_stock_icon (STOCK_REFLECTIVITY_SPECULAR_HIGH,  GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_specular_high);
  add_stock_icon (STOCK_REFLECTIVITY_HIGHLIGHT_LOW,  GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_highlight_low);
  add_stock_icon (STOCK_REFLECTIVITY_HIGHLIGHT_HIGH, GTK_ICON_SIZE_BUTTON,
                  stock_reflectivity_highlight_high);

  gtk_icon_factory_add_default (mapobject_icon_factory);

  gtk_stock_add_static (mapobject_stock_items,
                        G_N_ELEMENTS (mapobject_stock_items));

  initialized = TRUE;
}
示例#10
0
文件: icons.c 项目: andy-shev/LogJam
void
icons_initialize(void) {
	GtkIconFactory *factory;
	GdkPixbuf *goat;
	GList *l;

	factory = gtk_icon_factory_new();
	goat = add(factory, logjam_goat, "logjam-goat");
	add(factory, logjam_pencil, "logjam-server");
	add(factory, logjam_ljuser, "logjam-ljuser");
	add(factory, logjam_ljcomm, "logjam-ljcomm");
	add(factory, logjam_twuser, "logjam-twuser");
	add(factory, logjam_protected, "logjam-protected");
	add(factory, logjam_private, "logjam-private");
	add(factory, logjam_blogger, "logjam-blogger");
	gtk_icon_factory_add_default(factory);

	l = g_list_append(NULL, goat);
	gtk_window_set_default_icon_list(l);
	g_list_free(l);

	gtk_stock_add_static(logjam_stock_items, G_N_ELEMENTS(logjam_stock_items));
}
示例#11
0
文件: vino-util.c 项目: GNOME/vino
void
vino_init_stock_items (void)
{
  static gboolean  initialized = FALSE;
  GtkIconFactory  *factory;
  GtkStockItem    *items;
  int              i;

  if (initialized)
    return;

  factory = gtk_icon_factory_new ();
  gtk_icon_factory_add_default (factory);

  items = g_new (GtkStockItem, G_N_ELEMENTS (vino_stock_items));

  for (i = 0; i < G_N_ELEMENTS (vino_stock_items); i++)
    {
      GtkIconSet *icon_set;

      items [i].stock_id           = g_strdup (vino_stock_items [i].stock_id);
      items [i].label              = g_strdup (vino_stock_items [i].label);
      items [i].modifier           = 0;
      items [i].keyval             = 0;
      items [i].translation_domain = g_strdup (GETTEXT_PACKAGE);

      /* FIXME: does this take into account the theme? */
      icon_set = gtk_icon_factory_lookup_default (vino_stock_items [i].stock_icon_id);
      gtk_icon_factory_add (factory, vino_stock_items [i].stock_id, icon_set);
    }
  
  gtk_stock_add_static (items, G_N_ELEMENTS (vino_stock_items));

  g_object_unref (factory);

  initialized = TRUE;
}
static void
panel_init_stock_items (GtkIconFactory *factory)
{
	GtkStockItem *items;
	int           i;

	items = g_new (GtkStockItem, G_N_ELEMENTS (stock_items));

	for (i = 0; i < G_N_ELEMENTS (stock_items); i++) {
		GtkIconSet *icon_set;

		items [i].stock_id           = g_strdup (stock_items [i].stock_id);
		items [i].label              = g_strdup (stock_items [i].label);
		items [i].modifier           = 0;
		items [i].keyval             = 0;
		items [i].translation_domain = g_strdup (GETTEXT_PACKAGE);

		/* FIXME: does this take into account the theme? */
		icon_set = gtk_icon_factory_lookup_default (stock_items [i].stock_icon_id);
		gtk_icon_factory_add (factory, stock_items [i].stock_id, icon_set);
	}

	gtk_stock_add_static (items, G_N_ELEMENTS (stock_items));
}
示例#13
0
void
ar_stock_init (void)
{
  /* These stocks have a gtk stock icon */
  const char *stock_icon_aliases[][2] = {
    { AR_STOCK_CONTENTS,         "help-contents" },
    { AR_STOCK_HINT,             "dialog-information" },
    { AR_STOCK_NEW_GAME,         "document-new" },
    { AR_STOCK_START_NEW_GAME,   "document-new" },
    { AR_STOCK_RESET,            "edit-clear" },
    { AR_STOCK_RESTART_GAME,     "view-refresh" },
    { AR_STOCK_FULLSCREEN,       "view-fullscreen" },
    { AR_STOCK_LEAVE_FULLSCREEN, "view-restore" },
    { AR_STOCK_PAUSE_GAME,       "media-playback-pause" },
  };

#ifndef HAVE_GTK_ICON_FACTORY_ADD_ALIAS
  const char *stock_icon_aliases_bidi[][3] = {
    { AR_STOCK_REDO_MOVE, "edit-redo", "edit-undo" },
    { AR_STOCK_UNDO_MOVE, "edit-undo", "edit-redo" },
  };
#endif

  /* Private icon names */
  const char *private_icon_names[][2] = {
    { AR_STOCK_DEAL_CARDS, "cards-deal" }
  };

  static const GtkStockItem ar_stock_items[] = {
    { AR_STOCK_CONTENTS,         N_("_Contents"),          0, GDK_KEY_F1, NULL },
    { AR_STOCK_FULLSCREEN,       N_("_Fullscreen"),        0, GDK_KEY_F11, NULL },
    { AR_STOCK_HINT,             N_("_Hint"),              GDK_CONTROL_MASK, 'h', NULL },
    /* Translators: This "_New" is for the menu item 'Game->New', implies "New Game" */
    { AR_STOCK_NEW_GAME,         N_("_New"),               GDK_CONTROL_MASK, 'n', NULL },
    /* Translators: This "_New Game" is for the game-over dialogue */
    { AR_STOCK_START_NEW_GAME,   N_("_New Game"),          0, 0, NULL },
    { AR_STOCK_REDO_MOVE,        N_("_Redo Move"),         GDK_CONTROL_MASK | GDK_SHIFT_MASK, 'z', NULL },
    /* Translators: this is the "Reset" scores button in a scores dialogue */
    { AR_STOCK_RESET,            N_("_Reset"),             0, 0, NULL },
    /* Translators: "_Restart" is the menu item 'Game->Restart', implies "Restart Game" */
    { AR_STOCK_RESTART_GAME,     N_("_Restart"),           0, 0, NULL },
    { AR_STOCK_UNDO_MOVE,        N_("_Undo Move"),         GDK_CONTROL_MASK, 'z', NULL },
    { AR_STOCK_DEAL_CARDS,       N_("_Deal"),              GDK_CONTROL_MASK, 'd', NULL },
    { AR_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"),  0, GDK_KEY_F11, NULL },
    { AR_STOCK_PAUSE_GAME,       N_("_Pause"),             0, GDK_KEY_Pause, NULL },
  };

  guint i;
  GtkIconFactory *icon_factory;

  icon_factory = gtk_icon_factory_new ();

#ifdef HAVE_GTK_ICON_FACTORY_ADD_ALIAS
  for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases); ++i) {
    gtk_icon_factory_add_alias (stock_icon_aliases[i][0],
                                stock_icon_aliases[i][1]);
  }

#else
  for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases); ++i) {
    register_stock_icon (icon_factory,
                         stock_icon_aliases[i][0],
                         stock_icon_aliases[i][1]);
  }

  for (i = 0; i < G_N_ELEMENTS (stock_icon_aliases_bidi); ++i) {
    register_stock_icon_bidi (icon_factory,
                              stock_icon_aliases_bidi[i][0],
                              stock_icon_aliases_bidi[i][1],
                              stock_icon_aliases_bidi[i][2]);
  }
#endif /* HAVE_GTK_ICON_FACTORY_ADD_ALIAS */

  /* Register our private themeable icons */
  for (i = 0; i < G_N_ELEMENTS (private_icon_names); i++) {
    register_stock_icon (icon_factory,
                         private_icon_names[i][0],
                         private_icon_names[i][1]);
  }

  gtk_icon_factory_add_default (icon_factory);
  g_object_unref (icon_factory);

  /* GtkIconTheme will then look in our custom hicolor dir
   * for icons as well as the standard search paths.
   */
  /* FIXME: multi-head! */
  gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
                                     ar_runtime_get_directory (AR_RUNTIME_ICON_THEME_DIRECTORY));
 
  gtk_stock_add_static (ar_stock_items, G_N_ELEMENTS (ar_stock_items));
}
/** gui_misc_init:
  *	initializes the module
  */
void gui_misc_init()
{
	GtkIconSource * source;
	GtkIconSet * set;
	struct stock_pixbuf_map * map;
	gint num_items;

	/* setup icon factory and all the icons it contains
	 */
	if(icon_factory==0) {
		/* setup icon factory and all the icons it contains */
		icon_factory = gtk_icon_factory_new();
		gtk_icon_factory_add_default(icon_factory);

		/* register icons */
		for(map = stock_pixbuf_maps; map->stock_id; map ++) {
			GdkPixbuf * pixbuf, * composite;

			g_assert(map->pixbuf);

			set = gtk_icon_set_new();

			/* create icon source for a small 16x16 icon */
			source = gtk_icon_source_new();
			gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU);

			pixbuf = gdk_pixbuf_new_from_inline(-1, map->pixbuf, TRUE, NULL);
			if(map->pixbuf1) {
				composite = gdk_pixbuf_new_from_inline(
						-1, map->pixbuf1, FALSE, NULL);

				/* add composite pixbuf */
				gdk_pixbuf_composite(
					composite, pixbuf, 0, 0,
					gdk_pixbuf_get_width(pixbuf),
					gdk_pixbuf_get_height(pixbuf),
					0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);

				/* release the composite pixbuf */
				g_object_unref(G_OBJECT(composite));
			}
			gtk_icon_source_set_pixbuf(source, pixbuf);

			gtk_icon_set_add_source(set, source);
			gtk_icon_source_free(source);	/* this will g_object_unref `pixbuf, too */

			/* create icon source for a "button" 24x24 icon (if any) */
			if(map->button_pixbuf) {
				source = gtk_icon_source_new();
				gtk_icon_source_set_size(source, GTK_ICON_SIZE_BUTTON);

				pixbuf = gdk_pixbuf_new_from_inline(
						-1, map->button_pixbuf, TRUE, NULL);
				if(map->button_pixbuf1) {
					composite = gdk_pixbuf_new_from_inline(
							-1, map->button_pixbuf1, FALSE, NULL);

					gdk_pixbuf_composite(
						composite, pixbuf, 0, 0,
						gdk_pixbuf_get_width(pixbuf),
						gdk_pixbuf_get_height(pixbuf),
						0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255);

					g_object_unref(G_OBJECT(composite));
				}
				gtk_icon_source_set_pixbuf(source, pixbuf);

				gtk_icon_set_add_source(set, source);
				gtk_icon_source_free(source);	/* this will free the pixbuf, too */
			}

			/* add icon set to icon_factory & release it */
			gtk_icon_factory_add(icon_factory, map->stock_id, set);
			gtk_icon_set_unref(set);
		}
	}

	/* register stock items
	 */
	for(num_items=0; stock_items[num_items].stock_id!=NULL; num_items++) ;
	gtk_stock_add_static(stock_items, num_items);
}
示例#15
0
void
browser_stock_icons_init (void)
{
	GtkIconFactory *factory;
	GtkIconSet *icon_set;
	GtkIconSource *icon_source;
	int i;

	const char *icon_theme_items[] =
	{
		STOCK_NEW_WINDOW,
		STOCK_ADD_BOOKMARK,
	};

	static const GtkStockItem items[] =
	{
		{ BROWSER_STOCK_HISTORY, N_("History"), 0, 0, NULL },
		{ BROWSER_STOCK_BOOKMARKS, N_("Bookmarks"), 0, 0, NULL },
		{ BROWSER_STOCK_BEGIN, N_("Begin"), 0, 0, NULL },
		{ BROWSER_STOCK_COMMIT, N_("Commit"), 0, 0, NULL },
		{ BROWSER_STOCK_ROLLBACK, N_("Rollback"), 0, 0, NULL },
		{ BROWSER_STOCK_BUILDER, N_("Builder"), 0, 0, NULL },
		{ BROWSER_STOCK_LDAP_ENTRIES, N_("Ldap entries"), 0, 0, NULL },
		{ BROWSER_STOCK_TABLE_ADD, N_("Add table"), 0, 0, NULL},
		{ BROWSER_STOCK_GRID, N_("Grid"), 0, 0, NULL},
		{ BROWSER_STOCK_FORM, N_("Form"), 0, 0, NULL},
	};

	factory = gtk_icon_factory_new ();

	for (i = 0; i < (int) G_N_ELEMENTS (items); i++)
	{
		icon_source = gtk_icon_source_new ();
		gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);

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

		gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
		gtk_icon_set_unref (icon_set);
	}

	gtk_stock_add_static (items, G_N_ELEMENTS (items));

	for (i = 0; i < (int) G_N_ELEMENTS (icon_theme_items); i++)
	{
		icon_source = gtk_icon_source_new ();
		gtk_icon_source_set_icon_name (icon_source, icon_theme_items[i]);

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

		gtk_icon_factory_add (factory, icon_theme_items[i], icon_set);
		gtk_icon_set_unref (icon_set);
	}

	gtk_icon_factory_add_default (factory);
	g_object_unref (factory);

	/* GtkIconTheme will then look in Browser custom hicolor dir
	 * for icons as well as the standard search paths
	 */
	/* FIXME: multi-head! */
	gchar *path;
	path = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, "icons", NULL);
	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), path);
	g_free (path);
}
示例#16
0
/**
 * gimp_icons_init:
 *
 * Initializes the GIMP stock icon factory.
 *
 * You don't need to call this function as gimp_ui_init() already does
 * this for you.
 */
void
gimp_icons_init (void)
{
  static gboolean initialized = FALSE;

  GtkSettings *settings;
  GdkPixbuf   *pixbuf;
  GError      *error = NULL;
  gchar       *icons_dir;
  gchar       *system_icon_theme;
  gchar       *gimp_icon_theme;
  gint         i;

  if (initialized)
    return;

  gimp_stock_factory = gtk_icon_factory_new ();

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_items); i++)
    {
      register_stock_icon (gimp_stock_factory,
                           gimp_stock_items[i].stock_id,
                           gimp_stock_items[i].stock_id);
    }

  register_bidi_stock_icon (gimp_stock_factory,
                            GIMP_STOCK_MENU_LEFT,
                            GIMP_STOCK_MENU_LEFT, GIMP_STOCK_MENU_RIGHT);
  register_bidi_stock_icon (gimp_stock_factory,
                            GIMP_STOCK_MENU_RIGHT,
                            GIMP_STOCK_MENU_RIGHT, GIMP_STOCK_MENU_LEFT);

  register_stock_icon (gimp_stock_factory,
                       "gimp-indexed-palette", GIMP_STOCK_COLORMAP);
  register_stock_icon (gimp_stock_factory,
                       "gimp-qmask-off", GIMP_STOCK_QUICK_MASK_OFF);
  register_stock_icon (gimp_stock_factory,
                       "gimp-qmask-on", GIMP_STOCK_QUICK_MASK_ON);

  gtk_icon_factory_add_default (gimp_stock_factory);

  gtk_stock_add_static (gimp_stock_items,
                        G_N_ELEMENTS (gimp_stock_items));
  gtk_stock_add_static (gimp_compat_stock_items,
                        G_N_ELEMENTS (gimp_compat_stock_items));

  /*  always prepend the default icon theme, it's never removed from
   *  the path again and acts as fallback for missing icons in other
   *  themes.
   */
  if (! default_search_path)
    default_search_path = gimp_data_directory_file ("icons",
                                                    NULL);

  icons_dir = g_file_get_path (default_search_path);
  gtk_icon_theme_prepend_search_path (gtk_icon_theme_get_default (),
                                      icons_dir);
  g_free (icons_dir);

  /*  if an icon theme was chosen before init(), change to it  */
  if (icon_theme_path)
    {
      GFile *search_path = g_file_get_parent (icon_theme_path);

      if (!g_file_equal (search_path, default_search_path))
        {
          gchar *icon_dir = g_file_get_path (search_path);

          gtk_icon_theme_prepend_search_path (gtk_icon_theme_get_default (),
                                              icon_dir);
          g_free (icon_dir);
        }
      g_object_unref (search_path);

      gimp_icon_theme = g_file_get_basename (icon_theme_path);
    }
  else
    {
      gimp_icon_theme = g_strdup (GIMP_DEFAULT_ICON_THEME);
    }

  settings = gtk_settings_get_for_screen (gdk_screen_get_default ());

  g_object_get (settings, "gtk-icon-theme-name", &system_icon_theme, NULL);

  g_object_set (settings,
                "gtk-fallback-icon-theme", system_icon_theme,
                "gtk-icon-theme-name", gimp_icon_theme,
                NULL);

  g_free (gimp_icon_theme);
  g_free (system_icon_theme);

  g_signal_connect (settings, "notify::gtk-icon-theme-name",
                    G_CALLBACK (gimp_icons_notify_system_icon_theme), NULL);
  pixbuf = gdk_pixbuf_new_from_resource ("/org/gimp/icons/64/gimp-wilber-eek.png",
                                         &error);

  if (pixbuf)
    {
      gtk_icon_theme_add_builtin_icon (GIMP_STOCK_WILBER_EEK, 64, pixbuf);
      g_object_unref (pixbuf);
    }
  else
    {
      g_critical ("Failed to create icon image: %s", error->message);
      g_clear_error (&error);
    }

  initialized = TRUE;
}
示例#17
0
/**
 * gimp_stock_init:
 *
 * Initializes the GIMP stock icon factory.
 *
 * You don't need to call this function as gimp_ui_init() already does
 * this for you.
 */
void
gimp_stock_init (void)
{
  static gboolean initialized = FALSE;

  gint i;

  if (initialized)
    return;

  gimp_stock_factory = gtk_icon_factory_new ();

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_dialog_pixbufs); i++)
    {
      add_sized_with_same_fallback (gimp_stock_factory,
                                    gimp_stock_dialog_pixbufs[i].inline_data,
                                    NULL,
                                    GTK_ICON_SIZE_DIALOG,
                                    gimp_stock_dialog_pixbufs[i].stock_id);
    }

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_dnd_pixbufs); i++)
    {
      add_sized_with_same_fallback (gimp_stock_factory,
                                    gimp_stock_dnd_pixbufs[i].inline_data,
                                    NULL,
                                    GTK_ICON_SIZE_DND,
                                    gimp_stock_dnd_pixbufs[i].stock_id);
    }

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_button_pixbufs); i++)
    {
      add_sized_with_same_fallback (gimp_stock_factory,
                                    gimp_stock_button_pixbufs[i].inline_data,
                                    NULL,
                                    GTK_ICON_SIZE_BUTTON,
                                    gimp_stock_button_pixbufs[i].stock_id);
    }

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_menu_pixbufs); i++)
    {
      add_sized_with_same_fallback (gimp_stock_factory,
                                    gimp_stock_menu_pixbufs[i].inline_data,
                                    NULL,
                                    GTK_ICON_SIZE_MENU,
                                    gimp_stock_menu_pixbufs[i].stock_id);
    }

  for (i = 0; i < G_N_ELEMENTS (gimp_stock_direction_pixbufs); i++)
    {
      add_sized_with_same_fallback (gimp_stock_factory,
                                    gimp_stock_direction_pixbufs[i].inline_data_ltr,
                                    gimp_stock_direction_pixbufs[i].inline_data_rtl,
                                    GTK_ICON_SIZE_MENU,
                                    gimp_stock_direction_pixbufs[i].stock_id);
    }

  gtk_icon_factory_add_default (gimp_stock_factory);

  gtk_stock_add_static (gimp_stock_items, G_N_ELEMENTS (gimp_stock_items));

  initialized = TRUE;
}