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_reboot (IndicatorSessionActions * self G_GNUC_UNUSED)
49
return g_settings_get_boolean (mock_settings, "can-reboot");
53
my_can_switch (IndicatorSessionActions * self G_GNUC_UNUSED)
55
return g_settings_get_boolean (mock_settings, "can-switch-sessions");
59
my_can_suspend (IndicatorSessionActions * self G_GNUC_UNUSED)
61
return g_settings_get_boolean (mock_settings, "can-suspend");
65
my_can_hibernate (IndicatorSessionActions * self G_GNUC_UNUSED)
67
return g_settings_get_boolean (mock_settings, "can-hibernate");
71
my_logout (IndicatorSessionActions * self G_GNUC_UNUSED)
73
g_settings_set_string (mock_settings, "last-command", "logout");
77
my_suspend (IndicatorSessionActions * self G_GNUC_UNUSED)
79
g_settings_set_string (mock_settings, "last-command", "suspend");
83
my_hibernate (IndicatorSessionActions * self G_GNUC_UNUSED)
85
g_settings_set_string (mock_settings, "last-command", "hibernate");
89
my_reboot (IndicatorSessionActions * self G_GNUC_UNUSED)
91
g_settings_set_string (mock_settings, "last-command", "reboot");
95
my_power_off (IndicatorSessionActions * self G_GNUC_UNUSED)
97
g_settings_set_string (mock_settings, "last-command", "power-off");
101
my_switch_to_screensaver (IndicatorSessionActions * self G_GNUC_UNUSED)
103
g_settings_set_string (mock_settings, "last-command", "switch-to-screensaver");
107
my_switch_to_greeter (IndicatorSessionActions * self G_GNUC_UNUSED)
109
g_settings_set_string (mock_settings, "last-command", "switch-to-greeter");
113
my_switch_to_guest (IndicatorSessionActions * self G_GNUC_UNUSED)
115
g_settings_set_string (mock_settings, "last-command", "switch-to-guest");
119
my_switch_to_username (IndicatorSessionActions * self G_GNUC_UNUSED,
120
const char * username)
122
gchar * str = g_strdup_printf ("switch-to-user::%s", username);
123
g_settings_set_string (mock_settings, "last-command", str);
127
my_help (IndicatorSessionActions * self G_GNUC_UNUSED)
129
g_settings_set_string (mock_settings, "last-command", "help");
133
my_about (IndicatorSessionActions * self G_GNUC_UNUSED)
135
g_settings_set_string (mock_settings, "last-command", "about");
139
my_settings (IndicatorSessionActions * self G_GNUC_UNUSED)
141
g_settings_set_string (mock_settings, "last-command", "settings");
145
my_online_accounts (IndicatorSessionActions * self G_GNUC_UNUSED)
147
g_settings_set_string (mock_settings, "last-command", "online-accounts");
151
my_can_prompt (IndicatorSessionActions * self G_GNUC_UNUSED)
153
return g_settings_get_boolean (mock_settings, "can-prompt");
157
my_has_online_account_error (IndicatorSessionActions * self G_GNUC_UNUSED)
159
return g_settings_get_boolean (mock_settings, "has-online-account-error");
163
my_dispose (GObject * o)
165
G_OBJECT_CLASS (indicator_session_actions_mock_parent_class)->dispose (o);
169
my_finalize (GObject * o)
171
G_OBJECT_CLASS (indicator_session_actions_mock_parent_class)->finalize (o);
175
**** GObject Boilerplate
179
/* cppcheck-suppress unusedFunction */
180
indicator_session_actions_mock_class_init (IndicatorSessionActionsMockClass * klass)
182
GObjectClass * object_class;
183
IndicatorSessionActionsClass * actions_class;
185
object_class = G_OBJECT_CLASS (klass);
186
object_class->dispose = my_dispose;
187
object_class->finalize = my_finalize;
189
actions_class = INDICATOR_SESSION_ACTIONS_CLASS (klass);
190
actions_class->can_lock = my_can_lock;
191
actions_class->can_logout = my_can_logout;
192
actions_class->can_reboot = my_can_reboot;
193
actions_class->can_switch = my_can_switch;
194
actions_class->can_suspend = my_can_suspend;
195
actions_class->can_hibernate = my_can_hibernate;
196
actions_class->can_prompt = my_can_prompt;
197
actions_class->has_online_account_error = my_has_online_account_error;
198
actions_class->logout = my_logout;
199
actions_class->suspend = my_suspend;
200
actions_class->hibernate = my_hibernate;
201
actions_class->reboot = my_reboot;
202
actions_class->power_off = my_power_off;
203
actions_class->settings = my_settings;
204
actions_class->online_accounts = my_online_accounts;
205
actions_class->help = my_help;
206
actions_class->about = my_about;
207
actions_class->switch_to_screensaver = my_switch_to_screensaver;
208
actions_class->switch_to_greeter = my_switch_to_greeter;
209
actions_class->switch_to_guest = my_switch_to_guest;
210
actions_class->switch_to_username = my_switch_to_username;
214
/* cppcheck-suppress unusedFunction */
215
indicator_session_actions_mock_init (IndicatorSessionActionsMock * self)
217
g_signal_connect_swapped (mock_settings, "changed::can-lock",
218
G_CALLBACK(indicator_session_actions_notify_can_lock), self);
219
g_signal_connect_swapped (mock_settings, "changed::can-logout",
220
G_CALLBACK(indicator_session_actions_notify_can_logout), self);
221
g_signal_connect_swapped (mock_settings, "changed::can-switch-sessions",
222
G_CALLBACK(indicator_session_actions_notify_can_switch), self);
223
g_signal_connect_swapped (mock_settings, "changed::can-suspend",
224
G_CALLBACK(indicator_session_actions_notify_can_suspend), self);
225
g_signal_connect_swapped (mock_settings, "changed::can-hibernate",
226
G_CALLBACK(indicator_session_actions_notify_can_hibernate), self);
227
g_signal_connect_swapped (mock_settings, "changed::can-prompt",
228
G_CALLBACK(indicator_session_actions_notify_can_prompt), self);
229
g_signal_connect_swapped (mock_settings, "changed::has-online-account-error",
230
G_CALLBACK(indicator_session_actions_notify_has_online_account_error), self);
237
IndicatorSessionActions *
238
indicator_session_actions_mock_new (void)
240
gpointer o = g_object_new (INDICATOR_TYPE_SESSION_ACTIONS_MOCK, NULL);
242
return INDICATOR_SESSION_ACTIONS (o);