From 194de56db96d9773e8be654d80e9664848bae432 Mon Sep 17 00:00:00 2001 From: Jens Granseuer Date: Sun, 28 Oct 2007 22:33:18 +0000 Subject: [PATCH] simplify code thanks to the new unified theme type 2007-10-28 Jens Granseuer * 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 --- capplets/appearance/ChangeLog | 6 ++++ capplets/appearance/appearance-style.c | 24 +++---------- capplets/appearance/theme-util.c | 49 ++++++++------------------ 3 files changed, 25 insertions(+), 54 deletions(-) diff --git a/capplets/appearance/ChangeLog b/capplets/appearance/ChangeLog index c349b732c..731100de4 100644 --- a/capplets/appearance/ChangeLog +++ b/capplets/appearance/ChangeLog @@ -1,3 +1,9 @@ +2007-10-28 Jens Granseuer + + * 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 * appearance-style.c: (changed_on_disk_cb): add support for live cursor diff --git a/capplets/appearance/appearance-style.c b/capplets/appearance/appearance-style.c index 7f2df9ea9..ba5ed467f 100644 --- a/capplets/appearance/appearance-style.c +++ b/capplets/appearance/appearance-style.c @@ -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); diff --git a/capplets/appearance/theme-util.c b/capplets/appearance/theme-util.c index f34ce4f97..c253f5065 100644 --- a/capplets/appearance/theme-util.c +++ b/capplets/appearance/theme-util.c @@ -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: