diff options
author | mbkma <[email protected]> | 2021-02-10 12:02:25 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2021-03-02 22:19:58 +0100 |
commit | c0c513f3ef7e7ea432e799d8a5e10cfe94d38908 (patch) | |
tree | e4b7840617c282855884bd3fac3c1c1313cb68fa /pluma/pluma-window-activatable.c | |
parent | 814ae9fdeb8367d0f5b43a4691b32a514cf3e6e9 (diff) | |
download | pluma-c0c513f3ef7e7ea432e799d8a5e10cfe94d38908.tar.bz2 pluma-c0c513f3ef7e7ea432e799d8a5e10cfe94d38908.tar.xz |
Introduce PlumaWindowActivatable, PlumaAppActivatable, PlumaViewActivatable
These interfaces are for extensions that should be activated against a window/app/view.
Backport from
- https://gitlab.gnome.org/GNOME/gedit/-/commit/4fe7161560941ae1aa42165ff4d71121ad6f67b9
- https://gitlab.gnome.org/GNOME/gedit/-/commit/56a790a6851ebc98766cc4aca27cb32dde1b41bf
- https://gitlab.gnome.org/GNOME/gedit/-/commit/210ed41e48988646203fc94eba19ce94657821cd
In pluma-app.c we use gtk_main_quit instead of app object unref when last window closed.
Plugin engine finalization calls app_get_default which
reconstructs the app object. Before that was reasonably ok
because it didn't really do anything, but now the app does stuff
in 'init'.
See https://gitlab.gnome.org/GNOME/gedit/-/commit/90c9889a4a31fbebfa042c5d2c64bb2b05160b10
Diffstat (limited to 'pluma/pluma-window-activatable.c')
-rw-r--r-- | pluma/pluma-window-activatable.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/pluma/pluma-window-activatable.c b/pluma/pluma-window-activatable.c new file mode 100644 index 00000000..74597b2a --- /dev/null +++ b/pluma/pluma-window-activatable.c @@ -0,0 +1,114 @@ +/* + * pluma-window-activatable.h + * This file is part of pluma + * + * Copyright (C) 2010 Steve Frécinaux + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + +#include <config.h> + +#include "pluma-window-activatable.h" +#include "pluma-window.h" + +/** + * SECTION:pluma-window-activatable + * @short_description: Interface for activatable extensions on windows + * @see_also: #PeasExtensionSet + * + * #PlumaWindowActivatable is an interface which should be implemented by + * extensions that should be activated on a pluma main window. + **/ +G_DEFINE_INTERFACE(PlumaWindowActivatable, pluma_window_activatable, G_TYPE_OBJECT) + +void +pluma_window_activatable_default_init (PlumaWindowActivatableInterface *iface) +{ + /** + * PlumaWindowActivatable:window: + * + * The window property contains the pluma window for this + * #PlumaWindowActivatable instance. + */ + g_object_interface_install_property (iface, + g_param_spec_object ("window", + "Window", + "The pluma window", + PLUMA_TYPE_WINDOW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); +} + +/** + * pluma_window_activatable_activate: + * @activatable: A #PlumaWindowActivatable. + * + * Activates the extension on the window property. + */ +void +pluma_window_activatable_activate (PlumaWindowActivatable *activatable) +{ + PlumaWindowActivatableInterface *iface; + + g_return_if_fail (PLUMA_IS_WINDOW_ACTIVATABLE (activatable)); + + iface = PLUMA_WINDOW_ACTIVATABLE_GET_IFACE (activatable); + if (iface->activate != NULL) + { + iface->activate (activatable); + } +} + +/** + * pluma_window_activatable_deactivate: + * @activatable: A #PlumaWindowActivatable. + * + * Deactivates the extension on the window property. + */ +void +pluma_window_activatable_deactivate (PlumaWindowActivatable *activatable) +{ + PlumaWindowActivatableInterface *iface; + + g_return_if_fail (PLUMA_IS_WINDOW_ACTIVATABLE (activatable)); + + iface = PLUMA_WINDOW_ACTIVATABLE_GET_IFACE (activatable); + if (iface->deactivate != NULL) + { + iface->deactivate (activatable); + } +} + +/** + * pluma_window_activatable_update_state: + * @activatable: A #PlumaWindowActivatable. + * + * Triggers an update of the extension insternal state to take into account + * state changes in the window state, due to some event or user action. + */ +void +pluma_window_activatable_update_state (PlumaWindowActivatable *activatable) +{ + PlumaWindowActivatableInterface *iface; + + g_return_if_fail (PLUMA_IS_WINDOW_ACTIVATABLE (activatable)); + + iface = PLUMA_WINDOW_ACTIVATABLE_GET_IFACE (activatable); + if (iface->update_state != NULL) + { + iface->update_state (activatable); + } +} |