Commit 09ca1e89 authored by Jehan's avatar Jehan

app: add undo_remove ability to the extension manager.

This allows an extension removal to be cancelable for a given session
(at end of session, the extension removal is definitive and you have to
reinstall it if you want it back).
parent 5febc9a5
......@@ -720,6 +720,31 @@ gimp_extension_manager_can_run (GimpExtensionManager *manager,
return TRUE;
}
/**
* gimp_extension_manager_is_removed:
* @manager:
* @extension:
*
* Returns: %TRUE is @extension was installed and has been removed
* (hence gimp_extension_manager_undo_remove() can be used on it).
*/
gboolean
gimp_extension_manager_is_removed (GimpExtensionManager *manager,
GimpExtension *extension)
{
GList *iter;
g_return_val_if_fail (GIMP_IS_EXTENSION_MANAGER (manager), FALSE);
g_return_val_if_fail (GIMP_IS_EXTENSION (extension), FALSE);
iter = manager->p->uninstalled_extensions;
for (; iter; iter = iter->next)
if (gimp_extension_cmp (iter->data, extension) == 0)
break;
return (iter != NULL);
}
/**
* gimp_extension_manager_install:
* @manager:
......@@ -803,6 +828,31 @@ gimp_extension_manager_remove (GimpExtensionManager *manager,
return TRUE;
}
gboolean
gimp_extension_manager_undo_remove (GimpExtensionManager *manager,
GimpExtension *extension,
GError **error)
{
GList *iter;
g_return_val_if_fail (GIMP_IS_EXTENSION_MANAGER (manager), FALSE);
g_return_val_if_fail (GIMP_IS_EXTENSION (extension), FALSE);
iter = manager->p->uninstalled_extensions;
for (; iter; iter = iter->next)
if (gimp_extension_cmp (iter->data, extension) == 0)
break;
/* The extension has to be in the uninstalled extension list. */
g_return_val_if_fail (iter != NULL, FALSE);
manager->p->uninstalled_extensions = g_list_remove (manager->p->uninstalled_extensions,
extension);
gimp_extension_manager_install (manager, extension, error);
return TRUE;
}
/* Private functions. */
static void
......
......@@ -69,6 +69,8 @@ gboolean gimp_extension_manager_is_running (GimpExtensi
GimpExtension *extension);
gboolean gimp_extension_manager_can_run (GimpExtensionManager *manager,
GimpExtension *extension);
gboolean gimp_extension_manager_is_removed (GimpExtensionManager *manager,
GimpExtension *extension);
gboolean gimp_extension_manager_install (GimpExtensionManager *manager,
GimpExtension *extension,
......@@ -76,5 +78,8 @@ gboolean gimp_extension_manager_install (GimpExtensi
gboolean gimp_extension_manager_remove (GimpExtensionManager *manager,
GimpExtension *extension,
GError **error);
gboolean gimp_extension_manager_undo_remove (GimpExtensionManager *manager,
GimpExtension *extension,
GError **error);
#endif /* __GIMP_EXTENSION_MANAGER_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment