[Xfce4-commits] <parole:bluesabre/gtk3> Enhanced plugin load checking

Sean Davis noreply at xfce.org
Sun Sep 29 14:32:01 CEST 2013


Updating branch refs/heads/bluesabre/gtk3
         to e8848253c34aa8d34603e52e23efc7bca7f348af (commit)
       from 25fad955b1b2c0e8ba64660b1d60a43dc1bef4e9 (commit)

commit e8848253c34aa8d34603e52e23efc7bca7f348af
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Sep 29 08:31:39 2013 -0400

    Enhanced plugin load checking

 src/misc/parole-provider-plugin.c |    6 ------
 src/parole-module.c               |   21 +++++++++++++++------
 src/parole-module.h               |    2 +-
 src/parole-plugins-manager.c      |    9 ++++++++-
 4 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/misc/parole-provider-plugin.c b/src/misc/parole-provider-plugin.c
index 9162f9b..f2ce523 100644
--- a/src/misc/parole-provider-plugin.c
+++ b/src/misc/parole-provider-plugin.c
@@ -110,12 +110,6 @@ void parole_provider_plugin_configure (ParoleProviderPlugin *provider, GtkWidget
  **/
 void parole_provider_plugin_set_player (ParoleProviderPlugin *provider, ParoleProviderPlayer *player)
 {
-    if (!PAROLE_IS_PROVIDER_PLUGIN (provider))
-    {
-        g_warning ("Loading plugins failed, a warning dialog is in order.");
-        return;
-    }
-    
     if ( PAROLE_PROVIDER_PLUGIN_GET_INTERFACE (provider)->set_player )
     {
         (*PAROLE_PROVIDER_PLUGIN_GET_INTERFACE (provider)->set_player) (provider, player);
diff --git a/src/parole-module.c b/src/parole-module.c
index 8b5dde0..9412c86 100644
--- a/src/parole-module.c
+++ b/src/parole-module.c
@@ -196,22 +196,31 @@ parole_provider_module_new (const gchar *filename, const gchar *desktop_file)
     return module;
 }
 
-
-void parole_provider_module_new_plugin (ParoleProviderModule *module)
+/**
+ * parole_provider_module_new_plugin:
+ * @module : The #ParoleProviderModule that is being initialized.
+ *
+ * Initialize the #ParoleProviderModule plugin. Return #TRUE if successful.
+ **/
+gboolean parole_provider_module_new_plugin (ParoleProviderModule *module)
 {
     TRACE ("start");
     
-    g_return_if_fail (PAROLE_IS_PROVIDER_MODULE (module));
+    g_return_val_if_fail (PAROLE_IS_PROVIDER_MODULE (module), FALSE);
     
 #ifdef debug
-    g_return_if_fail (module->active == TRUE);
-    g_return_if_fail (module->instance == NULL);
-    g_return_if_fail (module->player == NULL);
+    g_return_val_if_fail (module->active == TRUE, FALSE);
+    g_return_val_if_fail (module->instance == NULL, FALSE);
+    g_return_val_if_fail (module->player == NULL, FALSE);
 #endif
 
     module->instance = g_object_new (module->provider_type, NULL);
     module->player = parole_plugin_player_new ();
+    
+    if (!PAROLE_IS_PROVIDER_PLUGIN (PAROLE_PROVIDER_PLUGIN (module->instance)))
+        return FALSE;
     parole_provider_plugin_set_player (PAROLE_PROVIDER_PLUGIN (module->instance), PAROLE_PROVIDER_PLAYER (module->player));
+    return TRUE;
 }
 
 void parole_provider_module_free_plugin (ParoleProviderModule *module)
diff --git a/src/parole-module.h b/src/parole-module.h
index 293196b..405e6a3 100644
--- a/src/parole-module.h
+++ b/src/parole-module.h
@@ -67,7 +67,7 @@ GType                       parole_provider_module_get_type        (void) G_GNUC
 ParoleProviderModule       *parole_provider_module_new             (const gchar *filename,
                                                                     const gchar *desktop_file);
 
-void                        parole_provider_module_new_plugin      (ParoleProviderModule *module);
+gboolean                    parole_provider_module_new_plugin      (ParoleProviderModule *module);
 
 void                        parole_provider_module_free_plugin     (ParoleProviderModule *module);
 
diff --git a/src/parole-plugins-manager.c b/src/parole-plugins-manager.c
index 0195455..795cc5d 100644
--- a/src/parole-plugins-manager.c
+++ b/src/parole-plugins-manager.c
@@ -270,7 +270,14 @@ parole_plugins_manager_cell_toggled_cb (GtkCellRendererToggle *cell_renderer,
             if ( active )
             {
                 g_type_module_use (G_TYPE_MODULE (module));
-                parole_provider_module_new_plugin (module);
+                if (!parole_provider_module_new_plugin (module))
+                {
+                    // If plugin loading fails...
+                    parole_dialog_error(GTK_WINDOW(pref->window), _("Plugin failed to load"), _("Please check your installation"));
+                    parole_provider_module_free_plugin (module);
+                    g_type_module_unuse (G_TYPE_MODULE (module));
+                    active = FALSE;
+                }
             }
             else
             {


More information about the Xfce4-commits mailing list