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/>.
23
#include "backend-mock.h"
24
#include "backend-mock-actions.h"
26
G_DEFINE_TYPE (IndicatorSessionActionsMock,
27
indicator_session_actions_mock,
28
INDICATOR_TYPE_SESSION_ACTIONS)
31
**** Virtual Functions
35
my_can_lock (IndicatorSessionActions * self G_GNUC_UNUSED)
37
return g_settings_get_boolean (mock_settings, "can-lock");
41
my_can_logout (IndicatorSessionActions * self G_GNUC_UNUSED)
43
return g_settings_get_boolean (mock_settings, "can-logout");
47
my_can_switch (IndicatorSessionActions * self G_GNUC_UNUSED)
49
return g_settings_get_boolean (mock_settings, "can-switch-sessions");
53
my_can_suspend (IndicatorSessionActions * self G_GNUC_UNUSED)
55
return g_settings_get_boolean (mock_settings, "can-suspend");
59
my_can_hibernate (IndicatorSessionActions * self G_GNUC_UNUSED)
61
return g_settings_get_boolean (mock_settings, "can-hibernate");
65
my_logout (IndicatorSessionActions * self G_GNUC_UNUSED)
67
g_settings_set_string (mock_settings, "last-command", "logout");
71
my_suspend (IndicatorSessionActions * self G_GNUC_UNUSED)
73
g_settings_set_string (mock_settings, "last-command", "suspend");
77
my_hibernate (IndicatorSessionActions * self G_GNUC_UNUSED)
79
g_settings_set_string (mock_settings, "last-command", "hibernate");
83
my_restart (IndicatorSessionActions * self G_GNUC_UNUSED)
85
g_settings_set_string (mock_settings, "last-command", "restart");
89
my_shutdown (IndicatorSessionActions * self G_GNUC_UNUSED)
91
g_settings_set_string (mock_settings, "last-command", "shutdown");
95
my_switch_to_screensaver (IndicatorSessionActions * self G_GNUC_UNUSED)
97
g_settings_set_string (mock_settings, "last-command", "switch-to-screensaver");
101
my_switch_to_greeter (IndicatorSessionActions * self G_GNUC_UNUSED)
103
g_settings_set_string (mock_settings, "last-command", "switch-to-greeter");
107
my_switch_to_guest (IndicatorSessionActions * self G_GNUC_UNUSED)
109
g_settings_set_string (mock_settings, "last-command", "switch-to-guest");
113
my_switch_to_username (IndicatorSessionActions * self G_GNUC_UNUSED,
114
const char * username)
116
gchar * str = g_strdup_printf ("switch-to-user::%s", username);
117
g_settings_set_string (mock_settings, "last-command", str);
121
my_help (IndicatorSessionActions * self G_GNUC_UNUSED)
123
g_settings_set_string (mock_settings, "last-command", "help");
127
my_about (IndicatorSessionActions * self G_GNUC_UNUSED)
129
g_settings_set_string (mock_settings, "last-command", "about");
133
my_settings (IndicatorSessionActions * self G_GNUC_UNUSED)
135
g_settings_set_string (mock_settings, "last-command", "settings");
139
my_can_prompt (IndicatorSessionActions * self G_GNUC_UNUSED)
141
return g_settings_get_boolean (mock_settings, "can-prompt");
145
my_has_online_account_error (IndicatorSessionActions * self G_GNUC_UNUSED)
147
return g_settings_get_boolean (mock_settings, "has-online-account-error");
151
my_dispose (GObject * o)
153
G_OBJECT_CLASS (indicator_session_actions_mock_parent_class)->dispose (o);
157
my_finalize (GObject * o)
159
G_OBJECT_CLASS (indicator_session_actions_mock_parent_class)->finalize (o);
163
**** GObject Boilerplate
167
/* cppcheck-suppress unusedFunction */
168
indicator_session_actions_mock_class_init (IndicatorSessionActionsMockClass * klass)
170
GObjectClass * object_class;
171
IndicatorSessionActionsClass * actions_class;
173
object_class = G_OBJECT_CLASS (klass);
174
object_class->dispose = my_dispose;
175
object_class->finalize = my_finalize;
177
actions_class = INDICATOR_SESSION_ACTIONS_CLASS (klass);
178
actions_class->can_lock = my_can_lock;
179
actions_class->can_logout = my_can_logout;
180
actions_class->can_switch = my_can_switch;
181
actions_class->can_suspend = my_can_suspend;
182
actions_class->can_hibernate = my_can_hibernate;
183
actions_class->can_prompt = my_can_prompt;
184
actions_class->has_online_account_error = my_has_online_account_error;
185
actions_class->logout = my_logout;
186
actions_class->suspend = my_suspend;
187
actions_class->hibernate = my_hibernate;
188
actions_class->restart = my_restart;
189
actions_class->shutdown = my_shutdown;
190
actions_class->settings = my_settings;
191
actions_class->help = my_help;
192
actions_class->about = my_about;
193
actions_class->switch_to_screensaver = my_switch_to_screensaver;
194
actions_class->switch_to_greeter = my_switch_to_greeter;
195
actions_class->switch_to_guest = my_switch_to_guest;
196
actions_class->switch_to_username = my_switch_to_username;
200
/* cppcheck-suppress unusedFunction */
201
indicator_session_actions_mock_init (IndicatorSessionActionsMock * self)
203
g_signal_connect_swapped (mock_settings, "changed::can-lock",
204
G_CALLBACK(indicator_session_actions_notify_can_lock), self);
205
g_signal_connect_swapped (mock_settings, "changed::can-logout",
206
G_CALLBACK(indicator_session_actions_notify_can_logout), self);
207
g_signal_connect_swapped (mock_settings, "changed::can-switch-sessions",
208
G_CALLBACK(indicator_session_actions_notify_can_switch), self);
209
g_signal_connect_swapped (mock_settings, "changed::can-suspend",
210
G_CALLBACK(indicator_session_actions_notify_can_suspend), self);
211
g_signal_connect_swapped (mock_settings, "changed::can-hibernate",
212
G_CALLBACK(indicator_session_actions_notify_can_hibernate), self);
213
g_signal_connect_swapped (mock_settings, "changed::can-prompt",
214
G_CALLBACK(indicator_session_actions_notify_can_prompt), self);
215
g_signal_connect_swapped (mock_settings, "changed::has-online-account-error",
216
G_CALLBACK(indicator_session_actions_notify_has_online_account_error), self);
223
IndicatorSessionActions *
224
indicator_session_actions_mock_new (void)
226
gpointer o = g_object_new (INDICATOR_TYPE_SESSION_ACTIONS_MOCK, NULL);
228
return INDICATOR_SESSION_ACTIONS (o);