[PATCH 2/2] test-ui: reload plugins functionality



Add a menu option for reloading all the available plugins. Now, in theory,
should be possible to reload a plugin in development process without
restarting the test-ui app.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez igalia com>
---
 tools/grilo-test-ui/main.c |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c
index e9f63cd..cc48998 100644
--- a/tools/grilo-test-ui/main.c
+++ b/tools/grilo-test-ui/main.c
@@ -171,6 +171,7 @@ static const gchar *ui_definition =
 " <menubar name='MainMenu'>"
 "  <menu name='FileMenu' action='FileMenuAction' >"
 "   <menuitem name='Authorize Flickr' action='AuthorizeFlickrAction' />"
+"   <menuitem name='Reload plugins' action='ReloadPluginsAction' />"
 "   <menuitem name='Quit' action='QuitAction' />"
 "  </menu>"
 " </menubar>"
@@ -182,10 +183,17 @@ static void quit_cb (GtkAction *action);
 static gchar *authorize_flickr (void);
 static void authorize_flickr_cb (GtkAction *action);
 
+static void reload_plugins_cb (GtkAction *action);
+static void reload_plugins (void);
+
 static GtkActionEntry entries[] = {
   { "FileMenuAction", NULL, "_File" },
-  { "AuthorizeFlickrAction", GTK_STOCK_CONNECT, "_Authorize Flickr", NULL, "AuthorizeFlickr", G_CALLBACK (authorize_flickr_cb)},
-  { "QuitAction", GTK_STOCK_QUIT, "_Quit", "<control>Q", "Quit", G_CALLBACK (quit_cb) }
+  { "AuthorizeFlickrAction", GTK_STOCK_CONNECT, "_Authorize Flickr", NULL,
+    "AuthorizeFlickr", G_CALLBACK (authorize_flickr_cb) },
+  { "ReloadPluginsAction", GTK_STOCK_REFRESH, "_Reload Plugins", "<control>R",
+    "ReloadPlugins", G_CALLBACK (reload_plugins_cb) },
+  { "QuitAction", GTK_STOCK_QUIT, "_Quit", "<control>Q",
+    "Quit", G_CALLBACK (quit_cb) }
 };
 
 static void
@@ -200,6 +208,12 @@ authorize_flickr_cb (GtkAction *action)
   authorize_flickr ();
 }
 
+static void
+reload_plugins_cb (GtkAction *action)
+{
+  reload_plugins ();
+}
+
 static GtkTreeModel *
 create_browser_model (void)
 {
@@ -1718,6 +1732,26 @@ load_plugins (void)
 }
 
 static void
+reload_plugins (void)
+{
+  GrlMediaPlugin **sources;
+  GrlPluginRegistry *registry;
+  int i;
+
+  registry = grl_plugin_registry_get_default ();
+  sources = grl_plugin_registry_get_sources (registry, FALSE);
+
+  for (i = 0; sources[i]; i++) {
+    grl_plugin_registry_unload (registry, grl_media_plugin_get_name (sources[i]));
+    grl_plugin_registry_unregister_source (registry, sources[i]);
+  }
+
+  g_free (sources);
+
+  load_plugins ();
+}
+
+static void
 configure_plugins ()
 {
   set_flickr_config ();
-- 
1.7.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]