~indicator-applet-developers/indicator-appmenu/trunk.13.04

« back to all changes in this revision

Viewing changes to src/gactionobservable.c

  • Committer: Ted Gould
  • Date: 2012-03-21 14:46:04 UTC
  • mfrom: (166.3.59 gmenumodel-menus)
  • Revision ID: ted@gould.cx-20120321144604-r4limdyast215291
Adding GMenuModel support for menus

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "gactionobservable.h"
 
23
 
 
24
G_DEFINE_INTERFACE (GActionObservable, g_action_observable, G_TYPE_OBJECT)
 
25
 
 
26
/*
 
27
 * SECTION:gactionobserable
 
28
 * @short_description: an interface implemented by objects that report
 
29
 *                     changes to actions
 
30
 */
 
31
 
 
32
void
 
33
g_action_observable_default_init (GActionObservableInterface *iface)
 
34
{
 
35
}
 
36
 
 
37
/*
 
38
 * g_action_observable_register_observer:
 
39
 * @observable: a #GActionObservable
 
40
 * @action_name: the name of the action
 
41
 * @observer: the #GActionObserver to which the events will be reported
 
42
 *
 
43
 * Registers @observer as being interested in changes to @action_name on
 
44
 * @observable.
 
45
 */
 
46
void
 
47
g_action_observable_register_observer (GActionObservable *observable,
 
48
                                       const gchar       *action_name,
 
49
                                       GActionObserver   *observer)
 
50
{
 
51
  g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
 
52
 
 
53
  G_ACTION_OBSERVABLE_GET_IFACE (observable)
 
54
    ->register_observer (observable, action_name, observer);
 
55
}
 
56
 
 
57
/*
 
58
 * g_action_observable_unregister_observer:
 
59
 * @observable: a #GActionObservable
 
60
 * @action_name: the name of the action
 
61
 * @observer: the #GActionObserver to which the events will be reported
 
62
 *
 
63
 * Removes the registration of @observer as being interested in changes
 
64
 * to @action_name on @observable.
 
65
 *
 
66
 * If the observer was registered multiple times, it must be
 
67
 * unregistered an equal number of times.
 
68
 */
 
69
void
 
70
g_action_observable_unregister_observer (GActionObservable *observable,
 
71
                                         const gchar       *action_name,
 
72
                                         GActionObserver   *observer)
 
73
{
 
74
  g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
 
75
 
 
76
  G_ACTION_OBSERVABLE_GET_IFACE (observable)
 
77
    ->unregister_observer (observable, action_name, observer);
 
78
}