Mercurial > pidgin
changeset 32728:5050da3d9c95
Add a directory probe to theme loaders. The default just checks for
$dir/purple/$type as the theme manager currently does.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 03 Mar 2012 06:39:49 +0000 |
parents | 089acf3a8aa1 |
children | b276701931d9 |
files | libpurple/theme-loader.c libpurple/theme-loader.h |
diffstat | 2 files changed, 40 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/theme-loader.c Tue Feb 28 07:10:15 2012 +0000 +++ b/libpurple/theme-loader.c Sat Mar 03 06:39:49 2012 +0000 @@ -85,6 +85,21 @@ } } +static gboolean +purple_theme_loader_probe_directory(PurpleThemeLoader *loader, const gchar *dir) +{ + const gchar *type = purple_theme_loader_get_type_string(loader); + char *themedir; + gboolean result; + + /* Checks for directory as $root/purple/$type */ + themedir = g_build_filename(dir, "purple", type, NULL); + result = g_file_test(themedir, G_FILE_TEST_IS_DIR); + g_free(themedir); + + return result; +} + static void purple_theme_loader_finalize(GObject *obj) { @@ -175,3 +190,13 @@ { return PURPLE_THEME_LOADER_GET_CLASS(loader)->purple_theme_loader_build(dir); } + +gboolean +purple_theme_loader_probe(PurpleThemeLoader *loader, const gchar *dir) +{ + if (PURPLE_THEME_LOADER_GET_CLASS(loader)->probe_directory != NULL) + return PURPLE_THEME_LOADER_GET_CLASS(loader)->probe_directory(dir); + else + return purple_theme_loader_probe_directory(loader, dir); +} +
--- a/libpurple/theme-loader.h Tue Feb 28 07:10:15 2012 +0000 +++ b/libpurple/theme-loader.h Sat Mar 03 06:39:49 2012 +0000 @@ -56,6 +56,7 @@ { GObjectClass parent_class; PurpleTheme *((*purple_theme_loader_build)(const gchar*)); + gboolean (*probe_directory)(const gchar *); }; /**************************************************************************/ @@ -88,5 +89,19 @@ */ PurpleTheme *purple_theme_loader_build(PurpleThemeLoader *loader, const gchar *dir); +/** + * Probes a directory to see if it might possibly contain a theme + * + * This function might only check for obvious files or directory structure. + * Loading of a theme may fail for other reasons. + * The default prober checks for $dir/purple/$type. + * + * @param loader The theme loader + * @param dir The directory that may contain the theme + * + * @returns TRUE if the directory appears to contain a theme, FALSE otherwise. + */ +gboolean purple_theme_loader_probe(PurpleThemeLoader *loader, const gchar *dir); + G_END_DECLS #endif /* PURPLE_THEME_LOADER_H */