pidgin: 232d6a40: Add a directory probe to theme loaders. ...

qulogic at pidgin.im qulogic at pidgin.im
Sat Mar 3 22:55:49 EST 2012


----------------------------------------------------------------------
Revision: 232d6a40fb096ab76c93c2a12bf3700ffa560e95
Parent:   4a9f0f93b98716d418d173e820f8638de94324f4
Author:   qulogic at pidgin.im
Date:     03/03/12 01:39:49
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/232d6a40fb096ab76c93c2a12bf3700ffa560e95

Changelog: 

Add a directory probe to theme loaders. The default just checks for
$dir/purple/$type as the theme manager currently does.

Changes against parent 4a9f0f93b98716d418d173e820f8638de94324f4

  patched  libpurple/theme-loader.c
  patched  libpurple/theme-loader.h

-------------- next part --------------
============================================================
--- libpurple/theme-loader.c	2d3bb6af1b849f019ff0921b3e9b0ec42f1463ae
+++ libpurple/theme-loader.c	74c91c85b687e131a45af02ecf590b5f5b169cf5
@@ -85,6 +85,21 @@ purple_theme_loader_set_property(GObject
 	}
 }
 
+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 @@ purple_theme_loader_build(PurpleThemeLoa
 {
 	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);
+}
+
============================================================
--- libpurple/theme-loader.h	eb80046e3c0c90a69f86f073bdfe6841a14cf654
+++ libpurple/theme-loader.h	1ce470e85cf5bef827f6487aaf82393f49ac5850
@@ -56,6 +56,7 @@ struct _PurpleThemeLoaderClass
 {
 	GObjectClass parent_class;
 	PurpleTheme *((*purple_theme_loader_build)(const gchar*));
+	gboolean (*probe_directory)(const gchar *);
 };
 
 /**************************************************************************/
@@ -88,5 +89,19 @@ PurpleTheme *purple_theme_loader_build(P
  */
 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 */


More information about the Commits mailing list