]> Pileus Git - ~andy/gtk/blob - gtk/gactionobservable.c
add GActionMuxer and observer interfaces
[~andy/gtk] / gtk / gactionobservable.c
1 /*
2  * Copyright © 2011 Canonical Limited
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * licence or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
17  * USA.
18  *
19  * Authors: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #include "config.h"
23
24 #include "gactionobservable.h"
25
26 G_DEFINE_INTERFACE (GActionObservable, g_action_observable, G_TYPE_OBJECT)
27
28 /**
29  * SECTION:gactionobserable
30  * @short_description: an interface implemented by objects that report
31  *                     changes to actions
32  *
33  * Since: 2.32
34  */
35
36 void
37 g_action_observable_default_init (GActionObservableInterface *iface)
38 {
39 }
40
41 /**
42  * g_action_observable_register_observer:
43  * @observable: a #GActionObservable
44  * @action_name: the name of the action
45  * @observer: the #GActionObserver to which the events will be reported
46  *
47  * Registers @observer as being interested in changes to @action_name on
48  * @observable.
49  *
50  * Since: 2.32
51  **/
52 void
53 g_action_observable_register_observer (GActionObservable *observable,
54                                        const gchar       *action_name,
55                                        GActionObserver   *observer)
56 {
57   g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
58
59   G_ACTION_OBSERVABLE_GET_IFACE (observable)
60     ->register_observer (observable, action_name, observer);
61 }
62
63 /**
64  * g_action_observable_unregister_observer:
65  * @observable: a #GActionObservable
66  * @action_name: the name of the action
67  * @observer: the #GActionObserver to which the events will be reported
68  *
69  * Removes the registration of @observer as being interested in changes
70  * to @action_name on @observable.
71  *
72  * If the observer was registered multiple times, it must be
73  * unregistered an equal number of times.
74  *
75  * Since: 2.32
76  **/
77 void
78 g_action_observable_unregister_observer (GActionObservable *observable,
79                                          const gchar       *action_name,
80                                          GActionObserver   *observer)
81 {
82   g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
83
84   G_ACTION_OBSERVABLE_GET_IFACE (observable)
85     ->unregister_observer (observable, action_name, observer);
86 }