diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2009-06-22 22:06:29 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2009-06-22 22:06:29 +0800 |
commit | 69989d77d169f08d9d5d702cd22f3cda4c2b2ce2 (patch) | |
tree | 98cb2136f563537675e8e3bcbdf5f1be5b81d0e5 | |
parent | 4c782007bf100a3820dc265bca6fceda17991a77 (diff) | |
download | gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar.gz gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar.bz2 gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar.lz gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar.xz gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.tar.zst gsoc2013-empathy-69989d77d169f08d9d5d702cd22f3cda4c2b2ce2.zip |
Add helper API to read info.plist file of an adium theme. Will be useful for upcoming theme selector
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.c | 50 | ||||
-rw-r--r-- | libempathy-gtk/empathy-theme-adium.h | 4 |
2 files changed, 42 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index 6a2f0610b..20d4797cf 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -769,7 +769,8 @@ empathy_theme_adium_class_init (EmpathyThemeAdiumClass *klass) "Data for the adium theme", EMPATHY_TYPE_ADIUM_DATA, G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); g_type_class_add_private (object_class, sizeof (EmpathyThemeAdiumPriv)); @@ -824,6 +825,27 @@ empathy_adium_path_is_valid (const gchar *path) return ret; } +GHashTable * +empathy_adium_info_new (const gchar *path) +{ + gchar *file; + GValue *value; + GHashTable *info = NULL; + + g_return_val_if_fail (empathy_adium_path_is_valid (path), NULL); + + file = g_build_filename (path, "Contents", "Info.plist", NULL); + value = empathy_plist_parse_from_file (file); + g_free (file); + + if (value) { + info = g_value_dup_boxed (value); + tp_g_value_slice_free (value); + } + + return info; +} + GType empathy_adium_data_get_type (void) { @@ -840,7 +862,7 @@ empathy_adium_data_get_type (void) } EmpathyAdiumData * -empathy_adium_data_new (const gchar *path) +empathy_adium_data_new_with_info (const gchar *path, GHashTable *info) { EmpathyAdiumData *data; gchar *file; @@ -853,7 +875,6 @@ empathy_adium_data_new (const gchar *path) gchar *css_path; guint len = 0; guint i = 0; - GValue *value; g_return_val_if_fail (empathy_adium_path_is_valid (path), NULL); @@ -862,6 +883,7 @@ empathy_adium_data_new (const gchar *path) data->path = g_strdup (path); data->basedir = g_strconcat (path, G_DIR_SEPARATOR_S "Contents" G_DIR_SEPARATOR_S "Resources" G_DIR_SEPARATOR_S, NULL); + data->info = g_hash_table_ref (info); /* Load html files */ file = g_build_filename (data->basedir, "Incoming", "Content.html", NULL); @@ -926,15 +948,6 @@ empathy_adium_data_new (const gchar *path) len = g_strv_length (strv); } - /* Load Info.plist into a hash table */ - file = g_build_filename (data->path, "Contents", "Info.plist", NULL); - value = empathy_plist_parse_from_file (file); - g_free (file); - if (value) { - data->info = g_value_dup_boxed (value); - tp_g_value_slice_free (value); - } - /* Replace %@ with the needed information in the template html. */ string = g_string_sized_new (template_len); g_string_append (string, strv[i++]); @@ -975,6 +988,19 @@ empathy_adium_data_new (const gchar *path) } EmpathyAdiumData * +empathy_adium_data_new (const gchar *path) +{ + EmpathyAdiumData *data; + GHashTable *info; + + info = empathy_adium_info_new (path); + data = empathy_adium_data_new_with_info (path, info); + g_hash_table_unref (info); + + return data; +} + +EmpathyAdiumData * empathy_adium_data_ref (EmpathyAdiumData *data) { g_return_val_if_fail (data != NULL, NULL); diff --git a/libempathy-gtk/empathy-theme-adium.h b/libempathy-gtk/empathy-theme-adium.h index 868703073..a8ed19de4 100644 --- a/libempathy-gtk/empathy-theme-adium.h +++ b/libempathy-gtk/empathy-theme-adium.h @@ -52,15 +52,19 @@ GType empathy_theme_adium_get_type (void) G_GNUC_CONST; EmpathyThemeAdium *empathy_theme_adium_new (EmpathyAdiumData *data); gboolean empathy_adium_path_is_valid (const gchar *path); +GHashTable *empathy_adium_info_new (const gchar *path); #define EMPATHY_TYPE_ADIUM_DATA (empathy_adium_data_get_type ()) GType empathy_adium_data_get_type (void) G_GNUC_CONST; EmpathyAdiumData *empathy_adium_data_new (const gchar *path); +EmpathyAdiumData *empathy_adium_data_new_with_info (const gchar *path, + GHashTable *info); EmpathyAdiumData *empathy_adium_data_ref (EmpathyAdiumData *data); void empathy_adium_data_unref (EmpathyAdiumData *data); GHashTable *empathy_adium_data_get_info (EmpathyAdiumData *data); const gchar *empathy_adium_data_get_path (EmpathyAdiumData *data); + G_END_DECLS #endif /* __EMPATHY_THEME_ADIUM_H__ */ |