move function here from common/

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

	* 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  <jensgr@gmx.net>

	* gnome-theme-info.c (gnome_theme_is_writable):
	* gnome-theme-info.h: move this function to the appearance capplet

svn path=/trunk/; revision=8211
This commit is contained in:
Jens Granseuer 2007-10-27 11:29:11 +00:00 committed by Jens Granseuer
parent 21b740a43f
commit 2ba498e0c2
8 changed files with 67 additions and 52 deletions

View file

@ -1,3 +1,12 @@
2007-10-27 Jens Granseuer <jensgr@gmx.net>
* 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 <jensgr@gmx.net>
* theme-util.c: (theme_delete): if the parent directory is empty after

View file

@ -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));
}

View file

@ -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);
}

View file

@ -25,6 +25,52 @@
#include <glib/gi18n.h>
#include <string.h>
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)

View file

@ -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);

View file

@ -1,3 +1,8 @@
2007-10-27 Jens Granseuer <jensgr@gmx.net>
* gnome-theme-info.c (gnome_theme_is_writable):
* gnome-theme-info.h: move this function to the appearance capplet
2007-10-25 Jens Granseuer <jensgr@gmx.net>
* gnome-theme-info.c: (gnome_theme_init): revert this part from the

View file

@ -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)

View file

@ -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);