Back to index

indicator-appmenu  12.10.0
gactionobserver.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 "gactionobserver.h"
00023 
00024 G_DEFINE_INTERFACE (GActionObserver, g_action_observer, G_TYPE_OBJECT)
00025 
00026 
00052 void
00053 g_action_observer_default_init (GActionObserverInterface *class)
00054 {
00055 }
00056 
00057 /*
00058  * g_action_observer_action_added:
00059  * @observer: a #GActionObserver
00060  * @observable: the source of the event
00061  * @action_name: the name of the action
00062  * @enabled: %TRUE if the action is now enabled
00063  * @parameter_type: the parameter type for action invocations, or %NULL
00064  *                  if no parameter is required
00065  * @state: the current state of the action, or %NULL if the action is
00066  *         stateless
00067  *
00068  * This function is called when an action that the observer is
00069  * registered to receive events for is added.
00070  *
00071  * This function should only be called by objects with which the
00072  * observer has explicitly registered itself to receive events.
00073  */
00074 void
00075 g_action_observer_action_added (GActionObserver    *observer,
00076                                 GActionObservable  *observable,
00077                                 const gchar        *action_name,
00078                                 const GVariantType *parameter_type,
00079                                 gboolean            enabled,
00080                                 GVariant           *state)
00081 {
00082   g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
00083 
00084   G_ACTION_OBSERVER_GET_IFACE (observer)
00085     ->action_added (observer, observable, action_name, parameter_type, enabled, state);
00086 }
00087 
00088 /*
00089  * g_action_observer_action_enabled_changed:
00090  * @observer: a #GActionObserver
00091  * @observable: the source of the event
00092  * @action_name: the name of the action
00093  * @enabled: %TRUE if the action is now enabled
00094  *
00095  * This function is called when an action that the observer is
00096  * registered to receive events for becomes enabled or disabled.
00097  *
00098  * This function should only be called by objects with which the
00099  * observer has explicitly registered itself to receive events.
00100  */
00101 void
00102 g_action_observer_action_enabled_changed (GActionObserver   *observer,
00103                                           GActionObservable *observable,
00104                                           const gchar       *action_name,
00105                                           gboolean           enabled)
00106 {
00107   g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
00108 
00109   G_ACTION_OBSERVER_GET_IFACE (observer)
00110     ->action_enabled_changed (observer, observable, action_name, enabled);
00111 }
00112 
00113 /*
00114  * g_action_observer_action_state_changed:
00115  * @observer: a #GActionObserver
00116  * @observable: the source of the event
00117  * @action_name: the name of the action
00118  * @state: the new state of the action
00119  *
00120  * This function is called when an action that the observer is
00121  * registered to receive events for changes its state.
00122  *
00123  * This function should only be called by objects with which the
00124  * observer has explicitly registered itself to receive events.
00125  */
00126 void
00127 g_action_observer_action_state_changed (GActionObserver   *observer,
00128                                         GActionObservable *observable,
00129                                         const gchar       *action_name,
00130                                         GVariant          *state)
00131 {
00132   g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
00133 
00134   G_ACTION_OBSERVER_GET_IFACE (observer)
00135     ->action_state_changed (observer, observable, action_name, state);
00136 }
00137 
00138 /*
00139  * g_action_observer_action_removed:
00140  * @observer: a #GActionObserver
00141  * @observable: the source of the event
00142  * @action_name: the name of the action
00143  *
00144  * This function is called when an action that the observer is
00145  * registered to receive events for is removed.
00146  *
00147  * This function should only be called by objects with which the
00148  * observer has explicitly registered itself to receive events.
00149  */
00150 void
00151 g_action_observer_action_removed (GActionObserver   *observer,
00152                                   GActionObservable *observable,
00153                                   const gchar       *action_name)
00154 {
00155   g_return_if_fail (G_IS_ACTION_OBSERVER (observer));
00156 
00157   G_ACTION_OBSERVER_GET_IFACE (observer)
00158     ->action_removed (observer, observable, action_name);
00159 }