1 | /* |
2 | * Copyright © 2011 Canonical Limited |
3 | * |
4 | * This library 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, see <http://www.gnu.org/licenses/>. |
16 | * |
17 | * Authors: Ryan Lortie <desrt@desrt.ca> |
18 | */ |
19 | |
20 | #include "config.h" |
21 | |
22 | #include "gtkactionobservableprivate.h" |
23 | |
24 | G_DEFINE_INTERFACE (GtkActionObservable, gtk_action_observable, G_TYPE_OBJECT) |
25 | |
26 | void |
27 | gtk_action_observable_default_init (GtkActionObservableInterface *iface) |
28 | { |
29 | } |
30 | |
31 | /** |
32 | * gtk_action_observable_register_observer: |
33 | * @observable: a `GtkActionObservable` |
34 | * @action_name: the name of the action |
35 | * @observer: the `GtkActionObserver` to which the events will be reported |
36 | * |
37 | * Registers @observer as being interested in changes to @action_name on |
38 | * @observable. |
39 | */ |
40 | void |
41 | gtk_action_observable_register_observer (GtkActionObservable *observable, |
42 | const char *action_name, |
43 | GtkActionObserver *observer) |
44 | { |
45 | g_return_if_fail (GTK_IS_ACTION_OBSERVABLE (observable)); |
46 | |
47 | GTK_ACTION_OBSERVABLE_GET_IFACE (observable) |
48 | ->register_observer (observable, action_name, observer); |
49 | } |
50 | |
51 | /** |
52 | * gtk_action_observable_unregister_observer: |
53 | * @observable: a `GtkActionObservable` |
54 | * @action_name: the name of the action |
55 | * @observer: the `GtkActionObserver` to which the events will be reported |
56 | * |
57 | * Removes the registration of @observer as being interested in changes |
58 | * to @action_name on @observable. |
59 | * |
60 | * If the observer was registered multiple times, it must be |
61 | * unregistered an equal number of times. |
62 | */ |
63 | void |
64 | gtk_action_observable_unregister_observer (GtkActionObservable *observable, |
65 | const char *action_name, |
66 | GtkActionObserver *observer) |
67 | { |
68 | g_return_if_fail (GTK_IS_ACTION_OBSERVABLE (observable)); |
69 | |
70 | GTK_ACTION_OBSERVABLE_GET_IFACE (observable) |
71 | ->unregister_observer (observable, action_name, observer); |
72 | } |
73 | |