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