]> git.0d.be Git - empathy.git/commitdiff
Add helper API to read info.plist file of an adium theme. Will be useful for upcoming...
authorXavier Claessens <xclaesse@gmail.com>
Mon, 22 Jun 2009 14:06:29 +0000 (16:06 +0200)
committerXavier Claessens <xclaesse@gmail.com>
Mon, 22 Jun 2009 14:06:29 +0000 (16:06 +0200)
libempathy-gtk/empathy-theme-adium.c
libempathy-gtk/empathy-theme-adium.h

index 6a2f0610b475f2465875fe6de621000e29248d68..20d4797cf2933f0e663ab5087ab14f46ec0ba590 100644 (file)
@@ -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++]);
@@ -974,6 +987,19 @@ empathy_adium_data_new (const gchar *path)
        return data;
 }
 
+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)
 {
index 8687030730be37a3ca89917ee1c3df76bb80f9f8..a8ed19de40bd7f762f7d20a1f582fb02a945bc97 100644 (file)
@@ -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__ */