modify the theme change callback to return more useful information and add
2007-06-07 Jens Granseuer <jensgr@gmx.net> * gnome-theme-info.c: (handle_change_signal), (gnome_theme_is_writable), (gnome_theme_info_register_theme_change): * gnome-theme-info.h: modify the theme change callback to return more useful information and add a function to determine whether a given theme is writable svn path=/trunk/; revision=7703
This commit is contained in:
parent
b8981e28cf
commit
7144393cbc
3 changed files with 66 additions and 16 deletions
|
@ -1,3 +1,13 @@
|
|||
2007-06-07 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
* gnome-theme-info.c: (handle_change_signal),
|
||||
(gnome_theme_is_writable),
|
||||
(gnome_theme_info_register_theme_change):
|
||||
* gnome-theme-info.h:
|
||||
modify the theme change callback to return more useful
|
||||
information and add a function to determine whether a given
|
||||
theme is writable
|
||||
|
||||
2007-06-06 Jens Granseuer <jensgr@gmx.net>
|
||||
|
||||
* Bonobo_Control_Capplet_generic.oaf.in:
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
typedef struct _ThemeCallbackData
|
||||
{
|
||||
GFunc func;
|
||||
ThemeChangedCallback func;
|
||||
gpointer data;
|
||||
} ThemeCallbackData;
|
||||
|
||||
|
@ -375,23 +375,15 @@ handle_change_signal (GnomeThemeType type,
|
|||
gchar *type_str = NULL;
|
||||
gchar *element_str = NULL;
|
||||
#endif
|
||||
gchar *uri = NULL;
|
||||
GList *list;
|
||||
|
||||
if (initting)
|
||||
return;
|
||||
|
||||
if (type == GNOME_THEME_TYPE_REGULAR)
|
||||
uri = ((GnomeThemeInfo *)theme)->path;
|
||||
else if (type == GNOME_THEME_TYPE_METATHEME)
|
||||
uri = ((GnomeThemeMetaInfo *)theme)->path;
|
||||
else if (type == GNOME_THEME_TYPE_ICON)
|
||||
uri = ((GnomeThemeIconInfo *)theme)->path;
|
||||
|
||||
for (list = callbacks; list; list = list->next)
|
||||
{
|
||||
ThemeCallbackData *callback_data = list->data;
|
||||
(* callback_data->func) (uri, callback_data->data);
|
||||
(* callback_data->func) (type, theme, change_type, element, callback_data->data);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -1279,7 +1271,6 @@ gnome_theme_info_find_by_uri (const gchar *theme_uri)
|
|||
return g_hash_table_lookup (theme_hash_by_uri, theme_uri);
|
||||
}
|
||||
|
||||
|
||||
/* Icon themes */
|
||||
GnomeThemeIconInfo *
|
||||
gnome_theme_icon_info_new (void)
|
||||
|
@ -1471,8 +1462,50 @@ gnome_theme_meta_info_compare (GnomeThemeMetaInfo *a,
|
|||
return safe_strcmp (a->background_image, b->background_image);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnome_theme_is_writable (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 = ((GnomeThemeInfo *) theme)->path;
|
||||
break;
|
||||
case GNOME_THEME_TYPE_ICON:
|
||||
theme_path = ((GnomeThemeIconInfo *) theme)->path;
|
||||
break;
|
||||
case GNOME_THEME_TYPE_METATHEME:
|
||||
theme_path = ((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 (GFunc func,
|
||||
gnome_theme_info_register_theme_change (ThemeChangedCallback func,
|
||||
gpointer data)
|
||||
{
|
||||
ThemeCallbackData *callback_data;
|
||||
|
|
|
@ -56,7 +56,6 @@ struct _GnomeThemeInfo
|
|||
guint has_gtk : 1;
|
||||
guint has_keybinding : 1;
|
||||
guint has_metacity : 1;
|
||||
guint user_writable : 1;
|
||||
};
|
||||
|
||||
typedef struct _GnomeThemeIconInfo GnomeThemeIconInfo;
|
||||
|
@ -90,6 +89,12 @@ struct _GnomeThemeMetaInfo
|
|||
gchar *background_image;
|
||||
};
|
||||
|
||||
typedef void (* ThemeChangedCallback) (GnomeThemeType type,
|
||||
gpointer theme,
|
||||
GnomeThemeChangeType change_type,
|
||||
GnomeThemeElement element,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
/* Generic Themes */
|
||||
GnomeThemeInfo *gnome_theme_info_new (void);
|
||||
|
@ -121,8 +126,10 @@ gint gnome_theme_meta_info_compare (GnomeThemeMetaInfo *
|
|||
GnomeThemeMetaInfo *gnome_theme_read_meta_theme (GnomeVFSURI *meta_theme_uri);
|
||||
|
||||
/* Other */
|
||||
void gnome_theme_init (gboolean *monitor_not_added);
|
||||
void gnome_theme_info_register_theme_change (GFunc func,
|
||||
gpointer data);
|
||||
void gnome_theme_init (gboolean *monitor_not_added);
|
||||
void gnome_theme_info_register_theme_change (ThemeChangedCallback func,
|
||||
gpointer data);
|
||||
gboolean gnome_theme_is_writable (gpointer theme,
|
||||
GnomeThemeType type);
|
||||
|
||||
#endif /* GNOME_THEME_INFO_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue