File: | ctk/ctkmountoperation.c |
Warning: | line 1644, column 80 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | /* CTK - The GIMP Toolkit |
3 | * Copyright (C) Christian Kellner <gicmo@gnome.org> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Lesser General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Lesser General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Lesser General Public |
16 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | /* |
20 | * Modified by the CTK+ Team and others 1997-2000. See the AUTHORS |
21 | * file for a list of people on the CTK+ Team. See the ChangeLog |
22 | * files for a list of changes. These files are distributed with |
23 | * CTK+ at ftp://ftp.ctk.org/pub/ctk/. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | |
28 | #include <errno(*__errno_location ()).h> |
29 | #include <string.h> |
30 | |
31 | #include "ctkmountoperationprivate.h" |
32 | #include "ctkbox.h" |
33 | #include "ctkcssiconthemevalueprivate.h" |
34 | #include "ctkdbusgenerated.h" |
35 | #include "ctkentry.h" |
36 | #include "ctkbox.h" |
37 | #include "ctkintl.h" |
38 | #include "ctklabel.h" |
39 | #include "ctkmessagedialog.h" |
40 | #include "ctkmountoperation.h" |
41 | #include "ctkprivate.h" |
42 | #include "ctkradiobutton.h" |
43 | #include "ctkgrid.h" |
44 | #include "ctkwindow.h" |
45 | #include "ctktreeview.h" |
46 | #include "ctktreeselection.h" |
47 | #include "ctkcellrenderertext.h" |
48 | #include "ctkcellrendererpixbuf.h" |
49 | #include "ctkscrolledwindow.h" |
50 | #include "ctkicontheme.h" |
51 | #include "ctkmenuitem.h" |
52 | #include "ctkmain.h" |
53 | #include "ctksettings.h" |
54 | #include "ctkstylecontextprivate.h" |
55 | |
56 | #include <glib/gprintf.h> |
57 | |
58 | /** |
59 | * SECTION:filesystem |
60 | * @short_description: Functions for working with GIO |
61 | * @Title: Filesystem utilities |
62 | * |
63 | * The functions and objects described here make working with CTK+ and |
64 | * GIO more convenient. |
65 | * |
66 | * #CtkMountOperation is needed when mounting volumes: |
67 | * It is an implementation of #GMountOperation that can be used with |
68 | * GIO functions for mounting volumes such as |
69 | * g_file_mount_enclosing_volume(), g_file_mount_mountable(), |
70 | * g_volume_mount(), g_mount_unmount_with_operation() and others. |
71 | * |
72 | * When necessary, #CtkMountOperation shows dialogs to ask for |
73 | * passwords, questions or show processes blocking unmount. |
74 | * |
75 | * ctk_show_uri_on_window() is a convenient way to launch applications for URIs. |
76 | * |
77 | * Another object that is worth mentioning in this context is |
78 | * #CdkAppLaunchContext, which provides visual feedback when lauching |
79 | * applications. |
80 | */ |
81 | |
82 | static void ctk_mount_operation_finalize (GObject *object); |
83 | static void ctk_mount_operation_set_property (GObject *object, |
84 | guint prop_id, |
85 | const GValue *value, |
86 | GParamSpec *pspec); |
87 | static void ctk_mount_operation_get_property (GObject *object, |
88 | guint prop_id, |
89 | GValue *value, |
90 | GParamSpec *pspec); |
91 | |
92 | static void ctk_mount_operation_ask_password (GMountOperation *op, |
93 | const char *message, |
94 | const char *default_user, |
95 | const char *default_domain, |
96 | GAskPasswordFlags flags); |
97 | |
98 | static void ctk_mount_operation_ask_question (GMountOperation *op, |
99 | const char *message, |
100 | const char *choices[]); |
101 | |
102 | static void ctk_mount_operation_show_processes (GMountOperation *op, |
103 | const char *message, |
104 | GArray *processes, |
105 | const char *choices[]); |
106 | |
107 | static void ctk_mount_operation_aborted (GMountOperation *op); |
108 | |
109 | struct _CtkMountOperationPrivate { |
110 | CtkWindow *parent_window; |
111 | CtkDialog *dialog; |
112 | CdkScreen *screen; |
113 | |
114 | /* bus proxy */ |
115 | _CtkMountOperationHandler *handler; |
116 | GCancellable *cancellable; |
117 | gboolean handler_showing; |
118 | |
119 | /* for the ask-password dialog */ |
120 | CtkWidget *grid; |
121 | CtkWidget *username_entry; |
122 | CtkWidget *domain_entry; |
123 | CtkWidget *password_entry; |
124 | CtkWidget *pim_entry; |
125 | CtkWidget *anonymous_toggle; |
126 | CtkWidget *tcrypt_hidden_toggle; |
127 | CtkWidget *tcrypt_system_toggle; |
128 | GList *user_widgets; |
129 | |
130 | GAskPasswordFlags ask_flags; |
131 | GPasswordSave password_save; |
132 | gboolean anonymous; |
133 | |
134 | /* for the show-processes dialog */ |
135 | CtkWidget *process_tree_view; |
136 | CtkListStore *process_list_store; |
137 | }; |
138 | |
139 | enum { |
140 | PROP_0, |
141 | PROP_PARENT, |
142 | PROP_IS_SHOWING, |
143 | PROP_SCREEN |
144 | |
145 | }; |
146 | |
147 | G_DEFINE_TYPE_WITH_PRIVATE (CtkMountOperation, ctk_mount_operation, G_TYPE_MOUNT_OPERATION)static void ctk_mount_operation_init (CtkMountOperation *self ); static void ctk_mount_operation_class_init (CtkMountOperationClass *klass); static GType ctk_mount_operation_get_type_once (void ); static gpointer ctk_mount_operation_parent_class = ((void* )0); static gint CtkMountOperation_private_offset; static void ctk_mount_operation_class_intern_init (gpointer klass) { ctk_mount_operation_parent_class = g_type_class_peek_parent (klass); if (CtkMountOperation_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkMountOperation_private_offset ); ctk_mount_operation_class_init ((CtkMountOperationClass*) klass ); } __attribute__ ((__unused__)) static inline gpointer ctk_mount_operation_get_instance_private (CtkMountOperation *self) { return (((gpointer) ((guint8*) ( self) + (glong) (CtkMountOperation_private_offset)))); } GType ctk_mount_operation_get_type (void) { static GType 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_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_mount_operation_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_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_mount_operation_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((g_mount_operation_get_type ()), g_intern_static_string ("CtkMountOperation" ), sizeof (CtkMountOperationClass), (GClassInitFunc)(void (*) (void)) ctk_mount_operation_class_intern_init, sizeof (CtkMountOperation ), (GInstanceInitFunc)(void (*)(void)) ctk_mount_operation_init , (GTypeFlags) 0); { {{ CtkMountOperation_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkMountOperationPrivate)); };} } return g_define_type_id; } |
148 | |
149 | static void |
150 | ctk_mount_operation_class_init (CtkMountOperationClass *klass) |
151 | { |
152 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
153 | GMountOperationClass *mount_op_class = G_MOUNT_OPERATION_CLASS (klass)((((GMountOperationClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((klass)), ((g_mount_operation_get_type ()))))) ); |
154 | |
155 | object_class->finalize = ctk_mount_operation_finalize; |
156 | object_class->get_property = ctk_mount_operation_get_property; |
157 | object_class->set_property = ctk_mount_operation_set_property; |
158 | |
159 | mount_op_class->ask_password = ctk_mount_operation_ask_password; |
160 | mount_op_class->ask_question = ctk_mount_operation_ask_question; |
161 | mount_op_class->show_processes = ctk_mount_operation_show_processes; |
162 | mount_op_class->aborted = ctk_mount_operation_aborted; |
163 | |
164 | g_object_class_install_property (object_class, |
165 | PROP_PARENT, |
166 | g_param_spec_object ("parent", |
167 | P_("Parent")g_dgettext("ctk30" "-properties","Parent"), |
168 | P_("The parent window")g_dgettext("ctk30" "-properties","The parent window"), |
169 | CTK_TYPE_WINDOW(ctk_window_get_type ()), |
170 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
171 | |
172 | g_object_class_install_property (object_class, |
173 | PROP_IS_SHOWING, |
174 | g_param_spec_boolean ("is-showing", |
175 | P_("Is Showing")g_dgettext("ctk30" "-properties","Is Showing"), |
176 | P_("Are we showing a dialog")g_dgettext("ctk30" "-properties","Are we showing a dialog"), |
177 | FALSE(0), |
178 | CTK_PARAM_READABLEG_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
179 | |
180 | g_object_class_install_property (object_class, |
181 | PROP_SCREEN, |
182 | g_param_spec_object ("screen", |
183 | P_("Screen")g_dgettext("ctk30" "-properties","Screen"), |
184 | P_("The screen where this window will be displayed.")g_dgettext("ctk30" "-properties","The screen where this window will be displayed." ), |
185 | CDK_TYPE_SCREEN(cdk_screen_get_type ()), |
186 | CTK_PARAM_READWRITEG_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); |
187 | } |
188 | |
189 | static void |
190 | ctk_mount_operation_init (CtkMountOperation *operation) |
191 | { |
192 | gchar *name_owner; |
193 | |
194 | operation->priv = ctk_mount_operation_get_instance_private (operation); |
195 | |
196 | operation->priv->handler = |
197 | _ctk_mount_operation_handler_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, |
198 | G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, |
199 | "org.ctk.MountOperationHandler", |
200 | "/org/ctk/MountOperationHandler", |
201 | NULL((void*)0), NULL((void*)0)); |
202 | name_owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (operation->priv->handler)((((GDBusProxy*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation->priv->handler)), ((g_dbus_proxy_get_type ()))))))); |
203 | if (!name_owner) |
204 | g_clear_object (&operation->priv->handler)do { _Static_assert (sizeof *((&operation->priv->handler )) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (((&operation->priv->handler))) _pp = ((&operation ->priv->handler)); __typeof__ (*((&operation->priv ->handler))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref ) (_ptr); } while (0); |
205 | g_free (name_owner); |
206 | |
207 | if (operation->priv->handler) |
208 | g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (operation->priv->handler)((((GDBusProxy*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation->priv->handler)), ((g_dbus_proxy_get_type ())))))), G_MAXINT2147483647); |
209 | } |
210 | |
211 | static void |
212 | ctk_mount_operation_finalize (GObject *object) |
213 | { |
214 | CtkMountOperation *operation = CTK_MOUNT_OPERATION (object)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_mount_operation_get_type ( ))))))); |
215 | CtkMountOperationPrivate *priv = operation->priv; |
216 | |
217 | if (priv->user_widgets) |
218 | g_list_free (priv->user_widgets); |
219 | |
220 | if (priv->parent_window) |
221 | { |
222 | g_signal_handlers_disconnect_by_func (priv->parent_window,g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )) |
223 | ctk_widget_destroyed,g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )) |
224 | &priv->parent_window)g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )); |
225 | g_object_unref (priv->parent_window); |
226 | } |
227 | |
228 | if (priv->screen) |
229 | g_object_unref (priv->screen); |
230 | |
231 | if (priv->handler) |
232 | g_object_unref (priv->handler); |
233 | |
234 | G_OBJECT_CLASS (ctk_mount_operation_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_mount_operation_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
235 | } |
236 | |
237 | static void |
238 | ctk_mount_operation_set_property (GObject *object, |
239 | guint prop_id, |
240 | const GValue *value, |
241 | GParamSpec *pspec) |
242 | { |
243 | CtkMountOperation *operation = CTK_MOUNT_OPERATION (object)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_mount_operation_get_type ( ))))))); |
244 | |
245 | switch (prop_id) |
246 | { |
247 | case PROP_PARENT: |
248 | ctk_mount_operation_set_parent (operation, g_value_get_object (value)); |
249 | break; |
250 | |
251 | case PROP_SCREEN: |
252 | ctk_mount_operation_set_screen (operation, g_value_get_object (value)); |
253 | break; |
254 | |
255 | case PROP_IS_SHOWING: |
256 | default: |
257 | 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'" , "ctkmountoperation.c", 257, ("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); |
258 | break; |
259 | } |
260 | } |
261 | |
262 | static void |
263 | ctk_mount_operation_get_property (GObject *object, |
264 | guint prop_id, |
265 | GValue *value, |
266 | GParamSpec *pspec) |
267 | { |
268 | CtkMountOperation *operation = CTK_MOUNT_OPERATION (object)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((object)), ((ctk_mount_operation_get_type ( ))))))); |
269 | CtkMountOperationPrivate *priv = operation->priv; |
270 | |
271 | switch (prop_id) |
272 | { |
273 | case PROP_PARENT: |
274 | g_value_set_object (value, priv->parent_window); |
275 | break; |
276 | |
277 | case PROP_IS_SHOWING: |
278 | g_value_set_boolean (value, priv->dialog != NULL((void*)0) || priv->handler_showing); |
279 | break; |
280 | |
281 | case PROP_SCREEN: |
282 | g_value_set_object (value, priv->screen); |
283 | break; |
284 | |
285 | default: |
286 | 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'" , "ctkmountoperation.c", 286, ("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); |
287 | break; |
288 | } |
289 | } |
290 | |
291 | static void |
292 | ctk_mount_operation_proxy_finish (CtkMountOperation *op, |
293 | GMountOperationResult result) |
294 | { |
295 | _ctk_mount_operation_handler_call_close (op->priv->handler, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
296 | |
297 | op->priv->handler_showing = FALSE(0); |
298 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
299 | |
300 | g_mount_operation_reply (G_MOUNT_OPERATION (op)((((GMountOperation*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), ((g_mount_operation_get_type ())))))), result); |
301 | |
302 | /* drop the reference acquired when calling the proxy method */ |
303 | g_object_unref (op); |
304 | } |
305 | |
306 | static void |
307 | remember_button_toggled (CtkToggleButton *button, |
308 | CtkMountOperation *operation) |
309 | { |
310 | CtkMountOperationPrivate *priv = operation->priv; |
311 | |
312 | if (ctk_toggle_button_get_active (button)) |
313 | { |
314 | gpointer data; |
315 | |
316 | data = g_object_get_data (G_OBJECT (button)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), (((GType) ((20) << (2)))))))), "password-save"); |
317 | priv->password_save = GPOINTER_TO_INT (data)((gint) (glong) (data)); |
318 | } |
319 | } |
320 | |
321 | static void |
322 | pw_dialog_got_response (CtkDialog *dialog, |
323 | gint response_id, |
324 | CtkMountOperation *mount_op) |
325 | { |
326 | CtkMountOperationPrivate *priv = mount_op->priv; |
327 | GMountOperation *op = G_MOUNT_OPERATION (mount_op)((((GMountOperation*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((mount_op)), ((g_mount_operation_get_type ())))))); |
328 | |
329 | if (response_id == CTK_RESPONSE_OK) |
330 | { |
331 | const char *text; |
332 | |
333 | if (priv->ask_flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED) |
334 | g_mount_operation_set_anonymous (op, priv->anonymous); |
335 | |
336 | if (priv->username_entry) |
337 | { |
338 | text = ctk_entry_get_text (CTK_ENTRY (priv->username_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->username_entry)), ((ctk_entry_get_type ()))))))); |
339 | g_mount_operation_set_username (op, text); |
340 | } |
341 | |
342 | if (priv->domain_entry) |
343 | { |
344 | text = ctk_entry_get_text (CTK_ENTRY (priv->domain_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->domain_entry)), ((ctk_entry_get_type ()))))))); |
345 | g_mount_operation_set_domain (op, text); |
346 | } |
347 | |
348 | if (priv->password_entry) |
349 | { |
350 | text = ctk_entry_get_text (CTK_ENTRY (priv->password_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->password_entry)), ((ctk_entry_get_type ()))))))); |
351 | g_mount_operation_set_password (op, text); |
352 | } |
353 | |
354 | if (priv->pim_entry) |
355 | { |
356 | text = ctk_entry_get_text (CTK_ENTRY (priv->pim_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->pim_entry)), ((ctk_entry_get_type ()))))))); |
357 | if (text && strlen (text) > 0) |
358 | { |
359 | guint64 pim; |
360 | gchar *end = NULL((void*)0); |
361 | |
362 | errno(*__errno_location ()) = 0; |
363 | pim = g_ascii_strtoull (text, &end, 10); |
364 | if (errno(*__errno_location ()) == 0 && pim <= G_MAXUINT(2147483647 *2U +1U) && end != text) |
365 | g_mount_operation_set_pim (op, (guint) pim); |
366 | } |
367 | } |
368 | |
369 | if (priv->tcrypt_hidden_toggle && ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->tcrypt_hidden_toggle)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->tcrypt_hidden_toggle)), ((ctk_toggle_button_get_type ())))))))) |
370 | g_mount_operation_set_is_tcrypt_hidden_volume (op, TRUE(!(0))); |
371 | |
372 | if (priv->tcrypt_system_toggle && ctk_toggle_button_get_active (CTK_TOGGLE_BUTTON (priv->tcrypt_system_toggle)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->tcrypt_system_toggle)), ((ctk_toggle_button_get_type ())))))))) |
373 | g_mount_operation_set_is_tcrypt_system_volume (op, TRUE(!(0))); |
374 | |
375 | if (priv->ask_flags & G_ASK_PASSWORD_SAVING_SUPPORTED) |
376 | g_mount_operation_set_password_save (op, priv->password_save); |
377 | |
378 | g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED); |
379 | } |
380 | else |
381 | g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED); |
382 | |
383 | priv->dialog = NULL((void*)0); |
384 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
385 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
386 | g_object_unref (op); |
387 | } |
388 | |
389 | static gboolean |
390 | entry_has_input (CtkWidget *entry_widget) |
391 | { |
392 | const char *text; |
393 | |
394 | if (entry_widget == NULL((void*)0)) |
395 | return TRUE(!(0)); |
396 | |
397 | text = ctk_entry_get_text (CTK_ENTRY (entry_widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry_widget)), ((ctk_entry_get_type ()))))))); |
398 | |
399 | return text != NULL((void*)0) && text[0] != '\0'; |
400 | } |
401 | |
402 | static gboolean |
403 | pim_entry_is_valid (CtkWidget *entry_widget) |
404 | { |
405 | const char *text; |
406 | gchar *end = NULL((void*)0); |
407 | guint64 pim; |
408 | |
409 | if (entry_widget == NULL((void*)0)) |
410 | return TRUE(!(0)); |
411 | |
412 | text = ctk_entry_get_text (CTK_ENTRY (entry_widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry_widget)), ((ctk_entry_get_type ()))))))); |
413 | /* An empty PIM entry is OK */ |
414 | if (text == NULL((void*)0) || text[0] == '\0') |
415 | return TRUE(!(0)); |
416 | |
417 | errno(*__errno_location ()) = 0; |
418 | pim = g_ascii_strtoull (text, &end, 10); |
419 | if (errno(*__errno_location ()) || pim > G_MAXUINT(2147483647 *2U +1U) || end == text) |
420 | return FALSE(0); |
421 | else |
422 | return TRUE(!(0)); |
423 | } |
424 | |
425 | static gboolean |
426 | pw_dialog_input_is_valid (CtkMountOperation *operation) |
427 | { |
428 | CtkMountOperationPrivate *priv = operation->priv; |
429 | gboolean is_valid = TRUE(!(0)); |
430 | |
431 | /* We don't require password to be non-empty here |
432 | * since there are situations where it is not needed, |
433 | * see bug 578365. |
434 | * We may add a way for the backend to specify that it |
435 | * definitively needs a password. |
436 | */ |
437 | is_valid = entry_has_input (priv->username_entry) && |
438 | entry_has_input (priv->domain_entry) && |
439 | pim_entry_is_valid (priv->pim_entry); |
440 | |
441 | return is_valid; |
442 | } |
443 | |
444 | static void |
445 | pw_dialog_verify_input (CtkEditable *editable G_GNUC_UNUSED__attribute__ ((__unused__)), |
446 | CtkMountOperation *operation) |
447 | { |
448 | CtkMountOperationPrivate *priv = operation->priv; |
449 | gboolean is_valid; |
450 | |
451 | is_valid = pw_dialog_input_is_valid (operation); |
452 | ctk_dialog_set_response_sensitive (CTK_DIALOG (priv->dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_dialog_get_type ())))))), |
453 | CTK_RESPONSE_OK, |
454 | is_valid); |
455 | } |
456 | |
457 | static void |
458 | pw_dialog_anonymous_toggled (CtkWidget *widget, |
459 | CtkMountOperation *operation) |
460 | { |
461 | CtkMountOperationPrivate *priv = operation->priv; |
462 | gboolean is_valid; |
463 | GList *l; |
464 | |
465 | priv->anonymous = widget == priv->anonymous_toggle; |
466 | |
467 | if (priv->anonymous) |
468 | is_valid = TRUE(!(0)); |
469 | else |
470 | is_valid = pw_dialog_input_is_valid (operation); |
471 | |
472 | for (l = priv->user_widgets; l != NULL((void*)0); l = l->next) |
473 | { |
474 | ctk_widget_set_sensitive (CTK_WIDGET (l->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((l->data)), ((ctk_widget_get_type ())))))), !priv->anonymous); |
475 | } |
476 | |
477 | ctk_dialog_set_response_sensitive (CTK_DIALOG (priv->dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_dialog_get_type ())))))), |
478 | CTK_RESPONSE_OK, |
479 | is_valid); |
480 | } |
481 | |
482 | |
483 | static void |
484 | pw_dialog_cycle_focus (CtkWidget *widget, |
485 | CtkMountOperation *operation) |
486 | { |
487 | CtkMountOperationPrivate *priv; |
488 | CtkWidget *next_widget = NULL((void*)0); |
489 | |
490 | priv = operation->priv; |
491 | |
492 | if (widget == priv->username_entry) |
493 | { |
494 | if (priv->domain_entry != NULL((void*)0)) |
495 | next_widget = priv->domain_entry; |
496 | else if (priv->password_entry != NULL((void*)0)) |
497 | next_widget = priv->password_entry; |
498 | } |
499 | else if (widget == priv->domain_entry && priv->password_entry) |
500 | next_widget = priv->password_entry; |
501 | |
502 | if (next_widget) |
503 | ctk_widget_grab_focus (next_widget); |
504 | else if (pw_dialog_input_is_valid (operation)) |
505 | ctk_window_activate_default (CTK_WINDOW (priv->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_window_get_type ()))))))); |
506 | } |
507 | |
508 | static CtkWidget * |
509 | table_add_entry (CtkMountOperation *operation, |
510 | int row, |
511 | const char *label_text, |
512 | const char *value, |
513 | gpointer user_data) |
514 | { |
515 | CtkWidget *entry; |
516 | CtkWidget *label; |
517 | |
518 | label = ctk_label_new_with_mnemonic (label_text); |
519 | ctk_widget_set_halign (label, CTK_ALIGN_END); |
520 | ctk_widget_set_valign (label, CTK_ALIGN_CENTER); |
521 | ctk_widget_set_hexpand (label, FALSE(0)); |
522 | operation->priv->user_widgets = g_list_prepend (operation->priv->user_widgets, label); |
523 | |
524 | entry = ctk_entry_new (); |
525 | ctk_widget_set_hexpand (entry, TRUE(!(0))); |
526 | |
527 | if (value) |
528 | ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), value); |
529 | |
530 | ctk_grid_attach (CTK_GRID (operation->priv->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation->priv->grid)), ((ctk_grid_get_type ()))) ))), label, 0, row, 1, 1); |
531 | ctk_grid_attach (CTK_GRID (operation->priv->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation->priv->grid)), ((ctk_grid_get_type ()))) ))), entry, 1, row, 1, 1); |
532 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), entry); |
533 | operation->priv->user_widgets = g_list_prepend (operation->priv->user_widgets, entry); |
534 | |
535 | g_signal_connect (entry, "changed",g_signal_connect_data ((entry), ("changed"), (((GCallback) (pw_dialog_verify_input ))), (user_data), ((void*)0), (GConnectFlags) 0) |
536 | G_CALLBACK (pw_dialog_verify_input), user_data)g_signal_connect_data ((entry), ("changed"), (((GCallback) (pw_dialog_verify_input ))), (user_data), ((void*)0), (GConnectFlags) 0); |
537 | |
538 | g_signal_connect (entry, "activate",g_signal_connect_data ((entry), ("activate"), (((GCallback) ( pw_dialog_cycle_focus))), (user_data), ((void*)0), (GConnectFlags ) 0) |
539 | G_CALLBACK (pw_dialog_cycle_focus), user_data)g_signal_connect_data ((entry), ("activate"), (((GCallback) ( pw_dialog_cycle_focus))), (user_data), ((void*)0), (GConnectFlags ) 0); |
540 | |
541 | return entry; |
542 | } |
543 | |
544 | static void |
545 | ctk_mount_operation_ask_password_do_ctk (CtkMountOperation *operation, |
546 | const gchar *message, |
547 | const gchar *default_user, |
548 | const gchar *default_domain) |
549 | { |
550 | CtkMountOperationPrivate *priv; |
551 | CtkWidget *widget; |
552 | CtkDialog *dialog; |
553 | CtkWindow *window; |
554 | CtkWidget *hbox, *main_vbox, *icon; |
555 | CtkWidget *grid; |
556 | CtkWidget *label; |
557 | CtkWidget *content_area, *action_area; |
558 | gboolean can_anonymous; |
559 | guint rows; |
560 | gchar *primary; |
561 | const gchar *secondary = NULL((void*)0); |
562 | PangoAttrList *attrs; |
563 | gboolean use_header; |
564 | |
565 | priv = operation->priv; |
566 | |
567 | g_object_get (ctk_settings_get_default (), |
568 | "ctk-dialogs-use-header", &use_header, |
569 | NULL((void*)0)); |
570 | widget = g_object_new (CTK_TYPE_DIALOG(ctk_dialog_get_type ()), |
571 | "use-header-bar", use_header, |
572 | NULL((void*)0)); |
573 | dialog = CTK_DIALOG (widget)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_dialog_get_type ())))))); |
574 | window = CTK_WINDOW (widget)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((ctk_window_get_type ())))))); |
575 | |
576 | priv->dialog = dialog; |
577 | |
578 | content_area = ctk_dialog_get_content_area (dialog); |
579 | |
580 | action_area = ctk_dialog_get_action_area (dialog); |
581 | |
582 | /* Set the dialog up with HIG properties */ |
583 | ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 5); |
584 | ctk_box_set_spacing (CTK_BOX (content_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((content_area)), ((ctk_box_get_type ())))))), 2); /* 2 * 5 + 2 = 12 */ |
585 | ctk_container_set_border_width (CTK_CONTAINER (action_area)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action_area)), ((ctk_container_get_type ())))))), 5); |
586 | ctk_box_set_spacing (CTK_BOX (action_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action_area)), ((ctk_box_get_type ())))))), 6); |
587 | |
588 | ctk_window_set_resizable (window, FALSE(0)); |
589 | ctk_window_set_title (window, ""); |
590 | ctk_window_set_icon_name (window, "dialog-password"); |
591 | |
592 | ctk_dialog_add_buttons (dialog, |
593 | _("_Cancel")((char *) g_dgettext ("ctk30", "_Cancel")), CTK_RESPONSE_CANCEL, |
594 | _("Co_nnect")((char *) g_dgettext ("ctk30", "Co_nnect")), CTK_RESPONSE_OK, |
595 | NULL((void*)0)); |
596 | ctk_dialog_set_default_response (dialog, CTK_RESPONSE_OK); |
597 | |
598 | G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push
clang diagnostic ignored "-Wdeprecated-declarations" |
599 | ctk_dialog_set_alternative_button_order (dialog, |
600 | CTK_RESPONSE_OK, |
601 | CTK_RESPONSE_CANCEL, |
602 | -1); |
603 | G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop |
604 | |
605 | /* Build contents */ |
606 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 12); |
607 | ctk_container_set_border_width (CTK_CONTAINER (hbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_container_get_type ())))))), 5); |
608 | ctk_box_pack_start (CTK_BOX (content_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((content_area)), ((ctk_box_get_type ())))))), hbox, TRUE(!(0)), TRUE(!(0)), 0); |
609 | |
610 | icon = ctk_image_new_from_icon_name ("dialog-password", |
611 | CTK_ICON_SIZE_DIALOG); |
612 | |
613 | ctk_widget_set_halign (icon, CTK_ALIGN_CENTER); |
614 | ctk_widget_set_valign (icon, CTK_ALIGN_START); |
615 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), icon, FALSE(0), FALSE(0), 0); |
616 | |
617 | main_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 18); |
618 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), main_vbox, TRUE(!(0)), TRUE(!(0)), 0); |
619 | |
620 | primary = strstr (message, "\n"); |
621 | if (primary) |
622 | { |
623 | secondary = primary + 1; |
624 | primary = g_strndup (message, primary - message); |
625 | } |
626 | |
627 | label = ctk_label_new (primary != NULL((void*)0) ? primary : message); |
628 | ctk_widget_set_halign (label, CTK_ALIGN_START); |
629 | ctk_widget_set_valign (label, CTK_ALIGN_CENTER); |
630 | ctk_label_set_line_wrap (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), TRUE(!(0))); |
631 | ctk_box_pack_start (CTK_BOX (main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_vbox)), ((ctk_box_get_type ())))))), CTK_WIDGET (label)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_widget_get_type ())))))), |
632 | FALSE(0), TRUE(!(0)), 0); |
633 | g_free (primary); |
634 | attrs = pango_attr_list_new (); |
635 | pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); |
636 | ctk_label_set_attributes (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), attrs); |
637 | pango_attr_list_unref (attrs); |
638 | |
639 | if (secondary != NULL((void*)0)) |
640 | { |
641 | label = ctk_label_new (secondary); |
642 | ctk_widget_set_halign (label, CTK_ALIGN_START); |
643 | ctk_widget_set_valign (label, CTK_ALIGN_CENTER); |
644 | ctk_label_set_line_wrap (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), TRUE(!(0))); |
645 | ctk_box_pack_start (CTK_BOX (main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_vbox)), ((ctk_box_get_type ())))))), CTK_WIDGET (label)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_widget_get_type ())))))), |
646 | FALSE(0), FALSE(0), 0); |
647 | } |
648 | |
649 | grid = ctk_grid_new (); |
650 | operation->priv->grid = grid; |
651 | ctk_grid_set_row_spacing (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), 12); |
652 | ctk_grid_set_column_spacing (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), 12); |
653 | ctk_widget_set_margin_bottom (grid, 12); |
654 | ctk_box_pack_start (CTK_BOX (main_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((main_vbox)), ((ctk_box_get_type ())))))), grid, FALSE(0), FALSE(0), 0); |
655 | |
656 | can_anonymous = priv->ask_flags & G_ASK_PASSWORD_ANONYMOUS_SUPPORTED; |
657 | |
658 | rows = 0; |
659 | |
660 | priv->anonymous_toggle = NULL((void*)0); |
661 | if (can_anonymous) |
662 | { |
663 | CtkWidget *anon_box; |
664 | CtkWidget *choice; |
665 | GSList *group; |
666 | |
667 | label = ctk_label_new (_("Connect As")((char *) g_dgettext ("ctk30", "Connect As"))); |
668 | ctk_widget_set_halign (label, CTK_ALIGN_END); |
669 | ctk_widget_set_valign (label, CTK_ALIGN_START); |
670 | ctk_widget_set_hexpand (label, FALSE(0)); |
671 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), label, 0, rows, 1, 1); |
672 | |
673 | anon_box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
674 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), anon_box, 1, rows++, 1, 1); |
675 | |
676 | choice = ctk_radio_button_new_with_mnemonic (NULL((void*)0), _("_Anonymous")((char *) g_dgettext ("ctk30", "_Anonymous"))); |
677 | ctk_box_pack_start (CTK_BOX (anon_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((anon_box)), ((ctk_box_get_type ())))))), |
678 | choice, |
679 | FALSE(0), FALSE(0), 0); |
680 | g_signal_connect (choice, "toggled",g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( pw_dialog_anonymous_toggled))), (operation), ((void*)0), (GConnectFlags ) 0) |
681 | G_CALLBACK (pw_dialog_anonymous_toggled), operation)g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( pw_dialog_anonymous_toggled))), (operation), ((void*)0), (GConnectFlags ) 0); |
682 | priv->anonymous_toggle = choice; |
683 | |
684 | group = ctk_radio_button_get_group (CTK_RADIO_BUTTON (choice)((((CtkRadioButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_radio_button_get_type ()))))))); |
685 | choice = ctk_radio_button_new_with_mnemonic (group, _("Registered U_ser")((char *) g_dgettext ("ctk30", "Registered U_ser"))); |
686 | ctk_box_pack_start (CTK_BOX (anon_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((anon_box)), ((ctk_box_get_type ())))))), |
687 | choice, |
688 | FALSE(0), FALSE(0), 0); |
689 | g_signal_connect (choice, "toggled",g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( pw_dialog_anonymous_toggled))), (operation), ((void*)0), (GConnectFlags ) 0) |
690 | G_CALLBACK (pw_dialog_anonymous_toggled), operation)g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( pw_dialog_anonymous_toggled))), (operation), ((void*)0), (GConnectFlags ) 0); |
691 | } |
692 | |
693 | priv->username_entry = NULL((void*)0); |
694 | |
695 | if (priv->ask_flags & G_ASK_PASSWORD_NEED_USERNAME) |
696 | priv->username_entry = table_add_entry (operation, rows++, _("_Username")((char *) g_dgettext ("ctk30", "_Username")), |
697 | default_user, operation); |
698 | |
699 | priv->domain_entry = NULL((void*)0); |
700 | if (priv->ask_flags & G_ASK_PASSWORD_NEED_DOMAIN) |
701 | priv->domain_entry = table_add_entry (operation, rows++, _("_Domain")((char *) g_dgettext ("ctk30", "_Domain")), |
702 | default_domain, operation); |
703 | |
704 | priv->pim_entry = NULL((void*)0); |
705 | if (priv->ask_flags & G_ASK_PASSWORD_TCRYPT) |
706 | { |
707 | CtkWidget *volume_type_label; |
708 | CtkWidget *volume_type_box; |
709 | |
710 | volume_type_label = ctk_label_new (_("Volume type")((char *) g_dgettext ("ctk30", "Volume type"))); |
711 | ctk_widget_set_halign (volume_type_label, CTK_ALIGN_END); |
712 | ctk_widget_set_hexpand (volume_type_label, FALSE(0)); |
713 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), volume_type_label, 0, rows, 1, 1); |
714 | priv->user_widgets = g_list_prepend (priv->user_widgets, volume_type_label); |
715 | |
716 | volume_type_box = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 10); |
717 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), volume_type_box, 1, rows++, 1, 1); |
718 | priv->user_widgets = g_list_prepend (priv->user_widgets, volume_type_box); |
719 | |
720 | priv->tcrypt_hidden_toggle = ctk_check_button_new_with_mnemonic (_("_Hidden")((char *) g_dgettext ("ctk30", "_Hidden"))); |
721 | ctk_container_add (CTK_CONTAINER (volume_type_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((volume_type_box)), ((ctk_container_get_type ())))))), priv->tcrypt_hidden_toggle); |
722 | |
723 | priv->tcrypt_system_toggle = ctk_check_button_new_with_mnemonic (_("_Windows system")((char *) g_dgettext ("ctk30", "_Windows system"))); |
724 | ctk_container_add (CTK_CONTAINER (volume_type_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((volume_type_box)), ((ctk_container_get_type ())))))), priv->tcrypt_system_toggle); |
725 | |
726 | priv->pim_entry = table_add_entry (operation, rows++, _("_PIM")((char *) g_dgettext ("ctk30", "_PIM")), NULL((void*)0), operation); |
727 | } |
728 | |
729 | priv->password_entry = NULL((void*)0); |
730 | if (priv->ask_flags & G_ASK_PASSWORD_NEED_PASSWORD) |
731 | { |
732 | priv->password_entry = table_add_entry (operation, rows++, _("_Password")((char *) g_dgettext ("ctk30", "_Password")), |
733 | NULL((void*)0), operation); |
734 | ctk_entry_set_visibility (CTK_ENTRY (priv->password_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->password_entry)), ((ctk_entry_get_type ())))))), FALSE(0)); |
735 | } |
736 | |
737 | if (priv->ask_flags & G_ASK_PASSWORD_SAVING_SUPPORTED) |
738 | { |
739 | CtkWidget *remember_box; |
740 | CtkWidget *choice; |
741 | GSList *group; |
742 | GPasswordSave password_save; |
743 | |
744 | remember_box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
745 | ctk_grid_attach (CTK_GRID (grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((grid)), ((ctk_grid_get_type ())))))), remember_box, 0, rows++, 2, 1); |
746 | priv->user_widgets = g_list_prepend (priv->user_widgets, remember_box); |
747 | |
748 | label = ctk_label_new (""); |
749 | ctk_container_add (CTK_CONTAINER (remember_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((remember_box)), ((ctk_container_get_type ())))))), label); |
750 | |
751 | password_save = g_mount_operation_get_password_save (G_MOUNT_OPERATION (operation)((((GMountOperation*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), ((g_mount_operation_get_type ()))))))); |
752 | priv->password_save = password_save; |
753 | |
754 | choice = ctk_radio_button_new_with_mnemonic (NULL((void*)0), _("Forget password _immediately")((char *) g_dgettext ("ctk30", "Forget password _immediately" ))); |
755 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (choice)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_toggle_button_get_type ())))))), |
756 | password_save == G_PASSWORD_SAVE_NEVER); |
757 | g_object_set_data (G_OBJECT (choice)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), (((GType) ((20) << (2)))))))), "password-save", |
758 | GINT_TO_POINTER (G_PASSWORD_SAVE_NEVER)((gpointer) (glong) (G_PASSWORD_SAVE_NEVER))); |
759 | g_signal_connect (choice, "toggled",g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0) |
760 | G_CALLBACK (remember_button_toggled), operation)g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0); |
761 | ctk_box_pack_start (CTK_BOX (remember_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((remember_box)), ((ctk_box_get_type ())))))), choice, FALSE(0), FALSE(0), 0); |
762 | |
763 | group = ctk_radio_button_get_group (CTK_RADIO_BUTTON (choice)((((CtkRadioButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_radio_button_get_type ()))))))); |
764 | choice = ctk_radio_button_new_with_mnemonic (group, _("Remember password until you _logout")((char *) g_dgettext ("ctk30", "Remember password until you _logout" ))); |
765 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (choice)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_toggle_button_get_type ())))))), |
766 | password_save == G_PASSWORD_SAVE_FOR_SESSION); |
767 | g_object_set_data (G_OBJECT (choice)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), (((GType) ((20) << (2)))))))), "password-save", |
768 | GINT_TO_POINTER (G_PASSWORD_SAVE_FOR_SESSION)((gpointer) (glong) (G_PASSWORD_SAVE_FOR_SESSION))); |
769 | g_signal_connect (choice, "toggled",g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0) |
770 | G_CALLBACK (remember_button_toggled), operation)g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0); |
771 | ctk_box_pack_start (CTK_BOX (remember_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((remember_box)), ((ctk_box_get_type ())))))), choice, FALSE(0), FALSE(0), 0); |
772 | |
773 | group = ctk_radio_button_get_group (CTK_RADIO_BUTTON (choice)((((CtkRadioButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_radio_button_get_type ()))))))); |
774 | choice = ctk_radio_button_new_with_mnemonic (group, _("Remember _forever")((char *) g_dgettext ("ctk30", "Remember _forever"))); |
775 | ctk_toggle_button_set_active (CTK_TOGGLE_BUTTON (choice)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), ((ctk_toggle_button_get_type ())))))), |
776 | password_save == G_PASSWORD_SAVE_PERMANENTLY); |
777 | g_object_set_data (G_OBJECT (choice)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((choice)), (((GType) ((20) << (2)))))))), "password-save", |
778 | GINT_TO_POINTER (G_PASSWORD_SAVE_PERMANENTLY)((gpointer) (glong) (G_PASSWORD_SAVE_PERMANENTLY))); |
779 | g_signal_connect (choice, "toggled",g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0) |
780 | G_CALLBACK (remember_button_toggled), operation)g_signal_connect_data ((choice), ("toggled"), (((GCallback) ( remember_button_toggled))), (operation), ((void*)0), (GConnectFlags ) 0); |
781 | ctk_box_pack_start (CTK_BOX (remember_box)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((remember_box)), ((ctk_box_get_type ())))))), choice, FALSE(0), FALSE(0), 0); |
782 | } |
783 | |
784 | g_signal_connect (G_OBJECT (dialog), "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (pw_dialog_got_response)) ), (operation), ((void*)0), (GConnectFlags) 0) |
785 | G_CALLBACK (pw_dialog_got_response), operation)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (pw_dialog_got_response)) ), (operation), ((void*)0), (GConnectFlags) 0); |
786 | |
787 | if (can_anonymous) |
788 | { |
789 | /* The anonymous option will be active by default, |
790 | * ensure the toggled signal is emitted for it. |
791 | */ |
792 | ctk_toggle_button_toggled (CTK_TOGGLE_BUTTON (priv->anonymous_toggle)((((CtkToggleButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->anonymous_toggle)), ((ctk_toggle_button_get_type ()))))))); |
793 | } |
794 | else if (! pw_dialog_input_is_valid (operation)) |
795 | ctk_dialog_set_response_sensitive (dialog, CTK_RESPONSE_OK, FALSE(0)); |
796 | |
797 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
798 | |
799 | if (priv->parent_window) |
800 | { |
801 | ctk_window_set_transient_for (window, priv->parent_window); |
802 | ctk_window_set_modal (window, TRUE(!(0))); |
803 | } |
804 | else if (priv->screen) |
805 | ctk_window_set_screen (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), priv->screen); |
806 | |
807 | ctk_widget_show_all (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
808 | |
809 | g_object_ref (operation)((__typeof__ (operation)) (g_object_ref) (operation)); |
810 | } |
811 | |
812 | static void |
813 | call_password_proxy_cb (GObject *source, |
814 | GAsyncResult *res, |
815 | gpointer user_data) |
816 | { |
817 | _CtkMountOperationHandler *proxy = _CTK_MOUNT_OPERATION_HANDLER (source)((((_CtkMountOperationHandler*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((source)), ((_ctk_mount_operation_handler_get_type ())))))); |
818 | GMountOperation *op = user_data; |
819 | GMountOperationResult result; |
820 | GVariant *result_details; |
821 | GVariantIter iter; |
822 | const gchar *key; |
823 | GVariant *value; |
824 | GError *error = NULL((void*)0); |
825 | |
826 | if (!_ctk_mount_operation_handler_call_ask_password_finish (proxy, |
827 | &result, |
828 | &result_details, |
829 | res, |
830 | &error)) |
831 | { |
832 | result = G_MOUNT_OPERATION_ABORTED; |
833 | g_warning ("Shell mount operation error: %s", error->message); |
834 | g_error_free (error); |
835 | goto out; |
836 | } |
837 | |
838 | g_variant_iter_init (&iter, result_details); |
839 | while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) |
840 | { |
841 | if (strcmp (key, "password") == 0) |
842 | g_mount_operation_set_password (op, g_variant_get_string (value, NULL((void*)0))); |
843 | else if (strcmp (key, "password_save") == 0) |
844 | g_mount_operation_set_password_save (op, g_variant_get_uint32 (value)); |
845 | else if (strcmp (key, "hidden_volume") == 0) |
846 | g_mount_operation_set_is_tcrypt_hidden_volume (op, g_variant_get_boolean (value)); |
847 | else if (strcmp (key, "system_volume") == 0) |
848 | g_mount_operation_set_is_tcrypt_system_volume (op, g_variant_get_boolean (value)); |
849 | else if (strcmp (key, "pim") == 0) |
850 | g_mount_operation_set_pim (op, g_variant_get_uint32 (value)); |
851 | } |
852 | |
853 | out: |
854 | ctk_mount_operation_proxy_finish (CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))), result); |
855 | } |
856 | |
857 | static void |
858 | ctk_mount_operation_ask_password_do_proxy (CtkMountOperation *operation, |
859 | const char *message, |
860 | const char *default_user, |
861 | const char *default_domain) |
862 | { |
863 | gchar id[255]; |
864 | g_sprintf(id, "CtkMountOperation%p", operation); |
865 | |
866 | operation->priv->handler_showing = TRUE(!(0)); |
867 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
868 | |
869 | /* keep a ref to the operation while the handler is showing */ |
870 | g_object_ref (operation)((__typeof__ (operation)) (g_object_ref) (operation)); |
871 | |
872 | _ctk_mount_operation_handler_call_ask_password (operation->priv->handler, id, |
873 | message, "drive-harddisk", |
874 | default_user, default_domain, |
875 | operation->priv->ask_flags, NULL((void*)0), |
876 | call_password_proxy_cb, operation); |
877 | } |
878 | |
879 | static void |
880 | ctk_mount_operation_ask_password (GMountOperation *mount_op, |
881 | const char *message, |
882 | const char *default_user, |
883 | const char *default_domain, |
884 | GAskPasswordFlags flags) |
885 | { |
886 | CtkMountOperation *operation; |
887 | CtkMountOperationPrivate *priv; |
888 | gboolean use_ctk; |
889 | |
890 | operation = CTK_MOUNT_OPERATION (mount_op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((mount_op)), ((ctk_mount_operation_get_type ())))))); |
891 | priv = operation->priv; |
892 | priv->ask_flags = flags; |
893 | |
894 | use_ctk = (operation->priv->handler == NULL((void*)0)) || |
895 | (priv->ask_flags & G_ASK_PASSWORD_NEED_DOMAIN) || |
896 | (priv->ask_flags & G_ASK_PASSWORD_NEED_USERNAME); |
897 | |
898 | if (use_ctk) |
899 | ctk_mount_operation_ask_password_do_ctk (operation, message, default_user, default_domain); |
900 | else |
901 | ctk_mount_operation_ask_password_do_proxy (operation, message, default_user, default_domain); |
902 | } |
903 | |
904 | static void |
905 | question_dialog_button_clicked (CtkDialog *dialog, |
906 | gint button_number, |
907 | GMountOperation *op) |
908 | { |
909 | CtkMountOperationPrivate *priv; |
910 | CtkMountOperation *operation; |
911 | |
912 | operation = CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))); |
913 | priv = operation->priv; |
914 | |
915 | if (button_number >= 0) |
916 | { |
917 | g_mount_operation_set_choice (op, button_number); |
918 | g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED); |
919 | } |
920 | else |
921 | g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED); |
922 | |
923 | priv->dialog = NULL((void*)0); |
924 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
925 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
926 | g_object_unref (op); |
927 | } |
928 | |
929 | static void |
930 | ctk_mount_operation_ask_question_do_ctk (CtkMountOperation *op, |
931 | const char *message, |
932 | const char *choices[]) |
933 | { |
934 | CtkMountOperationPrivate *priv; |
935 | CtkWidget *dialog; |
936 | const char *secondary = NULL((void*)0); |
937 | char *primary; |
938 | int count, len = 0; |
939 | |
940 | g_return_if_fail (CTK_IS_MOUNT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return; } } while (0); |
941 | g_return_if_fail (message != NULL)do { if ((message != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "message != NULL"); return ; } } while (0); |
942 | g_return_if_fail (choices != NULL)do { if ((choices != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "choices != NULL"); return ; } } while (0); |
943 | |
944 | priv = op->priv; |
945 | |
946 | primary = strstr (message, "\n"); |
947 | if (primary) |
948 | { |
949 | secondary = primary + 1; |
950 | primary = g_strndup (message, primary - message); |
951 | } |
952 | |
953 | dialog = ctk_message_dialog_new (priv->parent_window, 0, |
954 | CTK_MESSAGE_QUESTION, |
955 | CTK_BUTTONS_NONE, "%s", |
956 | primary != NULL((void*)0) ? primary : message); |
957 | g_free (primary); |
958 | |
959 | if (secondary) |
960 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), |
961 | "%s", secondary); |
962 | |
963 | /* First count the items in the list then |
964 | * add the buttons in reverse order */ |
965 | |
966 | while (choices[len] != NULL((void*)0)) |
967 | len++; |
968 | |
969 | for (count = len - 1; count >= 0; count--) |
970 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), choices[count], count); |
971 | |
972 | g_signal_connect (G_OBJECT (dialog), "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (question_dialog_button_clicked ))), (op), ((void*)0), (GConnectFlags) 0) |
973 | G_CALLBACK (question_dialog_button_clicked), op)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (question_dialog_button_clicked ))), (op), ((void*)0), (GConnectFlags) 0); |
974 | |
975 | priv->dialog = CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))); |
976 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
977 | |
978 | if (priv->parent_window == NULL((void*)0) && priv->screen) |
979 | ctk_window_set_screen (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), priv->screen); |
980 | |
981 | ctk_widget_show (dialog); |
982 | g_object_ref (op)((__typeof__ (op)) (g_object_ref) (op)); |
983 | } |
984 | |
985 | static void |
986 | call_question_proxy_cb (GObject *source, |
987 | GAsyncResult *res, |
988 | gpointer user_data) |
989 | { |
990 | _CtkMountOperationHandler *proxy = _CTK_MOUNT_OPERATION_HANDLER (source)((((_CtkMountOperationHandler*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((source)), ((_ctk_mount_operation_handler_get_type ())))))); |
991 | GMountOperation *op = user_data; |
992 | GMountOperationResult result; |
993 | GVariant *result_details; |
994 | GVariantIter iter; |
995 | const gchar *key; |
996 | GVariant *value; |
997 | GError *error = NULL((void*)0); |
998 | |
999 | if (!_ctk_mount_operation_handler_call_ask_question_finish (proxy, |
1000 | &result, |
1001 | &result_details, |
1002 | res, |
1003 | &error)) |
1004 | { |
1005 | result = G_MOUNT_OPERATION_ABORTED; |
1006 | g_warning ("Shell mount operation error: %s", error->message); |
1007 | g_error_free (error); |
1008 | goto out; |
1009 | } |
1010 | |
1011 | g_variant_iter_init (&iter, result_details); |
1012 | while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) |
1013 | { |
1014 | if (strcmp (key, "choice") == 0) |
1015 | g_mount_operation_set_choice (op, g_variant_get_int32 (value)); |
1016 | } |
1017 | |
1018 | out: |
1019 | ctk_mount_operation_proxy_finish (CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))), result); |
1020 | } |
1021 | |
1022 | static void |
1023 | ctk_mount_operation_ask_question_do_proxy (CtkMountOperation *operation, |
1024 | const char *message, |
1025 | const char *choices[]) |
1026 | { |
1027 | gchar id[255]; |
1028 | g_sprintf(id, "CtkMountOperation%p", operation); |
1029 | |
1030 | operation->priv->handler_showing = TRUE(!(0)); |
1031 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
1032 | |
1033 | /* keep a ref to the operation while the handler is showing */ |
1034 | g_object_ref (operation)((__typeof__ (operation)) (g_object_ref) (operation)); |
1035 | |
1036 | _ctk_mount_operation_handler_call_ask_question (operation->priv->handler, id, |
1037 | message, "drive-harddisk", |
1038 | choices, NULL((void*)0), |
1039 | call_question_proxy_cb, operation); |
1040 | } |
1041 | |
1042 | static void |
1043 | ctk_mount_operation_ask_question (GMountOperation *op, |
1044 | const char *message, |
1045 | const char *choices[]) |
1046 | { |
1047 | CtkMountOperation *operation; |
1048 | gboolean use_ctk; |
1049 | |
1050 | operation = CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))); |
1051 | use_ctk = (operation->priv->handler == NULL((void*)0)); |
1052 | |
1053 | if (use_ctk) |
1054 | ctk_mount_operation_ask_question_do_ctk (operation, message, choices); |
1055 | else |
1056 | ctk_mount_operation_ask_question_do_proxy (operation, message, choices); |
1057 | } |
1058 | |
1059 | static void |
1060 | show_processes_button_clicked (CtkDialog *dialog, |
1061 | gint button_number, |
1062 | GMountOperation *op) |
1063 | { |
1064 | CtkMountOperationPrivate *priv; |
1065 | CtkMountOperation *operation; |
1066 | |
1067 | operation = CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))); |
1068 | priv = operation->priv; |
1069 | |
1070 | if (button_number >= 0) |
1071 | { |
1072 | g_mount_operation_set_choice (op, button_number); |
1073 | g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED); |
1074 | } |
1075 | else |
1076 | g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED); |
1077 | |
1078 | priv->dialog = NULL((void*)0); |
1079 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
1080 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); |
1081 | g_object_unref (op); |
1082 | } |
1083 | |
1084 | static gint |
1085 | pid_equal (gconstpointer a, |
1086 | gconstpointer b) |
1087 | { |
1088 | GPid pa, pb; |
1089 | |
1090 | pa = *((GPid *) a); |
1091 | pb = *((GPid *) b); |
1092 | |
1093 | return GPOINTER_TO_INT(pb)((gint) (glong) (pb)) - GPOINTER_TO_INT(pa)((gint) (glong) (pa)); |
1094 | } |
1095 | |
1096 | static void |
1097 | diff_sorted_arrays (GArray *array1, |
1098 | GArray *array2, |
1099 | GCompareFunc compare, |
1100 | GArray *added_indices, |
1101 | GArray *removed_indices) |
1102 | { |
1103 | gint order; |
1104 | guint n1, n2; |
1105 | guint elem_size; |
1106 | |
1107 | n1 = n2 = 0; |
1108 | |
1109 | elem_size = g_array_get_element_size (array1); |
1110 | g_assert (elem_size == g_array_get_element_size (array2))do { if (elem_size == g_array_get_element_size (array2)) ; else g_assertion_message_expr ("Ctk", "ctkmountoperation.c", 1110 , ((const char*) (__func__)), "elem_size == g_array_get_element_size (array2)" ); } while (0); |
1111 | |
1112 | while (n1 < array1->len && n2 < array2->len) |
1113 | { |
1114 | order = (*compare) (((const char*) array1->data) + n1 * elem_size, |
1115 | ((const char*) array2->data) + n2 * elem_size); |
1116 | if (order < 0) |
1117 | { |
1118 | g_array_append_val (removed_indices, n1)g_array_append_vals (removed_indices, &(n1), 1); |
1119 | n1++; |
1120 | } |
1121 | else if (order > 0) |
1122 | { |
1123 | g_array_append_val (added_indices, n2)g_array_append_vals (added_indices, &(n2), 1); |
1124 | n2++; |
1125 | } |
1126 | else |
1127 | { /* same item */ |
1128 | n1++; |
1129 | n2++; |
1130 | } |
1131 | } |
1132 | |
1133 | while (n1 < array1->len) |
1134 | { |
1135 | g_array_append_val (removed_indices, n1)g_array_append_vals (removed_indices, &(n1), 1); |
1136 | n1++; |
1137 | } |
1138 | while (n2 < array2->len) |
1139 | { |
1140 | g_array_append_val (added_indices, n2)g_array_append_vals (added_indices, &(n2), 1); |
1141 | n2++; |
1142 | } |
1143 | } |
1144 | |
1145 | |
1146 | static void |
1147 | add_pid_to_process_list_store (CtkMountOperation *mount_operation, |
1148 | CtkMountOperationLookupContext *lookup_context, |
1149 | CtkListStore *list_store, |
1150 | GPid pid) |
1151 | { |
1152 | gchar *command_line; |
1153 | gchar *name; |
1154 | GdkPixbuf *pixbuf; |
1155 | gchar *markup; |
1156 | CtkTreeIter iter; |
1157 | |
1158 | name = NULL((void*)0); |
1159 | pixbuf = NULL((void*)0); |
1160 | command_line = NULL((void*)0); |
1161 | _ctk_mount_operation_lookup_info (lookup_context, |
1162 | pid, |
1163 | 24, |
1164 | &name, |
1165 | &command_line, |
1166 | &pixbuf); |
1167 | |
1168 | if (name == NULL((void*)0)) |
1169 | name = g_strdup_printf (_("Unknown Application (PID %d)")((char *) g_dgettext ("ctk30", "Unknown Application (PID %d)" )), (int) (gssize) pid); |
1170 | |
1171 | if (command_line == NULL((void*)0)) |
1172 | command_line = g_strdup ("")g_strdup_inline (""); |
1173 | |
1174 | if (pixbuf == NULL((void*)0)) |
1175 | { |
1176 | CtkIconTheme *theme; |
1177 | theme = ctk_css_icon_theme_value_get_icon_theme |
1178 | (_ctk_style_context_peek_property (ctk_widget_get_style_context (CTK_WIDGET (mount_operation->priv->dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((mount_operation->priv->dialog)), ((ctk_widget_get_type ()))))))), |
1179 | CTK_CSS_PROPERTY_ICON_THEME)); |
1180 | pixbuf = ctk_icon_theme_load_icon (theme, |
1181 | "application-x-executable", |
1182 | 24, |
1183 | 0, |
1184 | NULL((void*)0)); |
1185 | } |
1186 | |
1187 | markup = g_strdup_printf ("<b>%s</b>\n" |
1188 | "<small>%s</small>", |
1189 | name, |
1190 | command_line); |
1191 | |
1192 | ctk_list_store_append (list_store, &iter); |
1193 | ctk_list_store_set (list_store, &iter, |
1194 | 0, pixbuf, |
1195 | 1, markup, |
1196 | 2, pid, |
1197 | -1); |
1198 | |
1199 | if (pixbuf != NULL((void*)0)) |
1200 | g_object_unref (pixbuf); |
1201 | g_free (markup); |
1202 | g_free (name); |
1203 | g_free (command_line); |
1204 | } |
1205 | |
1206 | static void |
1207 | remove_pid_from_process_list_store (CtkMountOperation *mount_operation G_GNUC_UNUSED__attribute__ ((__unused__)), |
1208 | CtkListStore *list_store, |
1209 | GPid pid) |
1210 | { |
1211 | CtkTreeIter iter; |
1212 | GPid pid_of_item; |
1213 | |
1214 | if (ctk_tree_model_get_iter_first (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter)) |
1215 | { |
1216 | do |
1217 | { |
1218 | ctk_tree_model_get (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), |
1219 | &iter, |
1220 | 2, &pid_of_item, |
1221 | -1); |
1222 | |
1223 | if (pid_of_item == pid) |
1224 | { |
1225 | ctk_list_store_remove (list_store, &iter); |
1226 | break; |
1227 | } |
1228 | } |
1229 | while (ctk_tree_model_iter_next (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter)); |
1230 | } |
1231 | } |
1232 | |
1233 | |
1234 | static void |
1235 | update_process_list_store (CtkMountOperation *mount_operation, |
1236 | CtkListStore *list_store, |
1237 | GArray *processes) |
1238 | { |
1239 | guint n; |
1240 | CtkMountOperationLookupContext *lookup_context; |
1241 | GArray *current_pids; |
1242 | GArray *pid_indices_to_add; |
1243 | GArray *pid_indices_to_remove; |
1244 | CtkTreeIter iter; |
1245 | GPid pid; |
1246 | |
1247 | /* Just removing all items and adding new ones will screw up the |
1248 | * focus handling in the treeview - so compute the delta, and add/remove |
1249 | * items as appropriate |
1250 | */ |
1251 | current_pids = g_array_new (FALSE(0), FALSE(0), sizeof (GPid)); |
1252 | pid_indices_to_add = g_array_new (FALSE(0), FALSE(0), sizeof (gint)); |
1253 | pid_indices_to_remove = g_array_new (FALSE(0), FALSE(0), sizeof (gint)); |
1254 | |
1255 | if (ctk_tree_model_get_iter_first (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter)) |
1256 | { |
1257 | do |
1258 | { |
1259 | ctk_tree_model_get (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), |
1260 | &iter, |
1261 | 2, &pid, |
1262 | -1); |
1263 | |
1264 | g_array_append_val (current_pids, pid)g_array_append_vals (current_pids, &(pid), 1); |
1265 | } |
1266 | while (ctk_tree_model_iter_next (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter)); |
1267 | } |
1268 | |
1269 | g_array_sort (current_pids, pid_equal); |
1270 | g_array_sort (processes, pid_equal); |
1271 | |
1272 | diff_sorted_arrays (current_pids, processes, pid_equal, pid_indices_to_add, pid_indices_to_remove); |
1273 | |
1274 | for (n = 0; n < pid_indices_to_remove->len; n++) |
1275 | { |
1276 | pid = g_array_index (current_pids, GPid, n)(((GPid*) (void *) (current_pids)->data) [(n)]); |
1277 | remove_pid_from_process_list_store (mount_operation, list_store, pid); |
1278 | } |
1279 | |
1280 | if (pid_indices_to_add->len > 0) |
1281 | { |
1282 | lookup_context = _ctk_mount_operation_lookup_context_get (ctk_widget_get_display (mount_operation->priv->process_tree_view)); |
1283 | for (n = 0; n < pid_indices_to_add->len; n++) |
1284 | { |
1285 | pid = g_array_index (processes, GPid, n)(((GPid*) (void *) (processes)->data) [(n)]); |
1286 | add_pid_to_process_list_store (mount_operation, lookup_context, list_store, pid); |
1287 | } |
1288 | _ctk_mount_operation_lookup_context_free (lookup_context); |
1289 | } |
1290 | |
1291 | /* select the first item, if we went from a zero to a non-zero amount of processes */ |
1292 | if (current_pids->len == 0 && pid_indices_to_add->len > 0) |
1293 | { |
1294 | if (ctk_tree_model_get_iter_first (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter)) |
1295 | { |
1296 | CtkTreeSelection *tree_selection; |
1297 | tree_selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (mount_operation->priv->process_tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((mount_operation->priv->process_tree_view)), ((ctk_tree_view_get_type ()))))))); |
1298 | ctk_tree_selection_select_iter (tree_selection, &iter); |
1299 | } |
1300 | } |
1301 | |
1302 | g_array_unref (current_pids); |
1303 | g_array_unref (pid_indices_to_add); |
1304 | g_array_unref (pid_indices_to_remove); |
1305 | } |
1306 | |
1307 | static void |
1308 | on_end_process_activated (CtkMenuItem *item G_GNUC_UNUSED__attribute__ ((__unused__)), |
1309 | gpointer user_data) |
1310 | { |
1311 | CtkMountOperation *op = CTK_MOUNT_OPERATION (user_data)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((user_data)), ((ctk_mount_operation_get_type ())))))); |
1312 | CtkTreeSelection *selection; |
1313 | CtkTreeIter iter; |
1314 | GPid pid_to_kill; |
1315 | GError *error; |
1316 | |
1317 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (op->priv->process_tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->priv->process_tree_view)), ((ctk_tree_view_get_type ()))))))); |
1318 | |
1319 | if (!ctk_tree_selection_get_selected (selection, |
1320 | NULL((void*)0), |
1321 | &iter)) |
1322 | goto out; |
1323 | |
1324 | ctk_tree_model_get (CTK_TREE_MODEL (op->priv->process_list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->priv->process_list_store)), ((ctk_tree_model_get_type ())))))), |
1325 | &iter, |
1326 | 2, &pid_to_kill, |
1327 | -1); |
1328 | |
1329 | /* TODO: We might want to either |
1330 | * |
1331 | * - Be smart about things and send SIGKILL rather than SIGTERM if |
1332 | * this is the second time the user requests killing a process |
1333 | * |
1334 | * - Or, easier (but worse user experience), offer both "End Process" |
1335 | * and "Terminate Process" options |
1336 | * |
1337 | * But that's not how things work right now.... |
1338 | */ |
1339 | error = NULL((void*)0); |
1340 | if (!_ctk_mount_operation_kill_process (pid_to_kill, &error)) |
1341 | { |
1342 | CtkWidget *dialog; |
1343 | gint response; |
1344 | |
1345 | /* Use CTK_DIALOG_DESTROY_WITH_PARENT here since the parent dialog can be |
1346 | * indeed be destroyed via the GMountOperation::abort signal... for example, |
1347 | * this is triggered if the user yanks the device while we are showing |
1348 | * the dialog... |
1349 | */ |
1350 | dialog = ctk_message_dialog_new (CTK_WINDOW (op->priv->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->priv->dialog)), ((ctk_window_get_type ())))))), |
1351 | CTK_DIALOG_MODAL | CTK_DIALOG_DESTROY_WITH_PARENT, |
1352 | CTK_MESSAGE_ERROR, |
1353 | CTK_BUTTONS_CLOSE, |
1354 | _("Unable to end process")((char *) g_dgettext ("ctk30", "Unable to end process"))); |
1355 | ctk_message_dialog_format_secondary_text (CTK_MESSAGE_DIALOG (dialog)((((CtkMessageDialog*) (void *) g_type_check_instance_cast (( GTypeInstance*) ((dialog)), ((ctk_message_dialog_get_type ()) ))))), |
1356 | "%s", |
1357 | error->message); |
1358 | |
1359 | ctk_widget_show_all (dialog); |
1360 | response = ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
1361 | |
1362 | /* CTK_RESPONSE_NONE means the dialog were programmatically destroy, e.g. that |
1363 | * CTK_DIALOG_DESTROY_WITH_PARENT kicked in - so it would trigger a warning to |
1364 | * destroy the dialog in that case |
1365 | */ |
1366 | if (response != CTK_RESPONSE_NONE) |
1367 | ctk_widget_destroy (dialog); |
1368 | |
1369 | g_error_free (error); |
1370 | } |
1371 | |
1372 | out: |
1373 | ; |
1374 | } |
1375 | |
1376 | static gboolean |
1377 | do_popup_menu_for_process_tree_view (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
1378 | const CdkEvent *event, |
1379 | CtkMountOperation *op) |
1380 | { |
1381 | CtkWidget *menu; |
1382 | CtkWidget *item; |
1383 | |
1384 | menu = ctk_menu_new (); |
1385 | ctk_style_context_add_class (ctk_widget_get_style_context (menu), |
1386 | CTK_STYLE_CLASS_CONTEXT_MENU"context-menu"); |
1387 | |
1388 | item = ctk_menu_item_new_with_mnemonic (_("_End Process")((char *) g_dgettext ("ctk30", "_End Process"))); |
1389 | g_signal_connect (item, "activate",g_signal_connect_data ((item), ("activate"), (((GCallback) (on_end_process_activated ))), (op), ((void*)0), (GConnectFlags) 0) |
1390 | G_CALLBACK (on_end_process_activated),g_signal_connect_data ((item), ("activate"), (((GCallback) (on_end_process_activated ))), (op), ((void*)0), (GConnectFlags) 0) |
1391 | op)g_signal_connect_data ((item), ("activate"), (((GCallback) (on_end_process_activated ))), (op), ((void*)0), (GConnectFlags) 0); |
1392 | ctk_menu_shell_append (CTK_MENU_SHELL (menu)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_shell_get_type ())))))), item); |
1393 | ctk_widget_show_all (menu); |
1394 | |
1395 | if (event && cdk_event_triggers_context_menu (event)) |
1396 | { |
1397 | CtkTreePath *path; |
1398 | CtkTreeSelection *selection; |
1399 | |
1400 | if (ctk_tree_view_get_path_at_pos (CTK_TREE_VIEW (op->priv->process_tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->priv->process_tree_view)), ((ctk_tree_view_get_type ())))))), |
1401 | (gint) event->button.x, |
1402 | (gint) event->button.y, |
1403 | &path, |
1404 | NULL((void*)0), |
1405 | NULL((void*)0), |
1406 | NULL((void*)0))) |
1407 | { |
1408 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (op->priv->process_tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op->priv->process_tree_view)), ((ctk_tree_view_get_type ()))))))); |
1409 | ctk_tree_selection_select_path (selection, path); |
1410 | ctk_tree_path_free (path); |
1411 | } |
1412 | else |
1413 | { |
1414 | /* don't popup a menu if the user right-clicked in an area with no rows */ |
1415 | return FALSE(0); |
1416 | } |
1417 | } |
1418 | |
1419 | ctk_menu_popup_at_pointer (CTK_MENU (menu)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((menu)), ((ctk_menu_get_type ())))))), event); |
1420 | return TRUE(!(0)); |
1421 | } |
1422 | |
1423 | static gboolean |
1424 | on_popup_menu_for_process_tree_view (CtkWidget *widget, |
1425 | gpointer user_data) |
1426 | { |
1427 | CtkMountOperation *op = CTK_MOUNT_OPERATION (user_data)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((user_data)), ((ctk_mount_operation_get_type ())))))); |
1428 | return do_popup_menu_for_process_tree_view (widget, NULL((void*)0), op); |
1429 | } |
1430 | |
1431 | static gboolean |
1432 | on_button_press_event_for_process_tree_view (CtkWidget *widget, |
1433 | CdkEventButton *event, |
1434 | gpointer user_data) |
1435 | { |
1436 | CtkMountOperation *op = CTK_MOUNT_OPERATION (user_data)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((user_data)), ((ctk_mount_operation_get_type ())))))); |
1437 | gboolean ret; |
1438 | |
1439 | ret = FALSE(0); |
1440 | |
1441 | if (cdk_event_triggers_context_menu ((CdkEvent *) event)) |
1442 | { |
1443 | ret = do_popup_menu_for_process_tree_view (widget, (CdkEvent *) event, op); |
1444 | } |
1445 | |
1446 | return ret; |
1447 | } |
1448 | |
1449 | static CtkWidget * |
1450 | create_show_processes_dialog (CtkMountOperation *op, |
1451 | const char *message, |
1452 | const char *choices[]) |
1453 | { |
1454 | CtkMountOperationPrivate *priv; |
1455 | CtkWidget *dialog; |
1456 | const char *secondary = NULL((void*)0); |
1457 | char *primary; |
1458 | int count, len = 0; |
1459 | CtkWidget *label; |
1460 | CtkWidget *tree_view; |
1461 | CtkWidget *scrolled_window; |
1462 | CtkWidget *vbox; |
1463 | CtkWidget *content_area; |
1464 | CtkTreeViewColumn *column; |
1465 | CtkCellRenderer *renderer; |
1466 | CtkListStore *list_store; |
1467 | gchar *s; |
1468 | gboolean use_header; |
1469 | |
1470 | priv = op->priv; |
1471 | |
1472 | primary = strstr (message, "\n"); |
1473 | if (primary) |
1474 | { |
1475 | secondary = primary + 1; |
1476 | primary = g_strndup (message, primary - message); |
1477 | } |
1478 | |
1479 | g_object_get (ctk_settings_get_default (), |
1480 | "ctk-dialogs-use-header", &use_header, |
1481 | NULL((void*)0)); |
1482 | dialog = g_object_new (CTK_TYPE_DIALOG(ctk_dialog_get_type ()), |
1483 | "use-header-bar", use_header, |
1484 | NULL((void*)0)); |
1485 | |
1486 | if (priv->parent_window != NULL((void*)0)) |
1487 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), priv->parent_window); |
1488 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), ""); |
1489 | |
1490 | content_area = ctk_dialog_get_content_area (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); |
1491 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 12); |
1492 | ctk_container_set_border_width (CTK_CONTAINER (vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_container_get_type ())))))), 12); |
1493 | ctk_box_pack_start (CTK_BOX (content_area)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((content_area)), ((ctk_box_get_type ())))))), vbox, TRUE(!(0)), TRUE(!(0)), 0); |
1494 | |
1495 | if (secondary != NULL((void*)0)) |
1496 | s = g_strdup_printf ("<big><b>%s</b></big>\n\n%s", primary, secondary); |
1497 | else |
1498 | s = g_strdup_printf ("%s", primary); |
1499 | |
1500 | g_free (primary); |
1501 | label = ctk_label_new (NULL((void*)0)); |
1502 | ctk_label_set_markup (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), s); |
1503 | g_free (s); |
1504 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), label, TRUE(!(0)), TRUE(!(0)), 0); |
1505 | |
1506 | /* First count the items in the list then |
1507 | * add the buttons in reverse order */ |
1508 | |
1509 | while (choices[len] != NULL((void*)0)) |
1510 | len++; |
1511 | |
1512 | for (count = len - 1; count >= 0; count--) |
1513 | ctk_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), choices[count], count); |
1514 | |
1515 | g_signal_connect (G_OBJECT (dialog), "response",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (show_processes_button_clicked ))), (op), ((void*)0), (GConnectFlags) 0) |
1516 | G_CALLBACK (show_processes_button_clicked), op)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), (((GType) ((20) << (2))) )))))), ("response"), (((GCallback) (show_processes_button_clicked ))), (op), ((void*)0), (GConnectFlags) 0); |
1517 | |
1518 | priv->dialog = CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))); |
1519 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
1520 | |
1521 | if (priv->parent_window == NULL((void*)0) && priv->screen) |
1522 | ctk_window_set_screen (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), priv->screen); |
1523 | |
1524 | tree_view = ctk_tree_view_new (); |
1525 | /* TODO: should use EM's when ctk+ RI patches land */ |
1526 | ctk_widget_set_size_request (tree_view, |
1527 | 300, |
1528 | 120); |
1529 | |
1530 | column = ctk_tree_view_column_new (); |
1531 | renderer = ctk_cell_renderer_pixbuf_new (); |
1532 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); |
1533 | ctk_tree_view_column_set_attributes (column, renderer, |
1534 | "pixbuf", 0, |
1535 | NULL((void*)0)); |
1536 | renderer = ctk_cell_renderer_text_new (); |
1537 | g_object_set (renderer, |
1538 | "ellipsize", PANGO_ELLIPSIZE_MIDDLE, |
1539 | "ellipsize-set", TRUE(!(0)), |
1540 | NULL((void*)0)); |
1541 | ctk_tree_view_column_pack_start (column, renderer, TRUE(!(0))); |
1542 | ctk_tree_view_column_set_attributes (column, renderer, |
1543 | "markup", 1, |
1544 | NULL((void*)0)); |
1545 | ctk_tree_view_append_column (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), column); |
1546 | ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), FALSE(0)); |
1547 | |
1548 | |
1549 | scrolled_window = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); |
1550 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled_window)), ((ctk_scrolled_window_get_type ())))))), |
1551 | CTK_POLICY_NEVER, |
1552 | CTK_POLICY_AUTOMATIC); |
1553 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (scrolled_window)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled_window)), ((ctk_scrolled_window_get_type ())))))), CTK_SHADOW_IN); |
1554 | |
1555 | ctk_container_add (CTK_CONTAINER (scrolled_window)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scrolled_window)), ((ctk_container_get_type ())))))), tree_view); |
1556 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), scrolled_window, TRUE(!(0)), TRUE(!(0)), 0); |
1557 | |
1558 | g_signal_connect (tree_view, "popup-menu",g_signal_connect_data ((tree_view), ("popup-menu"), (((GCallback ) (on_popup_menu_for_process_tree_view))), (op), ((void*)0), ( GConnectFlags) 0) |
1559 | G_CALLBACK (on_popup_menu_for_process_tree_view),g_signal_connect_data ((tree_view), ("popup-menu"), (((GCallback ) (on_popup_menu_for_process_tree_view))), (op), ((void*)0), ( GConnectFlags) 0) |
1560 | op)g_signal_connect_data ((tree_view), ("popup-menu"), (((GCallback ) (on_popup_menu_for_process_tree_view))), (op), ((void*)0), ( GConnectFlags) 0); |
1561 | g_signal_connect (tree_view, "button-press-event",g_signal_connect_data ((tree_view), ("button-press-event"), ( ((GCallback) (on_button_press_event_for_process_tree_view))), (op), ((void*)0), (GConnectFlags) 0) |
1562 | G_CALLBACK (on_button_press_event_for_process_tree_view),g_signal_connect_data ((tree_view), ("button-press-event"), ( ((GCallback) (on_button_press_event_for_process_tree_view))), (op), ((void*)0), (GConnectFlags) 0) |
1563 | op)g_signal_connect_data ((tree_view), ("button-press-event"), ( ((GCallback) (on_button_press_event_for_process_tree_view))), (op), ((void*)0), (GConnectFlags) 0); |
1564 | |
1565 | list_store = ctk_list_store_new (3, |
1566 | GDK_TYPE_PIXBUF(gdk_pixbuf_get_type ()), |
1567 | G_TYPE_STRING((GType) ((16) << (2))), |
1568 | G_TYPE_INT((GType) ((6) << (2)))); |
1569 | |
1570 | ctk_tree_view_set_model (CTK_TREE_VIEW (tree_view)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_view)), ((ctk_tree_view_get_type ())))))), CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ()))))))); |
1571 | |
1572 | priv->process_list_store = list_store; |
1573 | priv->process_tree_view = tree_view; |
1574 | /* set pointers to NULL when dialog goes away */ |
1575 | g_object_add_weak_pointer (G_OBJECT (priv->process_list_store)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->process_list_store)), (((GType) ((20) << ( 2)))))))), (gpointer *) &priv->process_list_store); |
1576 | g_object_add_weak_pointer (G_OBJECT (priv->process_tree_view)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->process_tree_view)), (((GType) ((20) << ( 2)))))))), (gpointer *) &priv->process_tree_view); |
1577 | |
1578 | g_object_unref (list_store); |
1579 | g_object_ref (op)((__typeof__ (op)) (g_object_ref) (op)); |
1580 | |
1581 | return dialog; |
1582 | } |
1583 | |
1584 | static void |
1585 | call_processes_proxy_cb (GObject *source, |
1586 | GAsyncResult *res, |
1587 | gpointer user_data) |
1588 | { |
1589 | _CtkMountOperationHandler *proxy = _CTK_MOUNT_OPERATION_HANDLER (source)((((_CtkMountOperationHandler*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((source)), ((_ctk_mount_operation_handler_get_type ())))))); |
1590 | GMountOperation *op = user_data; |
1591 | GMountOperationResult result; |
1592 | GVariant *result_details; |
1593 | GVariantIter iter; |
1594 | const gchar *key; |
1595 | GVariant *value; |
1596 | GError *error = NULL((void*)0); |
1597 | |
1598 | if (!_ctk_mount_operation_handler_call_show_processes_finish (proxy, |
1599 | &result, |
1600 | &result_details, |
1601 | res, |
1602 | &error)) |
1603 | { |
1604 | result = G_MOUNT_OPERATION_ABORTED; |
1605 | g_warning ("Shell mount operation error: %s", error->message); |
1606 | g_error_free (error); |
1607 | goto out; |
1608 | } |
1609 | |
1610 | /* If the request was unhandled it means we called the method again; |
1611 | * in this case, just return and wait for the next response. |
1612 | */ |
1613 | if (result == G_MOUNT_OPERATION_UNHANDLED) |
1614 | return; |
1615 | |
1616 | g_variant_iter_init (&iter, result_details); |
1617 | while (g_variant_iter_loop (&iter, "{&sv}", &key, &value)) |
1618 | { |
1619 | if (strcmp (key, "choice") == 0) |
1620 | g_mount_operation_set_choice (op, g_variant_get_int32 (value)); |
1621 | } |
1622 | |
1623 | out: |
1624 | ctk_mount_operation_proxy_finish (CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))), result); |
1625 | } |
1626 | |
1627 | static void |
1628 | ctk_mount_operation_show_processes_do_proxy (CtkMountOperation *operation, |
1629 | const char *message, |
1630 | GArray *processes, |
1631 | const char *choices[]) |
1632 | { |
1633 | gchar id[255]; |
1634 | g_sprintf(id, "CtkMountOperation%p", operation); |
1635 | |
1636 | operation->priv->handler_showing = TRUE(!(0)); |
1637 | g_object_notify (G_OBJECT (operation)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((operation)), (((GType) ((20) << (2)))))))), "is-showing"); |
1638 | |
1639 | /* keep a ref to the operation while the handler is showing */ |
1640 | g_object_ref (operation)((__typeof__ (operation)) (g_object_ref) (operation)); |
1641 | |
1642 | _ctk_mount_operation_handler_call_show_processes (operation->priv->handler, id, |
1643 | message, "drive-harddisk", |
1644 | g_variant_new_fixed_array (G_VARIANT_TYPE_INT32((const GVariantType *) "i"), |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
1645 | processes->data, processes->len, |
1646 | sizeof (GPid)), |
1647 | choices, NULL((void*)0), |
1648 | call_processes_proxy_cb, operation); |
1649 | } |
1650 | |
1651 | static void |
1652 | ctk_mount_operation_show_processes_do_ctk (CtkMountOperation *op, |
1653 | const char *message, |
1654 | GArray *processes, |
1655 | const char *choices[]) |
1656 | { |
1657 | CtkMountOperationPrivate *priv; |
1658 | CtkWidget *dialog = NULL((void*)0); |
1659 | |
1660 | g_return_if_fail (CTK_IS_MOUNT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return; } } while (0); |
1661 | g_return_if_fail (message != NULL)do { if ((message != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "message != NULL"); return ; } } while (0); |
1662 | g_return_if_fail (processes != NULL)do { if ((processes != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "processes != NULL"); return ; } } while (0); |
1663 | g_return_if_fail (choices != NULL)do { if ((choices != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "choices != NULL"); return ; } } while (0); |
1664 | |
1665 | priv = op->priv; |
1666 | |
1667 | if (priv->process_list_store == NULL((void*)0)) |
1668 | { |
1669 | /* need to create the dialog */ |
1670 | dialog = create_show_processes_dialog (op, message, choices); |
1671 | } |
1672 | |
1673 | /* otherwise, we're showing the dialog, assume messages+choices hasn't changed */ |
1674 | |
1675 | update_process_list_store (op, |
1676 | priv->process_list_store, |
1677 | processes); |
1678 | |
1679 | if (dialog != NULL((void*)0)) |
1680 | { |
1681 | ctk_widget_show_all (dialog); |
1682 | } |
1683 | } |
1684 | |
1685 | |
1686 | static void |
1687 | ctk_mount_operation_show_processes (GMountOperation *op, |
1688 | const char *message, |
1689 | GArray *processes, |
1690 | const char *choices[]) |
1691 | { |
1692 | |
1693 | CtkMountOperation *operation; |
1694 | gboolean use_ctk; |
1695 | |
1696 | operation = CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) ))); |
1697 | use_ctk = (operation->priv->handler == NULL((void*)0)); |
1698 | |
1699 | if (use_ctk) |
1700 | ctk_mount_operation_show_processes_do_ctk (operation, message, processes, choices); |
1701 | else |
1702 | ctk_mount_operation_show_processes_do_proxy (operation, message, processes, choices); |
1703 | } |
1704 | |
1705 | static void |
1706 | ctk_mount_operation_aborted (GMountOperation *op) |
1707 | { |
1708 | CtkMountOperationPrivate *priv; |
1709 | |
1710 | priv = CTK_MOUNT_OPERATION (op)((((CtkMountOperation*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((op)), ((ctk_mount_operation_get_type ()))) )))->priv; |
1711 | |
1712 | if (priv->dialog != NULL((void*)0)) |
1713 | { |
1714 | ctk_widget_destroy (CTK_WIDGET (priv->dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_widget_get_type ()))))))); |
1715 | priv->dialog = NULL((void*)0); |
1716 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
1717 | g_object_unref (op); |
1718 | } |
1719 | |
1720 | if (priv->handler != NULL((void*)0)) |
1721 | { |
1722 | _ctk_mount_operation_handler_call_close (priv->handler, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
1723 | |
1724 | priv->handler_showing = FALSE(0); |
1725 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "is-showing"); |
1726 | } |
1727 | } |
1728 | |
1729 | /** |
1730 | * ctk_mount_operation_new: |
1731 | * @parent: (allow-none): transient parent of the window, or %NULL |
1732 | * |
1733 | * Creates a new #CtkMountOperation |
1734 | * |
1735 | * Returns: a new #CtkMountOperation |
1736 | * |
1737 | * Since: 2.14 |
1738 | */ |
1739 | GMountOperation * |
1740 | ctk_mount_operation_new (CtkWindow *parent) |
1741 | { |
1742 | GMountOperation *mount_operation; |
1743 | |
1744 | mount_operation = g_object_new (CTK_TYPE_MOUNT_OPERATION(ctk_mount_operation_get_type ()), |
1745 | "parent", parent, NULL((void*)0)); |
1746 | |
1747 | return mount_operation; |
1748 | } |
1749 | |
1750 | /** |
1751 | * ctk_mount_operation_is_showing: |
1752 | * @op: a #CtkMountOperation |
1753 | * |
1754 | * Returns whether the #CtkMountOperation is currently displaying |
1755 | * a window. |
1756 | * |
1757 | * Returns: %TRUE if @op is currently displaying a window |
1758 | * |
1759 | * Since: 2.14 |
1760 | */ |
1761 | gboolean |
1762 | ctk_mount_operation_is_showing (CtkMountOperation *op) |
1763 | { |
1764 | g_return_val_if_fail (CTK_IS_MOUNT_OPERATION (op), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return ((0)); } } while ( 0); |
1765 | |
1766 | return op->priv->dialog != NULL((void*)0); |
1767 | } |
1768 | |
1769 | /** |
1770 | * ctk_mount_operation_set_parent: |
1771 | * @op: a #CtkMountOperation |
1772 | * @parent: (allow-none): transient parent of the window, or %NULL |
1773 | * |
1774 | * Sets the transient parent for windows shown by the |
1775 | * #CtkMountOperation. |
1776 | * |
1777 | * Since: 2.14 |
1778 | */ |
1779 | void |
1780 | ctk_mount_operation_set_parent (CtkMountOperation *op, |
1781 | CtkWindow *parent) |
1782 | { |
1783 | CtkMountOperationPrivate *priv; |
1784 | |
1785 | g_return_if_fail (CTK_IS_MOUNT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return; } } while (0); |
1786 | g_return_if_fail (parent == NULL || CTK_IS_WINDOW (parent))do { if ((parent == ((void*)0) || (((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ((parent)); GType __t = ((ctk_window_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst-> g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "parent == NULL || CTK_IS_WINDOW (parent)" ); return; } } while (0); |
1787 | |
1788 | priv = op->priv; |
1789 | |
1790 | if (priv->parent_window == parent) |
1791 | return; |
1792 | |
1793 | if (priv->parent_window) |
1794 | { |
1795 | g_signal_handlers_disconnect_by_func (priv->parent_window,g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )) |
1796 | ctk_widget_destroyed,g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )) |
1797 | &priv->parent_window)g_signal_handlers_disconnect_matched ((priv->parent_window ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (ctk_widget_destroyed), (&priv->parent_window )); |
1798 | g_object_unref (priv->parent_window); |
1799 | } |
1800 | priv->parent_window = parent; |
1801 | if (priv->parent_window) |
1802 | { |
1803 | g_object_ref (priv->parent_window)((__typeof__ (priv->parent_window)) (g_object_ref) (priv-> parent_window)); |
1804 | g_signal_connect (priv->parent_window, "destroy",g_signal_connect_data ((priv->parent_window), ("destroy"), (((GCallback) (ctk_widget_destroyed))), (&priv->parent_window ), ((void*)0), (GConnectFlags) 0) |
1805 | G_CALLBACK (ctk_widget_destroyed),g_signal_connect_data ((priv->parent_window), ("destroy"), (((GCallback) (ctk_widget_destroyed))), (&priv->parent_window ), ((void*)0), (GConnectFlags) 0) |
1806 | &priv->parent_window)g_signal_connect_data ((priv->parent_window), ("destroy"), (((GCallback) (ctk_widget_destroyed))), (&priv->parent_window ), ((void*)0), (GConnectFlags) 0); |
1807 | } |
1808 | |
1809 | if (priv->dialog) |
1810 | ctk_window_set_transient_for (CTK_WINDOW (priv->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_window_get_type ())))))), priv->parent_window); |
1811 | |
1812 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "parent"); |
1813 | } |
1814 | |
1815 | /** |
1816 | * ctk_mount_operation_get_parent: |
1817 | * @op: a #CtkMountOperation |
1818 | * |
1819 | * Gets the transient parent used by the #CtkMountOperation |
1820 | * |
1821 | * Returns: (transfer none): the transient parent for windows shown by @op |
1822 | * |
1823 | * Since: 2.14 |
1824 | */ |
1825 | CtkWindow * |
1826 | ctk_mount_operation_get_parent (CtkMountOperation *op) |
1827 | { |
1828 | g_return_val_if_fail (CTK_IS_MOUNT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return (((void*)0)); } } while (0); |
1829 | |
1830 | return op->priv->parent_window; |
1831 | } |
1832 | |
1833 | /** |
1834 | * ctk_mount_operation_set_screen: |
1835 | * @op: a #CtkMountOperation |
1836 | * @screen: a #CdkScreen |
1837 | * |
1838 | * Sets the screen to show windows of the #CtkMountOperation on. |
1839 | * |
1840 | * Since: 2.14 |
1841 | */ |
1842 | void |
1843 | ctk_mount_operation_set_screen (CtkMountOperation *op, |
1844 | CdkScreen *screen) |
1845 | { |
1846 | CtkMountOperationPrivate *priv; |
1847 | |
1848 | g_return_if_fail (CTK_IS_MOUNT_OPERATION (op))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return; } } while (0); |
1849 | g_return_if_fail (CDK_IS_SCREEN (screen))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((screen)); GType __t = ((cdk_screen_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CDK_IS_SCREEN (screen)"); return; } } while (0); |
1850 | |
1851 | priv = op->priv; |
1852 | |
1853 | if (priv->screen == screen) |
1854 | return; |
1855 | |
1856 | if (priv->screen) |
1857 | g_object_unref (priv->screen); |
1858 | |
1859 | priv->screen = g_object_ref (screen)((__typeof__ (screen)) (g_object_ref) (screen)); |
1860 | |
1861 | if (priv->dialog) |
1862 | ctk_window_set_screen (CTK_WINDOW (priv->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_window_get_type ())))))), screen); |
1863 | |
1864 | g_object_notify (G_OBJECT (op)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((op)), (((GType) ((20) << (2)))))))), "screen"); |
1865 | } |
1866 | |
1867 | /** |
1868 | * ctk_mount_operation_get_screen: |
1869 | * @op: a #CtkMountOperation |
1870 | * |
1871 | * Gets the screen on which windows of the #CtkMountOperation |
1872 | * will be shown. |
1873 | * |
1874 | * Returns: (transfer none): the screen on which windows of @op are shown |
1875 | * |
1876 | * Since: 2.14 |
1877 | */ |
1878 | CdkScreen * |
1879 | ctk_mount_operation_get_screen (CtkMountOperation *op) |
1880 | { |
1881 | CtkMountOperationPrivate *priv; |
1882 | |
1883 | g_return_val_if_fail (CTK_IS_MOUNT_OPERATION (op), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((op)); GType __t = ((ctk_mount_operation_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_MOUNT_OPERATION (op)"); return (((void*)0)); } } while (0); |
1884 | |
1885 | priv = op->priv; |
1886 | |
1887 | if (priv->dialog) |
1888 | return ctk_window_get_screen (CTK_WINDOW (priv->dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->dialog)), ((ctk_window_get_type ()))))))); |
1889 | else if (priv->parent_window) |
1890 | return ctk_window_get_screen (CTK_WINDOW (priv->parent_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((priv->parent_window)), ((ctk_window_get_type ()))))))); |
1891 | else if (priv->screen) |
1892 | return priv->screen; |
1893 | else |
1894 | return cdk_screen_get_default (); |
1895 | } |