Add a function to determine if an extension is being deactivated
This commit is contained in:
parent
e3ce454b78
commit
d7f6c7ded8
2 changed files with 33 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue