2
* Copyright 2013 Canonical Ltd.
5
* Charles Kerr <charles.kerr@canonical.com>
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 3, as published
9
* by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranties of
13
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14
* PURPOSE. See the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
22
G_DEFINE_TYPE (IndicatorSessionGuest,
23
indicator_session_guest,
35
static GParamSpec *properties[PROP_LAST];
38
my_get_property (GObject * o,
43
IndicatorSessionGuest * self = INDICATOR_SESSION_GUEST (o);
48
g_value_set_boolean (value, indicator_session_guest_is_allowed (self));
52
g_value_set_boolean (value, indicator_session_guest_is_logged_in (self));
56
g_value_set_boolean (value, indicator_session_guest_is_active (self));
60
G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec);
65
my_dispose (GObject *object)
67
G_OBJECT_CLASS (indicator_session_guest_parent_class)->dispose (object);
71
/* cppcheck-suppress unusedFunction */
72
indicator_session_guest_class_init (IndicatorSessionGuestClass * klass)
74
GObjectClass * object_class;
75
const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS;
77
object_class = G_OBJECT_CLASS (klass);
78
object_class->get_property = my_get_property;
79
object_class->dispose = my_dispose;
81
klass->is_allowed = NULL;
82
klass->is_logged_in = NULL;
83
klass->is_active = NULL;
84
klass->switch_to_guest = NULL;
86
properties[PROP_0] = NULL;
88
properties[PROP_ALLOWED] =
89
g_param_spec_boolean (INDICATOR_SESSION_GUEST_PROPERTY_ALLOWED,
91
"Whether or not a Guest user is allowed",
94
properties[PROP_LOGGED_IN] =
95
g_param_spec_boolean (INDICATOR_SESSION_GUEST_PROPERTY_LOGGED_IN,
97
"Whether or not the Guest account is logged in",
100
properties[PROP_ACTIVE] =
101
g_param_spec_boolean (INDICATOR_SESSION_GUEST_PROPERTY_ACTIVE,
103
"If the Guest account has the current session",
106
g_object_class_install_properties (object_class, PROP_LAST, properties);
110
/* cppcheck-suppress unusedFunction */
111
indicator_session_guest_init (IndicatorSessionGuest *self G_GNUC_UNUSED)
120
indicator_session_guest_is_active (IndicatorSessionGuest * self)
122
g_return_val_if_fail (INDICATOR_IS_SESSION_GUEST (self), FALSE);
124
return INDICATOR_SESSION_GUEST_GET_CLASS (self)->is_active (self);
128
indicator_session_guest_is_allowed (IndicatorSessionGuest * self)
130
g_return_val_if_fail (INDICATOR_IS_SESSION_GUEST (self), FALSE);
132
return INDICATOR_SESSION_GUEST_GET_CLASS (self)->is_allowed (self);
136
indicator_session_guest_is_logged_in (IndicatorSessionGuest * self)
138
g_return_val_if_fail (INDICATOR_IS_SESSION_GUEST (self), FALSE);
140
return INDICATOR_SESSION_GUEST_GET_CLASS (self)->is_logged_in (self);
147
notify_func (IndicatorSessionGuest * self, int prop)
149
g_return_if_fail (INDICATOR_IS_SESSION_GUEST (self));
151
g_debug ("%s %s emitting '%s' prop notify", G_STRLOC, G_STRFUNC, properties[prop]->name);
153
g_object_notify_by_pspec (G_OBJECT(self), properties[prop]);
157
indicator_session_guest_notify_active (IndicatorSessionGuest * self)
159
notify_func (self, PROP_ACTIVE);
163
indicator_session_guest_notify_allowed (IndicatorSessionGuest * self)
165
notify_func (self, PROP_ALLOWED);
169
indicator_session_guest_notify_logged_in (IndicatorSessionGuest * self)
171
notify_func (self, PROP_LOGGED_IN);
179
indicator_session_guest_switch_to_guest (IndicatorSessionGuest * self)
183
g_return_if_fail (INDICATOR_IS_SESSION_GUEST (self));
185
g_object_get (self, INDICATOR_SESSION_GUEST_PROPERTY_ALLOWED, &allowed, NULL);
186
g_return_if_fail (allowed);
188
INDICATOR_SESSION_GUEST_GET_CLASS (self)->switch_to_guest (self);