3
* Copyright 2013 Canonical Ltd.
6
* Charles Kerr <charles.kerr@canonical.com>
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License version 3, as published
10
* by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranties of
14
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
* PURPOSE. See the GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
24
**** GObject Boilerplate
27
G_DEFINE_TYPE (IndicatorSessionActions, indicator_session_actions, G_TYPE_OBJECT)
38
PROP_HAS_ONLINE_ACCOUNT_ERROR,
42
static GParamSpec *properties[PROP_LAST];
45
my_get_property (GObject * o,
50
IndicatorSessionActions * self = INDICATOR_SESSION_ACTIONS (o);
55
g_value_set_boolean (value, indicator_session_actions_can_switch (self));
58
case PROP_CAN_HIBERNATE:
59
g_value_set_boolean (value, indicator_session_actions_can_hibernate (self));
62
case PROP_CAN_SUSPEND:
63
g_value_set_boolean (value, indicator_session_actions_can_suspend (self));
67
g_value_set_boolean (value, indicator_session_actions_can_lock (self));
71
g_value_set_boolean (value, indicator_session_actions_can_logout (self));
75
g_value_set_boolean (value, indicator_session_actions_can_prompt (self));
78
case PROP_HAS_ONLINE_ACCOUNT_ERROR:
79
g_value_set_boolean (value, indicator_session_actions_has_online_account_error (self));
83
G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec);
88
/* cppcheck-suppress unusedFunction */
89
indicator_session_actions_class_init (IndicatorSessionActionsClass * klass)
91
GObjectClass * object_class;
92
const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS;
94
object_class = G_OBJECT_CLASS (klass);
95
object_class->get_property = my_get_property;
97
klass->can_lock = NULL;
98
klass->can_logout = NULL;
99
klass->can_switch = NULL;
100
klass->can_suspend = NULL;
101
klass->can_hibernate = NULL;
102
klass->has_online_account_error = NULL;
103
klass->logout = NULL;
104
klass->suspend = NULL;
105
klass->hibernate = NULL;
106
klass->restart = NULL;
107
klass->shutdown = NULL;
108
klass->switch_to_screensaver = NULL;
109
klass->switch_to_greeter = NULL;
110
klass->switch_to_guest = NULL;
111
klass->switch_to_username = NULL;
115
properties[PROP_0] = NULL;
117
properties[PROP_CAN_SWITCH] =
118
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_SWITCH,
119
"Can Switch Sessions",
120
"Whether or not the system services allow session switching",
123
properties[PROP_CAN_HIBERNATE] =
124
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_HIBERNATE,
126
"Whether or not the system services allow the user to hibernate",
129
properties[PROP_CAN_SUSPEND] =
130
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_SUSPEND,
132
"Whether or not the system services allow the user to suspend",
135
properties[PROP_CAN_LOCK] =
136
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_LOCK,
138
"Whether or not the system services allow the user to lock the screen",
141
properties[PROP_CAN_LOGOUT] =
142
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_LOGOUT,
144
"Whether or not the system services allow the user to logout",
147
properties[PROP_CAN_PROMPT] =
148
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_CAN_PROMPT,
149
"Can Show End Session Dialog",
150
"Whether or not we can show an End Session dialog",
153
properties[PROP_HAS_ONLINE_ACCOUNT_ERROR] =
154
g_param_spec_boolean (INDICATOR_SESSION_ACTIONS_PROP_HAS_ONLINE_ACCOUNT_ERROR,
155
"Has Online Account Error",
156
"Whether or not an online account setting requires attention from the user",
159
g_object_class_install_properties (object_class, PROP_LAST, properties);
163
/* cppcheck-suppress unusedFunction */
164
indicator_session_actions_init (IndicatorSessionActions * self G_GNUC_UNUSED)
173
indicator_session_actions_can_lock (IndicatorSessionActions * self)
175
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
177
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_lock (self);
181
indicator_session_actions_can_logout (IndicatorSessionActions * self)
183
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
185
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_logout (self);
189
indicator_session_actions_can_switch (IndicatorSessionActions * self)
191
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
193
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_switch (self);
197
indicator_session_actions_can_suspend (IndicatorSessionActions * self)
199
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
201
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_suspend (self);
205
indicator_session_actions_can_hibernate (IndicatorSessionActions * self)
207
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
209
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_hibernate (self);
213
indicator_session_actions_can_prompt (IndicatorSessionActions * self)
215
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
217
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->can_prompt (self);
221
indicator_session_actions_has_online_account_error (IndicatorSessionActions * self)
223
g_return_val_if_fail (INDICATOR_IS_SESSION_ACTIONS (self), FALSE);
225
return INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->has_online_account_error (self);
233
indicator_session_actions_settings (IndicatorSessionActions * self)
235
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
237
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->settings (self);
241
indicator_session_actions_logout (IndicatorSessionActions * self)
243
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
245
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->logout (self);
249
indicator_session_actions_shutdown (IndicatorSessionActions * self)
251
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
253
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->shutdown (self);
257
indicator_session_actions_help (IndicatorSessionActions * self)
259
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
261
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->help (self);
265
indicator_session_actions_about (IndicatorSessionActions * self)
267
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
269
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->about (self);
273
indicator_session_actions_restart (IndicatorSessionActions * self)
275
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
277
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->restart (self);
281
indicator_session_actions_suspend (IndicatorSessionActions * self)
283
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
285
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->suspend (self);
289
indicator_session_actions_hibernate (IndicatorSessionActions * self)
291
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
293
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->hibernate (self);
297
indicator_session_actions_switch_to_screensaver (IndicatorSessionActions * self)
299
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
301
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->switch_to_screensaver (self);
305
indicator_session_actions_switch_to_greeter (IndicatorSessionActions * self)
307
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
309
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->switch_to_greeter (self);
313
indicator_session_actions_switch_to_guest (IndicatorSessionActions * self)
315
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
317
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->switch_to_guest (self);
321
indicator_session_actions_switch_to_username (IndicatorSessionActions * self,
322
const gchar * username)
324
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
326
INDICATOR_SESSION_ACTIONS_GET_CLASS (self)->switch_to_username (self, username);
334
notify_func (IndicatorSessionActions * self, int prop)
336
g_return_if_fail (INDICATOR_IS_SESSION_ACTIONS (self));
338
g_debug ("%s %s emitting '%s' prop notify", G_STRLOC, G_STRFUNC, properties[prop]->name);
340
g_object_notify_by_pspec (G_OBJECT(self), properties[prop]);
344
indicator_session_actions_notify_can_lock (IndicatorSessionActions * self)
346
notify_func (self, PROP_CAN_LOCK);
350
indicator_session_actions_notify_can_logout (IndicatorSessionActions * self)
352
notify_func (self, PROP_CAN_LOGOUT);
356
indicator_session_actions_notify_can_switch (IndicatorSessionActions * self)
358
notify_func (self, PROP_CAN_SWITCH);
362
indicator_session_actions_notify_can_suspend (IndicatorSessionActions * self)
364
notify_func (self, PROP_CAN_SUSPEND);
368
indicator_session_actions_notify_can_hibernate (IndicatorSessionActions * self)
370
notify_func (self, PROP_CAN_HIBERNATE);
374
indicator_session_actions_notify_can_prompt (IndicatorSessionActions * self)
376
notify_func (self, PROP_CAN_PROMPT);
380
indicator_session_actions_notify_has_online_account_error (IndicatorSessionActions * self)
382
notify_func (self, PROP_HAS_ONLINE_ACCOUNT_ERROR);