Back to index

indicator-appmenu  12.10.0
gactionobservable.c
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2011 Canonical Limited
00003  *
00004  * This library is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * licence or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authors: Ryan Lortie <desrt@desrt.ca>
00018  */
00019 
00020 #include "config.h"
00021 
00022 #include "gactionobservable.h"
00023 
00024 G_DEFINE_INTERFACE (GActionObservable, g_action_observable, G_TYPE_OBJECT)
00025 
00026 /*
00027  * SECTION:gactionobserable
00028  * @short_description: an interface implemented by objects that report
00029  *                     changes to actions
00030  */
00031 
00032 void
00033 g_action_observable_default_init (GActionObservableInterface *iface)
00034 {
00035 }
00036 
00037 /*
00038  * g_action_observable_register_observer:
00039  * @observable: a #GActionObservable
00040  * @action_name: the name of the action
00041  * @observer: the #GActionObserver to which the events will be reported
00042  *
00043  * Registers @observer as being interested in changes to @action_name on
00044  * @observable.
00045  */
00046 void
00047 g_action_observable_register_observer (GActionObservable *observable,
00048                                        const gchar       *action_name,
00049                                        GActionObserver   *observer)
00050 {
00051   g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
00052 
00053   G_ACTION_OBSERVABLE_GET_IFACE (observable)
00054     ->register_observer (observable, action_name, observer);
00055 }
00056 
00057 /*
00058  * g_action_observable_unregister_observer:
00059  * @observable: a #GActionObservable
00060  * @action_name: the name of the action
00061  * @observer: the #GActionObserver to which the events will be reported
00062  *
00063  * Removes the registration of @observer as being interested in changes
00064  * to @action_name on @observable.
00065  *
00066  * If the observer was registered multiple times, it must be
00067  * unregistered an equal number of times.
00068  */
00069 void
00070 g_action_observable_unregister_observer (GActionObservable *observable,
00071                                          const gchar       *action_name,
00072                                          GActionObserver   *observer)
00073 {
00074   g_return_if_fail (G_IS_ACTION_OBSERVABLE (observable));
00075 
00076   G_ACTION_OBSERVABLE_GET_IFACE (observable)
00077     ->unregister_observer (observable, action_name, observer);
00078 }