simplify code thanks to the new unified theme type

2007-10-28  Jens Granseuer  <jensgr@gmx.net>

	* appearance-style.c: (prepare_list):
	* theme-util.c: (theme_is_writable), (theme_delete): simplify code
	thanks to the new unified theme type

svn path=/trunk/; revision=8227
This commit is contained in:
Jens Granseuer 2007-10-28 22:33:18 +00:00 committed by Jens Granseuer
parent 190963ea61
commit 194de56db9
3 changed files with 25 additions and 54 deletions

View file

@ -1,3 +1,9 @@
2007-10-28 Jens Granseuer <jensgr@gmx.net>
* appearance-style.c: (prepare_list):
* theme-util.c: (theme_is_writable), (theme_delete): simplify code
thanks to the new unified theme type
2007-10-28 Jens Granseuer <jensgr@gmx.net>
* appearance-style.c: (changed_on_disk_cb): add support for live cursor

View file

@ -785,32 +785,18 @@ prepare_list (AppearanceData *data, GtkWidget *list, ThemeType type, GCallback c
for (l = themes; l; l = g_list_next (l))
{
const gchar *name = NULL;
const gchar *label = NULL;
GnomeThemeCommonInfo *theme = (GnomeThemeCommonInfo *) l->data;
GtkTreeIter i;
if (type == THEME_TYPE_GTK || type == THEME_TYPE_WINDOW) {
name = ((GnomeThemeInfo *) l->data)->name;
} else if (type == THEME_TYPE_ICON) {
name = ((GnomeThemeIconInfo *) l->data)->name;
label = ((GnomeThemeIconInfo *) l->data)->readable_name;
} else if (type == THEME_TYPE_CURSOR) {
name = ((GnomeThemeCursorInfo *) l->data)->name;
label = ((GnomeThemeCursorInfo *) l->data)->readable_name;
}
if (!name)
continue; /* just in case... */
if (type == THEME_TYPE_CURSOR) {
thumbnail = ((GnomeThemeCursorInfo *) l->data)->thumbnail;
thumbnail = ((GnomeThemeCursorInfo *) theme)->thumbnail;
} else {
generator (l->data, thumb_cb, data, NULL);
generator (theme, thumb_cb, data, NULL);
}
gtk_list_store_insert_with_values (store, &i, 0,
COL_LABEL, label ? label : name,
COL_NAME, name,
COL_LABEL, theme->readable_name,
COL_NAME, theme->name,
COL_THUMBNAIL, thumbnail,
-1);

View file

@ -28,38 +28,17 @@
gboolean
theme_is_writable (const gpointer theme, ThemeType type)
{
GnomeThemeCommonInfo *info = theme;
GnomeVFSResult vfs_result;
GnomeVFSFileInfo *vfs_info;
const gchar *theme_path;
gboolean writable;
if (theme == NULL)
return FALSE;
switch (type) {
case THEME_TYPE_GTK:
case THEME_TYPE_WINDOW:
theme_path = ((const GnomeThemeInfo *) theme)->path;
break;
case THEME_TYPE_ICON:
theme_path = ((const GnomeThemeIconInfo *) theme)->path;
break;
case THEME_TYPE_CURSOR:
theme_path = ((const GnomeThemeCursorInfo *) theme)->path;
break;
case THEME_TYPE_META:
theme_path = ((const GnomeThemeMetaInfo *) theme)->path;
break;
default:
g_assert_not_reached ();
break;
}
if (theme_path == NULL)
if (info == NULL || info->path == NULL)
return FALSE;
vfs_info = gnome_vfs_file_info_new ();
vfs_result = gnome_vfs_get_file_info (theme_path,
vfs_result = gnome_vfs_get_file_info (info->path,
vfs_info,
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS);
@ -77,12 +56,12 @@ theme_delete (const gchar *name, ThemeType type)
{
gboolean rc;
GtkDialog *dialog;
gpointer theme;
gchar *theme_dir;
gint response;
GList *uri_list;
GnomeVFSResult result;
GnomeVFSURI *uri;
GnomeThemeCommonInfo *theme;
dialog = (GtkDialog *) gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
@ -97,28 +76,28 @@ theme_delete (const gchar *name, ThemeType type)
switch (type) {
case THEME_TYPE_GTK:
theme = gnome_theme_info_find (name);
theme_dir = g_build_filename (((GnomeThemeInfo *) theme)->path, "gtk-2.0", NULL);
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (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);
theme = (GnomeThemeCommonInfo *) gnome_theme_icon_info_find (name);
theme_dir = g_path_get_dirname (theme->path);
break;
case THEME_TYPE_WINDOW:
theme = gnome_theme_info_find (name);
theme_dir = g_build_filename (((GnomeThemeInfo *) theme)->path, "metacity-1", NULL);
theme = (GnomeThemeCommonInfo *) gnome_theme_info_find (name);
theme_dir = g_build_filename (theme->path, "metacity-1", NULL);
break;
case THEME_TYPE_META:
theme = gnome_theme_meta_info_find (name);
theme_dir = g_strdup (((GnomeThemeMetaInfo *) theme)->path);
theme = (GnomeThemeCommonInfo *) gnome_theme_meta_info_find (name);
theme_dir = g_strdup (theme->path);
break;
case THEME_TYPE_CURSOR:
theme = gnome_theme_cursor_info_find (name);
theme_dir = g_build_filename (((GnomeThemeCursorInfo *) theme)->path, "cursors", NULL);
theme = (GnomeThemeCommonInfo *) gnome_theme_cursor_info_find (name);
theme_dir = g_build_filename (theme->path, "cursors", NULL);
break;
default: