From 7cfbc97f12a8c1bae86b2e1b6a1f573ff5a9c23b Mon Sep 17 00:00:00 2001 From: Jonathan Matthew Date: Tue, 19 Jul 2016 22:06:47 +1000 Subject: [PATCH] file-helpers: add helper for constructing resource paths for plugins --- lib/rb-file-helpers.c | 24 ++++++++++++++++++++++++ lib/rb-file-helpers.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/lib/rb-file-helpers.c b/lib/rb-file-helpers.c index f5454ee5e..dbe48af30 100644 --- a/lib/rb-file-helpers.c +++ b/lib/rb-file-helpers.c @@ -290,6 +290,30 @@ rb_find_plugin_data_file (GObject *object, const char *name) return ret; } +/** + * rb_find_plugin_resource: + * @plugin: the plugin object + * @name: name of the file to find + * + * Constructs a resource path for a plugin data file. + * + * Returns: allocated string containing the resource path + */ +char * +rb_find_plugin_resource (GObject *object, const char *name) +{ + PeasPluginInfo *info; + const char *plugin_name; + + g_object_get (object, "plugin-info", &info, NULL); + if (info == NULL) + return NULL; + + plugin_name = peas_plugin_info_get_module_name (info); + return g_strdup_printf ("/org/gnome/Rhythmbox/%s/%s", plugin_name, name); +} + + /** * rb_file_helpers_init: * @uninstalled: if %TRUE, search in source and build directories diff --git a/lib/rb-file-helpers.h b/lib/rb-file-helpers.h index cea76f328..606eeb31e 100644 --- a/lib/rb-file-helpers.h +++ b/lib/rb-file-helpers.h @@ -43,6 +43,8 @@ char * rb_find_user_data_file (const char *name); char * rb_find_user_cache_file (const char *name); char * rb_find_plugin_data_file (GObject *plugin, const char *name); +char * rb_find_plugin_resource (GObject *plugin, + const char *name); char * rb_canonicalise_uri (const char *uri);