After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 671934 - Added peas_plugin_info_get_external_data
Added peas_plugin_info_get_external_data
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2012-03-12 19:21 UTC by jessevdk@gmail.com
Modified: 2012-03-29 01:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Added peas_plugin_info_get_external_data (3.38 KB, patch)
2012-03-12 19:21 UTC, jessevdk@gmail.com
none Details | Review
Added peas_plugin_info_get_external_data (4.24 KB, patch)
2012-03-18 19:26 UTC, jessevdk@gmail.com
none Details | Review
Added peas_plugin_info_get_external_data (5.15 KB, patch)
2012-03-18 19:31 UTC, jessevdk@gmail.com
none Details | Review
external data (5.20 KB, patch)
2012-03-23 07:46 UTC, Ignacio Casal Quinteiro (nacho)
none Details | Review
Added peas_plugin_info_get_external_data() (5.00 KB, patch)
2012-03-23 09:11 UTC, Garrett Regier
reviewed Details | Review

Description jessevdk@gmail.com 2012-03-12 19:21:13 UTC
This patch adds peas_plugin_info_get_external_data which allows
users to retrieve external data from a plugin info file. This
external data is composed of keys prefixed with X- (as is customary
in free desktop entries).
Comment 1 jessevdk@gmail.com 2012-03-12 19:21:15 UTC
Created attachment 209525 [details] [review]
Added peas_plugin_info_get_external_data
Comment 2 Steve Frécinaux 2012-03-13 18:41:49 UTC
I like the idea but I'm not very fond of keeping all the GKeyFiles around just for X- key usages as I'm pretty sure not many people will make use of that feature.
Comment 3 Ignacio Casal Quinteiro (nacho) 2012-03-13 19:47:56 UTC
Probably the solution would be to have a hashtable. But is it worth? Is it so expensive keeping the KeyFile?
Comment 4 jessevdk@gmail.com 2012-03-14 08:20:22 UTC
I also don't see the problem keeping the key file around. It's not going to be big, and anyway you don't have thousands of plugins. The other thing is a hash table, but I found it lame that I had to iterate again over all the keys to match each key and construct the hash. Seemed easier (and more efficient) to keep the key file around.
Comment 5 Steve Frécinaux 2012-03-15 12:47:11 UTC
Well, wouldn't it be possible to just keep the keyfile only if there is at least one X- key?

The thing is, if we keep the keyfile around, then there is no need to populate the PluginInfo struct anyhow, we could just fetch the values straight from the keyfile, especially for string-only values like copyright, help uri and so on which are only ever going to be used for about boxes anyway.

I honnestly don't know how gkeyfile stores its data and how big it is in memory.
Comment 6 jessevdk@gmail.com 2012-03-15 13:27:11 UTC
I don't really care about the implementation so much to be honest. I can just implement whatever you prefer. You would like a hashtable?
Comment 7 jessevdk@gmail.com 2012-03-18 09:30:29 UTC
Ping
Comment 8 jessevdk@gmail.com 2012-03-18 19:26:09 UTC
Created attachment 210056 [details] [review]
Added peas_plugin_info_get_external_data
Comment 9 jessevdk@gmail.com 2012-03-18 19:31:45 UTC
Created attachment 210057 [details] [review]
Added peas_plugin_info_get_external_data
Comment 10 jessevdk@gmail.com 2012-03-18 19:32:58 UTC
Latest implements external data with a hash table and adds a simple test for external data to the plugin-info test.
Comment 11 Ignacio Casal Quinteiro (nacho) 2012-03-19 09:58:53 UTC
Review of attachment 210057 [details] [review]:

Patch looks good to me. See the minor comment though.

::: libpeas/peas-plugin-info.c
@@ +97,3 @@
 
+  if (info->external_data != NULL)
+    g_hash_table_destroy (info->external_data);

use unref instead of destroy
Comment 12 Garrett Regier 2012-03-19 15:16:59 UTC
Review of attachment 210057 [details] [review]:

::: libpeas/peas-plugin-info.c
@@ +260,3 @@
+  keys = g_key_file_get_keys (plugin_file, "Plugin", NULL, NULL);
+
+  for (keysptr = keys; keysptr && *keysptr; ++keysptr)

keysptr will never be NULL

@@ +262,3 @@
+  for (keysptr = keys; keysptr && *keysptr; ++keysptr)
+    {
+      if (g_str_has_prefix (*keysptr, "X-"))

Use a continue to avoid the large indent

@@ +268,3 @@
+                                                         g_str_equal,
+                                                         (GDestroyNotify)g_free,
+      if (g_str_has_prefix (*keysptr, "X-"))

Space after casts

@@ +279,3 @@
+    }
+
+                                                         (GDestroyNotify)g_free);

keys will never be NULL

@@ +745,3 @@
+/**
+ * peas_plugin_info_get_external_data:
+ * @info: a #PeasPluginInfo

"A #PeasPluginInfo."

@@ +746,3 @@
+ * peas_plugin_info_get_external_data:
+ * @info: a #PeasPluginInfo
+ * @key: a key

"The key to lookup."

@@ +751,3 @@
+ *
+ * External info is specified in the plugin info file prefixed with X-. For
+ * @key: a key

X-Peas = 1 is invalid GKeyFile syntax, use X-Peas=1 instead

@@ +756,3 @@
+ * in the file.
+ *
+ * Gets external info specified for the plugin.

Use external data in comment

::: tests/libpeas/plugin-info.c
@@ +92,3 @@
   g_assert_cmpstr (authors[0], ==, "Garrett Regier");
+
+  g_assert_cmpstr (peas_plugin_info_get_external_data (info, "External"), ==, "external data");

Also test X-External
Comment 13 Ignacio Casal Quinteiro (nacho) 2012-03-23 07:46:00 UTC
Created attachment 210396 [details] [review]
external data

There it goes with the comments fixed. If it is ok please push it and make a new release :) We are already suppose to be in hardcode freeze
Comment 14 jessevdk@gmail.com 2012-03-23 08:49:58 UTC
Thanks for picking this up Ignacio, looks good to me.
Comment 15 Garrett Regier 2012-03-23 09:11:22 UTC
Created attachment 210399 [details] [review]
Added peas_plugin_info_get_external_data()

External info was still mentioned multiple times instead of external data.
Comment 16 Ignacio Casal Quinteiro (nacho) 2012-03-23 09:41:17 UTC
Review of attachment 210399 [details] [review]:

Just one comment, feel free to push

::: libpeas/peas-plugin-info.c
@@ +257,3 @@
     info->hidden = b;
 
+  strv = g_key_file_get_keys (plugin_file, "Plugin", NULL, NULL);

why strv? IMHO it is more understandable keys...
Comment 17 Garrett Regier 2012-03-29 01:10:10 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.