Skip to content

Commit

Permalink
file-helpers: add helper for constructing resource paths for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Matthew committed Aug 10, 2016
1 parent 98f4920 commit 7cfbc97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/rb-file-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/rb-file-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 7cfbc97

Please sign in to comment.