diff options
author | Juan A. Suarez Romero <jasuarez@igalia.com> | 2010-03-01 10:53:41 +0100 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2010-03-01 10:53:41 +0100 |
commit | 41b83c0b57de025aaeeaff78b40eda2997722a66 (patch) | |
tree | f88506cccf37df3500559494048f2eb8e4e7bb54 | |
parent | 796ba811851dc80307af0a2163c3a484eeb8ee0b (diff) | |
download | grilo-41b83c0b57de025aaeeaff78b40eda2997722a66.tar.gz |
Return const when getting information from plugins
In most cases, users do not need a dupped string when getting information from
a plugin (author, description, etc.)
-rw-r--r-- | src/grl-media-plugin.c | 70 | ||||
-rw-r--r-- | src/grl-media-plugin.h | 14 | ||||
-rw-r--r-- | tools/grilo-test-ui/main.c | 3 |
3 files changed, 36 insertions, 51 deletions
diff --git a/src/grl-media-plugin.c b/src/grl-media-plugin.c index c29ad34..fc88b01 100644 --- a/src/grl-media-plugin.c +++ b/src/grl-media-plugin.c @@ -85,16 +85,14 @@ grl_media_plugin_set_plugin_info (GrlMediaPlugin *plugin, * * Get the id of the plugin * - * Returns: (transfer full): the id of the @plugin + * Returns: (transfer none): the id of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_id (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->id) - r = g_strdup (plugin->priv->info->id); - return r; + + return plugin->priv->info->id; } /** @@ -103,16 +101,14 @@ grl_media_plugin_get_id (GrlMediaPlugin *plugin) * * Get the name of the plugin * - * Returns: (transfer full): the name of the @plugin + * Returns: (transfer none): the name of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_name (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->name) - r = g_strdup (plugin->priv->info->name); - return r; + + return plugin->priv->info->name; } /** @@ -121,16 +117,14 @@ grl_media_plugin_get_name (GrlMediaPlugin *plugin) * * Get the description of the plugin * - * Returns: (transfer full): the description of the @plugin + * Returns: (transfer none): the description of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_description (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->desc) - r = g_strdup (plugin->priv->info->desc); - return r; + + return plugin->priv->info->desc; } /** @@ -139,16 +133,14 @@ grl_media_plugin_get_description (GrlMediaPlugin *plugin) * * Get the version of the plugin * - * Returns: (transfer full): the version of the @plugin + * Returns: (transfer none): the version of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_version (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->version) - r = g_strdup (plugin->priv->info->version); - return r; + + return plugin->priv->info->version; } /** @@ -157,16 +149,14 @@ grl_media_plugin_get_version (GrlMediaPlugin *plugin) * * Get the license of the plugin * - * Returns: (transfer full): the license of the @plugin + * Returns: (transfer none): the license of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_license (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->license) - r = g_strdup (plugin->priv->info->license); - return r; + + return plugin->priv->info->license; } @@ -176,16 +166,14 @@ grl_media_plugin_get_license (GrlMediaPlugin *plugin) * * Get the author of the plugin * - * Returns: (transfer full): the author of the @plugin + * Returns: (transfer none): the author of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_author (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->author) - r = g_strdup (plugin->priv->info->author); - return r; + + return plugin->priv->info->author; } /** @@ -194,16 +182,14 @@ grl_media_plugin_get_author (GrlMediaPlugin *plugin) * * Get the site of the plugin * - * Returns: (transfer full): the site of the @plugin + * Returns: (transfer none): the site of the @plugin */ -gchar * +const gchar * grl_media_plugin_get_site (GrlMediaPlugin *plugin) { g_return_val_if_fail (GRL_IS_MEDIA_PLUGIN (plugin), NULL); - gchar *r = NULL; - if (plugin->priv->info->site) - r = g_strdup (plugin->priv->info->site); - return r; + + return plugin->priv->info->site; } /** diff --git a/src/grl-media-plugin.h b/src/grl-media-plugin.h index aa6359a..4b6e898 100644 --- a/src/grl-media-plugin.h +++ b/src/grl-media-plugin.h @@ -87,13 +87,13 @@ G_BEGIN_DECLS GType grl_media_plugin_get_type (void); -gchar *grl_media_plugin_get_id (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_name (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_description (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_version (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_license (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_author (GrlMediaPlugin *plugin); -gchar *grl_media_plugin_get_site (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_id (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_name (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_description (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_version (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_license (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_author (GrlMediaPlugin *plugin); +const gchar *grl_media_plugin_get_site (GrlMediaPlugin *plugin); gint grl_media_plugin_get_rank (GrlMediaPlugin *plugin); G_END_DECLS diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c index c7394be..ccf5d71 100644 --- a/tools/grilo-test-ui/main.c +++ b/tools/grilo-test-ui/main.c @@ -1356,10 +1356,9 @@ show_plugins () GRL_OP_BROWSE, FALSE); while (sources[i]) { - gchar *id, *name; + gchar *name; GdkPixbuf *icon; icon = load_icon (GTK_STOCK_DIRECTORY); - id = grl_media_plugin_get_id (sources[i]); name = g_strdup (grl_metadata_source_get_name (GRL_METADATA_SOURCE (sources[i]))); g_debug ("Loaded source: '%s'", name); |