-/* create GdkPixmap if it has not created yet */
-gint stock_pixmap_gdk(GtkWidget *window, StockPixmap icon,
- GdkPixmap **pixmap, GdkBitmap **mask)
-{
- StockPixmapData *pix_d;
- static const char *extension[]={".png", ".xpm", NULL};
- int i = 0;
- gboolean theme_changed = FALSE;
-
- if (pixmap) *pixmap = NULL;
- if (mask) *mask = NULL;
-
- g_return_val_if_fail(window != NULL, -1);
- g_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1);
-
- pix_d = &pixmaps[icon];
-
- theme_changed = (strcmp2(pix_d->icon_path, prefs_common.pixmap_theme_path) != 0);
- if (!pix_d->pixmap || theme_changed) {
- GdkPixmap *pix = NULL;
-
- if (theme_changed && pix_d->pixbuf) {
- g_object_unref(pix_d->pixbuf);
- pix_d->pixbuf = NULL;
- }
-
- if (strcmp(prefs_common.pixmap_theme_path, DEFAULT_PIXMAP_THEME) != 0) {
- if ( is_dir_exist(prefs_common.pixmap_theme_path) ) {
- char *icon_file_name;
-try_next_extension:
- icon_file_name = g_strconcat(prefs_common.pixmap_theme_path,
- G_DIR_SEPARATOR_S,
- pix_d->file,
- extension[i],
- NULL);
- if (is_file_exist(icon_file_name))
- PIXMAP_CREATE_FROM_FILE(window, pix, pix_d->mask, icon_file_name);
- if (pix) {
- g_free(pix_d->icon_path);
- pix_d->icon_path = g_strdup(prefs_common.pixmap_theme_path);
- }
- g_free(icon_file_name);
- if (!pix) {
- i++;
- if (extension[i])
- goto try_next_extension;
- }
- } else {
- /* even the path does not exist (deleted between two sessions), so
- set the preferences to the internal theme */
- prefs_common.pixmap_theme_path = g_strdup(DEFAULT_PIXMAP_THEME);
- }
- }
- pix_d->pixmap = pix;
- }
-
- if (!pix_d->pixmap) {
- PIXMAP_CREATE(window, pix_d->pixmap, pix_d->mask, pix_d->data);
- if (pix_d->pixmap) {
- g_free(pix_d->icon_path);
- pix_d->icon_path = g_strdup(DEFAULT_PIXMAP_THEME);
- }
- }
-
- g_return_val_if_fail(pix_d->pixmap != NULL, -1);
-
- if (pixmap)
- *pixmap = pix_d->pixmap;
- if (mask)
- *mask = pix_d->mask;
-
- return 0;
-}
-