1 /*
2  * xed-view-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-view-activatable.h"
25 #include "xed-view.h"
26 
27 /**
28  * SECTION:xed-view-activatable
29  * @short_description: Interface for activatable extensions on views
30  * @see_also: #PeasExtensionSet
31  *
32  * #XedViewActivatable is an interface which should be implemented by
33  * extensions that should be activated on a xed view.
34  **/
G_DEFINE_INTERFACE(XedViewActivatable,xed_view_activatable,G_TYPE_OBJECT)35 G_DEFINE_INTERFACE(XedViewActivatable, xed_view_activatable, G_TYPE_OBJECT)
36 
37 void
38 xed_view_activatable_default_init (XedViewActivatableInterface *iface)
39 {
40     /**
41      * XedViewActivatable:view:
42      *
43      * The window property contains the xed window for this
44      * #XedViewActivatable instance.
45      */
46     g_object_interface_install_property (iface,
47                                          g_param_spec_object ("view",
48                                                               "view",
49                                                               "A xed view",
50                                                               XED_TYPE_VIEW,
51                                                               G_PARAM_READWRITE |
52                                                               G_PARAM_CONSTRUCT_ONLY |
53                                                               G_PARAM_STATIC_STRINGS));
54 }
55 
56 /**
57  * xed_view_activatable_activate:
58  * @activatable: A #XedViewActivatable.
59  *
60  * Activates the extension on the window property.
61  */
62 void
xed_view_activatable_activate(XedViewActivatable * activatable)63 xed_view_activatable_activate (XedViewActivatable *activatable)
64 {
65     XedViewActivatableInterface *iface;
66 
67     g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
68 
69     iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
70     if (iface->activate != NULL)
71     {
72         iface->activate (activatable);
73     }
74 }
75 
76 /**
77  * xed_view_activatable_deactivate:
78  * @activatable: A #XedViewActivatable.
79  *
80  * Deactivates the extension on the window property.
81  */
82 void
xed_view_activatable_deactivate(XedViewActivatable * activatable)83 xed_view_activatable_deactivate (XedViewActivatable *activatable)
84 {
85     XedViewActivatableInterface *iface;
86 
87     g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
88 
89     iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
90     if (iface->deactivate != NULL)
91     {
92         iface->deactivate (activatable);
93     }
94 }
95