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/>.
31
static guint signals[LAST_SIGNAL] = { 0 };
33
G_DEFINE_TYPE (IndicatorSessionUsers, indicator_session_users, G_TYPE_OBJECT)
42
static GParamSpec *properties[PROP_LAST];
45
my_get_property (GObject * o,
50
IndicatorSessionUsers * self = INDICATOR_SESSION_USERS (o);
54
case PROP_IS_LIVE_SESSION:
55
g_value_set_boolean (value, indicator_session_users_is_live_session (self));
59
G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec);
64
/* cppcheck-suppress unusedFunction */
65
indicator_session_users_class_init (IndicatorSessionUsersClass * klass)
67
GObjectClass * object_class;
68
const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS;
70
object_class = G_OBJECT_CLASS (klass);
71
object_class->get_property = my_get_property;
73
signals[USER_ADDED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_ADDED,
74
G_TYPE_FROM_CLASS(klass),
76
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_added),
78
g_cclosure_marshal_VOID__STRING,
79
G_TYPE_NONE, 1, G_TYPE_STRING);
81
signals[USER_REMOVED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_REMOVED,
82
G_TYPE_FROM_CLASS(klass),
84
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_removed),
86
g_cclosure_marshal_VOID__STRING,
87
G_TYPE_NONE, 1, G_TYPE_STRING);
89
signals[USER_CHANGED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_CHANGED,
90
G_TYPE_FROM_CLASS(klass),
92
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_changed),
94
g_cclosure_marshal_VOID__STRING,
95
G_TYPE_NONE, 1, G_TYPE_STRING);
98
properties[PROP_IS_LIVE_SESSION] =
99
g_param_spec_boolean (INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION,
101
"Whether or this is a 'live session', such as booting from a live CD",
104
g_object_class_install_properties (object_class, PROP_LAST, properties);
109
/* cppcheck-suppress unusedFunction */
110
indicator_session_users_init (IndicatorSessionUsers * self G_GNUC_UNUSED)
115
**** Virtual Functions
119
indicator_session_users_get_keys (IndicatorSessionUsers * self)
121
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), NULL);
123
return INDICATOR_SESSION_USERS_GET_CLASS (self)->get_keys (self);
126
IndicatorSessionUser *
127
indicator_session_users_get_user (IndicatorSessionUsers * self,
130
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), NULL);
132
return INDICATOR_SESSION_USERS_GET_CLASS (self)->get_user (self, key);
136
indicator_session_users_activate_user (IndicatorSessionUsers * self,
139
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
141
INDICATOR_SESSION_USERS_GET_CLASS (self)->activate_user (self, key);
145
indicator_session_users_is_live_session (IndicatorSessionUsers * self)
147
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), FALSE);
149
return INDICATOR_SESSION_USERS_GET_CLASS (self)->is_live_session (self);
153
indicator_session_user_free (IndicatorSessionUser * user)
155
g_return_if_fail (user != NULL);
157
g_free (user->real_name);
158
g_free (user->user_name);
159
g_free (user->icon_file);
164
**** Signal Convenience
168
indicator_session_users_added (IndicatorSessionUsers * self, const char * key)
170
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
172
g_signal_emit (self, signals[USER_ADDED], 0, key);
176
indicator_session_users_removed (IndicatorSessionUsers * self, const char * key)
178
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
180
g_signal_emit (self, signals[USER_REMOVED], 0, key);
184
indicator_session_users_changed (IndicatorSessionUsers * self, const char * key)
186
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
188
g_signal_emit (self, signals[USER_CHANGED], 0, key);
192
indicator_session_users_notify_is_live_session (IndicatorSessionUsers * self)
194
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
196
g_object_notify_by_pspec (G_OBJECT(self), properties[PROP_IS_LIVE_SESSION]);