diff --git a/capplets/appearance/ChangeLog b/capplets/appearance/ChangeLog index 5f54fd841..2bbc21296 100644 --- a/capplets/appearance/ChangeLog +++ b/capplets/appearance/ChangeLog @@ -1,3 +1,12 @@ +2007-10-27 Jens Granseuer + + * theme-util.c: (theme_is_writable): + * theme-util.h: move function here from common/ + + * appearance-style.c: (gtk_theme_changed), (window_theme_changed), + (icon_theme_changed), (cursor_theme_changed): + * appearance-themes.c: (theme_selection_changed_cb): adapt callers + 2007-10-27 Jens Granseuer * theme-util.c: (theme_delete): if the parent directory is empty after diff --git a/capplets/appearance/appearance-style.c b/capplets/appearance/appearance-style.c index 7d4c64a59..d8c5b1d88 100644 --- a/capplets/appearance/appearance-style.c +++ b/capplets/appearance/appearance-style.c @@ -328,7 +328,7 @@ gtk_theme_changed (GConfPropertyEditor *peditor, } gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "gtk_themes_delete"), - gnome_theme_is_writable (theme, GNOME_THEME_TYPE_REGULAR)); + theme_is_writable (theme, THEME_TYPE_GTK)); } static void @@ -344,7 +344,7 @@ window_theme_changed (GConfPropertyEditor *peditor, theme = gnome_theme_info_find (name); gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "window_themes_delete"), - gnome_theme_is_writable (theme, GNOME_THEME_TYPE_REGULAR)); + theme_is_writable (theme, THEME_TYPE_WINDOW)); } static void @@ -360,7 +360,7 @@ icon_theme_changed (GConfPropertyEditor *peditor, theme = gnome_theme_icon_info_find (name); gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "icon_themes_delete"), - gnome_theme_is_writable (theme, GNOME_THEME_TYPE_ICON)); + theme_is_writable (theme, THEME_TYPE_ICON)); } #ifdef HAVE_XCURSOR @@ -456,7 +456,7 @@ cursor_theme_changed (GConfPropertyEditor *peditor, #endif gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "cursor_themes_delete"), - gnome_theme_is_writable (theme, GNOME_THEME_TYPE_CURSOR)); + theme_is_writable (theme, THEME_TYPE_CURSOR)); } diff --git a/capplets/appearance/appearance-themes.c b/capplets/appearance/appearance-themes.c index 7435d3525..e790d4384 100644 --- a/capplets/appearance/appearance-themes.c +++ b/capplets/appearance/appearance-themes.c @@ -597,7 +597,7 @@ theme_selection_changed_cb (GtkWidget *icon_view, AppearanceData *data) } gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "theme_delete"), - gnome_theme_is_writable (theme, GNOME_THEME_TYPE_METATHEME)); + theme_is_writable (theme, THEME_TYPE_META)); gtk_widget_set_sensitive (glade_xml_get_widget (data->xml, "theme_save"), is_custom); } diff --git a/capplets/appearance/theme-util.c b/capplets/appearance/theme-util.c index fc6dbd942..f34ce4f97 100644 --- a/capplets/appearance/theme-util.c +++ b/capplets/appearance/theme-util.c @@ -25,6 +25,52 @@ #include #include +gboolean +theme_is_writable (const gpointer theme, ThemeType type) +{ + 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) + return FALSE; + + vfs_info = gnome_vfs_file_info_new (); + vfs_result = gnome_vfs_get_file_info (theme_path, + vfs_info, + GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS); + + writable = ((vfs_result == GNOME_VFS_OK) && + (vfs_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) && + (vfs_info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE)); + + gnome_vfs_file_info_unref (vfs_info); + + return writable; +} gboolean theme_delete (const gchar *name, ThemeType type) diff --git a/capplets/appearance/theme-util.h b/capplets/appearance/theme-util.h index aa67cd970..1f9d982e1 100644 --- a/capplets/appearance/theme-util.h +++ b/capplets/appearance/theme-util.h @@ -46,6 +46,8 @@ typedef enum { THEME_TYPE_CURSOR } ThemeType; +gboolean theme_is_writable (const gpointer theme, ThemeType type); gboolean theme_delete (const gchar *name, ThemeType type); + gboolean theme_model_iter_last (GtkTreeModel *model, GtkTreeIter *iter); gboolean theme_find_in_model (GtkTreeModel *model, const gchar *name, GtkTreeIter *iter); diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index ff416607a..b09304d71 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,8 @@ +2007-10-27 Jens Granseuer + + * gnome-theme-info.c (gnome_theme_is_writable): + * gnome-theme-info.h: move this function to the appearance capplet + 2007-10-25 Jens Granseuer * gnome-theme-info.c: (gnome_theme_init): revert this part from the diff --git a/capplets/common/gnome-theme-info.c b/capplets/common/gnome-theme-info.c index 68afb0fec..1c3487549 100644 --- a/capplets/common/gnome-theme-info.c +++ b/capplets/common/gnome-theme-info.c @@ -1697,51 +1697,6 @@ gnome_theme_meta_info_compare (GnomeThemeMetaInfo *a, return safe_strcmp (a->background_image, b->background_image); } -gboolean -gnome_theme_is_writable (const gpointer theme, GnomeThemeType type) { - GnomeVFSResult vfs_result; - GnomeVFSFileInfo *vfs_info; - const gchar *theme_path; - gboolean writable; - - if (theme == NULL) - return FALSE; - - switch (type) { - case GNOME_THEME_TYPE_REGULAR: - theme_path = ((const GnomeThemeInfo *) theme)->path; - break; - case GNOME_THEME_TYPE_ICON: - theme_path = ((const GnomeThemeIconInfo *) theme)->path; - break; - case GNOME_THEME_TYPE_CURSOR: - theme_path = ((const GnomeThemeCursorInfo *) theme)->path; - break; - case GNOME_THEME_TYPE_METATHEME: - theme_path = ((const GnomeThemeMetaInfo *) theme)->path; - break; - default: - g_assert_not_reached (); - break; - } - - if (theme_path == NULL) - return FALSE; - - vfs_info = gnome_vfs_file_info_new (); - vfs_result = gnome_vfs_get_file_info (theme_path, - vfs_info, - GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS); - - writable = ((vfs_result == GNOME_VFS_OK) && - (vfs_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_ACCESS) && - (vfs_info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE)); - - gnome_vfs_file_info_unref (vfs_info); - - return writable; -} - void gnome_theme_info_register_theme_change (ThemeChangedCallback func, gpointer data) diff --git a/capplets/common/gnome-theme-info.h b/capplets/common/gnome-theme-info.h index 9e7ba97c3..d12ee2893 100644 --- a/capplets/common/gnome-theme-info.h +++ b/capplets/common/gnome-theme-info.h @@ -164,8 +164,6 @@ GnomeThemeMetaInfo *gnome_theme_read_meta_theme (GnomeVFSURI *meta_th void gnome_theme_init (gboolean *monitor_not_added); void gnome_theme_info_register_theme_change (ThemeChangedCallback func, gpointer data); -gboolean gnome_theme_is_writable (const gpointer theme, - GnomeThemeType type); gboolean gnome_theme_color_scheme_parse (const gchar *scheme, GdkColor *colors);