static gchar * find_icon_file(PidginIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl) { const gchar *file, *dir; gchar *file_full = NULL; gchar *tmp; if (theme != NULL) { file = pidgin_icon_theme_get_icon(PIDGIN_ICON_THEME(theme), sized_icon.name); dir = purple_theme_get_dir(PURPLE_THEME(theme)); if (rtl) file_full = g_build_filename(dir, size, "rtl", file, NULL); else file_full = g_build_filename(dir, size, file, NULL); if (g_file_test(file_full, G_FILE_TEST_IS_REGULAR)) return file_full; g_free(file_full); } if (rtl) tmp = g_build_filename("pixmaps", "pidgin", sized_icon.dir, size, "rtl", sized_icon.filename, NULL); else tmp = g_build_filename("pixmaps", "pidgin", sized_icon.dir, size, sized_icon.filename, NULL); file_full = find_file_common(tmp); g_free(tmp); return file_full; }
void pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme) { GtkIconFactory *icon_factory; gint i; GtkIconSet *normal; GtkIconSet *translucent = NULL; GtkWidget *win; if (theme != NULL) { purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme", purple_theme_get_name(PURPLE_THEME(theme))); purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", purple_theme_get_dir(PURPLE_THEME(theme))); } else { purple_prefs_set_string(PIDGIN_PREFS_ROOT "/status/icon-theme", ""); purple_prefs_set_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", ""); } icon_factory = gtk_icon_factory_new(); gtk_icon_factory_add_default(icon_factory); win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(win); for (i = 0; i < G_N_ELEMENTS(sized_status_icons); i++) { normal = gtk_icon_set_new(); if (sized_status_icons[i].translucent_name) translucent = gtk_icon_set_new(); #define ADD_SIZED_ICON(name, size) \ if (sized_status_icons[i].name) { \ add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \ if (sized_status_icons[i].translucent_name) \ add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \ } ADD_SIZED_ICON(microscopic, "11"); ADD_SIZED_ICON(extra_small, "16"); ADD_SIZED_ICON(small, "22"); ADD_SIZED_ICON(medium, "32"); ADD_SIZED_ICON(large, "48"); ADD_SIZED_ICON(huge, "64"); #undef ADD_SIZED_ICON gtk_icon_factory_add(icon_factory, sized_status_icons[i].name, normal); gtk_icon_set_unref(normal); if (sized_status_icons[i].translucent_name) { gtk_icon_factory_add(icon_factory, sized_status_icons[i].translucent_name, translucent); gtk_icon_set_unref(translucent); } } gtk_widget_destroy(win); g_object_unref(G_OBJECT(icon_factory)); reload_settings(); }
gchar * purple_sound_theme_get_file_full(PurpleSoundTheme *theme, const gchar *event) { const gchar *filename; g_return_val_if_fail(PURPLE_IS_SOUND_THEME(theme), NULL); filename = purple_sound_theme_get_file(theme, event); g_return_val_if_fail(filename, NULL); return g_build_filename(purple_theme_get_dir(PURPLE_THEME(theme)), filename, NULL); }
void pidgin_stock_load_stock_icon_theme(PidginStockIconTheme *theme) { GtkIconFactory *icon_factory; gint i; GtkWidget *win; if (theme != NULL) { purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", purple_theme_get_name(PURPLE_THEME(theme))); purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", purple_theme_get_dir(PURPLE_THEME(theme))); } else { purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", ""); purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", ""); } icon_factory = gtk_icon_factory_new(); gtk_icon_factory_add_default(icon_factory); win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(win); /* All non-sized icons */ for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) { GtkIconSource *source; GtkIconSet *iconset; gchar *filename; if (stock_icons[i].dir == NULL) { /* GTK+ Stock icon */ iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), stock_icons[i].filename); } else { filename = find_file(stock_icons[i].dir, stock_icons[i].filename); if (filename == NULL) continue; source = gtk_icon_source_new(); gtk_icon_source_set_filename(source, filename); gtk_icon_source_set_direction_wildcarded(source, TRUE); gtk_icon_source_set_size_wildcarded(source, TRUE); gtk_icon_source_set_state_wildcarded(source, TRUE); iconset = gtk_icon_set_new(); gtk_icon_set_add_source(iconset, source); gtk_icon_source_free(source); g_free(filename); } gtk_icon_factory_add(icon_factory, stock_icons[i].name, iconset); gtk_icon_set_unref(iconset); } /* All non-status sized icons */ for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++) { GtkIconSet *iconset = gtk_icon_set_new(); #define ADD_SIZED_ICON(name, size) \ if (sized_stock_icons[i].name) \ add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE); ADD_SIZED_ICON(microscopic, "11"); ADD_SIZED_ICON(extra_small, "16"); ADD_SIZED_ICON(small, "22"); ADD_SIZED_ICON(medium, "32"); ADD_SIZED_ICON(large, "48"); ADD_SIZED_ICON(huge, "64"); #undef ADD_SIZED_ICON gtk_icon_factory_add(icon_factory, sized_stock_icons[i].name, iconset); gtk_icon_set_unref(iconset); } gtk_widget_destroy(win); g_object_unref(G_OBJECT(icon_factory)); reload_settings(); }