File: | cafe-session/csm-logout-dialog.c |
Warning: | line 210, column 9 Value stored to 'ret' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
2 | * |
3 | * Copyright (C) 2006 Vincent Untz |
4 | * Copyright (C) 2008 Red Hat, Inc. |
5 | * |
6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation; either version 2 of the |
9 | * License, or (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, but |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | * General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
19 | * 02110-1301, USA. |
20 | * |
21 | * Authors: |
22 | * Vincent Untz <vuntz@gnome.org> |
23 | */ |
24 | |
25 | #include <config.h> |
26 | |
27 | #include <glib/gi18n.h> |
28 | #include <ctk/ctk.h> |
29 | |
30 | #include "csm-logout-dialog.h" |
31 | #ifdef HAVE_SYSTEMD1 |
32 | #include "csm-systemd.h" |
33 | #endif |
34 | #include "csm-consolekit.h" |
35 | #include "cdm.h" |
36 | #include "csm-util.h" |
37 | |
38 | #define CSM_ICON_LOGOUT"system-log-out" "system-log-out" |
39 | #define CSM_ICON_SHUTDOWN"system-shutdown" "system-shutdown" |
40 | |
41 | #define SESSION_SCHEMA"org.cafe.session" "org.cafe.session" |
42 | #define KEY_LOGOUT_TIMEOUT"logout-timeout" "logout-timeout" |
43 | |
44 | #define LOCKDOWN_SCHEMA"org.cafe.lockdown" "org.cafe.lockdown" |
45 | #define KEY_USER_SWITCHING_DISABLE"disable-user-switching" "disable-user-switching" |
46 | |
47 | typedef enum { |
48 | CSM_DIALOG_LOGOUT_TYPE_LOGOUT, |
49 | CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN |
50 | } CsmDialogLogoutType; |
51 | |
52 | struct _CsmLogoutDialog |
53 | { |
54 | CtkMessageDialog parent; |
55 | CsmDialogLogoutType type; |
56 | #ifdef HAVE_SYSTEMD1 |
57 | CsmSystemd *systemd; |
58 | #endif |
59 | CsmConsolekit *consolekit; |
60 | |
61 | CtkWidget *progressbar; |
62 | |
63 | int timeout; |
64 | unsigned int timeout_id; |
65 | |
66 | unsigned int default_response; |
67 | }; |
68 | |
69 | static CsmLogoutDialog *current_dialog = NULL((void*)0); |
70 | |
71 | static void csm_logout_dialog_set_timeout (CsmLogoutDialog *logout_dialog); |
72 | |
73 | static void csm_logout_dialog_destroy (CsmLogoutDialog *logout_dialog, |
74 | gpointer data); |
75 | |
76 | static void csm_logout_dialog_show (CsmLogoutDialog *logout_dialog, |
77 | gpointer data); |
78 | |
79 | enum { |
80 | PROP_0, |
81 | PROP_MESSAGE_TYPE |
82 | }; |
83 | |
84 | G_DEFINE_TYPE (CsmLogoutDialog, csm_logout_dialog, CTK_TYPE_MESSAGE_DIALOG)static void csm_logout_dialog_init (CsmLogoutDialog *self); static void csm_logout_dialog_class_init (CsmLogoutDialogClass *klass ); static GType csm_logout_dialog_get_type_once (void); static gpointer csm_logout_dialog_parent_class = ((void*)0); static gint CsmLogoutDialog_private_offset; static void csm_logout_dialog_class_intern_init (gpointer klass) { csm_logout_dialog_parent_class = g_type_class_peek_parent (klass); if (CsmLogoutDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CsmLogoutDialog_private_offset); csm_logout_dialog_class_init ((CsmLogoutDialogClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer csm_logout_dialog_get_instance_private (CsmLogoutDialog *self) { return (((gpointer) ((guint8*) (self ) + (glong) (CsmLogoutDialog_private_offset)))); } GType csm_logout_dialog_get_type (void) { static gsize static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id )); }))) { GType g_define_type_id = csm_logout_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id) = (g_define_type_id) ) : (void) 0; g_once_init_leave ((&static_g_define_type_id ), (gsize) (g_define_type_id)); })); } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType csm_logout_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_message_dialog_get_type ()), g_intern_static_string ("CsmLogoutDialog" ), sizeof (CsmLogoutDialogClass), (GClassInitFunc)(void (*)(void )) csm_logout_dialog_class_intern_init, sizeof (CsmLogoutDialog ), (GInstanceInitFunc)(void (*)(void)) csm_logout_dialog_init , (GTypeFlags) 0); { {{};} } return g_define_type_id; }; |
85 | |
86 | static void |
87 | csm_logout_dialog_set_property (GObject *object, |
88 | guint prop_id, |
89 | const GValue *value, |
90 | GParamSpec *pspec) |
91 | { |
92 | switch (prop_id) { |
93 | case PROP_MESSAGE_TYPE: |
94 | break; |
95 | default: |
96 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "csm-logout-dialog.c", 96, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
97 | break; |
98 | } |
99 | } |
100 | |
101 | static void |
102 | csm_logout_dialog_get_property (GObject *object, |
103 | guint prop_id, |
104 | GValue *value, |
105 | GParamSpec *pspec) |
106 | { |
107 | switch (prop_id) { |
108 | case PROP_MESSAGE_TYPE: |
109 | g_value_set_enum (value, CTK_MESSAGE_WARNING); |
110 | break; |
111 | default: |
112 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "csm-logout-dialog.c", 112, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
113 | break; |
114 | } |
115 | } |
116 | |
117 | static void |
118 | csm_logout_dialog_class_init (CsmLogoutDialogClass *klass) |
119 | { |
120 | GObjectClass *gobject_class; |
121 | |
122 | gobject_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
123 | |
124 | /* This is a workaround to avoid a stupid crash: libcafeui |
125 | * listens for the "show" signal on all CtkMessageDialog and |
126 | * gets the "message-type" of the dialogs. We will crash when |
127 | * it accesses this property if we don't override it since we |
128 | * didn't define it. */ |
129 | gobject_class->set_property = csm_logout_dialog_set_property; |
130 | gobject_class->get_property = csm_logout_dialog_get_property; |
131 | |
132 | g_object_class_override_property (gobject_class, |
133 | PROP_MESSAGE_TYPE, |
134 | "message-type"); |
135 | } |
136 | |
137 | static void |
138 | csm_logout_dialog_init (CsmLogoutDialog *logout_dialog) |
139 | { |
140 | logout_dialog->timeout_id = 0; |
141 | logout_dialog->timeout = 0; |
142 | logout_dialog->default_response = CTK_RESPONSE_CANCEL; |
143 | |
144 | CtkStyleContext *context; |
145 | context = ctk_widget_get_style_context (CTK_WIDGET (logout_dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_widget_get_type ()))))))); |
146 | ctk_style_context_add_class (context, "logout-dialog"); |
147 | |
148 | ctk_window_set_skip_taskbar_hint (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); |
149 | ctk_window_set_keep_above (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), TRUE(!(0))); |
150 | ctk_window_stick (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ()))))))); |
151 | #ifdef HAVE_SYSTEMD1 |
152 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
153 | logout_dialog->systemd = csm_get_systemd (); |
154 | else |
155 | #endif |
156 | logout_dialog->consolekit = csm_get_consolekit (); |
157 | |
158 | g_signal_connect (logout_dialog,g_signal_connect_data ((logout_dialog), ("destroy"), (((GCallback ) (csm_logout_dialog_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
159 | "destroy",g_signal_connect_data ((logout_dialog), ("destroy"), (((GCallback ) (csm_logout_dialog_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
160 | G_CALLBACK (csm_logout_dialog_destroy),g_signal_connect_data ((logout_dialog), ("destroy"), (((GCallback ) (csm_logout_dialog_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
161 | NULL)g_signal_connect_data ((logout_dialog), ("destroy"), (((GCallback ) (csm_logout_dialog_destroy))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); |
162 | |
163 | g_signal_connect (logout_dialog,g_signal_connect_data ((logout_dialog), ("show"), (((GCallback ) (csm_logout_dialog_show))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
164 | "show",g_signal_connect_data ((logout_dialog), ("show"), (((GCallback ) (csm_logout_dialog_show))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
165 | G_CALLBACK (csm_logout_dialog_show),g_signal_connect_data ((logout_dialog), ("show"), (((GCallback ) (csm_logout_dialog_show))), (((void*)0)), ((void*)0), (GConnectFlags ) 0) |
166 | NULL)g_signal_connect_data ((logout_dialog), ("show"), (((GCallback ) (csm_logout_dialog_show))), (((void*)0)), ((void*)0), (GConnectFlags ) 0); |
167 | } |
168 | |
169 | static void |
170 | csm_logout_dialog_destroy (CsmLogoutDialog *logout_dialog, |
171 | gpointer data) |
172 | { |
173 | if (logout_dialog->timeout_id != 0) { |
174 | g_source_remove (logout_dialog->timeout_id); |
175 | logout_dialog->timeout_id = 0; |
176 | } |
177 | #ifdef HAVE_SYSTEMD1 |
178 | if (logout_dialog->systemd) { |
179 | g_object_unref (logout_dialog->systemd); |
180 | logout_dialog->systemd = NULL((void*)0); |
181 | } |
182 | #endif |
183 | |
184 | if (logout_dialog->consolekit) { |
185 | g_object_unref (logout_dialog->consolekit); |
186 | logout_dialog->consolekit = NULL((void*)0); |
187 | } |
188 | |
189 | current_dialog = NULL((void*)0); |
190 | } |
191 | |
192 | static gboolean |
193 | csm_logout_supports_system_suspend (CsmLogoutDialog *logout_dialog) |
194 | { |
195 | gboolean ret; |
196 | ret = FALSE(0); |
197 | #ifdef HAVE_SYSTEMD1 |
198 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
199 | ret = csm_systemd_can_suspend (logout_dialog->systemd); |
200 | else |
201 | #endif |
202 | ret = csm_consolekit_can_suspend (logout_dialog->consolekit); |
203 | return ret; |
204 | } |
205 | |
206 | static gboolean |
207 | csm_logout_supports_system_hibernate (CsmLogoutDialog *logout_dialog) |
208 | { |
209 | gboolean ret; |
210 | ret = FALSE(0); |
Value stored to 'ret' is never read | |
211 | #ifdef HAVE_SYSTEMD1 |
212 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
213 | ret = csm_systemd_can_hibernate (logout_dialog->systemd); |
214 | else |
215 | #endif |
216 | ret = csm_consolekit_can_hibernate (logout_dialog->consolekit); |
217 | return ret; |
218 | } |
219 | |
220 | static gboolean |
221 | csm_logout_supports_switch_user (CsmLogoutDialog *logout_dialog) |
222 | { |
223 | GSettings *settings; |
224 | gboolean ret = FALSE(0); |
225 | gboolean locked; |
226 | |
227 | settings = g_settings_new (LOCKDOWN_SCHEMA"org.cafe.lockdown"); |
228 | |
229 | locked = g_settings_get_boolean (settings, KEY_USER_SWITCHING_DISABLE"disable-user-switching"); |
230 | g_object_unref (settings); |
231 | |
232 | if (!locked) { |
233 | #ifdef HAVE_SYSTEMD1 |
234 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
235 | ret = csm_systemd_can_switch_user (logout_dialog->systemd); |
236 | else |
237 | #endif |
238 | ret = csm_consolekit_can_switch_user (logout_dialog->consolekit); |
239 | } |
240 | |
241 | return ret; |
242 | } |
243 | |
244 | static gboolean |
245 | csm_logout_supports_reboot (CsmLogoutDialog *logout_dialog) |
246 | { |
247 | gboolean ret; |
248 | |
249 | #ifdef HAVE_SYSTEMD1 |
250 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
251 | ret = csm_systemd_can_restart (logout_dialog->systemd); |
252 | else |
253 | #endif |
254 | ret = csm_consolekit_can_restart (logout_dialog->consolekit); |
255 | if (!ret) { |
256 | ret = cdm_supports_logout_action (CDM_LOGOUT_ACTION_REBOOT); |
257 | } |
258 | |
259 | return ret; |
260 | } |
261 | |
262 | static gboolean |
263 | csm_logout_supports_shutdown (CsmLogoutDialog *logout_dialog) |
264 | { |
265 | gboolean ret; |
266 | |
267 | #ifdef HAVE_SYSTEMD1 |
268 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) |
269 | ret = csm_systemd_can_stop (logout_dialog->systemd); |
270 | else |
271 | #endif |
272 | ret = csm_consolekit_can_stop (logout_dialog->consolekit); |
273 | |
274 | if (!ret) { |
275 | ret = cdm_supports_logout_action (CDM_LOGOUT_ACTION_SHUTDOWN); |
276 | } |
277 | |
278 | return ret; |
279 | } |
280 | |
281 | static void |
282 | csm_logout_dialog_show (CsmLogoutDialog *logout_dialog, gpointer user_data) |
283 | { |
284 | csm_logout_dialog_set_timeout (logout_dialog); |
285 | } |
286 | |
287 | static gboolean |
288 | csm_logout_dialog_timeout (gpointer data) |
289 | { |
290 | CsmLogoutDialog *logout_dialog; |
291 | char *seconds_warning; |
292 | char *secondary_text; |
293 | static char *session_type = NULL((void*)0); |
294 | static gboolean is_not_login; |
295 | |
296 | logout_dialog = (CsmLogoutDialog *) data; |
297 | |
298 | if (!logout_dialog->timeout) { |
299 | ctk_dialog_response (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
300 | logout_dialog->default_response); |
301 | |
302 | return FALSE(0); |
303 | } |
304 | |
305 | switch (logout_dialog->type) { |
306 | case CSM_DIALOG_LOGOUT_TYPE_LOGOUT: |
307 | seconds_warning = ngettext ("You will be automatically logged " |
308 | "out in %d second", |
309 | "You will be automatically logged " |
310 | "out in %d seconds", |
311 | logout_dialog->timeout); |
312 | break; |
313 | |
314 | case CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: |
315 | seconds_warning = ngettext ("This system will be automatically " |
316 | "shut down in %d second", |
317 | "This system will be automatically " |
318 | "shut down in %d seconds", |
319 | logout_dialog->timeout); |
320 | break; |
321 | |
322 | default: |
323 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "csm-logout-dialog.c" , 323, ((const char*) (__func__)), ((void*)0)); } while (0); |
324 | } |
325 | seconds_warning = g_strdup_printf (seconds_warning, logout_dialog->timeout); |
326 | |
327 | if (session_type == NULL((void*)0)) { |
328 | #ifdef HAVE_SYSTEMD1 |
329 | if (LOGIND_RUNNING()(access("/run/systemd/seats/", 0) >= 0)) { |
330 | CsmSystemd *systemd; |
331 | systemd = csm_get_systemd (); |
332 | session_type = csm_systemd_get_current_session_type (systemd); |
333 | g_object_unref (systemd); |
334 | is_not_login = (g_strcmp0 (session_type, CSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW"greeter") != 0); |
335 | } |
336 | else { |
337 | #endif |
338 | CsmConsolekit *consolekit; |
339 | consolekit = csm_get_consolekit (); |
340 | session_type = csm_consolekit_get_current_session_type (consolekit); |
341 | g_object_unref (consolekit); |
342 | is_not_login = (g_strcmp0 (session_type, CSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW"LoginWindow") != 0); |
343 | #ifdef HAVE_SYSTEMD1 |
344 | } |
345 | #endif |
346 | } |
347 | |
348 | if (is_not_login) { |
349 | char *name; |
350 | |
351 | name = g_locale_to_utf8 (g_get_real_name (), -1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
352 | |
353 | if (!name || name[0] == '\0' || strcmp (name, "Unknown") == 0) { |
354 | name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
355 | } |
356 | |
357 | if (!name) { |
358 | name = g_strdup (g_get_user_name ())g_strdup_inline (g_get_user_name ()); |
359 | } |
360 | |
361 | secondary_text = g_strdup_printf (_("You are currently logged in as \"%s\".")gettext ("You are currently logged in as \"%s\"."), name); |
362 | |
363 | g_free (name); |
364 | } else { |
365 | secondary_text = g_strdup (seconds_warning)g_strdup_inline (seconds_warning); |
366 | } |
367 | |
368 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (logout_dialog->progressbar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog->progressbar)), ((ctk_progress_bar_get_type ())))))), |
369 | logout_dialog->timeout / 60.0); |
370 | ctk_progress_bar_set_text (CTK_PROGRESS_BAR (logout_dialog->progressbar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog->progressbar)), ((ctk_progress_bar_get_type ())))))), |
371 | seconds_warning); |
372 | |
373 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (logout_dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((logout_dialog)), ((ctk_message_dialog_get_type ())))))), |
374 | secondary_text, |
375 | NULL((void*)0)); |
376 | |
377 | logout_dialog->timeout--; |
378 | |
379 | g_free (secondary_text); |
380 | g_free (seconds_warning); |
381 | |
382 | return TRUE(!(0)); |
383 | } |
384 | |
385 | static void |
386 | csm_logout_dialog_set_timeout (CsmLogoutDialog *logout_dialog) |
387 | { |
388 | GSettings *settings; |
389 | |
390 | settings = g_settings_new (SESSION_SCHEMA"org.cafe.session"); |
391 | |
392 | logout_dialog->timeout = g_settings_get_int (settings, KEY_LOGOUT_TIMEOUT"logout-timeout"); |
393 | |
394 | if (logout_dialog->timeout > 0) { |
395 | /* Sets the secondary text */ |
396 | csm_logout_dialog_timeout (logout_dialog); |
397 | |
398 | if (logout_dialog->timeout_id != 0) { |
399 | g_source_remove (logout_dialog->timeout_id); |
400 | } |
401 | |
402 | logout_dialog->timeout_id = g_timeout_add (1000, |
403 | csm_logout_dialog_timeout, |
404 | logout_dialog); |
405 | } |
406 | else { |
407 | ctk_widget_hide (logout_dialog->progressbar); |
408 | } |
409 | |
410 | g_object_unref (settings); |
411 | } |
412 | |
413 | static CtkWidget * |
414 | csm_get_dialog (CsmDialogLogoutType type, |
415 | CdkScreen *screen, |
416 | guint32 activate_time) |
417 | { |
418 | CsmLogoutDialog *logout_dialog; |
419 | CtkWidget *hbox; |
420 | const char *primary_text; |
421 | const char *icon_name; |
422 | |
423 | if (current_dialog != NULL((void*)0)) { |
424 | ctk_widget_destroy (CTK_WIDGET (current_dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current_dialog)), ((ctk_widget_get_type ()))))))); |
425 | } |
426 | |
427 | logout_dialog = g_object_new (CSM_TYPE_LOGOUT_DIALOG(csm_logout_dialog_get_type ()), NULL((void*)0)); |
428 | |
429 | current_dialog = logout_dialog; |
430 | |
431 | ctk_window_set_title (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), ""); |
432 | |
433 | logout_dialog->type = type; |
434 | |
435 | icon_name = NULL((void*)0); |
436 | primary_text = NULL((void*)0); |
437 | |
438 | switch (type) { |
439 | case CSM_DIALOG_LOGOUT_TYPE_LOGOUT: |
440 | icon_name = CSM_ICON_LOGOUT"system-log-out"; |
441 | primary_text = _("Log out of this system now?")gettext ("Log out of this system now?"); |
442 | |
443 | logout_dialog->default_response = CSM_LOGOUT_RESPONSE_LOGOUT; |
444 | |
445 | if (csm_logout_supports_switch_user (logout_dialog)) { |
446 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
447 | _("_Switch User")gettext ("_Switch User"), |
448 | CSM_LOGOUT_RESPONSE_SWITCH_USER); |
449 | } |
450 | |
451 | csm_util_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
452 | _("_Cancel")gettext ("_Cancel"), "process-stop", |
453 | CTK_RESPONSE_CANCEL); |
454 | |
455 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
456 | _("_Log Out")gettext ("_Log Out"), |
457 | CSM_LOGOUT_RESPONSE_LOGOUT); |
458 | |
459 | break; |
460 | case CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN: |
461 | icon_name = CSM_ICON_SHUTDOWN"system-shutdown"; |
462 | primary_text = _("Shut down this system now?")gettext ("Shut down this system now?"); |
463 | |
464 | logout_dialog->default_response = CSM_LOGOUT_RESPONSE_SHUTDOWN; |
465 | |
466 | if (csm_logout_supports_system_suspend (logout_dialog)) { |
467 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
468 | _("S_uspend")gettext ("S_uspend"), |
469 | CSM_LOGOUT_RESPONSE_SLEEP); |
470 | } |
471 | |
472 | if (csm_logout_supports_system_hibernate (logout_dialog)) { |
473 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
474 | _("_Hibernate")gettext ("_Hibernate"), |
475 | CSM_LOGOUT_RESPONSE_HIBERNATE); |
476 | } |
477 | |
478 | if (csm_logout_supports_reboot (logout_dialog)) { |
479 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
480 | _("_Restart")gettext ("_Restart"), |
481 | CSM_LOGOUT_RESPONSE_REBOOT); |
482 | } |
483 | |
484 | csm_util_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
485 | _("_Cancel")gettext ("_Cancel"), "process-stop", |
486 | CTK_RESPONSE_CANCEL); |
487 | |
488 | if (csm_logout_supports_shutdown (logout_dialog)) { |
489 | ctk_dialog_add_button (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
490 | _("_Shut Down")gettext ("_Shut Down"), |
491 | CSM_LOGOUT_RESPONSE_SHUTDOWN); |
492 | } |
493 | break; |
494 | default: |
495 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "csm-logout-dialog.c" , 495, ((const char*) (__func__)), ((void*)0)); } while (0); |
496 | } |
497 | |
498 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 0); |
499 | logout_dialog->progressbar = ctk_progress_bar_new (); |
500 | ctk_progress_bar_set_show_text (CTK_PROGRESS_BAR (logout_dialog->progressbar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog->progressbar)), ((ctk_progress_bar_get_type ())))))), TRUE(!(0))); |
501 | ctk_progress_bar_set_fraction (CTK_PROGRESS_BAR (logout_dialog->progressbar)((((CtkProgressBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog->progressbar)), ((ctk_progress_bar_get_type ())))))), 1.0); |
502 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), |
503 | logout_dialog->progressbar, |
504 | TRUE(!(0)), TRUE(!(0)), 12); |
505 | ctk_widget_show_all (hbox); |
506 | ctk_container_add (CTK_CONTAINER (ctk_dialog_get_content_area (CTK_DIALOG (logout_dialog)))((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((logout_dialog)), ((ctk_dialog_get_type ( )))))))))), ((ctk_container_get_type ())))))), hbox); |
507 | |
508 | ctk_window_set_icon_name (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), icon_name); |
509 | ctk_window_set_position (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), CTK_WIN_POS_CENTER_ALWAYS); |
510 | ctk_message_dialog_set_markup (CTK_MESSAGE_DIALOG (logout_dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((logout_dialog)), ((ctk_message_dialog_get_type ())))))), primary_text); |
511 | |
512 | ctk_dialog_set_default_response (CTK_DIALOG (logout_dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_dialog_get_type ())))))), |
513 | logout_dialog->default_response); |
514 | |
515 | ctk_window_set_screen (CTK_WINDOW (logout_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_window_get_type ())))))), screen); |
516 | |
517 | return CTK_WIDGET (logout_dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((logout_dialog)), ((ctk_widget_get_type ())))))); |
518 | } |
519 | |
520 | CtkWidget * |
521 | csm_get_shutdown_dialog (CdkScreen *screen, |
522 | guint32 activate_time) |
523 | { |
524 | return csm_get_dialog (CSM_DIALOG_LOGOUT_TYPE_SHUTDOWN, |
525 | screen, |
526 | activate_time); |
527 | } |
528 | |
529 | CtkWidget * |
530 | csm_get_logout_dialog (CdkScreen *screen, |
531 | guint32 activate_time) |
532 | { |
533 | return csm_get_dialog (CSM_DIALOG_LOGOUT_TYPE_LOGOUT, |
534 | screen, |
535 | activate_time); |
536 | } |