static void create_thumbnail (const gchar *name, GdkPixbuf *default_thumb, AppearanceData *data) { if (default_thumb == data->icon_theme_icon) { MateThemeIconInfo *info; info = mate_theme_icon_info_find (name); if (info != NULL) { generate_icon_theme_thumbnail_async (info, (ThemeThumbnailFunc) icon_theme_thumbnail_cb, data, NULL); } } else if (default_thumb == data->gtk_theme_icon) { MateThemeInfo *info; info = mate_theme_info_find (name); if (info != NULL && info->has_gtk) { generate_gtk_theme_thumbnail_async (info, (ThemeThumbnailFunc) gtk_theme_thumbnail_cb, data, NULL); } } else if (default_thumb == data->window_theme_icon) { MateThemeInfo *info; info = mate_theme_info_find (name); if (info != NULL && info->has_marco) { generate_marco_theme_thumbnail_async (info, (ThemeThumbnailFunc) marco_theme_thumbnail_cb, data, NULL); } } }
static void gtk_theme_changed (GSettings *settings, gchar *key, AppearanceData *data) { MateThemeInfo *theme = NULL; gchar *name; GtkSettings *gtksettings = gtk_settings_get_default (); name = g_settings_get_string (settings, key); if (name) { gchar *current; theme = mate_theme_info_find (name); /* Manually update GtkSettings to new gtk+ theme. * This will eventually happen anyway, but we need the * info for the color scheme updates already. */ g_object_get (gtksettings, "gtk-theme-name", ¤t, NULL); if (strcmp (current, name) != 0) { g_object_set (gtksettings, "gtk-theme-name", name, NULL); update_message_area (data); } g_free (current); check_color_schemes_enabled (gtksettings, data); update_color_buttons_from_settings (gtksettings, data); g_free (name); } gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "gtk_themes_delete"), theme_is_writable (theme)); }
static void window_theme_changed (GSettings *settings, gchar *key, AppearanceData *data) { MateThemeInfo *theme = NULL; gchar *name; name = g_settings_get_string (settings, key); if (name) { theme = mate_theme_info_find (name); g_free (name); } gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "window_themes_delete"), theme_is_writable (theme)); }
gboolean theme_delete (const gchar *name, ThemeType type) { gboolean rc; GtkDialog *dialog; gchar *theme_dir; gint response; MateThemeCommonInfo *theme; GFile *dir; gboolean del_empty_parent; dialog = (GtkDialog *) gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_CANCEL, _("Would you like to delete this theme?")); #if GTK_CHECK_VERSION (3, 10, 0) gtk_dialog_add_button (dialog, _("_Delete"), GTK_RESPONSE_ACCEPT); #else gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT); #endif response = gtk_dialog_run (dialog); gtk_widget_destroy (GTK_WIDGET (dialog)); if (response != GTK_RESPONSE_ACCEPT) return FALSE; /* Most theme types are put into separate subdirectories. For those we want to delete those directories as well. */ del_empty_parent = TRUE; switch (type) { case THEME_TYPE_GTK: theme = (MateThemeCommonInfo *) mate_theme_info_find (name); theme_dir = g_build_filename (theme->path, "gtk-2.0", NULL); break; case THEME_TYPE_ICON: theme = (MateThemeCommonInfo *) mate_theme_icon_info_find (name); theme_dir = g_path_get_dirname (theme->path); del_empty_parent = FALSE; break; case THEME_TYPE_WINDOW: theme = (MateThemeCommonInfo *) mate_theme_info_find (name); theme_dir = g_build_filename (theme->path, "marco-1", NULL); break; case THEME_TYPE_META: theme = (MateThemeCommonInfo *) mate_theme_meta_info_find (name); theme_dir = g_strdup (theme->path); break; case THEME_TYPE_CURSOR: theme = (MateThemeCommonInfo *) mate_theme_cursor_info_find (name); theme_dir = g_build_filename (theme->path, "cursors", NULL); break; default: return FALSE; } dir = g_file_new_for_path (theme_dir); g_free (theme_dir); if (!capplet_file_delete_recursive (dir, NULL)) { GtkWidget *info_dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Theme cannot be deleted")); gtk_dialog_run (GTK_DIALOG (info_dialog)); gtk_widget_destroy (info_dialog); rc = FALSE; } else { if (del_empty_parent) { /* also delete empty parent directories */ GFile *parent = g_file_get_parent (dir); g_file_delete (parent, NULL, NULL); g_object_unref (parent); } rc = TRUE; } g_object_unref (dir); return rc; }