1 /*
2 * xed-window-activatable.h
3 * This file is part of xed
4 *
5 * Copyright (C) 2010 Steve Frécinaux
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 #include <config.h>
23
24 #include "xed-window-activatable.h"
25 #include "xed-window.h"
26
27 /**
28 * SECTION:xed-window-activatable
29 * @short_description: Interface for activatable extensions on windows
30 * @see_also: #PeasExtensionSet
31 *
32 * #XedWindowActivatable is an interface which should be implemented by
33 * extensions that should be activated on a xed main window.
34 **/
G_DEFINE_INTERFACE(XedWindowActivatable,xed_window_activatable,G_TYPE_OBJECT)35 G_DEFINE_INTERFACE(XedWindowActivatable, xed_window_activatable, G_TYPE_OBJECT)
36
37 void
38 xed_window_activatable_default_init (XedWindowActivatableInterface *iface)
39 {
40 /**
41 * XedWindowActivatable:window:
42 *
43 * The window property contains the xed window for this
44 * #XedWindowActivatable instance.
45 */
46 g_object_interface_install_property (iface,
47 g_param_spec_object ("window",
48 "Window",
49 "The xed window",
50 XED_TYPE_WINDOW,
51 G_PARAM_READWRITE |
52 G_PARAM_CONSTRUCT_ONLY |
53 G_PARAM_STATIC_STRINGS));
54 }
55
56 /**
57 * xed_window_activatable_activate:
58 * @activatable: A #XedWindowActivatable.
59 *
60 * Activates the extension on the window property.
61 */
62 void
xed_window_activatable_activate(XedWindowActivatable * activatable)63 xed_window_activatable_activate (XedWindowActivatable *activatable)
64 {
65 XedWindowActivatableInterface *iface;
66
67 g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
68
69 iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
70 if (iface->activate != NULL)
71 {
72 iface->activate (activatable);
73 }
74 }
75
76 /**
77 * xed_window_activatable_deactivate:
78 * @activatable: A #XedWindowActivatable.
79 *
80 * Deactivates the extension on the window property.
81 */
82 void
xed_window_activatable_deactivate(XedWindowActivatable * activatable)83 xed_window_activatable_deactivate (XedWindowActivatable *activatable)
84 {
85 XedWindowActivatableInterface *iface;
86
87 g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
88
89 iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
90 if (iface->deactivate != NULL)
91 {
92 iface->deactivate (activatable);
93 }
94 }
95
96 /**
97 * xed_window_activatable_update_state:
98 * @activatable: A #XedWindowActivatable.
99 *
100 * Triggers an update of the extension insternal state to take into account
101 * state changes in the window state, due to some event or user action.
102 */
103 void
xed_window_activatable_update_state(XedWindowActivatable * activatable)104 xed_window_activatable_update_state (XedWindowActivatable *activatable)
105 {
106 XedWindowActivatableInterface *iface;
107
108 g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
109
110 iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
111 if (iface->update_state != NULL)
112 {
113 iface->update_state (activatable);
114 }
115 }
116