new files
2007-06-14 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* theme-util.c: (theme_delete), (theme_model_iter_last):
* theme-util.h: new files
* appearance.glade: default delete buttons to insensitive,
change label for "Custom" key, adjust column ids for icon view
* appearance-style.c: (style_init), (prepare_list),
(update_color_buttons_from_settings), (theme_name_changed),
(color_button_clicked_cb),
(color_scheme_defaults_button_clicked_cb):
* appearance-themes.c: (theme_get_selected_name),
(theme_get_selected), (theme_select_iter), (theme_select_name),
(theme_is_equal), (theme_set_custom_from_theme),
(theme_changed_on_disk_cb), (theme_custom_cb), (theme_delete_cb),
(theme_details_changed_cb), (theme_color_scheme_changed_cb),
(theme_gconf_changed), (theme_postinit), (themes_init),
(themes_shutdown):
* appearance.h: improvements all around the block (metatheme
deletion now working, and custom theme working much better)
svn path=/trunk/; revision=7725
2007-06-14 21:20:25 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The GNOME Foundation
|
|
|
|
* Written by Thomas Wood <thos@gnome.org>
|
|
|
|
* Jens Granseuer <jensgr@gmx.net>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "appearance.h"
|
2007-07-28 10:53:57 +00:00
|
|
|
#include "theme-util.h"
|
new files
2007-06-14 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* theme-util.c: (theme_delete), (theme_model_iter_last):
* theme-util.h: new files
* appearance.glade: default delete buttons to insensitive,
change label for "Custom" key, adjust column ids for icon view
* appearance-style.c: (style_init), (prepare_list),
(update_color_buttons_from_settings), (theme_name_changed),
(color_button_clicked_cb),
(color_scheme_defaults_button_clicked_cb):
* appearance-themes.c: (theme_get_selected_name),
(theme_get_selected), (theme_select_iter), (theme_select_name),
(theme_is_equal), (theme_set_custom_from_theme),
(theme_changed_on_disk_cb), (theme_custom_cb), (theme_delete_cb),
(theme_details_changed_cb), (theme_color_scheme_changed_cb),
(theme_gconf_changed), (theme_postinit), (themes_init),
(themes_shutdown):
* appearance.h: improvements all around the block (metatheme
deletion now working, and custom theme working much better)
svn path=/trunk/; revision=7725
2007-06-14 21:20:25 +00:00
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
2007-07-28 10:53:57 +00:00
|
|
|
#include <string.h>
|
new files
2007-06-14 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* theme-util.c: (theme_delete), (theme_model_iter_last):
* theme-util.h: new files
* appearance.glade: default delete buttons to insensitive,
change label for "Custom" key, adjust column ids for icon view
* appearance-style.c: (style_init), (prepare_list),
(update_color_buttons_from_settings), (theme_name_changed),
(color_button_clicked_cb),
(color_scheme_defaults_button_clicked_cb):
* appearance-themes.c: (theme_get_selected_name),
(theme_get_selected), (theme_select_iter), (theme_select_name),
(theme_is_equal), (theme_set_custom_from_theme),
(theme_changed_on_disk_cb), (theme_custom_cb), (theme_delete_cb),
(theme_details_changed_cb), (theme_color_scheme_changed_cb),
(theme_gconf_changed), (theme_postinit), (themes_init),
(themes_shutdown):
* appearance.h: improvements all around the block (metatheme
deletion now working, and custom theme working much better)
svn path=/trunk/; revision=7725
2007-06-14 21:20:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
theme_delete (const gchar *name, ThemeType type)
|
|
|
|
{
|
2007-06-23 12:55:38 +00:00
|
|
|
GtkDialog *dialog;
|
new files
2007-06-14 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* theme-util.c: (theme_delete), (theme_model_iter_last):
* theme-util.h: new files
* appearance.glade: default delete buttons to insensitive,
change label for "Custom" key, adjust column ids for icon view
* appearance-style.c: (style_init), (prepare_list),
(update_color_buttons_from_settings), (theme_name_changed),
(color_button_clicked_cb),
(color_scheme_defaults_button_clicked_cb):
* appearance-themes.c: (theme_get_selected_name),
(theme_get_selected), (theme_select_iter), (theme_select_name),
(theme_is_equal), (theme_set_custom_from_theme),
(theme_changed_on_disk_cb), (theme_custom_cb), (theme_delete_cb),
(theme_details_changed_cb), (theme_color_scheme_changed_cb),
(theme_gconf_changed), (theme_postinit), (themes_init),
(themes_shutdown):
* appearance.h: improvements all around the block (metatheme
deletion now working, and custom theme working much better)
svn path=/trunk/; revision=7725
2007-06-14 21:20:25 +00:00
|
|
|
gpointer theme;
|
|
|
|
gchar *theme_dir;
|
|
|
|
gint response;
|
|
|
|
GList *uri_list;
|
|
|
|
GnomeVFSResult result;
|
|
|
|
|
2007-06-23 12:55:38 +00:00
|
|
|
dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
|
|
|
|
GTK_DIALOG_MODAL,
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
GTK_BUTTONS_CANCEL,
|
|
|
|
_("Would you like to delete this theme?"));
|
|
|
|
gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT);
|
|
|
|
response = gtk_dialog_run (dialog);
|
|
|
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
new files
2007-06-14 Jens Granseuer <jensgr@gmx.net>
* Makefile.am:
* theme-util.c: (theme_delete), (theme_model_iter_last):
* theme-util.h: new files
* appearance.glade: default delete buttons to insensitive,
change label for "Custom" key, adjust column ids for icon view
* appearance-style.c: (style_init), (prepare_list),
(update_color_buttons_from_settings), (theme_name_changed),
(color_button_clicked_cb),
(color_scheme_defaults_button_clicked_cb):
* appearance-themes.c: (theme_get_selected_name),
(theme_get_selected), (theme_select_iter), (theme_select_name),
(theme_is_equal), (theme_set_custom_from_theme),
(theme_changed_on_disk_cb), (theme_custom_cb), (theme_delete_cb),
(theme_details_changed_cb), (theme_color_scheme_changed_cb),
(theme_gconf_changed), (theme_postinit), (themes_init),
(themes_shutdown):
* appearance.h: improvements all around the block (metatheme
deletion now working, and custom theme working much better)
svn path=/trunk/; revision=7725
2007-06-14 21:20:25 +00:00
|
|
|
if (response == GTK_RESPONSE_CANCEL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case THEME_TYPE_GTK:
|
|
|
|
theme = gnome_theme_info_find (name);
|
|
|
|
theme_dir = g_build_filename (((GnomeThemeInfo *) theme)->path, "gtk-2.0", NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case THEME_TYPE_ICON:
|
|
|
|
theme = gnome_theme_icon_info_find (name);
|
|
|
|
theme_dir = g_path_get_dirname (((GnomeThemeIconInfo *) theme)->path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case THEME_TYPE_WINDOW:
|
|
|
|
theme = gnome_theme_info_find (name);
|
|
|
|
theme_dir = g_build_filename (((GnomeThemeInfo *) theme)->path, "metacity-1", NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case THEME_TYPE_META:
|
|
|
|
theme = gnome_theme_meta_info_find (name);
|
|
|
|
theme_dir = g_strdup (((GnomeThemeMetaInfo *) theme)->path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
uri_list = g_list_prepend (NULL, gnome_vfs_uri_new (theme_dir));
|
|
|
|
g_free (theme_dir);
|
|
|
|
|
|
|
|
result = gnome_vfs_xfer_delete_list (uri_list,
|
|
|
|
GNOME_VFS_XFER_ERROR_MODE_ABORT,
|
|
|
|
GNOME_VFS_XFER_RECURSIVE,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
gnome_vfs_uri_list_free (uri_list);
|
|
|
|
|
|
|
|
if (result != GNOME_VFS_OK) {
|
|
|
|
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);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreeIter walk, prev;
|
|
|
|
gboolean valid;
|
|
|
|
|
|
|
|
valid = gtk_tree_model_get_iter_first (model, &walk);
|
|
|
|
|
|
|
|
if (valid) {
|
|
|
|
do {
|
|
|
|
prev = walk;
|
|
|
|
valid = gtk_tree_model_iter_next (model, &walk);
|
|
|
|
} while (valid);
|
|
|
|
|
|
|
|
*iter = prev;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-06-23 11:08:21 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
GtkTreeIter walk;
|
|
|
|
gboolean valid;
|
|
|
|
gchar *test;
|
|
|
|
|
|
|
|
if (!name)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (valid = gtk_tree_model_get_iter_first (model, &walk); valid;
|
|
|
|
valid = gtk_tree_model_iter_next (model, &walk))
|
|
|
|
{
|
|
|
|
gtk_tree_model_get (model, &walk, COL_NAME, &test, -1);
|
|
|
|
|
|
|
|
if (test) {
|
|
|
|
gint cmp = strcmp (test, name);
|
|
|
|
g_free (test);
|
|
|
|
|
|
|
|
if (!cmp) {
|
|
|
|
if (iter)
|
|
|
|
*iter = walk;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|