File: | capplet/csm-app-dialog.c |
Warning: | line 573, column 32 Array access (from variable 'argv') results in an undefined pointer dereference |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- | |||
2 | * | |||
3 | * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> | |||
4 | * | |||
5 | * This program is free software; you can redistribute it and/or modify | |||
6 | * it under the terms of the GNU General Public License as published by | |||
7 | * the Free Software Foundation; either version 2 of the License, or | |||
8 | * (at your option) any later version. | |||
9 | * | |||
10 | * This program 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 | |||
13 | * GNU General Public License for more details. | |||
14 | * | |||
15 | * You should have received a copy of the GNU General Public License | |||
16 | * along with this program; if not, write to the Free Software | |||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |||
18 | * | |||
19 | */ | |||
20 | ||||
21 | #include "config.h" | |||
22 | ||||
23 | #include <glib.h> | |||
24 | #include <glib/gi18n.h> | |||
25 | #include <ctk/ctk.h> | |||
26 | ||||
27 | #include "csm-util.h" | |||
28 | ||||
29 | #include "csm-app-dialog.h" | |||
30 | ||||
31 | #define CTKBUILDER_FILE"session-properties.ui" "session-properties.ui" | |||
32 | ||||
33 | #define CAPPLET_NAME_ENTRY_WIDGET_NAME"session_properties_name_entry" "session_properties_name_entry" | |||
34 | #define CAPPLET_COMMAND_ENTRY_WIDGET_NAME"session_properties_command_entry" "session_properties_command_entry" | |||
35 | #define CAPPLET_COMMENT_ENTRY_WIDGET_NAME"session_properties_comment_entry" "session_properties_comment_entry" | |||
36 | #define CAPPLET_DELAY_SPIN_WIDGET_NAME"session_properties_delay_spin" "session_properties_delay_spin" | |||
37 | #define CAPPLET_BROWSE_WIDGET_NAME"session_properties_browse_button" "session_properties_browse_button" | |||
38 | ||||
39 | #ifdef __GNUC__4 | |||
40 | #define UNUSED_VARIABLE__attribute__ ((unused)) __attribute__ ((unused)) | |||
41 | #else | |||
42 | #define UNUSED_VARIABLE__attribute__ ((unused)) | |||
43 | #endif | |||
44 | ||||
45 | struct _CsmAppDialog | |||
46 | { | |||
47 | CtkDialog parent; | |||
48 | CtkWidget *name_entry; | |||
49 | CtkWidget *command_entry; | |||
50 | CtkWidget *comment_entry; | |||
51 | CtkWidget *delay_spin; | |||
52 | CtkWidget *browse_button; | |||
53 | char *name; | |||
54 | char *command; | |||
55 | char *comment; | |||
56 | guint delay; | |||
57 | }; | |||
58 | ||||
59 | enum { | |||
60 | PROP_0, | |||
61 | PROP_NAME, | |||
62 | PROP_COMMAND, | |||
63 | PROP_COMMENT, | |||
64 | PROP_DELAY | |||
65 | }; | |||
66 | ||||
67 | G_DEFINE_TYPE (CsmAppDialog, csm_app_dialog, CTK_TYPE_DIALOG)static void csm_app_dialog_init (CsmAppDialog *self); static void csm_app_dialog_class_init (CsmAppDialogClass *klass); static GType csm_app_dialog_get_type_once (void); static gpointer csm_app_dialog_parent_class = ((void*)0); static gint CsmAppDialog_private_offset; static void csm_app_dialog_class_intern_init (gpointer klass) { csm_app_dialog_parent_class = g_type_class_peek_parent (klass); if (CsmAppDialog_private_offset != 0) g_type_class_adjust_private_offset (klass, &CsmAppDialog_private_offset ); csm_app_dialog_class_init ((CsmAppDialogClass*) klass); } __attribute__ ((__unused__)) static inline gpointer csm_app_dialog_get_instance_private (CsmAppDialog *self) { return (((gpointer) ((guint8*) (self) + (glong) (CsmAppDialog_private_offset)))); } GType csm_app_dialog_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 = csm_app_dialog_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType csm_app_dialog_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( ctk_dialog_get_type ()), g_intern_static_string ("CsmAppDialog" ), sizeof (CsmAppDialogClass), (GClassInitFunc)(void (*)(void )) csm_app_dialog_class_intern_init, sizeof (CsmAppDialog), ( GInstanceInitFunc)(void (*)(void)) csm_app_dialog_init, (GTypeFlags ) 0); { {{};} } return g_define_type_id; } | |||
68 | ||||
69 | static char * | |||
70 | make_exec_uri (const char *exec) | |||
71 | { | |||
72 | GString *str; | |||
73 | const char *c; | |||
74 | ||||
75 | if (exec == NULL((void*)0)) { | |||
76 | return g_strdup ("")g_strdup_inline (""); | |||
77 | } | |||
78 | ||||
79 | if (strchr (exec, ' ') == NULL((void*)0)) { | |||
80 | return g_strdup (exec)g_strdup_inline (exec); | |||
81 | } | |||
82 | ||||
83 | str = g_string_new_len (NULL((void*)0), strlen (exec)); | |||
84 | ||||
85 | str = g_string_append_c (str, '"')g_string_append_c_inline (str, '"'); | |||
86 | for (c = exec; *c != '\0'; c++) { | |||
87 | /* FIXME: GKeyFile will add an additional backslach so we'll | |||
88 | * end up with toto\\" instead of toto\" | |||
89 | * We could use g_key_file_set_value(), but then we don't | |||
90 | * benefit from the other escaping that glib is doing... | |||
91 | */ | |||
92 | if (*c == '"') { | |||
93 | str = g_string_append (str, "\\\"")(__builtin_constant_p ("\\\"") ? __extension__ ({ const char * const __val = ("\\\""); g_string_append_len_inline (str, __val , (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val ))) : (gssize) -1); }) : g_string_append_len_inline (str, "\\\"" , (gssize) -1)); | |||
94 | } else { | |||
95 | str = g_string_append_c (str, *c)g_string_append_c_inline (str, *c); | |||
96 | } | |||
97 | } | |||
98 | str = g_string_append_c (str, '"')g_string_append_c_inline (str, '"'); | |||
99 | ||||
100 | return g_string_free (str, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((str) , ((0))) : g_string_free_and_steal (str)) : (g_string_free) ( (str), ((0)))); | |||
101 | } | |||
102 | ||||
103 | static void | |||
104 | on_browse_button_clicked (CtkWidget *widget, | |||
105 | CsmAppDialog *dialog) | |||
106 | { | |||
107 | CtkWidget *chooser; | |||
108 | int response; | |||
109 | ||||
110 | chooser = ctk_file_chooser_dialog_new ("", | |||
111 | CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), | |||
112 | CTK_FILE_CHOOSER_ACTION_OPEN, | |||
113 | "ctk-cancel", | |||
114 | CTK_RESPONSE_CANCEL, | |||
115 | "ctk-open", | |||
116 | CTK_RESPONSE_ACCEPT, | |||
117 | NULL((void*)0)); | |||
118 | ||||
119 | ctk_window_set_transient_for (CTK_WINDOW (chooser)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_window_get_type ())))))), | |||
120 | CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ()))))))); | |||
121 | ||||
122 | ctk_window_set_destroy_with_parent (CTK_WINDOW (chooser)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_window_get_type ())))))), TRUE(!(0))); | |||
123 | ||||
124 | ctk_window_set_title (CTK_WINDOW (chooser)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_window_get_type ())))))), _("Select Command")gettext ("Select Command")); | |||
125 | ||||
126 | ctk_widget_show (chooser); | |||
127 | ||||
128 | response = ctk_dialog_run (CTK_DIALOG (chooser)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_dialog_get_type ()))))))); | |||
129 | ||||
130 | if (response == CTK_RESPONSE_ACCEPT) { | |||
131 | char *text; | |||
132 | char *uri; | |||
133 | ||||
134 | text = ctk_file_chooser_get_filename (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ()))))))); | |||
135 | ||||
136 | uri = make_exec_uri (text); | |||
137 | ||||
138 | g_free (text); | |||
139 | ||||
140 | ctk_entry_set_text (CTK_ENTRY (dialog->command_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->command_entry)), ((ctk_entry_get_type ()))))) ), uri); | |||
141 | ||||
142 | g_free (uri); | |||
143 | } | |||
144 | ||||
145 | ctk_widget_destroy (chooser); | |||
146 | } | |||
147 | ||||
148 | static void | |||
149 | on_entry_activate (CtkEntry *entry, | |||
150 | CsmAppDialog *dialog) | |||
151 | { | |||
152 | ctk_dialog_response (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), CTK_RESPONSE_OK); | |||
153 | } | |||
154 | ||||
155 | static gboolean | |||
156 | on_spin_output (CtkSpinButton *spin, CsmAppDialog *dialog) | |||
157 | { | |||
158 | CtkAdjustment *adjustment; | |||
159 | gchar *text; | |||
160 | int value; | |||
161 | ||||
162 | adjustment = ctk_spin_button_get_adjustment (spin); | |||
163 | value = ctk_adjustment_get_value (adjustment); | |||
164 | dialog->delay = value; | |||
165 | ||||
166 | if (value == 1) | |||
167 | text = g_strdup_printf ("%d %s", value, _("second")gettext ("second")); | |||
168 | else if (value > 1) | |||
169 | text = g_strdup_printf ("%d %s", value, _("seconds")gettext ("seconds")); | |||
170 | else | |||
171 | text = g_strdup_printf ("%d", value); | |||
172 | ||||
173 | ctk_entry_set_text (CTK_ENTRY (spin)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((spin)), ((ctk_entry_get_type ())))))), text); | |||
174 | g_free (text); | |||
175 | ||||
176 | return TRUE(!(0)); | |||
177 | } | |||
178 | ||||
179 | static void | |||
180 | setup_dialog (CsmAppDialog *dialog) | |||
181 | { | |||
182 | CtkWidget *content_area; | |||
183 | CtkWidget *widget; | |||
184 | CtkBuilder *xml; | |||
185 | GError *error; | |||
186 | ||||
187 | xml = ctk_builder_new (); | |||
188 | ctk_builder_set_translation_domain (xml, GETTEXT_PACKAGE"cafe-session-manager"); | |||
189 | ||||
190 | error = NULL((void*)0); | |||
191 | if (!ctk_builder_add_from_file (xml, | |||
192 | CTKBUILDER_DIR"/usr/share/cafe-session-manager" "/" CTKBUILDER_FILE"session-properties.ui", | |||
193 | &error)) { | |||
194 | if (error) { | |||
195 | g_warning ("Could not load capplet UI file: %s", | |||
196 | error->message); | |||
197 | g_error_free (error); | |||
198 | } else { | |||
199 | g_warning ("Could not load capplet UI file."); | |||
200 | } | |||
201 | } | |||
202 | ||||
203 | content_area = ctk_dialog_get_content_area (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))); | |||
204 | widget = CTK_WIDGET (ctk_builder_get_object (xml, "main-table"))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "main-table"))), ((ctk_widget_get_type ())))))); | |||
205 | ctk_container_add (CTK_CONTAINER (content_area)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((content_area)), ((ctk_container_get_type ())))))), widget); | |||
206 | ||||
207 | ctk_container_set_border_width (CTK_CONTAINER (dialog)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_container_get_type ())))))), 6); | |||
208 | ctk_window_set_icon_name (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), "cafe-session-properties"); | |||
209 | ||||
210 | g_object_set (dialog, | |||
211 | "resizable", FALSE(0), | |||
212 | NULL((void*)0)); | |||
213 | ||||
214 | csm_util_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), | |||
215 | _("_Cancel")gettext ("_Cancel"), "process-stop", | |||
216 | CTK_RESPONSE_CANCEL); | |||
217 | ||||
218 | if (dialog->name == NULL((void*)0) | |||
219 | && dialog->command == NULL((void*)0) | |||
220 | && dialog->comment == NULL((void*)0)) { | |||
221 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Add Startup Program")gettext ("Add Startup Program")); | |||
222 | csm_util_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), | |||
223 | _("_Add")gettext ("_Add"), "list-add", | |||
224 | CTK_RESPONSE_OK); | |||
225 | } else { | |||
226 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Edit Startup Program")gettext ("Edit Startup Program")); | |||
227 | csm_util_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), | |||
228 | _("_Save")gettext ("_Save"), "document-save", | |||
229 | CTK_RESPONSE_OK); | |||
230 | } | |||
231 | ||||
232 | dialog->name_entry = CTK_WIDGET (ctk_builder_get_object (xml, CAPPLET_NAME_ENTRY_WIDGET_NAME))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "session_properties_name_entry" ))), ((ctk_widget_get_type ())))))); | |||
233 | g_signal_connect (dialog->name_entry,g_signal_connect_data ((dialog->name_entry), ("activate"), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), ( GConnectFlags) 0) | |||
234 | "activate",g_signal_connect_data ((dialog->name_entry), ("activate"), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), ( GConnectFlags) 0) | |||
235 | G_CALLBACK (on_entry_activate),g_signal_connect_data ((dialog->name_entry), ("activate"), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), ( GConnectFlags) 0) | |||
236 | dialog)g_signal_connect_data ((dialog->name_entry), ("activate"), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), ( GConnectFlags) 0); | |||
237 | if (dialog->name != NULL((void*)0)) { | |||
238 | ctk_entry_set_text (CTK_ENTRY (dialog->name_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->name_entry)), ((ctk_entry_get_type ())))))), dialog->name); | |||
239 | } | |||
240 | ||||
241 | dialog->browse_button = CTK_WIDGET (ctk_builder_get_object (xml, CAPPLET_BROWSE_WIDGET_NAME))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "session_properties_browse_button" ))), ((ctk_widget_get_type ())))))); | |||
242 | g_signal_connect (dialog->browse_button,g_signal_connect_data ((dialog->browse_button), ("clicked" ), (((GCallback) (on_browse_button_clicked))), (dialog), ((void *)0), (GConnectFlags) 0) | |||
243 | "clicked",g_signal_connect_data ((dialog->browse_button), ("clicked" ), (((GCallback) (on_browse_button_clicked))), (dialog), ((void *)0), (GConnectFlags) 0) | |||
244 | G_CALLBACK (on_browse_button_clicked),g_signal_connect_data ((dialog->browse_button), ("clicked" ), (((GCallback) (on_browse_button_clicked))), (dialog), ((void *)0), (GConnectFlags) 0) | |||
245 | dialog)g_signal_connect_data ((dialog->browse_button), ("clicked" ), (((GCallback) (on_browse_button_clicked))), (dialog), ((void *)0), (GConnectFlags) 0); | |||
246 | ||||
247 | dialog->command_entry = CTK_WIDGET (ctk_builder_get_object (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "session_properties_command_entry" ))), ((ctk_widget_get_type ())))))); | |||
248 | g_signal_connect (dialog->command_entry,g_signal_connect_data ((dialog->command_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
249 | "activate",g_signal_connect_data ((dialog->command_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
250 | G_CALLBACK (on_entry_activate),g_signal_connect_data ((dialog->command_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
251 | dialog)g_signal_connect_data ((dialog->command_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0); | |||
252 | if (dialog->command != NULL((void*)0)) { | |||
253 | ctk_entry_set_text (CTK_ENTRY (dialog->command_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->command_entry)), ((ctk_entry_get_type ()))))) ), dialog->command); | |||
254 | } | |||
255 | ||||
256 | dialog->comment_entry = CTK_WIDGET (ctk_builder_get_object (xml, CAPPLET_COMMENT_ENTRY_WIDGET_NAME))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "session_properties_comment_entry" ))), ((ctk_widget_get_type ())))))); | |||
257 | g_signal_connect (dialog->comment_entry,g_signal_connect_data ((dialog->comment_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
258 | "activate",g_signal_connect_data ((dialog->comment_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
259 | G_CALLBACK (on_entry_activate),g_signal_connect_data ((dialog->comment_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0) | |||
260 | dialog)g_signal_connect_data ((dialog->comment_entry), ("activate" ), (((GCallback) (on_entry_activate))), (dialog), ((void*)0), (GConnectFlags) 0); | |||
261 | if (dialog->comment != NULL((void*)0)) { | |||
262 | ctk_entry_set_text (CTK_ENTRY (dialog->comment_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->comment_entry)), ((ctk_entry_get_type ()))))) ), dialog->comment); | |||
263 | } | |||
264 | ||||
265 | dialog->delay_spin = CTK_WIDGET(ctk_builder_get_object (xml, CAPPLET_DELAY_SPIN_WIDGET_NAME))((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_builder_get_object (xml, "session_properties_delay_spin" ))), ((ctk_widget_get_type ())))))); | |||
266 | g_signal_connect (dialog->delay_spin,g_signal_connect_data ((dialog->delay_spin), ("output"), ( ((GCallback) (on_spin_output))), (dialog), ((void*)0), (GConnectFlags ) 0) | |||
267 | "output",g_signal_connect_data ((dialog->delay_spin), ("output"), ( ((GCallback) (on_spin_output))), (dialog), ((void*)0), (GConnectFlags ) 0) | |||
268 | G_CALLBACK (on_spin_output),g_signal_connect_data ((dialog->delay_spin), ("output"), ( ((GCallback) (on_spin_output))), (dialog), ((void*)0), (GConnectFlags ) 0) | |||
269 | dialog)g_signal_connect_data ((dialog->delay_spin), ("output"), ( ((GCallback) (on_spin_output))), (dialog), ((void*)0), (GConnectFlags ) 0); | |||
270 | if (dialog->delay > 0) { | |||
271 | CtkAdjustment *adjustment; | |||
272 | adjustment = ctk_spin_button_get_adjustment (CTK_SPIN_BUTTON(dialog->delay_spin)((((CtkSpinButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->delay_spin)), ((ctk_spin_button_get_type ())) ))))); | |||
273 | ctk_adjustment_set_value (adjustment, (gdouble) dialog->delay); | |||
274 | } | |||
275 | ||||
276 | if (xml != NULL((void*)0)) { | |||
277 | g_object_unref (xml); | |||
278 | } | |||
279 | } | |||
280 | ||||
281 | static GObject * | |||
282 | csm_app_dialog_constructor (GType type, | |||
283 | guint n_construct_app, | |||
284 | GObjectConstructParam *construct_app) | |||
285 | { | |||
286 | CsmAppDialog *dialog; | |||
287 | ||||
288 | dialog = CSM_APP_DIALOG (G_OBJECT_CLASS (csm_app_dialog_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((csm_app_dialog_parent_class)), (((GType) ((20) << ( 2))))))))->constructor (type, | |||
289 | n_construct_app, | |||
290 | construct_app)); | |||
291 | ||||
292 | setup_dialog (dialog); | |||
293 | ||||
294 | return G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))); | |||
295 | } | |||
296 | ||||
297 | static void | |||
298 | csm_app_dialog_dispose (GObject *object) | |||
299 | { | |||
300 | CsmAppDialog *dialog; | |||
301 | ||||
302 | g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "object != NULL") ; return; } } while (0); | |||
303 | g_return_if_fail (CSM_IS_APP_DIALOG (object))do { if ((CSM_IS_APP_DIALOG (object))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (object)" ); return; } } while (0); | |||
304 | ||||
305 | dialog = CSM_APP_DIALOG (object); | |||
306 | ||||
307 | g_free (dialog->name); | |||
308 | dialog->name = NULL((void*)0); | |||
309 | g_free (dialog->command); | |||
310 | dialog->command = NULL((void*)0); | |||
311 | g_free (dialog->comment); | |||
312 | dialog->comment = NULL((void*)0); | |||
313 | ||||
314 | G_OBJECT_CLASS (csm_app_dialog_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((csm_app_dialog_parent_class)), (((GType) ((20) << ( 2))))))))->dispose (object); | |||
315 | } | |||
316 | ||||
317 | static void | |||
318 | csm_app_dialog_set_name (CsmAppDialog *dialog, | |||
319 | const char *name) | |||
320 | { | |||
321 | g_return_if_fail (CSM_IS_APP_DIALOG (dialog))do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return; } } while (0); | |||
322 | ||||
323 | g_free (dialog->name); | |||
324 | ||||
325 | dialog->name = g_strdup (name)g_strdup_inline (name); | |||
326 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "name"); | |||
327 | } | |||
328 | ||||
329 | static void | |||
330 | csm_app_dialog_set_command (CsmAppDialog *dialog, | |||
331 | const char *name) | |||
332 | { | |||
333 | g_return_if_fail (CSM_IS_APP_DIALOG (dialog))do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return; } } while (0); | |||
334 | ||||
335 | g_free (dialog->command); | |||
336 | ||||
337 | dialog->command = g_strdup (name)g_strdup_inline (name); | |||
338 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "command"); | |||
339 | } | |||
340 | ||||
341 | static void | |||
342 | csm_app_dialog_set_comment (CsmAppDialog *dialog, | |||
343 | const char *name) | |||
344 | { | |||
345 | g_return_if_fail (CSM_IS_APP_DIALOG (dialog))do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return; } } while (0); | |||
346 | ||||
347 | g_free (dialog->comment); | |||
348 | ||||
349 | dialog->comment = g_strdup (name)g_strdup_inline (name); | |||
350 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "comment"); | |||
351 | } | |||
352 | ||||
353 | static void | |||
354 | csm_app_dialog_set_delay (CsmAppDialog *dialog, | |||
355 | guint delay) | |||
356 | { | |||
357 | g_return_if_fail (CSM_IS_APP_DIALOG (dialog))do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return; } } while (0); | |||
358 | ||||
359 | dialog->delay = delay; | |||
360 | g_object_notify (G_OBJECT (dialog)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), (((GType) ((20) << (2)))))))), "delay"); | |||
361 | } | |||
362 | ||||
363 | const char * | |||
364 | csm_app_dialog_get_name (CsmAppDialog *dialog) | |||
365 | { | |||
366 | g_return_val_if_fail (CSM_IS_APP_DIALOG (dialog), NULL)do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return (((void*)0)); } } while (0); | |||
367 | return ctk_entry_get_text (CTK_ENTRY (dialog->name_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->name_entry)), ((ctk_entry_get_type ()))))))); | |||
368 | } | |||
369 | ||||
370 | const char * | |||
371 | csm_app_dialog_get_command (CsmAppDialog *dialog) | |||
372 | { | |||
373 | g_return_val_if_fail (CSM_IS_APP_DIALOG (dialog), NULL)do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return (((void*)0)); } } while (0); | |||
374 | return ctk_entry_get_text (CTK_ENTRY (dialog->command_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->command_entry)), ((ctk_entry_get_type ()))))) )); | |||
375 | } | |||
376 | ||||
377 | const char * | |||
378 | csm_app_dialog_get_comment (CsmAppDialog *dialog) | |||
379 | { | |||
380 | g_return_val_if_fail (CSM_IS_APP_DIALOG (dialog), NULL)do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return (((void*)0)); } } while (0); | |||
381 | return ctk_entry_get_text (CTK_ENTRY (dialog->comment_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog->comment_entry)), ((ctk_entry_get_type ()))))) )); | |||
382 | } | |||
383 | ||||
384 | guint | |||
385 | csm_app_dialog_get_delay (CsmAppDialog *dialog) | |||
386 | { | |||
387 | g_return_val_if_fail (CSM_IS_APP_DIALOG (dialog), 0)do { if ((CSM_IS_APP_DIALOG (dialog))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "CSM_IS_APP_DIALOG (dialog)" ); return (0); } } while (0); | |||
388 | return dialog->delay; | |||
389 | } | |||
390 | ||||
391 | static void | |||
392 | csm_app_dialog_set_property (GObject *object, | |||
393 | guint prop_id, | |||
394 | const GValue *value, | |||
395 | GParamSpec *pspec) | |||
396 | { | |||
397 | CsmAppDialog *dialog = CSM_APP_DIALOG (object); | |||
398 | ||||
399 | switch (prop_id) { | |||
400 | case PROP_NAME: | |||
401 | csm_app_dialog_set_name (dialog, g_value_get_string (value)); | |||
402 | break; | |||
403 | case PROP_COMMAND: | |||
404 | csm_app_dialog_set_command (dialog, g_value_get_string (value)); | |||
405 | break; | |||
406 | case PROP_COMMENT: | |||
407 | csm_app_dialog_set_comment (dialog, g_value_get_string (value)); | |||
408 | break; | |||
409 | case PROP_DELAY: | |||
410 | csm_app_dialog_set_delay (dialog, g_value_get_uint (value)); | |||
411 | break; | |||
412 | default: | |||
413 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "csm-app-dialog.c", 413, ("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); | |||
414 | break; | |||
415 | } | |||
416 | } | |||
417 | ||||
418 | static void | |||
419 | csm_app_dialog_get_property (GObject *object, | |||
420 | guint prop_id, | |||
421 | GValue *value, | |||
422 | GParamSpec *pspec) | |||
423 | { | |||
424 | CsmAppDialog *dialog = CSM_APP_DIALOG (object); | |||
425 | ||||
426 | switch (prop_id) { | |||
427 | case PROP_NAME: | |||
428 | g_value_set_string (value, dialog->name); | |||
429 | break; | |||
430 | case PROP_COMMAND: | |||
431 | g_value_set_string (value, dialog->command); | |||
432 | break; | |||
433 | case PROP_COMMENT: | |||
434 | g_value_set_string (value, dialog->comment); | |||
435 | break; | |||
436 | case PROP_DELAY: | |||
437 | g_value_set_uint (value, dialog->delay); | |||
438 | break; | |||
439 | default: | |||
440 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "csm-app-dialog.c", 440, ("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); | |||
441 | break; | |||
442 | } | |||
443 | } | |||
444 | ||||
445 | static void | |||
446 | csm_app_dialog_class_init (CsmAppDialogClass *klass) | |||
447 | { | |||
448 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); | |||
449 | ||||
450 | object_class->get_property = csm_app_dialog_get_property; | |||
451 | object_class->set_property = csm_app_dialog_set_property; | |||
452 | object_class->constructor = csm_app_dialog_constructor; | |||
453 | object_class->dispose = csm_app_dialog_dispose; | |||
454 | ||||
455 | g_object_class_install_property (object_class, | |||
456 | PROP_NAME, | |||
457 | g_param_spec_string ("name", | |||
458 | "name", | |||
459 | "name", | |||
460 | NULL((void*)0), | |||
461 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | |||
462 | g_object_class_install_property (object_class, | |||
463 | PROP_COMMAND, | |||
464 | g_param_spec_string ("command", | |||
465 | "command", | |||
466 | "command", | |||
467 | NULL((void*)0), | |||
468 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | |||
469 | g_object_class_install_property (object_class, | |||
470 | PROP_COMMENT, | |||
471 | g_param_spec_string ("comment", | |||
472 | "comment", | |||
473 | "comment", | |||
474 | NULL((void*)0), | |||
475 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | |||
476 | g_object_class_install_property (object_class, | |||
477 | PROP_DELAY, | |||
478 | g_param_spec_uint ("delay", | |||
479 | "delay", | |||
480 | "delay", | |||
481 | 0, | |||
482 | 100, | |||
483 | 0, | |||
484 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); | |||
485 | } | |||
486 | ||||
487 | static void | |||
488 | csm_app_dialog_init (CsmAppDialog *dialog) | |||
489 | { | |||
490 | ||||
491 | } | |||
492 | ||||
493 | CtkWidget * | |||
494 | csm_app_dialog_new (const char *name, | |||
495 | const char *command, | |||
496 | const char *comment, | |||
497 | guint delay) | |||
498 | { | |||
499 | GObject *object; | |||
500 | ||||
501 | object = g_object_new (CSM_TYPE_APP_DIALOG(csm_app_dialog_get_type ()), | |||
502 | "name", name, | |||
503 | "command", command, | |||
504 | "comment", comment, | |||
505 | "delay", delay, | |||
506 | NULL((void*)0)); | |||
507 | ||||
508 | return CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ())))))); | |||
509 | } | |||
510 | ||||
511 | gboolean | |||
512 | csm_app_dialog_run (CsmAppDialog *dialog, | |||
513 | char **name_p, | |||
514 | char **command_p, | |||
515 | char **comment_p, | |||
516 | guint *delay_p) | |||
517 | { | |||
518 | gboolean retval; | |||
519 | ||||
520 | retval = FALSE(0); | |||
521 | ||||
522 | while (ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))) == CTK_RESPONSE_OK) { | |||
| ||||
523 | const char *name; | |||
524 | const char *exec; | |||
525 | const char *comment; | |||
526 | guint delay; | |||
527 | const char *error_msg; | |||
528 | GError *error; | |||
529 | char **argv; | |||
530 | int argc; | |||
531 | ||||
532 | name = csm_app_dialog_get_name (CSM_APP_DIALOG (dialog)); | |||
533 | exec = csm_app_dialog_get_command (CSM_APP_DIALOG (dialog)); | |||
534 | comment = csm_app_dialog_get_comment (CSM_APP_DIALOG (dialog)); | |||
535 | delay = csm_app_dialog_get_delay (CSM_APP_DIALOG (dialog)); | |||
536 | ||||
537 | error = NULL((void*)0); | |||
538 | error_msg = NULL((void*)0); | |||
539 | ||||
540 | if (csm_util_text_is_blank (exec)) { | |||
541 | error_msg = _("The startup command cannot be empty")gettext ("The startup command cannot be empty"); | |||
542 | } else { | |||
543 | if (!g_shell_parse_argv (exec, &argc, &argv, &error)) { | |||
544 | if (error != NULL((void*)0)) { | |||
545 | error_msg = error->message; | |||
546 | } else { | |||
547 | error_msg = _("The startup command is not valid")gettext ("The startup command is not valid"); | |||
548 | } | |||
549 | } | |||
550 | } | |||
551 | ||||
552 | if (error_msg != NULL((void*)0)) { | |||
553 | CtkWidget *msgbox; | |||
554 | ||||
555 | msgbox = ctk_message_dialog_new (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), | |||
556 | CTK_DIALOG_MODAL, | |||
557 | CTK_MESSAGE_ERROR, | |||
558 | CTK_BUTTONS_CLOSE, | |||
559 | "%s", error_msg); | |||
560 | ||||
561 | if (error != NULL((void*)0)) { | |||
562 | g_error_free (error); | |||
563 | } | |||
564 | ||||
565 | ctk_dialog_run (CTK_DIALOG (msgbox)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((msgbox)), ((ctk_dialog_get_type ()))))))); | |||
566 | ||||
567 | ctk_widget_destroy (msgbox); | |||
568 | ||||
569 | continue; | |||
570 | } | |||
571 | ||||
572 | if (csm_util_text_is_blank (name)) { | |||
573 | name = argv[0]; | |||
| ||||
574 | } | |||
575 | ||||
576 | if (name_p) { | |||
577 | *name_p = g_strdup (name)g_strdup_inline (name); | |||
578 | } | |||
579 | ||||
580 | g_strfreev (argv); | |||
581 | ||||
582 | if (command_p) { | |||
583 | *command_p = g_strdup (exec)g_strdup_inline (exec); | |||
584 | } | |||
585 | ||||
586 | if (comment_p) { | |||
587 | *comment_p = g_strdup (comment)g_strdup_inline (comment); | |||
588 | } | |||
589 | ||||
590 | if (delay_p) { | |||
591 | *delay_p = delay; | |||
592 | } | |||
593 | ||||
594 | retval = TRUE(!(0)); | |||
595 | break; | |||
596 | } | |||
597 | ||||
598 | ctk_widget_destroy (CTK_WIDGET (dialog)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_widget_get_type ()))))))); | |||
599 | ||||
600 | return retval; | |||
601 | } |