diff --git a/midori/midori-extension.c b/midori/midori-extension.c index ca9dbd94..e882172c 100644 --- a/midori/midori-extension.c +++ b/midori/midori-extension.c @@ -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); } diff --git a/midori/midori-extension.h b/midori/midori-extension.h index 1125d4cb..54e96b94 100644 --- a/midori/midori-extension.h +++ b/midori/midori-extension.h @@ -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);