]> spindle.queued.net Git - midori/commitdiff
Add a function to determine if an extension is being deactivated
authorChristian Dywan <christian@twotoasts.de>
Wed, 22 Apr 2009 18:01:10 +0000 (20:01 +0200)
committerChristian Dywan <christian@twotoasts.de>
Wed, 22 Apr 2009 18:01:10 +0000 (20:01 +0200)
midori/midori-extension.c
midori/midori-extension.h

index ca9dbd947f95bd3adfa9f9efdb163c60f0729f95..e882172cb70cb598309eb3cadf954cd7dfd80bd8 100644 (file)
@@ -29,7 +29,7 @@ struct _MidoriExtensionPrivate
     gchar* authors;
 
     MidoriApp* app;
-    gboolean active;
+    gint active;
     gchar* config_dir;
     GList* lsettings;
     GHashTable* settings;
@@ -73,7 +73,7 @@ void me_setting_free (gpointer setting)
 }
 
 #define midori_extension_can_install_setting(extension, name) \
-    if (extension->priv->active) \
+    if (extension->priv->active > 0) \
     { \
         g_critical ("%s: Settings have to be installed before " \
                     "the extension is activated.", G_STRFUNC); \
@@ -283,7 +283,7 @@ midori_extension_activate_cb (MidoriExtension* extension,
     }
 
     extension->priv->app = g_object_ref (app);
-    extension->priv->active = TRUE;
+    extension->priv->active = 1;
     /* FIXME: Disconnect all signal handlers */
 }
 
@@ -294,7 +294,7 @@ midori_extension_init (MidoriExtension* extension)
         MIDORI_TYPE_EXTENSION, MidoriExtensionPrivate);
 
     extension->priv->app = NULL;
-    extension->priv->active = FALSE;
+    extension->priv->active = 0;
     extension->priv->config_dir = NULL;
     extension->priv->lsettings = NULL;
     extension->priv->settings = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -416,7 +416,30 @@ midori_extension_is_active (MidoriExtension* extension)
 {
     g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
 
-    return extension->priv->active;
+    return extension->priv->active > 0;
+}
+
+/**
+ * midori_extension_is_deactivating:
+ * @extension: a #MidoriExtension
+ *
+ * Determines if @extension is currently in the process of
+ * being deactivated.
+ *
+ * Extensions remain fully functional even while being
+ * deactivated, so you can for instance still save settings
+ * but you may need to cleanup during deactivation.
+ *
+ * Return value: %TRUE if @extension is deactivating
+ *
+ * Since: 0.1.7
+ **/
+gboolean
+midori_extension_is_deactivating (MidoriExtension* extension)
+{
+    g_return_val_if_fail (MIDORI_IS_EXTENSION (extension), FALSE);
+
+    return extension->priv->active == 2;
 }
 
 /**
@@ -430,8 +453,9 @@ midori_extension_deactivate (MidoriExtension* extension)
 {
     g_return_if_fail (midori_extension_is_active (extension));
 
+    extension->priv->active = 2;
     g_signal_emit (extension, signals[DEACTIVATE], 0);
-    extension->priv->active = FALSE;
+    extension->priv->active = 0;
     katze_object_assign (extension->priv->app, NULL);
 }
 
index 1125d4cb1e77afa8752dce6b4239bc21bd8a920d..54e96b941813d405054d2b2af360a5c078ea79e6 100644 (file)
@@ -54,6 +54,9 @@ midori_extension_is_prepared         (MidoriExtension* extension);
 gboolean
 midori_extension_is_active           (MidoriExtension* extension);
 
+gboolean
+midori_extension_is_deactivating     (MidoriExtension* extension);
+
 void
 midori_extension_deactivate          (MidoriExtension* extension);