File: | dlg-update.c |
Warning: | line 152, column 20 Access to field 'data' results in a dereference of a null pointer (loaded from field 'file_list') |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ | |||
2 | ||||
3 | /* | |||
4 | * Grapa | |||
5 | * | |||
6 | * Copyright (C) 2008 Free Software Foundation, Inc. | |||
7 | * | |||
8 | * This program is free software; you can redistribute it and/or modify | |||
9 | * it under the terms of the GNU General Public License as published by | |||
10 | * the Free Software Foundation; either version 2 of the License, or | |||
11 | * (at your option) any later version. | |||
12 | * | |||
13 | * This program is distributed in the hope that it will be useful, | |||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
16 | * GNU General Public License for more details. | |||
17 | * | |||
18 | * You should have received a copy of the GNU General Public License | |||
19 | * along with this program; if not, write to the Free Software | |||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |||
21 | */ | |||
22 | ||||
23 | #include <config.h> | |||
24 | #include <string.h> | |||
25 | #include <ctk/ctk.h> | |||
26 | #include "dlg-update.h" | |||
27 | #include "file-utils.h" | |||
28 | #include "glib-utils.h" | |||
29 | #include "ctk-utils.h" | |||
30 | #include "fr-init.h" | |||
31 | #include "fr-window.h" | |||
32 | ||||
33 | ||||
34 | enum { | |||
35 | IS_SELECTED_COLUMN, | |||
36 | NAME_COLUMN, | |||
37 | DATA_COLUMN, | |||
38 | N_COLUMNS | |||
39 | }; | |||
40 | ||||
41 | typedef struct { | |||
42 | FrWindow *window; | |||
43 | CtkBuilder *builder; | |||
44 | ||||
45 | CtkWidget *update_file_dialog; | |||
46 | CtkWidget *update_file_primary_text_label; | |||
47 | CtkWidget *update_file_secondary_text_label; | |||
48 | ||||
49 | CtkWidget *update_files_dialog; | |||
50 | CtkWidget *update_files_primary_text_label; | |||
51 | CtkWidget *update_files_secondary_text_label; | |||
52 | CtkWidget *update_files_treeview; | |||
53 | CtkWidget *update_files_ok_button; | |||
54 | ||||
55 | GList *file_list; | |||
56 | CtkTreeModel *list_model; | |||
57 | } DialogData; | |||
58 | ||||
59 | ||||
60 | /* called when the main dialog is closed. */ | |||
61 | static void | |||
62 | dlg_update__destroy_cb (CtkWidget *widget, | |||
63 | DialogData *data) | |||
64 | { | |||
65 | fr_window_update_dialog_closed (data->window); | |||
66 | g_object_unref (G_OBJECT (data->builder)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->builder)), (((GType) ((20) << (2))))))))); | |||
67 | if (data->file_list != NULL((void*)0)) | |||
68 | g_list_free (data->file_list); | |||
69 | g_free (data); | |||
70 | } | |||
71 | ||||
72 | ||||
73 | static GList* | |||
74 | get_selected_files (DialogData *data) | |||
75 | { | |||
76 | GList *selection = NULL((void*)0); | |||
77 | CtkTreeIter iter; | |||
78 | ||||
79 | if (! ctk_tree_model_get_iter_first (data->list_model, &iter)) | |||
80 | return NULL((void*)0); | |||
81 | ||||
82 | do { | |||
83 | gboolean is_selected; | |||
84 | OpenFile *file; | |||
85 | ||||
86 | ctk_tree_model_get (data->list_model, &iter, | |||
87 | IS_SELECTED_COLUMN, &is_selected, | |||
88 | DATA_COLUMN, &file, | |||
89 | -1); | |||
90 | if (is_selected) | |||
91 | selection = g_list_prepend (selection, file); | |||
92 | } while (ctk_tree_model_iter_next (data->list_model, &iter)); | |||
93 | ||||
94 | return g_list_reverse (selection); | |||
95 | } | |||
96 | ||||
97 | ||||
98 | static void | |||
99 | update_cb (CtkWidget *widget, | |||
100 | gpointer callback_data) | |||
101 | { | |||
102 | DialogData *data = callback_data; | |||
103 | GList *selection; | |||
104 | ||||
105 | selection = get_selected_files (data); | |||
106 | if (fr_window_update_files (data->window, selection)) { | |||
107 | int n_files; | |||
108 | ||||
109 | n_files = g_list_length (data->file_list); | |||
110 | if (n_files == 1) | |||
111 | ctk_widget_destroy (data->update_file_dialog); | |||
112 | else | |||
113 | ctk_widget_destroy (data->update_files_dialog); | |||
114 | } | |||
115 | if (selection != NULL((void*)0)) | |||
116 | g_list_free (selection); | |||
117 | } | |||
118 | ||||
119 | ||||
120 | static void | |||
121 | update_file_list (DialogData *data) | |||
122 | { | |||
123 | gboolean n_files; | |||
124 | GList *scan; | |||
125 | CtkTreeIter iter; | |||
126 | ||||
127 | n_files = g_list_length (data->file_list); | |||
128 | ||||
129 | /* update the file list */ | |||
130 | ||||
131 | ctk_list_store_clear (CTK_LIST_STORE (data->list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), ((ctk_list_store_get_type ()))))) )); | |||
132 | for (scan = data->file_list; scan; scan = scan->next) { | |||
133 | char *utf8_name; | |||
134 | OpenFile *file = scan->data; | |||
135 | ||||
136 | ctk_list_store_append (CTK_LIST_STORE (data->list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), ((ctk_list_store_get_type ()))))) ), | |||
137 | &iter); | |||
138 | ||||
139 | utf8_name = g_filename_display_name (file_name_from_path (file->path)); | |||
140 | ctk_list_store_set (CTK_LIST_STORE (data->list_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), ((ctk_list_store_get_type ()))))) ), | |||
141 | &iter, | |||
142 | IS_SELECTED_COLUMN, TRUE(!(0)), | |||
143 | NAME_COLUMN, utf8_name, | |||
144 | DATA_COLUMN, file, | |||
145 | -1); | |||
146 | g_free (utf8_name); | |||
147 | } | |||
148 | ||||
149 | /* update the labels */ | |||
150 | ||||
151 | if (n_files == 1) { | |||
152 | OpenFile *file = data->file_list->data; | |||
| ||||
153 | char *file_name; | |||
154 | char *unescaped; | |||
155 | char *archive_name; | |||
156 | char *label; | |||
157 | char *markup; | |||
158 | ||||
159 | /* primary text */ | |||
160 | ||||
161 | file_name = g_filename_display_name (file_name_from_path (file->path)); | |||
162 | unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL((void*)0)); | |||
163 | archive_name = g_path_get_basename (unescaped); | |||
164 | label = g_markup_printf_escaped (_("Update the file \"%s\" in the archive \"%s\"?")gettext ("Update the file \"%s\" in the archive \"%s\"?"), file_name, archive_name); | |||
165 | markup = g_strdup_printf ("<big><b>%s</b></big>", label); | |||
166 | ctk_label_set_markup (CTK_LABEL (data->update_file_primary_text_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_primary_text_label)), ((ctk_label_get_type ())))))), markup); | |||
167 | ||||
168 | g_free (markup); | |||
169 | g_free (label); | |||
170 | g_free (archive_name); | |||
171 | g_free (unescaped); | |||
172 | g_free (file_name); | |||
173 | ||||
174 | /* secondary text */ | |||
175 | ||||
176 | label = g_strdup_printf (ngettext ("The file has been modified with an external application. If you don't update the file in the archive, all of your changes will be lost.", | |||
177 | "%d files have been modified with an external application. If you don't update the files in the archive, all of your changes will be lost.", | |||
178 | n_files), | |||
179 | n_files); | |||
180 | ctk_label_set_text (CTK_LABEL (data->update_file_secondary_text_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_secondary_text_label)), ((ctk_label_get_type ())))))), label); | |||
181 | g_free (label); | |||
182 | } | |||
183 | else if (n_files > 1) { | |||
184 | char *unescaped; | |||
185 | char *archive_name; | |||
186 | char *label; | |||
187 | char *markup; | |||
188 | ||||
189 | /* primary text */ | |||
190 | ||||
191 | unescaped = g_uri_unescape_string (fr_window_get_archive_uri (data->window), NULL((void*)0)); | |||
192 | archive_name = g_path_get_basename (unescaped); | |||
193 | label = g_markup_printf_escaped (_("Update the files in the archive \"%s\"?")gettext ("Update the files in the archive \"%s\"?"), archive_name); | |||
194 | markup = g_strdup_printf ("<big><b>%s</b></big>", label); | |||
195 | ctk_label_set_markup (CTK_LABEL (data->update_files_primary_text_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_primary_text_label)), ((ctk_label_get_type ())))))), markup); | |||
196 | ||||
197 | g_free (markup); | |||
198 | g_free (label); | |||
199 | g_free (archive_name); | |||
200 | g_free (unescaped); | |||
201 | ||||
202 | /* secondary text */ | |||
203 | ||||
204 | label = g_strdup_printf (ngettext ("The file has been modified with an external application. If you don't update the file in the archive, all of your changes will be lost.", | |||
205 | "%d files have been modified with an external application. If you don't update the files in the archive, all of your changes will be lost.", | |||
206 | n_files), | |||
207 | n_files); | |||
208 | ctk_label_set_text (CTK_LABEL (data->update_files_secondary_text_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_secondary_text_label)), ((ctk_label_get_type ())))))), label); | |||
209 | g_free (label); | |||
210 | } | |||
211 | ||||
212 | /* show the appropriate dialog */ | |||
213 | ||||
214 | if (n_files == 1) { | |||
215 | /*ctk_window_set_modal (CTK_WINDOW (data->update_files_dialog), FALSE);*/ | |||
216 | ctk_widget_hide (data->update_files_dialog); | |||
217 | /*ctk_window_set_modal (CTK_WINDOW (data->update_file_dialog), TRUE);*/ | |||
218 | ctk_widget_show (data->update_file_dialog); | |||
219 | } | |||
220 | else if (n_files > 1) { | |||
221 | /*ctk_window_set_modal (CTK_WINDOW (data->update_file_dialog), FALSE);*/ | |||
222 | ctk_widget_hide (data->update_file_dialog); | |||
223 | /*ctk_window_set_modal (CTK_WINDOW (data->update_files_dialog), TRUE);*/ | |||
224 | ctk_widget_show (data->update_files_dialog); | |||
225 | } | |||
226 | else { /* n_files == 0 */ | |||
227 | /*ctk_window_set_modal (CTK_WINDOW (data->update_files_dialog), FALSE);*/ | |||
228 | ctk_widget_hide (data->update_files_dialog); | |||
229 | /*ctk_window_set_modal (CTK_WINDOW (data->update_file_dialog), FALSE);*/ | |||
230 | ctk_widget_hide (data->update_file_dialog); | |||
231 | } | |||
232 | } | |||
233 | ||||
234 | ||||
235 | static int | |||
236 | n_selected (DialogData *data) | |||
237 | { | |||
238 | int n = 0; | |||
239 | CtkTreeIter iter; | |||
240 | ||||
241 | if (! ctk_tree_model_get_iter_first (data->list_model, &iter)) | |||
242 | return 0; | |||
243 | ||||
244 | do { | |||
245 | gboolean is_selected; | |||
246 | ctk_tree_model_get (data->list_model, &iter, IS_SELECTED_COLUMN, &is_selected, -1); | |||
247 | if (is_selected) | |||
248 | n++; | |||
249 | } while (ctk_tree_model_iter_next (data->list_model, &iter)); | |||
250 | ||||
251 | return n; | |||
252 | } | |||
253 | ||||
254 | ||||
255 | static void | |||
256 | is_selected_toggled (CtkCellRendererToggle *cell, | |||
257 | char *path_string, | |||
258 | gpointer callback_data) | |||
259 | { | |||
260 | DialogData *data = callback_data; | |||
261 | CtkTreeModel *model = CTK_TREE_MODEL (data->list_model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), ((ctk_tree_model_get_type ()))))) ); | |||
262 | CtkTreeIter iter; | |||
263 | CtkTreePath *path = ctk_tree_path_new_from_string (path_string); | |||
264 | guint value; | |||
265 | ||||
266 | ctk_tree_model_get_iter (model, &iter, path); | |||
267 | value = ! ctk_cell_renderer_toggle_get_active (cell); | |||
268 | ctk_list_store_set (CTK_LIST_STORE (model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))), &iter, IS_SELECTED_COLUMN, value, -1); | |||
269 | ||||
270 | ctk_tree_path_free (path); | |||
271 | ||||
272 | ctk_widget_set_sensitive (data->update_files_ok_button, n_selected (data) > 0); | |||
273 | } | |||
274 | ||||
275 | ||||
276 | gpointer | |||
277 | dlg_update (FrWindow *window) | |||
278 | { | |||
279 | DialogData *data; | |||
280 | CtkWidget *update_file_ok_button; | |||
281 | CtkWidget *update_file_cancel_button; | |||
282 | CtkWidget *update_files_cancel_button; | |||
283 | CtkCellRenderer *renderer; | |||
284 | CtkTreeViewColumn *column; | |||
285 | ||||
286 | data = g_new0 (DialogData, 1)((DialogData *) g_malloc0_n ((1), sizeof (DialogData))); | |||
287 | ||||
288 | data->builder = _ctk_builder_new_from_resource ("update.ui"); | |||
289 | if (data->builder == NULL((void*)0)) { | |||
290 | g_free (data); | |||
291 | return NULL((void*)0); | |||
292 | } | |||
293 | ||||
294 | data->file_list = NULL((void*)0); | |||
295 | data->window = window; | |||
296 | ||||
297 | /* Get the widgets. */ | |||
298 | ||||
299 | data->update_file_dialog = _ctk_builder_get_widget (data->builder, "update_file_dialog"); | |||
300 | data->update_file_primary_text_label = _ctk_builder_get_widget (data->builder, "update_file_primary_text_label"); | |||
301 | data->update_file_secondary_text_label = _ctk_builder_get_widget (data->builder, "update_file_secondary_text_label"); | |||
302 | ||||
303 | update_file_ok_button = _ctk_builder_get_widget (data->builder, "update_file_ok_button"); | |||
304 | update_file_cancel_button = _ctk_builder_get_widget (data->builder, "update_file_cancel_button"); | |||
305 | ||||
306 | data->update_files_dialog = _ctk_builder_get_widget (data->builder, "update_files_dialog"); | |||
307 | data->update_files_primary_text_label = _ctk_builder_get_widget (data->builder, "update_files_primary_text_label"); | |||
308 | data->update_files_secondary_text_label = _ctk_builder_get_widget (data->builder, "update_files_secondary_text_label"); | |||
309 | data->update_files_treeview = _ctk_builder_get_widget (data->builder, "update_files_treeview"); | |||
310 | data->update_files_ok_button = _ctk_builder_get_widget (data->builder, "update_files_ok_button"); | |||
311 | update_files_cancel_button = _ctk_builder_get_widget (data->builder, "update_files_cancel_button"); | |||
312 | ||||
313 | /* Set the signals handlers. */ | |||
314 | ||||
315 | g_signal_connect (G_OBJECT (data->update_file_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_file_dialog)), (((GType) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
316 | "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_file_dialog)), (((GType) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
317 | G_CALLBACK (dlg_update__destroy_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_file_dialog)), (((GType) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
318 | data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_file_dialog)), (((GType) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0); | |||
319 | g_signal_connect (G_OBJECT (update_file_ok_button),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_ok_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb) )), (data), ((void*)0), (GConnectFlags) 0) | |||
320 | "clicked",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_ok_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb) )), (data), ((void*)0), (GConnectFlags) 0) | |||
321 | G_CALLBACK (update_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_ok_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb) )), (data), ((void*)0), (GConnectFlags) 0) | |||
322 | data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_ok_button)), (((GType) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb) )), (data), ((void*)0), (GConnectFlags) 0); | |||
323 | g_signal_connect_swapped (G_OBJECT (update_file_cancel_button),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_dialog)), (((GType) ((20) << ( 2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
324 | "clicked",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_dialog)), (((GType) ((20) << ( 2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
325 | G_CALLBACK (ctk_widget_destroy),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_dialog)), (((GType) ((20) << ( 2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
326 | G_OBJECT (data->update_file_dialog))g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_file_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_dialog)), (((GType) ((20) << ( 2))))))))), ((void*)0), G_CONNECT_SWAPPED); | |||
327 | g_signal_connect (G_OBJECT (data->update_files_dialog),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_dialog)), (((GType ) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
328 | "destroy",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_dialog)), (((GType ) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
329 | G_CALLBACK (dlg_update__destroy_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_dialog)), (((GType ) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
330 | data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_dialog)), (((GType ) ((20) << (2))))))))), ("destroy"), (((GCallback) (dlg_update__destroy_cb ))), (data), ((void*)0), (GConnectFlags) 0); | |||
331 | g_signal_connect (G_OBJECT (data->update_files_ok_button),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_ok_button)), (((GType ) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
332 | "clicked",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_ok_button)), (((GType ) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
333 | G_CALLBACK (update_cb),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_ok_button)), (((GType ) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb ))), (data), ((void*)0), (GConnectFlags) 0) | |||
334 | data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((data->update_files_ok_button)), (((GType ) ((20) << (2))))))))), ("clicked"), (((GCallback) (update_cb ))), (data), ((void*)0), (GConnectFlags) 0); | |||
335 | g_signal_connect_swapped (G_OBJECT (update_files_cancel_button),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_files_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_dialog)), (((GType) ((20) << (2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
336 | "clicked",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_files_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_dialog)), (((GType) ((20) << (2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
337 | G_CALLBACK (ctk_widget_destroy),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_files_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_dialog)), (((GType) ((20) << (2))))))))), ((void*)0), G_CONNECT_SWAPPED) | |||
338 | G_OBJECT (data->update_files_dialog))g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((update_files_cancel_button)), (((GType) ( (20) << (2))))))))), ("clicked"), (((GCallback) (ctk_widget_destroy ))), (((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_dialog)), (((GType) ((20) << (2))))))))), ((void*)0), G_CONNECT_SWAPPED); | |||
339 | ||||
340 | /* Set dialog data. */ | |||
341 | ||||
342 | data->list_model = CTK_TREE_MODEL (ctk_list_store_new (N_COLUMNS,((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_store_new (N_COLUMNS, ((GType) ((5) << (2 ))), ((GType) ((16) << (2))), ((GType) ((17) << ( 2)))))), ((ctk_tree_model_get_type ())))))) | |||
343 | G_TYPE_BOOLEAN,((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_store_new (N_COLUMNS, ((GType) ((5) << (2 ))), ((GType) ((16) << (2))), ((GType) ((17) << ( 2)))))), ((ctk_tree_model_get_type ())))))) | |||
344 | G_TYPE_STRING,((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_store_new (N_COLUMNS, ((GType) ((5) << (2 ))), ((GType) ((16) << (2))), ((GType) ((17) << ( 2)))))), ((ctk_tree_model_get_type ())))))) | |||
345 | G_TYPE_POINTER))((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_list_store_new (N_COLUMNS, ((GType) ((5) << (2 ))), ((GType) ((16) << (2))), ((GType) ((17) << ( 2)))))), ((ctk_tree_model_get_type ())))))); | |||
346 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (data->list_model)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), ((ctk_tree_sortable_get_type ())) )))), | |||
347 | NAME_COLUMN, | |||
348 | CTK_SORT_ASCENDING); | |||
349 | ctk_tree_view_set_model (CTK_TREE_VIEW (data->update_files_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_treeview)), ((ctk_tree_view_get_type ())))))), | |||
350 | data->list_model); | |||
351 | g_object_unref (G_OBJECT (data->list_model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->list_model)), (((GType) ((20) << (2)))))) ))); | |||
352 | ||||
353 | column = ctk_tree_view_column_new (); | |||
354 | ||||
355 | renderer = ctk_cell_renderer_toggle_new (); | |||
356 | g_signal_connect (G_OBJECT (renderer),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (is_selected_toggled))), (data), ((void*)0), (GConnectFlags) 0) | |||
357 | "toggled",g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (is_selected_toggled))), (data), ((void*)0), (GConnectFlags) 0) | |||
358 | G_CALLBACK (is_selected_toggled),g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (is_selected_toggled))), (data), ((void*)0), (GConnectFlags) 0) | |||
359 | data)g_signal_connect_data ((((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((renderer)), (((GType) ((20) << (2) )))))))), ("toggled"), (((GCallback) (is_selected_toggled))), (data), ((void*)0), (GConnectFlags) 0); | |||
360 | ctk_tree_view_column_pack_start (column, renderer, FALSE(0)); | |||
361 | ctk_tree_view_column_set_attributes (column, renderer, | |||
362 | "active", IS_SELECTED_COLUMN, | |||
363 | NULL((void*)0)); | |||
364 | ||||
365 | renderer = ctk_cell_renderer_text_new (); | |||
366 | ctk_tree_view_column_pack_start (column, renderer, TRUE(!(0))); | |||
367 | ctk_tree_view_column_set_attributes (column, renderer, | |||
368 | "text", NAME_COLUMN, | |||
369 | NULL((void*)0)); | |||
370 | ||||
371 | ctk_tree_view_append_column (CTK_TREE_VIEW (data->update_files_treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_treeview)), ((ctk_tree_view_get_type ())))))), column); | |||
372 | ||||
373 | /* Run dialog. */ | |||
374 | ||||
375 | ctk_window_set_transient_for (CTK_WINDOW (data->update_file_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_file_dialog)), ((ctk_window_get_type ()) ))))), | |||
376 | CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
377 | ctk_window_set_transient_for (CTK_WINDOW (data->update_files_dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->update_files_dialog)), ((ctk_window_get_type () )))))), | |||
378 | CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); | |||
379 | ||||
380 | update_file_list (data); | |||
381 | ||||
382 | return data; | |||
383 | } | |||
384 | ||||
385 | ||||
386 | void | |||
387 | dlg_update_add_file (gpointer dialog, | |||
388 | OpenFile *file) | |||
389 | { | |||
390 | DialogData *data = dialog; | |||
391 | GList *scan; | |||
392 | ||||
393 | /* avoid duplicates */ | |||
394 | ||||
395 | for (scan = data->file_list; scan; scan = scan->next) { | |||
| ||||
396 | OpenFile *test = scan->data; | |||
397 | if (uricmp (test->extracted_uri, file->extracted_uri) == 0) | |||
398 | return; | |||
399 | } | |||
400 | ||||
401 | /**/ | |||
402 | ||||
403 | data->file_list = g_list_append (data->file_list, file); | |||
404 | update_file_list (data); | |||
405 | } |