Example #1
0
void
ghb_load_icons()
{
    GHashTableIter iter;
    gchar *key;
    GValue *gval;

    GValue *icons = ghb_resource_get("icons");
    ghb_dict_iter_init(&iter, icons);
    // middle (void*) cast prevents gcc warning "defreferencing type-punned
    // pointer will break strict-aliasing rules"
    while (g_hash_table_iter_next(
            &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
    {
        ghb_rawdata_t *rd;
        gint size;
        GdkPixbuf *pb;
        gboolean svg;
        char *name = g_strdup(key);
        char *pos;

        pos = g_strstr_len(name, -1, ".");
        if (pos != NULL)
            *pos = '\0';

        GInputStream *gis;
        svg = ghb_value_boolean(ghb_dict_lookup(gval, "svg"));
        rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
        if (svg)
        {
            int ii;
            int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0};
            for (ii = 0; sizes[ii]; ii++)
            {
                gis = g_memory_input_stream_new_from_data(rd->data, rd->size,
                                                          NULL);
                pb = gdk_pixbuf_new_from_stream_at_scale(gis,
                                                         sizes[ii], sizes[ii],
                                                         TRUE, NULL, NULL);
                g_input_stream_close(gis, NULL, NULL);
                size = gdk_pixbuf_get_height(pb);
                gtk_icon_theme_add_builtin_icon(name, size, pb);
                g_object_unref(pb);
            }
        }
        else
        {
            gis = g_memory_input_stream_new_from_data(rd->data, rd->size, NULL);
            pb = gdk_pixbuf_new_from_stream(gis, NULL, NULL);
            g_input_stream_close(gis, NULL, NULL);
            size = gdk_pixbuf_get_height(pb);
            gtk_icon_theme_add_builtin_icon(name, size, pb);
            g_object_unref(pb);
        }
        g_free(name);
    }
}
Example #2
0
/**
 * 接收好友头像数据.
 * @return 头像文件名
 */
char *UdpData::RecvPalIcon()
{
        GdkPixbuf *pixbuf;
        char path[MAX_PATHLEN];
        char *iconfile;
        size_t len;
        int fd;

        /* 若无头像数据则返回null */
        if ((len = strlen(buf) + 1) >= size)
                return NULL;

        /* 将头像数据刷入磁盘 */
        snprintf(path, MAX_PATHLEN, "%s" ICON_PATH "/%" PRIx32,
                                 g_get_user_cache_dir(), ipv4);
        if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
                return NULL;
        xwrite(fd, buf + len, size - len);
        close(fd);

        /* 将头像pixbuf加入内建 */
        iconfile = NULL;
        gdk_threads_enter();
        if ( (pixbuf = gdk_pixbuf_new_from_file(path, NULL))) {
                iconfile = g_strdup_printf("%" PRIx32, ipv4);
                gtk_icon_theme_add_builtin_icon(iconfile, MAX_ICONSIZE, pixbuf);
                g_object_unref(pixbuf);
        }
        gdk_threads_leave();

        return iconfile;
}
Example #3
0
static VALUE
it_s_add_builtin_icon(VALUE self, VALUE icon_name, VALUE size, VALUE pixbuf)
{
    gtk_icon_theme_add_builtin_icon(RVAL2CSTR(icon_name), NUM2INT(size),
                                    GDK_PIXBUF(RVAL2GOBJ(pixbuf)));
    return self;
}
/**
 * rb_stock_icons_init:
 *
 * Initializes the stock icons, adding the necessary filesystem
 * locations to the GTK icon search path.  Must be called on startup.
 */
void
rb_stock_icons_init (void)
{
	GtkIconTheme *theme = gtk_icon_theme_get_default ();
	int i;
	int icon_size;
	char *dot_icon_dir;

	/* add our icon search paths */
	dot_icon_dir = g_build_filename (rb_user_data_dir (), "icons", NULL);
	gtk_icon_theme_append_search_path (theme, dot_icon_dir);
	g_free (dot_icon_dir);

	gtk_icon_theme_append_search_path (theme, SHARE_DIR G_DIR_SEPARATOR_S "icons");
#ifdef USE_UNINSTALLED_DIRS
	gtk_icon_theme_append_search_path (theme, SHARE_UNINSTALLED_DIR G_DIR_SEPARATOR_S "icons");
#endif

	/* add inline icons */
	gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &icon_size, NULL);
	for (i = 0; i < (int) G_N_ELEMENTS (inline_icons); i++) {
		GdkPixbuf *pixbuf;

		pixbuf = gdk_pixbuf_new_from_inline (-1,
						     inline_icons[i].data,
						     FALSE,
						     NULL);
		g_assert (pixbuf);

		gtk_icon_theme_add_builtin_icon (inline_icons[i].name,
						 icon_size,
						 pixbuf);
	}
}
Example #5
0
void
ghb_load_icons()
{
#if GTK_CHECK_VERSION(3, 14, 0)
    ghb_icons_register_resource();
    gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
                                     "/fr/handbrake/ghb/icons");
#else
    ghb_icons_register_resource();
    GResource *icon_res = ghb_icons_get_resource();

    char ** children = g_resource_enumerate_children(icon_res,
                            "/fr/handbrake/ghb/icons/scalable/apps", 0, NULL);

    if (children == NULL)
    {
        g_warning("No icons in resources!");
        return;
    }
    int ii;
    for (ii = 0; children[ii] != NULL; ii++)
    {
        char * path;

        path = g_strdup_printf("/fr/handbrake/ghb/icons/scalable/apps/%s",
                               children[ii]);
        GBytes *gbytes = g_resource_lookup_data(icon_res, path, 0, NULL);
        gsize data_size;
        gconstpointer data = g_bytes_get_data(gbytes, &data_size);
        g_free(path);

        char *pos;
        char *name = g_strdup(children[ii]);
        pos = g_strstr_len(name, -1, ".");
        if (pos != NULL)
            *pos = '\0';

        int jj;
        int sizes[] = {16, 22, 24, 32, 48, 64, 128, 256, 0};
        for (jj = 0; sizes[jj]; jj++)
        {
            GdkPixbuf *pb;
            GInputStream *gis;
            int size;

            gis = g_memory_input_stream_new_from_data(data, data_size,
                                                      NULL);
            pb = gdk_pixbuf_new_from_stream_at_scale(gis,
                                                     sizes[jj], sizes[jj],
                                                     TRUE, NULL, NULL);
            g_input_stream_close(gis, NULL, NULL);
            size = gdk_pixbuf_get_height(pb);
            gtk_icon_theme_add_builtin_icon(name, size, pb);
            g_object_unref(pb);
        }
        g_bytes_unref(gbytes);
    }
    g_strfreev(children);
#endif
}
Example #6
0
static void
register_icon (const gchar    *new_icon_name,
               gint            size,
               const gchar    *icon_name,
               const gchar    *file_name)
{
  GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
  GdkPixbuf *pixbuf;
  GtkIconInfo *info;

  if ((info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 0)))
    {
      pixbuf = gtk_icon_info_load_icon (info, NULL);
    }
  else
    {
      gchar *path = g_build_filename (glade_app_get_pixmaps_dir (), file_name, NULL);
      pixbuf = gdk_pixbuf_new_from_file (path, NULL);
      g_free (path);
    }

  if (pixbuf)
    {
      gtk_icon_theme_add_builtin_icon (new_icon_name, size, pixbuf);
      g_object_unref (pixbuf);
    }
}
Example #7
0
static void
add_default_image(const gchar* stock_id, gint size, const guchar* inline_data) {
    GdkPixbuf* buf = gdk_pixbuf_new_from_inline(-1, inline_data, FALSE, NULL);
    g_return_if_fail(buf);

    gtk_icon_theme_add_builtin_icon(stock_id, size, buf);
    g_object_unref(buf);
}
Example #8
0
static void
install_icons (void)
{
	GdkPixbuf *pixbuf = go_gdk_pixbuf_load_from_file ("res:go:utils/unknown_image.png");
	int size = gdk_pixbuf_get_width (pixbuf);
	gtk_icon_theme_add_builtin_icon ("unknown_image",
					 size,
					 pixbuf);
	g_object_unref (pixbuf);
}
Example #9
0
/**
 * gnomemeeting_stock_icons_init:
 *
 * Initializes the GnomeMeeting stock icons
 *
 **/
void
gnomemeeting_stock_icons_init (void)
{
	int i;

        typedef struct
        {
                char *id;
                gint size;
                const guint8 *data;
        } GmThemeIcon;

	static const GmThemeIcon theme_builtins[] =
	{
	        { "audio-volume", 16, gm_audio_volume_16 },
		{ "brightness", 16, gm_brightness_16},
		{ "call-placed", 16, gm_call_placed_16},
		{ "call-missed", 16, gm_call_missed_16},
		{ "call-received", 16, gm_call_received_16},
		{ "call-transfer", 16, gm_call_transfer_16},
		{ "color", 16, gm_color_16},
		{ "contrast", 16, gm_contrast_16},
		{ "im-message", 16, gm_im_message_16},
		{ "im-message-new", 16, gm_im_message_new_16},
		{ "whiteness", 16, gm_whiteness_16},
	        { "video-settings", 16, gm_video_settings_16 },
	        { GM_ICON_LOGO, 16, gm_logo_16_stock_data },
	        { GM_ICON_LOGO, 22, gm_logo_22_stock_data },
	        { GM_ICON_LOGO, 32, gm_logo_32_stock_data },
	        { GM_ICON_LOGO, 48, gm_logo_48_stock_data },
	        { GM_ICON_LOGO, 72, gm_logo_72_stock_data },
		{ "phone-hang-up", 16, gm_phone_hang_up_16 },
		{ "phone-pick-up", 16, gm_phone_pick_up_16 },
		{ "phone-hang-up", 24, gm_phone_hang_up_24 },
		{ "phone-pick-up", 24, gm_phone_pick_up_24 },
		{ "user-inacall", 16, gm_user_inacall_16 },
		{ "user-ringing", 16, gm_user_ringing_16 },

	};

	/* Now install theme builtins */
	for (i = 0; i < (int) G_N_ELEMENTS (theme_builtins); i++)
	{
		GdkPixbuf *pixbuf;

		pixbuf = gdk_pixbuf_new_from_inline (-1, theme_builtins[i].data,
						     FALSE, NULL);

		gtk_icon_theme_add_builtin_icon (theme_builtins[i].id,
						 theme_builtins[i].size, pixbuf);

		g_object_unref (G_OBJECT (pixbuf));
	}
}
Example #10
0
static void
pointer_mode_register_icon (const gchar     *icon_name,
                            gint             real_size,
                            GladePointerMode mode,
                            GtkIconSize      size)
{
  GdkPixbuf *pixbuf;

  if ((pixbuf = glade_utils_pointer_mode_render_icon (mode, size)))
    {
      gtk_icon_theme_add_builtin_icon (icon_name, real_size, pixbuf);
      g_object_unref (pixbuf);
    }
}
Example #11
0
static void
walk_resource_path (const char *path, int level, int size)
{
	char **children = g_resources_enumerate_children (path, 0, NULL);
	int i;

	if (!children)
		return;

	for (i = 0; children[i]; i++) {
		const char *child = children[i];
		char *subpath;
		GBytes *data;

		if (level == 0) {
			size = atol (child);
			if (size <= 0)
				continue;
		}

		subpath = g_build_path ("/", path, child, NULL);

		data = g_resources_lookup_data (subpath, 0, NULL);
		if (data) {
			GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource (subpath, NULL);
			if (pixbuf && size > 0 && strchr (child, '.')) {
				char *iconname = g_strdup (child);
				strchr(iconname, '.')[0] = 0;
				if (gnm_debug_flag ("icons"))
					g_printerr ("Defining icon %s at size %d\n", iconname, size);
				gtk_icon_theme_add_builtin_icon (iconname,
								 size,
								 pixbuf);

				g_object_unref (pixbuf);
				g_free (iconname);
			}

			g_bytes_unref (data);
		} else
			walk_resource_path (subpath, level + 1, size);
		g_free (subpath);
	}

	g_strfreev (children);
}
Example #12
0
int
clip_GTK_ICONTHEMEADDBUILTINAICON(ClipMachine * cm)
{
        gchar     *name   = _clip_parc(cm, 1);
        gint       size   = _clip_parni(cm, 2);
        C_object *cpixbuf = _fetch_cobject(cm, _clip_spar(cm, 3));

        CHECKARG(1, CHARACTER_t);
        CHECKARG(2, NUMERIC_t);
	CHECKCOBJ(cpixbuf, GDK_IS_PIXBUF(cpixbuf->object));

	gtk_icon_theme_add_builtin_icon(name,
		size, GDK_PIXBUF(cpixbuf->object));

	return 0;
err:
	return 1;
}
Example #13
0
void
ghb_load_icons()
{
    GHashTableIter iter;
    gchar *key;
    GValue *gval;

    GValue *icons = ghb_resource_get("icons");
    ghb_dict_iter_init(&iter, icons);
    // middle (void*) cast prevents gcc warning "defreferencing type-punned
    // pointer will break strict-aliasing rules"
    while (g_hash_table_iter_next(
            &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
    {
        gint colorspace, bps, width, height, rowstride;
        gboolean alpha;
        ghb_rawdata_t *rd;
        gint size;
        GdkPixbuf *pb;
        char *name = g_strdup(key);
        char *pos;

        pos = g_strstr_len(name, -1, ".");
        if (pos != NULL)
            *pos = '\0';

        colorspace = ghb_value_int(ghb_dict_lookup(gval, "colorspace"));
        alpha = ghb_value_boolean(ghb_dict_lookup(gval, "alpha"));
        bps = ghb_value_int(ghb_dict_lookup(gval, "bps"));
        width = ghb_value_int(ghb_dict_lookup(gval, "width"));
        height = ghb_value_int(ghb_dict_lookup(gval, "height"));
        rowstride = ghb_value_int(ghb_dict_lookup(gval, "rowstride"));
        rd = g_value_get_boxed(ghb_dict_lookup(gval, "data"));
        pb = gdk_pixbuf_new_from_data(
                rd->data, colorspace, alpha, bps,
                width, height, rowstride,
                NULL, NULL);
        size = gdk_pixbuf_get_height(pb);
        gtk_icon_theme_add_builtin_icon(name, size, pb);
        g_object_unref(pb);
        g_free(name);
    }
}
Example #14
0
static void
install_icons (GnmApp *app)
{
	static const char *icons[] = {
		/* Cursors */
		"cursor_cross.xpm",
		"bucket.xpm",
		"font.xpm",
		"sheet_move_marker.xpm",

		/* Patterns */
		"gp_125grey.xpm",
		"gp_25grey.xpm",
		"gp_50grey.xpm",
		"gp_625grey.xpm",
		"gp_75grey.xpm",
		"gp_bricks.xpm",
		"gp_diag.xpm",
		"gp_diag_cross.xpm",
		"gp_foreground_solid.xpm",
		"gp_horiz.xpm",
		"gp_large_circles.xpm",
		"gp_rev_diag.xpm",
		"gp_semi_circle.xpm",
		"gp_small_circle.xpm",
		"gp_solid.xpm",
		"gp_thatch.xpm",
		"gp_thick_diag_cross.xpm",
		"gp_thin_diag.xpm",
		"gp_thin_diag_cross.xpm",
		"gp_thin_horiz.xpm",
		"gp_thin_horiz_cross.xpm",
		"gp_thin_rev_diag.xpm",
		"gp_thin_vert.xpm",
		"gp_vert.xpm",
		"line_pattern_dash_dot.xpm",
		"line_pattern_dash_dot_dot.xpm",
		"line_pattern_dashed.xpm",
		"line_pattern_dotted.xpm",
		"line_pattern_double.xpm",
		"line_pattern_hair.xpm",
		"line_pattern_medium.xpm",
		"line_pattern_medium_dash.xpm",
		"line_pattern_medium_dash_dot.xpm",
		"line_pattern_medium_dash_dot_dot.xpm",
		"line_pattern_slant.xpm",
		"line_pattern_thick.xpm",
		"line_pattern_thin.xpm",

		/* Borders */
		"bottom_border.xpm",
		"diag_border.xpm",
		"inside_border.xpm",
		"inside_horiz_border.xpm",
		"inside_vert_border.xpm",
		"left_border.xpm",
		"no_border.xpm",
		"outline_border.xpm",
		"rev_diag_border.xpm",
		"right_border.xpm",
		"top_border.xpm"
	};
	static struct {
		const char *scalable_filename;
		const char *sized_filename;
		const char *stock_id;
	} const icons2[] = {
		{
			"column_add_24.xpm",
			"column_add_16.xpm",
			"Gnumeric_ColumnAdd"
		},
		{
			"column_delete_24.xpm",
			"column_delete_16.xpm",
			"Gnumeric_ColumnDelete"
		},
		{
			"column_size_24.xpm",
			"column_size_16.xpm",
			"Gnumeric_ColumnSize"
		},
		{
			"column_hide_24.xpm",
			"column_hide_16.xpm",
			"Gnumeric_ColumnHide"
		},
		{
			"column_unhide_24.xpm",
			"column_unhide_16.xpm",
			"Gnumeric_ColumnUnhide"
		},
		{
			"row_add_24.xpm",
			"row_add_16.xpm",
			"Gnumeric_RowAdd"
		},
		{
			"row_delete_24.xpm",
			"row_delete_16.xpm",
			"Gnumeric_RowDelete"
		},
		{
			"row_size_24.xpm",
			"row_size_16.xpm",
			"Gnumeric_RowSize"
		},
		{
			"row_hide_24.xpm",
			"row_hide_16.xpm",
			"Gnumeric_RowHide"
		},
		{
			"row_unhide_24.xpm",
			"row_unhide_16.xpm",
			"Gnumeric_RowUnhide"
		},

		{
			"group_24.xpm",
			"group_16.xpm",
			"Gnumeric_Group"
		},
		{
			"ungroup_24.xpm",
			"ungroup_16.xpm",
			"Gnumeric_Ungroup"
		},
		{
			"show_detail_24.xpm",
			"show_detail_16.xpm",
			"Gnumeric_ShowDetail"
		},
		{
			"hide_detail_24.xpm",
			"hide_detail_16.xpm",
			"Gnumeric_HideDetail"
		},

		{
			"graph_guru_24.xpm",
			"graph_guru_16.xpm",
			"Gnumeric_GraphGuru"
		},
		{
			"insert_component_24.xpm",
			"insert_component_16.xpm",
			"Gnumeric_InsertComponent"
		},
		{
			"insert_shaped_component_24.xpm",
			"insert_shaped_component_16.xpm",
			"Gnumeric_InsertShapedComponent"
		},

		{
			"center_across_selection_24.xpm",
			"center_across_selection_16.xpm",
			"Gnumeric_CenterAcrossSelection"
		},
		{
			"merge_cells_24.xpm",
			"merge_cells_16.xpm",
			"Gnumeric_MergeCells"
		},
		{
			"split_cells_24.xpm",
			"split_cells_16.xpm",
			"Gnumeric_SplitCells"
		},

		{
			"halign-fill_24.png",
			NULL,
			"Gnumeric_HAlignFill"
		},
		{
			"halign-general_24.png",
			NULL,
			"Gnumeric_HAlignGeneral"
		},

		{
			NULL,
			"comment_add_16.xpm",
			"Gnumeric_CommentAdd"
		},
		{
			NULL,
			"comment_delete_16.xpm",
			"Gnumeric_CommentDelete"
		},
		{
			NULL,
			"comment_edit_16.xpm",
			"Gnumeric_CommentEdit"
		},

		{
			"add_decimals.png",
			NULL,
			"Gnumeric_FormatAddPrecision"
		},
		{
			"remove_decimals.png",
			NULL,
			"Gnumeric_FormatRemovePrecision"
		},
		{
			"format_money_24.png",
			NULL,
			"Gnumeric_FormatAsAccounting"
		},
		{
			"format_percent_24.png",
			NULL,
			"Gnumeric_FormatAsPercentage"
		},
		{
			"thousands.xpm",
			NULL,
			"Gnumeric_FormatThousandSeparator"
		},
		{
			"gnm_subscript_24.png",
			"gnm_subscript_16.png",
			"Gnumeric_Subscript"
		},
		{
			"gnm_superscript_24.png",
			"gnm_superscript_16.png",
			"Gnumeric_Superscript"
		},

		{
			"auto-sum.xpm",
			NULL,
			"Gnumeric_AutoSum"
		},
		{
			"equal-sign.xpm",
			NULL,
			"Gnumeric_Equal"
		},
		{
			"formula_guru_24.png",
			"formula_guru_16.png",
			"Gnumeric_FormulaGuru"
		},
		{
			"insert_image_24.png",
			"insert_image_16.png",
			"Gnumeric_InsertImage"
		},
		{
			"bucket.xpm",
			NULL,
			"Gnumeric_Bucket"
		},
		{
			"font.xpm",
			NULL,
			"Gnumeric_Font"
		},
		{
			"expr_entry.png",
			NULL,
			"Gnumeric_ExprEntry"
		},
		{
			"brush-22.png",
			"brush-16.png",
			"Gnumeric_Brush"
		},

		{
			"object_arrow_24.png",
			NULL,
			"Gnumeric_ObjectArrow"
		},
		{
			"object_ellipse_24.png",
			NULL,
			"Gnumeric_ObjectEllipse"
		},
		{
			"object_line_24.png",
			NULL,
			"Gnumeric_ObjectLine"
		},

		{
			"object_rectangle_24.png",
			NULL,
			"Gnumeric_ObjectRectangle"
		},

		{
			"object_frame_24.png",
			NULL,
			"Gnumeric_ObjectFrame"
		},
		{
			"object_label_24.png",
			NULL,
			"Gnumeric_ObjectLabel"
		},
		{
			"object_button_24.png",
			NULL,
			"Gnumeric_ObjectButton"
		},
		{
			"object_checkbox_24.png",
			NULL,
			"Gnumeric_ObjectCheckbox"
		},
		{
			"object_radiobutton_24.png",
			NULL,
			"Gnumeric_ObjectRadioButton"
		},
		{
			"object_scrollbar_24.png",
			NULL,
			"Gnumeric_ObjectScrollbar"
		},
		{
			"object_spinbutton_24.png",
			NULL,
			"Gnumeric_ObjectSpinButton"
		},
		{
			"object_slider_24.png",
			NULL,
			"Gnumeric_ObjectSlider"
		},
		{
			"object_combo_24.png",
			NULL,
			"Gnumeric_ObjectCombo"
		},
		{
			"object_list_24.png",
			NULL,
			"Gnumeric_ObjectList"
		},

		{
			"pivottable_24.png",
			"pivottable_16.png",
			"Gnumeric_PivotTable"
		},
		{
			"protection_yes_24.png",
			NULL,
			"Gnumeric_Protection_Yes"
		},
		{
			"protection_no_24.png",
			NULL,
			"Gnumeric_Protection_No"
		},
		{
			"protection_yes_48.png",
			NULL,
			"Gnumeric_Protection_Yes_Dialog"
		},
		{
			"visible.png",
			NULL,
			"Gnumeric_Visible"
		},

		{
			"link_add_24.png",
			"link_add_16.png",
			"Gnumeric_Link_Add"
		},
		{
			NULL,
			"link_delete_16.png",
			"Gnumeric_Link_Delete"
		},
		{
			NULL,
			"link_edit_16.png",
			"Gnumeric_Link_Edit"
		},
		{
			"link_external_24.png",
			"link_external_16.png",
			"Gnumeric_Link_External"
		},
		{
			"link_internal_24.png",
			"link_internal_16.png",
			"Gnumeric_Link_Internal"
		},
		{
			"link_email_24.png",
			"link_email_16.png",
			"Gnumeric_Link_EMail"
		},
		{
			"link_url_24.png",
			"link_url_16.png",
			"Gnumeric_Link_URL"
		},

		{
			"autofilter_24.png",
			"autofilter_16.png",
			"Gnumeric_AutoFilter"
		},
		{
			"autofilter_delete_24.png",
			"autofilter_delete_16.png",
			"Gnumeric_AutoFilterDelete"
		},

		{
			"border_left.xpm",
			NULL,
			"Gnumeric_BorderLeft"
		},
		{
			"border_none.xpm",
			NULL,
			"Gnumeric_BorderNone"
		},
		{
			"border_right.xpm",
			NULL,
			"Gnumeric_BorderRight"
		},
		{
			"border_all.xpm",
			NULL,
			"Gnumeric_BorderAll"
		},
		{
			"border_outside.xpm",
			NULL,
			"Gnumeric_BorderOutside"
		},
		{
			"border_thick_outside.xpm",
			NULL,
			"Gnumeric_BorderThickOutside"
		},
		{
			"border_bottom.xpm",
			NULL,
			"Gnumeric_BorderBottom"
		},
		{
			"border_double_bottom.xpm",
			NULL,
			"Gnumeric_BorderDoubleBottom"
		},
		{
			"border_thick_bottom.xpm",
			NULL,
			"Gnumeric_BorderThickBottom"
		},
		{
			"border_top_n_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_Bottom"
		},
		{
			"border_top_n_double_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_DoubleBottom"
		},
		{
			"border_top_n_thick_bottom.xpm",
			NULL,
			"Gnumeric_BorderTop_n_ThickBottom"
		},

		{
			"hf_page.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Page"
		},
		{
			"hf_pages.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Pages"
		},
		{
			"hf_time.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Time"
		},
		{
			"hf_date.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Date"
		},
		{
			"hf_sheet.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Sheet"
		},
		{
			"hf_cell.png",
			NULL,
			"Gnumeric_Pagesetup_HF_Cell"
		},
	};

	GtkIconFactory *factory = gtk_icon_factory_new ();
	unsigned int ui;

	for (ui = 0; ui < G_N_ELEMENTS (icons); ui++) {
		const char *filename = icons[ui];
		char *res = g_strconcat ("res:gnm:pixmaps/", filename, NULL);
		char *iconname;
		GdkPixbuf *pixbuf = go_gdk_pixbuf_load_from_file (res);
		int size = gdk_pixbuf_get_width (pixbuf);

		iconname = g_strdup (filename);
		strchr(iconname, '.')[0] = 0;
		gtk_icon_theme_add_builtin_icon (iconname,
						 size,
						 pixbuf);

		g_object_unref (pixbuf);
		g_free (iconname);
		g_free (res);
	}

	for (ui = 0; ui < G_N_ELEMENTS (icons2) ; ui++)
		add_icon (factory,
			  icons2[ui].scalable_filename,
			  icons2[ui].sized_filename,
			  icons2[ui].stock_id);
	gtk_icon_factory_add_default (factory);
	g_object_set_data_full (G_OBJECT (app),
				"icon-factory", factory,
				(GDestroyNotify)gtk_icon_factory_remove_default);
	g_object_unref (factory);
}
Example #15
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;
}
Example #16
0
/**
 * gnomemeeting_stock_icons_init:
 *
 * Initializes the GnomeMeeting stock icons 
 *
 **/
void
gnomemeeting_stock_icons_init (void)
{
	GtkIconFactory *factory;
	int i;

        typedef struct 
        {
                char *id;
                const guint8 *data;
        } GmStockIcon;                

	static const GmStockIcon items[] =
	{
	        { GM_STOCK_COLOR_BRIGHTNESS_CONTRAST, gm_color_brightness_contrast_stock_data },

		{ GM_STOCK_STATUS_ONLINE, gm_status_online_stock_data },
		{ GM_STOCK_STATUS_OFFLINE, gm_status_offline_stock_data },
		{ GM_STOCK_STATUS_UNKNOWN, gm_status_unknown_stock_data },
		{ GM_STOCK_STATUS_AWAY, gm_status_away_stock_data },
		{ GM_STOCK_STATUS_DND, gm_status_dnd_stock_data },
		{ GM_STOCK_STATUS_INACALL, gm_status_inacall_stock_data_16 },
		{ GM_STOCK_STATUS_RINGING, gm_status_ringing_stock_data_16 },

		{ GM_STOCK_REMOTE_OBJECT, gm_remote_contact_stock_data},
		{ GM_STOCK_LOCAL_OBJECT, gm_local_contact_stock_data},
		{ GM_STOCK_MESSAGE, gm_message_stock_data},
		{ GM_STOCK_CALL_PLACED, gm_call_placed_stock_data},
		{ GM_STOCK_CALL_MISSED, gm_call_missed_stock_data},
		{ GM_STOCK_CALL_RECEIVED, gm_call_received_stock_data},
		{ GM_STOCK_CALL_TRANSFER, gm_call_transfer_stock_data},

		{ GM_STOCK_PHONE_HANG_UP_16, gm_phone_hang_up_stock_data_16},
		{ GM_STOCK_PHONE_PICK_UP_16, gm_phone_pick_up_stock_data_16},
		{ GM_STOCK_PHONE_HANG_UP_24, gm_phone_hang_up_stock_data_24},
		{ GM_STOCK_PHONE_PICK_UP_24, gm_phone_pick_up_stock_data_24},
	};

        typedef struct 
        {
                char *id;
                gint size;
                const guint8 *data;
        } GmThemeIcon;                

	static const GmThemeIcon theme_builtins[] =
	{
		{ GM_ICON_ADD_CONTACT, 24, gm_add_contact_24_stock_data},
	        { GM_ICON_AUDIO_VOLUME_HIGH, 16, gm_audio_volume_high_16_stock_data },
		{ GM_ICON_BRIGHTNESS, 16, gm_brightness_16_stock_data},
		{ GM_ICON_CAMERA_VIDEO, 16, gm_camera_video_16_stock_data },
		{ GM_ICON_COLOURNESS, 16, gm_colourness_16_stock_data},
		{ GM_ICON_CONTRAST, 16, gm_contrast_16_stock_data},
		{ GM_ICON_INTERNET_GROUP_CHAT, 24, gm_internet_group_chat_24_stock_data },
	        { GM_ICON_LOGO, 16, gm_logo_16_stock_data },
	        { GM_ICON_LOGO, 22, gm_logo_22_stock_data },
	        { GM_ICON_LOGO, 32, gm_logo_32_stock_data },
	        { GM_ICON_LOGO, 48, gm_logo_48_stock_data },
	        { GM_ICON_LOGO, 72, gm_logo_72_stock_data },
		{ GM_ICON_MEDIA_PLAYBACK_PAUSE, 16, gm_media_playback_pause_16_stock_data },
		{ GM_ICON_MICROPHONE, 24, gm_microphone_24_stock_data },
		{ GM_ICON_SYSTEM_SEARCH, 16, gm_system_search_16_stock_data},
		{ GM_ICON_WHITENESS, 16, gm_whiteness_16_stock_data},
	};

	/* First, register honest-to-goodness custom stock icons */
	factory = gtk_icon_factory_new ();
	gtk_icon_factory_add_default (factory);

	for (i = 0; i < (int) G_N_ELEMENTS (items); i++)
	{
		GtkIconSet *icon_set;
		GdkPixbuf *pixbuf;

                pixbuf = gdk_pixbuf_new_from_inline (-1, items[i].data, FALSE, NULL);

		icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);

		gtk_icon_factory_add (factory, items[i].id, icon_set);
		gtk_icon_set_unref (icon_set);
		
		g_object_unref (G_OBJECT (pixbuf));
	}

	g_object_unref (G_OBJECT (factory));
	
	/* Now install theme builtins */
	for (i = 0; i < (int) G_N_ELEMENTS (theme_builtins); i++)
	{
		GdkPixbuf *pixbuf;

		pixbuf = gdk_pixbuf_new_from_inline (-1, theme_builtins[i].data,
						     FALSE, NULL);

		gtk_icon_theme_add_builtin_icon (theme_builtins[i].id,
						 theme_builtins[i].size, pixbuf);

		g_object_unref (G_OBJECT (pixbuf));
	}
}