File: | src/baul-query-editor.c |
Warning: | line 1158, column 5 Value stored to 'datetime' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
2 | /* |
3 | * Copyright (C) 2005 Red Hat, Inc. |
4 | * |
5 | * Baul is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as |
7 | * published by the Free Software Foundation; either version 2 of the |
8 | * License, or (at your option) any later version. |
9 | * |
10 | * Baul 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 | * General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public |
16 | * License along with this program; see the file COPYING. If not, |
17 | * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | * |
20 | * Author: Alexander Larsson <alexl@redhat.com> |
21 | * |
22 | */ |
23 | |
24 | #include <config.h> |
25 | #include <string.h> |
26 | |
27 | #include <glib/gi18n.h> |
28 | #include <gio/gio.h> |
29 | #include <cdk/cdkkeysyms.h> |
30 | #include <ctk/ctk.h> |
31 | |
32 | #include <eel/eel-ctk-macros.h> |
33 | #include <eel/eel-glib-extensions.h> |
34 | #include <eel/eel-stock-dialogs.h> |
35 | |
36 | #include <libbaul-private/baul-global-preferences.h> |
37 | |
38 | #include "baul-query-editor.h" |
39 | #include "baul-src-marshal.h" |
40 | #include "baul-window-slot.h" |
41 | |
42 | enum |
43 | { |
44 | DURATION_INVALID, |
45 | DURATION_ONE_HOUR, |
46 | DURATION_ONE_DAY, |
47 | DURATION_ONE_WEEK, |
48 | DURATION_ONE_MONTH, |
49 | DURATION_SIX_MONTHS, |
50 | DURATION_ONE_YEAR, |
51 | }; |
52 | |
53 | typedef enum |
54 | { |
55 | BAUL_QUERY_EDITOR_ROW_LOCATION, |
56 | BAUL_QUERY_EDITOR_ROW_TYPE, |
57 | BAUL_QUERY_EDITOR_ROW_TAGS, |
58 | BAUL_QUERY_EDITOR_ROW_TIME_MODIFIED, |
59 | BAUL_QUERY_EDITOR_ROW_SIZE, |
60 | BAUL_QUERY_EDITOR_ROW_CONTAINED_TEXT, |
61 | |
62 | BAUL_QUERY_EDITOR_ROW_LAST |
63 | } BaulQueryEditorRowType; |
64 | |
65 | typedef struct |
66 | { |
67 | BaulQueryEditorRowType type; |
68 | BaulQueryEditor *editor; |
69 | CtkWidget *hbox; |
70 | CtkWidget *combo; |
71 | |
72 | CtkWidget *type_widget; |
73 | |
74 | void *data; |
75 | } BaulQueryEditorRow; |
76 | |
77 | |
78 | typedef struct |
79 | { |
80 | const char *name; |
81 | CtkWidget * (*create_widgets) (BaulQueryEditorRow *row); |
82 | void (*add_to_query) (BaulQueryEditorRow *row, |
83 | BaulQuery *query); |
84 | void (*free_data) (BaulQueryEditorRow *row); |
85 | void (*add_rows_from_query) (BaulQueryEditor *editor, |
86 | BaulQuery *query); |
87 | } BaulQueryEditorRowOps; |
88 | |
89 | struct BaulQueryEditorDetails |
90 | { |
91 | gboolean is_indexed; |
92 | CtkWidget *entry; |
93 | gboolean change_frozen; |
94 | guint typing_timeout_id; |
95 | gboolean is_visible; |
96 | CtkWidget *invisible_vbox; |
97 | CtkWidget *visible_vbox; |
98 | |
99 | GList *rows; |
100 | char *last_set_query_text; |
101 | |
102 | BaulSearchBar *bar; |
103 | BaulWindowSlot *slot; |
104 | }; |
105 | |
106 | enum |
107 | { |
108 | CHANGED, |
109 | CANCEL, |
110 | LAST_SIGNAL |
111 | }; |
112 | |
113 | static guint signals[LAST_SIGNAL] = { 0 }; |
114 | |
115 | static void baul_query_editor_class_init (BaulQueryEditorClass *class); |
116 | static void baul_query_editor_init (BaulQueryEditor *editor); |
117 | |
118 | static void go_search_cb (CtkButton *clicked_button, BaulQueryEditor *editor); |
119 | |
120 | static void entry_activate_cb (CtkWidget *entry, BaulQueryEditor *editor); |
121 | static void entry_changed_cb (CtkWidget *entry, BaulQueryEditor *editor); |
122 | static void baul_query_editor_changed_force (BaulQueryEditor *editor, |
123 | gboolean force); |
124 | static void baul_query_editor_changed (BaulQueryEditor *editor); |
125 | static BaulQueryEditorRow * baul_query_editor_add_row (BaulQueryEditor *editor, |
126 | BaulQueryEditorRowType type); |
127 | |
128 | static CtkWidget *location_row_create_widgets (BaulQueryEditorRow *row); |
129 | static void location_row_add_to_query (BaulQueryEditorRow *row, |
130 | BaulQuery *query); |
131 | static void location_row_free_data (BaulQueryEditorRow *row); |
132 | static void location_add_rows_from_query (BaulQueryEditor *editor, |
133 | BaulQuery *query); |
134 | |
135 | static CtkWidget *tags_row_create_widgets (BaulQueryEditorRow *row); |
136 | static void tags_row_add_to_query (BaulQueryEditorRow *row, |
137 | BaulQuery *query); |
138 | static void tags_row_free_data (BaulQueryEditorRow *row); |
139 | static void tags_add_rows_from_query (BaulQueryEditor *editor, |
140 | BaulQuery *query); |
141 | |
142 | static CtkWidget *type_row_create_widgets (BaulQueryEditorRow *row); |
143 | static void type_row_add_to_query (BaulQueryEditorRow *row, |
144 | BaulQuery *query); |
145 | static void type_row_free_data (BaulQueryEditorRow *row); |
146 | static void type_add_rows_from_query (BaulQueryEditor *editor, |
147 | BaulQuery *query); |
148 | static CtkWidget *modtime_row_create_widgets(BaulQueryEditorRow *row); |
149 | static void modtime_row_add_to_query(BaulQueryEditorRow *row, |
150 | BaulQuery *query); |
151 | static void modtime_row_free_data(BaulQueryEditorRow *row); |
152 | static void modtime_add_rows_from_query(BaulQueryEditor *editor, |
153 | BaulQuery *query); |
154 | static CtkWidget *size_row_create_widgets(BaulQueryEditorRow *row); |
155 | static void size_row_add_to_query(BaulQueryEditorRow *row, |
156 | BaulQuery *query); |
157 | static void size_row_free_data(BaulQueryEditorRow *row); |
158 | static void size_add_rows_from_query(BaulQueryEditor *editor, |
159 | BaulQuery *query); |
160 | |
161 | static CtkWidget *contained_text_row_create_widgets(BaulQueryEditorRow *row); |
162 | static void contained_text_row_add_to_query(BaulQueryEditorRow *row, |
163 | BaulQuery *query); |
164 | static void contained_text_row_free_data(BaulQueryEditorRow *row); |
165 | static void contained_text_add_rows_from_query(BaulQueryEditor *editor, |
166 | BaulQuery *query); |
167 | |
168 | static BaulQueryEditorRowOps row_type[] = |
169 | { |
170 | { |
171 | N_("Location")("Location"), |
172 | location_row_create_widgets, |
173 | location_row_add_to_query, |
174 | location_row_free_data, |
175 | location_add_rows_from_query |
176 | }, |
177 | { |
178 | N_("File Type")("File Type"), |
179 | type_row_create_widgets, |
180 | type_row_add_to_query, |
181 | type_row_free_data, |
182 | type_add_rows_from_query |
183 | }, |
184 | { |
185 | N_("Tags")("Tags"), |
186 | tags_row_create_widgets, |
187 | tags_row_add_to_query, |
188 | tags_row_free_data, |
189 | tags_add_rows_from_query |
190 | }, |
191 | { |
192 | N_("Modification Time")("Modification Time"), |
193 | modtime_row_create_widgets, |
194 | modtime_row_add_to_query, |
195 | modtime_row_free_data, |
196 | modtime_add_rows_from_query |
197 | }, |
198 | { |
199 | N_("Size")("Size"), |
200 | size_row_create_widgets, |
201 | size_row_add_to_query, |
202 | size_row_free_data, |
203 | size_add_rows_from_query |
204 | }, |
205 | { |
206 | N_("Contained text")("Contained text"), |
207 | contained_text_row_create_widgets, |
208 | contained_text_row_add_to_query, |
209 | contained_text_row_free_data, |
210 | contained_text_add_rows_from_query |
211 | } |
212 | }; |
213 | |
214 | EEL_CLASS_BOILERPLATE (BaulQueryEditor,static gpointer parent_class; GType baul_query_editor_get_type (void) { GType parent_type; static GType type; if (type == 0 ) { static GTypeInfo info = { sizeof (BaulQueryEditorClass), ( (void*)0), ((void*)0), (GClassInitFunc) baul_query_editor_class_init , ((void*)0), ((void*)0), sizeof (BaulQueryEditor), 0, (GInstanceInitFunc ) baul_query_editor_init, ((void*)0) }; parent_type = ((ctk_box_get_type ())); type = g_type_register_static (parent_type, "BaulQueryEditor" , &info, 0); parent_class = g_type_class_ref (parent_type ); } return type; } |
215 | baul_query_editor,static gpointer parent_class; GType baul_query_editor_get_type (void) { GType parent_type; static GType type; if (type == 0 ) { static GTypeInfo info = { sizeof (BaulQueryEditorClass), ( (void*)0), ((void*)0), (GClassInitFunc) baul_query_editor_class_init , ((void*)0), ((void*)0), sizeof (BaulQueryEditor), 0, (GInstanceInitFunc ) baul_query_editor_init, ((void*)0) }; parent_type = ((ctk_box_get_type ())); type = g_type_register_static (parent_type, "BaulQueryEditor" , &info, 0); parent_class = g_type_class_ref (parent_type ); } return type; } |
216 | CTK_TYPE_BOX)static gpointer parent_class; GType baul_query_editor_get_type (void) { GType parent_type; static GType type; if (type == 0 ) { static GTypeInfo info = { sizeof (BaulQueryEditorClass), ( (void*)0), ((void*)0), (GClassInitFunc) baul_query_editor_class_init , ((void*)0), ((void*)0), sizeof (BaulQueryEditor), 0, (GInstanceInitFunc ) baul_query_editor_init, ((void*)0) }; parent_type = ((ctk_box_get_type ())); type = g_type_register_static (parent_type, "BaulQueryEditor" , &info, 0); parent_class = g_type_class_ref (parent_type ); } return type; } |
217 | |
218 | static void |
219 | baul_query_editor_finalize (GObject *object) |
220 | { |
221 | BaulQueryEditor *editor; |
222 | |
223 | editor = BAUL_QUERY_EDITOR (object)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), (baul_query_editor_get_type()))))); |
224 | |
225 | g_free (editor->details); |
226 | |
227 | EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object))do { if (((((GObjectClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((parent_class)), (((GType) ((20) << (2)) ))))))->finalize != ((void*)0)) { (* ((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((parent_class)), ( ((GType) ((20) << (2))))))))->finalize) (object); } } while (0); |
228 | } |
229 | |
230 | static void |
231 | baul_query_editor_dispose (GObject *object) |
232 | { |
233 | BaulQueryEditor *editor; |
234 | |
235 | editor = BAUL_QUERY_EDITOR (object)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), (baul_query_editor_get_type()))))); |
236 | |
237 | if (editor->details->typing_timeout_id) |
238 | { |
239 | g_source_remove (editor->details->typing_timeout_id); |
240 | editor->details->typing_timeout_id = 0; |
241 | } |
242 | |
243 | if (editor->details->bar != NULL((void*)0)) |
244 | { |
245 | g_signal_handlers_disconnect_by_func (editor->details->entry,g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
246 | entry_activate_cb,g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
247 | editor)g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)); |
248 | g_signal_handlers_disconnect_by_func (editor->details->entry,g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
249 | entry_changed_cb,g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
250 | editor)g_signal_handlers_disconnect_matched ((editor->details-> entry), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)); |
251 | |
252 | baul_search_bar_return_entry (editor->details->bar); |
253 | eel_remove_weak_pointer (&editor->details->bar); |
254 | } |
255 | |
256 | EEL_CALL_PARENT (G_OBJECT_CLASS, dispose, (object))do { if (((((GObjectClass*) (void *) g_type_check_class_cast ( (GTypeClass*) ((parent_class)), (((GType) ((20) << (2)) ))))))->dispose != ((void*)0)) { (* ((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((parent_class)), ( ((GType) ((20) << (2))))))))->dispose) (object); } } while (0); |
257 | } |
258 | |
259 | static void |
260 | baul_query_editor_class_init (BaulQueryEditorClass *class) |
261 | { |
262 | GObjectClass *gobject_class; |
263 | CtkBindingSet *binding_set; |
264 | |
265 | gobject_class = G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2)))))))); |
266 | gobject_class->finalize = baul_query_editor_finalize; |
267 | gobject_class->dispose = baul_query_editor_dispose; |
268 | |
269 | signals[CHANGED] = |
270 | g_signal_new ("changed", |
271 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), |
272 | G_SIGNAL_RUN_LAST, |
273 | G_STRUCT_OFFSET (BaulQueryEditorClass, changed)((glong) __builtin_offsetof(BaulQueryEditorClass, changed)), |
274 | NULL((void*)0), NULL((void*)0), |
275 | baul_src_marshal_VOID__OBJECT_BOOLEAN, |
276 | G_TYPE_NONE((GType) ((1) << (2))), 2, BAUL_TYPE_QUERY(baul_query_get_type ()), G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
277 | |
278 | signals[CANCEL] = |
279 | g_signal_new ("cancel", |
280 | G_TYPE_FROM_CLASS (class)(((GTypeClass*) (class))->g_type), |
281 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
282 | G_STRUCT_OFFSET (BaulQueryEditorClass, cancel)((glong) __builtin_offsetof(BaulQueryEditorClass, cancel)), |
283 | NULL((void*)0), NULL((void*)0), |
284 | g_cclosure_marshal_VOID__VOID, |
285 | G_TYPE_NONE((GType) ((1) << (2))), 0); |
286 | |
287 | binding_set = ctk_binding_set_by_class (class); |
288 | ctk_binding_entry_add_signal (binding_set, CDK_KEY_Escape0xff1b, 0, "cancel", 0); |
289 | } |
290 | |
291 | static void |
292 | entry_activate_cb (CtkWidget *entry, BaulQueryEditor *editor) |
293 | { |
294 | if (editor->details->typing_timeout_id) |
295 | { |
296 | g_source_remove (editor->details->typing_timeout_id); |
297 | editor->details->typing_timeout_id = 0; |
298 | } |
299 | |
300 | baul_query_editor_changed_force (editor, TRUE(!(0))); |
301 | } |
302 | |
303 | static gboolean |
304 | typing_timeout_cb (gpointer user_data) |
305 | { |
306 | BaulQueryEditor *editor; |
307 | |
308 | editor = BAUL_QUERY_EDITOR (user_data)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((user_data)), (baul_query_editor_get_type()))))); |
309 | |
310 | baul_query_editor_changed (editor); |
311 | |
312 | editor->details->typing_timeout_id = 0; |
313 | |
314 | return FALSE(0); |
315 | } |
316 | |
317 | #define TYPING_TIMEOUT750 750 |
318 | |
319 | static void |
320 | entry_changed_cb (CtkWidget *entry, BaulQueryEditor *editor) |
321 | { |
322 | if (editor->details->change_frozen) |
323 | { |
324 | return; |
325 | } |
326 | |
327 | if (editor->details->typing_timeout_id) |
328 | { |
329 | g_source_remove (editor->details->typing_timeout_id); |
330 | } |
331 | |
332 | editor->details->typing_timeout_id = |
333 | g_timeout_add (TYPING_TIMEOUT750, |
334 | typing_timeout_cb, |
335 | editor); |
336 | } |
337 | |
338 | static void |
339 | edit_clicked (CtkButton *button, BaulQueryEditor *editor) |
340 | { |
341 | baul_query_editor_set_visible (editor, TRUE(!(0))); |
342 | baul_query_editor_grab_focus (editor); |
343 | } |
344 | |
345 | /* Location */ |
346 | |
347 | static CtkWidget * |
348 | location_row_create_widgets (BaulQueryEditorRow *row) |
349 | { |
350 | CtkWidget *chooser; |
351 | |
352 | chooser = ctk_file_chooser_button_new (_("Select folder to search in")gettext ("Select folder to search in"), |
353 | CTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); |
354 | ctk_file_chooser_set_local_only (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ())))))), TRUE(!(0))); |
355 | ctk_file_chooser_set_current_folder (CTK_FILE_CHOOSER (chooser)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((chooser)), ((ctk_file_chooser_get_type ())))))), |
356 | g_get_home_dir ()); |
357 | ctk_widget_show (chooser); |
358 | |
359 | g_signal_connect_swapped (chooser, "current-folder-changed",g_signal_connect_data ((chooser), ("current-folder-changed"), (((GCallback) (baul_query_editor_changed))), (row->editor ), ((void*)0), G_CONNECT_SWAPPED) |
360 | G_CALLBACK (baul_query_editor_changed),g_signal_connect_data ((chooser), ("current-folder-changed"), (((GCallback) (baul_query_editor_changed))), (row->editor ), ((void*)0), G_CONNECT_SWAPPED) |
361 | row->editor)g_signal_connect_data ((chooser), ("current-folder-changed"), (((GCallback) (baul_query_editor_changed))), (row->editor ), ((void*)0), G_CONNECT_SWAPPED); |
362 | |
363 | ctk_box_pack_start (CTK_BOX (row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), chooser, FALSE(0), FALSE(0), 0); |
364 | |
365 | return chooser; |
366 | } |
367 | |
368 | static void |
369 | location_row_add_to_query (BaulQueryEditorRow *row, |
370 | BaulQuery *query) |
371 | { |
372 | char *folder, *uri; |
373 | |
374 | folder = ctk_file_chooser_get_filename (CTK_FILE_CHOOSER (row->type_widget)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_file_chooser_get_type ()))) )))); |
375 | if (folder == NULL((void*)0)) |
376 | { |
377 | /* I don't know why, but i got NULL here on initial search in browser mode |
378 | even with the location set to the homedir in create_widgets... */ |
379 | folder = g_strdup (g_get_home_dir ()); |
380 | } |
381 | |
382 | uri = g_filename_to_uri (folder, NULL((void*)0), NULL((void*)0)); |
383 | g_free (folder); |
384 | |
385 | baul_query_set_location (query, uri); |
386 | g_free (uri); |
387 | } |
388 | |
389 | static void |
390 | location_row_free_data (BaulQueryEditorRow *row) |
391 | { |
392 | } |
393 | |
394 | static void |
395 | location_add_rows_from_query (BaulQueryEditor *editor, |
396 | BaulQuery *query) |
397 | { |
398 | BaulQueryEditorRow *row; |
399 | char *uri, *folder; |
400 | |
401 | uri = baul_query_get_location (query); |
402 | |
403 | if (uri == NULL((void*)0)) |
404 | { |
405 | return; |
406 | } |
407 | folder = g_filename_from_uri (uri, NULL((void*)0), NULL((void*)0)); |
408 | g_free (uri); |
409 | if (folder == NULL((void*)0)) |
410 | { |
411 | return; |
412 | } |
413 | |
414 | row = baul_query_editor_add_row (editor, |
415 | BAUL_QUERY_EDITOR_ROW_LOCATION); |
416 | ctk_file_chooser_set_current_folder (CTK_FILE_CHOOSER (row->type_widget)((((CtkFileChooser*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_file_chooser_get_type ()))) ))), |
417 | folder); |
418 | |
419 | g_free (folder); |
420 | } |
421 | |
422 | /* Tags */ |
423 | static void |
424 | tags_entry_changed_cb (CtkWidget *entry, gpointer *data) |
425 | { |
426 | /* remove commas from string */ |
427 | const gchar *text = ctk_entry_get_text ( CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ()))))))); |
428 | if (g_strrstr (text, ",") == NULL((void*)0)) { |
429 | return; |
430 | } |
431 | |
432 | gchar **words = g_strsplit (text, ",", -1); |
433 | gchar *sanitized = g_strjoinv ("", words); |
434 | g_strfreev (words); |
435 | |
436 | ctk_entry_set_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), sanitized); |
437 | g_free(sanitized); |
438 | } |
439 | |
440 | #define MAX_TAGS_ENTRY_LEN4096 4096 // arbitrary value. |
441 | |
442 | static CtkWidget * |
443 | tags_row_create_widgets (BaulQueryEditorRow *row) |
444 | { |
445 | CtkWidget *entry = ctk_entry_new(); |
446 | ctk_entry_set_max_length (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), MAX_TAGS_ENTRY_LEN4096); |
447 | ctk_widget_set_tooltip_text (entry, |
448 | _("Tags separated by spaces. "gettext ("Tags separated by spaces. " "Matches files that contains ALL specified tags." ) |
449 | "Matches files that contains ALL specified tags.")gettext ("Tags separated by spaces. " "Matches files that contains ALL specified tags." )); |
450 | |
451 | ctk_entry_set_placeholder_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), |
452 | _("Tags separated by spaces. "gettext ("Tags separated by spaces. " "Matches files that contains ALL specified tags." ) |
453 | "Matches files that contains ALL specified tags.")gettext ("Tags separated by spaces. " "Matches files that contains ALL specified tags." )); |
454 | |
455 | ctk_widget_show (entry); |
456 | ctk_box_pack_start (CTK_BOX (row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), entry, TRUE(!(0)), TRUE(!(0)), 0); |
457 | g_signal_connect (entry, "changed", G_CALLBACK (tags_entry_changed_cb), entry)g_signal_connect_data ((entry), ("changed"), (((GCallback) (tags_entry_changed_cb ))), (entry), ((void*)0), (GConnectFlags) 0); |
458 | g_signal_connect (entry, "activate", G_CALLBACK (go_search_cb), row->editor)g_signal_connect_data ((entry), ("activate"), (((GCallback) ( go_search_cb))), (row->editor), ((void*)0), (GConnectFlags ) 0); |
459 | |
460 | return entry; |
461 | } |
462 | |
463 | static void |
464 | tags_row_add_to_query (BaulQueryEditorRow *row, |
465 | BaulQuery *query) |
466 | { |
467 | CtkEntry *entry = CTK_ENTRY (row->type_widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_entry_get_type ())))))); |
468 | const gchar *tags = ctk_entry_get_text (entry); |
469 | |
470 | char **strv = g_strsplit (tags, " ", -1); |
471 | guint len = g_strv_length (strv); |
472 | int i; |
473 | |
474 | for (i = 0; i < len; ++i) { |
475 | strv[i] = g_strstrip (strv[i])g_strchomp (g_strchug (strv[i])); |
476 | if (strlen (strv[i]) > 0) { |
477 | baul_query_add_tag (query, strv[i]); |
478 | } |
479 | } |
480 | g_strfreev (strv); |
481 | } |
482 | |
483 | static void |
484 | tags_row_free_data (BaulQueryEditorRow *row) |
485 | { |
486 | } |
487 | |
488 | gchar * |
489 | xattr_tags_list_to_str (const GList *tags) |
490 | { |
491 | gchar *result = NULL((void*)0); |
492 | |
493 | const GList *tags_iter = NULL((void*)0); |
494 | for (tags_iter = tags; tags_iter; tags_iter = tags_iter->next) { |
495 | gchar *tmp; |
496 | |
497 | if (result != NULL((void*)0)) { |
498 | tmp = g_strconcat (result, ",", tags_iter->data, NULL((void*)0)); |
499 | g_free (result); |
500 | } else { |
501 | tmp = g_strdup (tags_iter->data); |
502 | } |
503 | |
504 | result = tmp; |
505 | } |
506 | |
507 | return result; |
508 | } |
509 | |
510 | static void |
511 | tags_add_rows_from_query (BaulQueryEditor *editor, |
512 | BaulQuery *query) |
513 | { |
514 | GList *tags = baul_query_get_tags (query); |
515 | if (tags == NULL((void*)0)) { |
516 | return; |
517 | } |
518 | |
519 | BaulQueryEditorRow *row; |
520 | row = baul_query_editor_add_row (editor, BAUL_QUERY_EDITOR_ROW_TAGS); |
521 | |
522 | gchar *tags_str = xattr_tags_list_to_str (tags); |
523 | g_list_free_full (tags, g_free); |
524 | |
525 | ctk_entry_set_text (CTK_ENTRY (row->type_widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_entry_get_type ())))))), tags_str); |
526 | g_free (tags_str); |
527 | } |
528 | |
529 | |
530 | /* Type */ |
531 | |
532 | static gboolean |
533 | type_separator_func (CtkTreeModel *model, |
534 | CtkTreeIter *iter, |
535 | gpointer data) |
536 | { |
537 | char *text; |
538 | gboolean res; |
539 | |
540 | ctk_tree_model_get (model, iter, 0, &text, -1); |
541 | |
542 | res = text != NULL((void*)0) && strcmp (text, "---") == 0; |
543 | |
544 | g_free (text); |
545 | return res; |
546 | } |
547 | |
548 | struct |
549 | { |
550 | char *name; |
551 | char *mimetypes[20]; |
552 | } mime_type_groups[] = |
553 | { |
554 | { |
555 | N_("Documents")("Documents"), |
556 | { |
557 | "application/rtf", |
558 | "application/msword", |
559 | "application/vnd.sun.xml.writer", |
560 | "application/vnd.sun.xml.writer.global", |
561 | "application/vnd.sun.xml.writer.template", |
562 | "application/vnd.oasis.opendocument.text", |
563 | "application/vnd.oasis.opendocument.text-template", |
564 | "application/x-abiword", |
565 | "application/x-applix-word", |
566 | "application/x-mswrite", |
567 | "application/docbook+xml", |
568 | "application/x-kword", |
569 | "application/x-kword-crypt", |
570 | "application/x-lyx", |
571 | NULL((void*)0) |
572 | } |
573 | }, |
574 | { |
575 | N_("Music")("Music"), |
576 | { |
577 | "application/ogg", |
578 | "audio/ac3", |
579 | "audio/basic", |
580 | "audio/midi", |
581 | "audio/x-flac", |
582 | "audio/mp4", |
583 | "audio/mpeg", |
584 | "audio/x-mpeg", |
585 | "audio/x-ms-asx", |
586 | "audio/x-pn-realaudio", |
587 | NULL((void*)0) |
588 | } |
589 | }, |
590 | { |
591 | N_("Video")("Video"), |
592 | { |
593 | "video/mp4", |
594 | "video/3gpp", |
595 | "video/mpeg", |
596 | "video/quicktime", |
597 | "video/vivo", |
598 | "video/x-avi", |
599 | "video/x-mng", |
600 | "video/x-ms-asf", |
601 | "video/x-ms-wmv", |
602 | "video/x-msvideo", |
603 | "video/x-nsv", |
604 | "video/x-real-video", |
605 | NULL((void*)0) |
606 | } |
607 | }, |
608 | { |
609 | N_("Picture")("Picture"), |
610 | { |
611 | "application/vnd.oasis.opendocument.image", |
612 | "application/x-krita", |
613 | "image/bmp", |
614 | "image/cgm", |
615 | "image/gif", |
616 | "image/jpeg", |
617 | "image/jpeg2000", |
618 | "image/png", |
619 | "image/svg+xml", |
620 | "image/tiff", |
621 | "image/x-compressed-xcf", |
622 | "image/x-pcx", |
623 | "image/x-photo-cd", |
624 | "image/x-psd", |
625 | "image/x-tga", |
626 | "image/x-xcf", |
627 | NULL((void*)0) |
628 | } |
629 | }, |
630 | { |
631 | N_("Illustration")("Illustration"), |
632 | { |
633 | "application/illustrator", |
634 | "application/vnd.corel-draw", |
635 | "application/vnd.stardivision.draw", |
636 | "application/vnd.oasis.opendocument.graphics", |
637 | "application/x-dia-diagram", |
638 | "application/x-karbon", |
639 | "application/x-killustrator", |
640 | "application/x-kivio", |
641 | "application/x-kontour", |
642 | "application/x-wpg", |
643 | NULL((void*)0) |
644 | } |
645 | }, |
646 | { |
647 | N_("Spreadsheet")("Spreadsheet"), |
648 | { |
649 | "application/vnd.lotus-1-2-3", |
650 | "application/vnd.ms-excel", |
651 | "application/vnd.stardivision.calc", |
652 | "application/vnd.sun.xml.calc", |
653 | "application/vnd.oasis.opendocument.spreadsheet", |
654 | "application/x-applix-spreadsheet", |
655 | "application/x-gnumeric", |
656 | "application/x-kspread", |
657 | "application/x-kspread-crypt", |
658 | "application/x-quattropro", |
659 | "application/x-sc", |
660 | "application/x-siag", |
661 | NULL((void*)0) |
662 | } |
663 | }, |
664 | { |
665 | N_("Presentation")("Presentation"), |
666 | { |
667 | "application/vnd.ms-powerpoint", |
668 | "application/vnd.sun.xml.impress", |
669 | "application/vnd.oasis.opendocument.presentation", |
670 | "application/x-magicpoint", |
671 | "application/x-kpresenter", |
672 | NULL((void*)0) |
673 | } |
674 | }, |
675 | { |
676 | N_("Pdf / Postscript")("Pdf / Postscript"), |
677 | { |
678 | "application/pdf", |
679 | "application/postscript", |
680 | "application/x-dvi", |
681 | "image/x-eps", |
682 | NULL((void*)0) |
683 | } |
684 | }, |
685 | { |
686 | N_("Text File")("Text File"), |
687 | { |
688 | "text/plain", |
689 | NULL((void*)0) |
690 | } |
691 | } |
692 | }; |
693 | |
694 | static void |
695 | type_add_custom_type (BaulQueryEditorRow *row, |
696 | const char *mime_type, |
697 | const char *description, |
698 | CtkTreeIter *iter) |
699 | { |
700 | CtkTreeModel *model; |
701 | CtkListStore *store; |
702 | |
703 | model = ctk_combo_box_get_model (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ()))))))); |
704 | store = CTK_LIST_STORE (model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((model)), ((ctk_list_store_get_type ())))))); |
705 | |
706 | ctk_list_store_append (store, iter); |
707 | ctk_list_store_set (store, iter, |
708 | 0, description, |
709 | 2, mime_type, |
710 | -1); |
711 | } |
712 | |
713 | |
714 | static void |
715 | type_combo_changed (CtkComboBox *combo_box, BaulQueryEditorRow *row) |
716 | { |
717 | CtkTreeIter iter; |
718 | gboolean other; |
719 | CtkTreeModel *model; |
720 | |
721 | if (!ctk_combo_box_get_active_iter (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), |
722 | &iter)) |
723 | { |
724 | return; |
725 | } |
726 | |
727 | model = ctk_combo_box_get_model (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ()))))))); |
728 | ctk_tree_model_get (model, &iter, 3, &other, -1); |
729 | |
730 | if (other) |
731 | { |
732 | GList *mime_infos, *l; |
733 | CtkWidget *dialog; |
734 | CtkWidget *scrolled, *treeview; |
735 | CtkListStore *store; |
736 | CtkTreeViewColumn *column; |
737 | CtkCellRenderer *renderer; |
738 | CtkWidget *toplevel; |
739 | CtkTreeSelection *selection; |
740 | |
741 | mime_infos = g_content_types_get_registered (); |
742 | |
743 | store = ctk_list_store_new (2, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_STRING((GType) ((16) << (2)))); |
744 | for (l = mime_infos; l != NULL((void*)0); l = l->next) |
745 | { |
746 | CtkTreeIter iter; |
747 | char *mime_type = l->data; |
748 | char *description; |
749 | |
750 | description = g_content_type_get_description (mime_type); |
751 | if (description == NULL((void*)0)) |
752 | { |
753 | description = g_strdup (mime_type); |
754 | } |
755 | |
756 | ctk_list_store_append (store, &iter); |
757 | ctk_list_store_set (store, &iter, |
758 | 0, description, |
759 | 1, mime_type, |
760 | -1); |
761 | |
762 | g_free (mime_type); |
763 | g_free (description); |
764 | } |
765 | g_list_free (mime_infos); |
766 | |
767 | |
768 | |
769 | toplevel = ctk_widget_get_toplevel (CTK_WIDGET (combo_box)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo_box)), ((ctk_widget_get_type ()))))))); |
770 | |
771 | dialog = ctk_dialog_new (); |
772 | ctk_window_set_title (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), _("Select type")gettext ("Select type")); |
773 | ctk_window_set_transient_for (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), CTK_WINDOW (toplevel)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((toplevel)), ((ctk_window_get_type ()))))))); |
774 | |
775 | eel_dialog_add_button (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ())))))), |
776 | _("_OK")gettext ("_OK"), |
777 | "ctk-ok", |
778 | CTK_RESPONSE_OK); |
779 | |
780 | ctk_window_set_default_size (CTK_WINDOW (dialog)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_window_get_type ())))))), 400, 600); |
781 | |
782 | scrolled = ctk_scrolled_window_new (NULL((void*)0), NULL((void*)0)); |
783 | ctk_scrolled_window_set_policy (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), |
784 | CTK_POLICY_AUTOMATIC, |
785 | CTK_POLICY_AUTOMATIC); |
786 | ctk_scrolled_window_set_shadow_type (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), |
787 | CTK_SHADOW_IN); |
788 | ctk_scrolled_window_set_overlay_scrolling (CTK_SCROLLED_WINDOW (scrolled)((((CtkScrolledWindow*) (void *) g_type_check_instance_cast ( (GTypeInstance*) ((scrolled)), ((ctk_scrolled_window_get_type ())))))), |
789 | FALSE(0)); |
790 | |
791 | ctk_widget_show (scrolled); |
792 | ctk_box_pack_start (CTK_BOX (ctk_dialog_get_content_area (CTK_DIALOG (dialog)))((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((ctk_dialog_get_content_area (((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((dialog)), ((ctk_dialog_get_type ())))))) ))), ((ctk_box_get_type ())))))), scrolled, TRUE(!(0)), TRUE(!(0)), 6); |
793 | |
794 | treeview = ctk_tree_view_new (); |
795 | ctk_tree_view_set_model (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), |
796 | CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ()))))))); |
797 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (store)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_sortable_get_type ())))))), 0, |
798 | CTK_SORT_ASCENDING); |
799 | |
800 | selection = ctk_tree_view_get_selection (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ()))))))); |
801 | ctk_tree_selection_set_mode (selection, CTK_SELECTION_BROWSE); |
802 | |
803 | |
804 | renderer = ctk_cell_renderer_text_new (); |
805 | column = ctk_tree_view_column_new_with_attributes ("Name", |
806 | renderer, |
807 | "text", |
808 | 0, |
809 | NULL((void*)0)); |
810 | ctk_tree_view_append_column (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), column); |
811 | ctk_tree_view_set_headers_visible (CTK_TREE_VIEW (treeview)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((treeview)), ((ctk_tree_view_get_type ())))))), FALSE(0)); |
812 | |
813 | ctk_widget_show (treeview); |
814 | ctk_container_add (CTK_CONTAINER (scrolled)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((scrolled)), ((ctk_container_get_type ())))))), treeview); |
815 | |
816 | if (ctk_dialog_run (CTK_DIALOG (dialog)((((CtkDialog*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((dialog)), ((ctk_dialog_get_type ()))))))) == CTK_RESPONSE_OK) |
817 | { |
818 | char *mimetype, *description; |
819 | |
820 | ctk_tree_selection_get_selected (selection, NULL((void*)0), &iter); |
821 | ctk_tree_model_get (CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))), &iter, |
822 | 0, &description, |
823 | 1, &mimetype, |
824 | -1); |
825 | |
826 | type_add_custom_type (row, mimetype, description, &iter); |
827 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), |
828 | &iter); |
829 | } |
830 | else |
831 | { |
832 | ctk_combo_box_set_active (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), 0); |
833 | } |
834 | |
835 | ctk_widget_destroy (dialog); |
836 | } |
837 | |
838 | baul_query_editor_changed (row->editor); |
839 | } |
840 | |
841 | static CtkWidget * |
842 | type_row_create_widgets (BaulQueryEditorRow *row) |
843 | { |
844 | CtkWidget *combo; |
845 | CtkCellRenderer *cell; |
846 | CtkListStore *store; |
847 | CtkTreeIter iter; |
848 | int i; |
849 | |
850 | store = ctk_list_store_new (4, G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_POINTER((GType) ((17) << (2))), G_TYPE_STRING((GType) ((16) << (2))), G_TYPE_BOOLEAN((GType) ((5) << (2)))); |
851 | combo = ctk_combo_box_new_with_model (CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ()))))))); |
852 | g_object_unref (store); |
853 | |
854 | cell = ctk_cell_renderer_text_new (); |
855 | ctk_cell_layout_pack_start (CTK_CELL_LAYOUT (combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, TRUE(!(0))); |
856 | ctk_cell_layout_set_attributes (CTK_CELL_LAYOUT (combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, |
857 | "text", 0, |
858 | NULL((void*)0)); |
859 | ctk_combo_box_set_row_separator_func (CTK_COMBO_BOX (combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), |
860 | type_separator_func, |
861 | NULL((void*)0), NULL((void*)0)); |
862 | |
863 | ctk_list_store_append (store, &iter); |
864 | ctk_list_store_set (store, &iter, 0, _("Any")gettext ("Any"), -1); |
865 | ctk_list_store_append (store, &iter); |
866 | ctk_list_store_set (store, &iter, 0, "---", -1); |
867 | |
868 | for (i = 0; i < G_N_ELEMENTS (mime_type_groups)(sizeof (mime_type_groups) / sizeof ((mime_type_groups)[0])); i++) |
869 | { |
870 | ctk_list_store_append (store, &iter); |
871 | ctk_list_store_set (store, &iter, |
872 | 0, gettext (mime_type_groups[i].name), |
873 | 1, mime_type_groups[i].mimetypes, |
874 | -1); |
875 | } |
876 | |
877 | ctk_list_store_append (store, &iter); |
878 | ctk_list_store_set (store, &iter, 0, "---", -1); |
879 | ctk_list_store_append (store, &iter); |
880 | ctk_list_store_set (store, &iter, 0, _("Other Type...")gettext ("Other Type..."), 3, TRUE(!(0)), -1); |
881 | |
882 | ctk_combo_box_set_active (CTK_COMBO_BOX (combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), 0); |
883 | |
884 | g_signal_connect (combo, "changed",g_signal_connect_data ((combo), ("changed"), (((GCallback) (type_combo_changed ))), (row), ((void*)0), (GConnectFlags) 0) |
885 | G_CALLBACK (type_combo_changed),g_signal_connect_data ((combo), ("changed"), (((GCallback) (type_combo_changed ))), (row), ((void*)0), (GConnectFlags) 0) |
886 | row)g_signal_connect_data ((combo), ("changed"), (((GCallback) (type_combo_changed ))), (row), ((void*)0), (GConnectFlags) 0); |
887 | |
888 | ctk_widget_show (combo); |
889 | |
890 | ctk_box_pack_start (CTK_BOX (row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), combo, FALSE(0), FALSE(0), 0); |
891 | |
892 | return combo; |
893 | } |
894 | |
895 | static void |
896 | type_row_add_to_query (BaulQueryEditorRow *row, |
897 | BaulQuery *query) |
898 | { |
899 | CtkTreeIter iter; |
900 | char **mimetypes; |
901 | char *mimetype; |
902 | CtkTreeModel *model; |
903 | |
904 | if (!ctk_combo_box_get_active_iter (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), |
905 | &iter)) |
906 | { |
907 | return; |
908 | } |
909 | |
910 | model = ctk_combo_box_get_model (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ()))))))); |
911 | ctk_tree_model_get (model, &iter, 1, &mimetypes, 2, &mimetype, -1); |
912 | |
913 | if (mimetypes != NULL((void*)0)) |
914 | { |
915 | while (*mimetypes != NULL((void*)0)) |
916 | { |
917 | baul_query_add_mime_type (query, *mimetypes); |
918 | mimetypes++; |
919 | } |
920 | } |
921 | if (mimetype) |
922 | { |
923 | baul_query_add_mime_type (query, mimetype); |
924 | g_free (mimetype); |
925 | } |
926 | } |
927 | |
928 | static void |
929 | type_row_free_data (BaulQueryEditorRow *row) |
930 | { |
931 | } |
932 | |
933 | static gboolean |
934 | all_group_types_in_list (char **group_types, GList *mime_types) |
935 | { |
936 | GList *l; |
937 | char **group_type; |
938 | char *mime_type; |
939 | gboolean found; |
940 | |
941 | group_type = group_types; |
942 | while (*group_type != NULL((void*)0)) |
943 | { |
944 | found = FALSE(0); |
945 | |
946 | for (l = mime_types; l != NULL((void*)0); l = l->next) |
947 | { |
948 | mime_type = l->data; |
949 | |
950 | if (strcmp (mime_type, *group_type) == 0) |
951 | { |
952 | found = TRUE(!(0)); |
953 | break; |
954 | } |
955 | } |
956 | |
957 | if (!found) |
958 | { |
959 | return FALSE(0); |
960 | } |
961 | group_type++; |
962 | } |
963 | return TRUE(!(0)); |
964 | } |
965 | |
966 | static GList * |
967 | remove_group_types_from_list (char **group_types, GList *mime_types) |
968 | { |
969 | GList *l, *next; |
970 | char **group_type; |
971 | char *mime_type; |
972 | |
973 | group_type = group_types; |
974 | while (*group_type != NULL((void*)0)) |
975 | { |
976 | for (l = mime_types; l != NULL((void*)0); l = next) |
977 | { |
978 | mime_type = l->data; |
979 | next = l->next; |
980 | |
981 | if (strcmp (mime_type, *group_type) == 0) |
982 | { |
983 | mime_types = g_list_remove_link (mime_types, l); |
984 | g_free (mime_type); |
985 | break; |
986 | } |
987 | } |
988 | |
989 | group_type++; |
990 | } |
991 | return mime_types; |
992 | } |
993 | |
994 | |
995 | static void |
996 | type_add_rows_from_query (BaulQueryEditor *editor, |
997 | BaulQuery *query) |
998 | { |
999 | GList *mime_types; |
1000 | char *mime_type; |
1001 | BaulQueryEditorRow *row; |
1002 | CtkTreeIter iter; |
1003 | int i; |
1004 | CtkTreeModel *model; |
1005 | GList *l; |
1006 | |
1007 | mime_types = baul_query_get_mime_types (query); |
1008 | |
1009 | if (mime_types == NULL((void*)0)) |
1010 | { |
1011 | return; |
1012 | } |
1013 | |
1014 | for (i = 0; i < G_N_ELEMENTS (mime_type_groups)(sizeof (mime_type_groups) / sizeof ((mime_type_groups)[0])); i++) |
1015 | { |
1016 | if (all_group_types_in_list (mime_type_groups[i].mimetypes, |
1017 | mime_types)) |
1018 | { |
1019 | mime_types = remove_group_types_from_list (mime_type_groups[i].mimetypes, |
1020 | mime_types); |
1021 | |
1022 | row = baul_query_editor_add_row (editor, |
1023 | BAUL_QUERY_EDITOR_ROW_TYPE); |
1024 | |
1025 | model = ctk_combo_box_get_model (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ()))))))); |
1026 | |
1027 | ctk_tree_model_iter_nth_child (model, &iter, NULL((void*)0), i + 2); |
1028 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), |
1029 | &iter); |
1030 | } |
1031 | } |
1032 | |
1033 | for (l = mime_types; l != NULL((void*)0); l = l->next) |
1034 | { |
1035 | const char *desc; |
1036 | |
1037 | mime_type = l->data; |
1038 | |
1039 | desc = g_content_type_get_description (mime_type); |
1040 | if (desc == NULL((void*)0)) |
1041 | { |
1042 | desc = mime_type; |
1043 | } |
1044 | |
1045 | row = baul_query_editor_add_row (editor, |
1046 | BAUL_QUERY_EDITOR_ROW_TYPE); |
1047 | model = ctk_combo_box_get_model (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ()))))))); |
1048 | |
1049 | type_add_custom_type (row, mime_type, desc, &iter); |
1050 | ctk_combo_box_set_active_iter (CTK_COMBO_BOX (row->type_widget)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_combo_box_get_type ())))))), |
1051 | &iter); |
1052 | } |
1053 | |
1054 | g_list_free_full (mime_types, g_free); |
1055 | } |
1056 | |
1057 | /* End of row types */ |
1058 | |
1059 | |
1060 | static CtkWidget *modtime_row_create_widgets(BaulQueryEditorRow *row) |
1061 | { |
1062 | CtkWidget *hbox = NULL((void*)0); |
1063 | CtkWidget *combo = NULL((void*)0); |
1064 | CtkWidget *duration_combo = NULL((void*)0); |
1065 | CtkCellRenderer *cell = NULL((void*)0); |
1066 | CtkListStore *store = NULL((void*)0); |
1067 | CtkListStore *duration_store = NULL((void*)0); |
1068 | CtkTreeIter iter; |
1069 | |
1070 | hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 7); |
1071 | |
1072 | store = ctk_list_store_new(2, G_TYPE_BOOLEAN((GType) ((5) << (2))), G_TYPE_STRING((GType) ((16) << (2)))); |
1073 | combo = ctk_combo_box_new_with_model(CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ()))))))); |
1074 | g_object_unref(store); |
1075 | |
1076 | cell = ctk_cell_renderer_text_new(); |
1077 | ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, TRUE(!(0))); |
1078 | ctk_cell_layout_set_attributes(CTK_CELL_LAYOUT(combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, "text", 1, |
1079 | NULL((void*)0)); |
1080 | |
1081 | ctk_list_store_append(store, &iter); |
1082 | ctk_list_store_set(store, &iter, 0, FALSE(0), 1, _("Less than or equal to")gettext ("Less than or equal to"), -1); |
1083 | ctk_list_store_append(store, &iter); |
1084 | ctk_list_store_set(store, &iter, 0, TRUE(!(0)), 1, _("Greater than or equal to")gettext ("Greater than or equal to"), -1); |
1085 | |
1086 | ctk_combo_box_set_active(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), 0); |
1087 | |
1088 | duration_store = ctk_list_store_new(2, G_TYPE_INT((GType) ((6) << (2))), G_TYPE_STRING((GType) ((16) << (2)))); |
1089 | duration_combo = ctk_combo_box_new_with_model(CTK_TREE_MODEL(duration_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_store)), ((ctk_tree_model_get_type ()))))))); |
1090 | g_object_unref(duration_store); |
1091 | |
1092 | ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(duration_combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_combo)), ((ctk_cell_layout_get_type ())))))), cell, TRUE(!(0))); |
1093 | ctk_cell_layout_set_attributes(CTK_CELL_LAYOUT(duration_combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_combo)), ((ctk_cell_layout_get_type ())))))), cell, |
1094 | "text", 1, NULL((void*)0)); |
1095 | |
1096 | ctk_list_store_append(duration_store, &iter); |
1097 | ctk_list_store_set(duration_store, &iter, 0, DURATION_ONE_HOUR, 1, _("1 Hour")gettext ("1 Hour"), -1); |
1098 | ctk_list_store_append(duration_store, &iter); |
1099 | ctk_list_store_set(duration_store, &iter, 0, DURATION_ONE_DAY, 1, _("1 Day")gettext ("1 Day"), -1); |
1100 | ctk_list_store_append(duration_store, &iter); |
1101 | ctk_list_store_set(duration_store, &iter, 0, DURATION_ONE_WEEK, 1, _("1 Week")gettext ("1 Week"), -1); |
1102 | ctk_list_store_append(duration_store, &iter); |
1103 | ctk_list_store_set(duration_store, &iter, 0, DURATION_ONE_MONTH, 1, _("1 Month")gettext ("1 Month"), -1); |
1104 | ctk_list_store_append(duration_store, &iter); |
1105 | ctk_list_store_set(duration_store, &iter, 0, DURATION_SIX_MONTHS, 1, _("6 Months")gettext ("6 Months"), -1); |
1106 | ctk_list_store_append(duration_store, &iter); |
1107 | ctk_list_store_set(duration_store, &iter, 0, DURATION_ONE_YEAR, 1, _("1 Year")gettext ("1 Year"), -1); |
1108 | |
1109 | ctk_combo_box_set_active(CTK_COMBO_BOX(duration_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_combo)), ((ctk_combo_box_get_type ())))))), 0); |
1110 | |
1111 | ctk_box_pack_start(CTK_BOX(hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), combo, FALSE(0), FALSE(0), 0); |
1112 | ctk_box_pack_start(CTK_BOX(hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), duration_combo, FALSE(0), FALSE(0), 0); |
1113 | ctk_widget_show_all(hbox); |
1114 | |
1115 | ctk_box_pack_start(CTK_BOX(row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), hbox, FALSE(0), FALSE(0), 0); |
1116 | |
1117 | return hbox; |
1118 | } |
1119 | |
1120 | static void modtime_row_add_to_query(BaulQueryEditorRow *row, BaulQuery *query) |
1121 | { |
1122 | GList *children = NULL((void*)0); |
1123 | CtkWidget *combo = NULL((void*)0); |
1124 | CtkWidget *duration_combo = NULL((void*)0); |
1125 | CtkTreeModel *model = NULL((void*)0); |
1126 | CtkTreeModel *duration_model = NULL((void*)0); |
1127 | CtkTreeIter iter; |
1128 | CtkTreeIter duration_iter; |
1129 | gboolean is_greater = FALSE(0); |
1130 | GDateTime *now, *datetime; |
1131 | gint duration; |
1132 | gint64 timestamp; |
1133 | |
1134 | if (!CTK_IS_CONTAINER(row->type_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (row->type_widget)); GType __t = ((ctk_container_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; }))))) |
1135 | return; |
1136 | |
1137 | children = ctk_container_get_children(CTK_CONTAINER(row->type_widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_container_get_type ()))))))); |
1138 | if (g_list_length(children) != 2) |
1139 | return; |
1140 | |
1141 | combo = CTK_WIDGET(g_list_nth(children, 0)->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_list_nth(children, 0)->data)), ((ctk_widget_get_type ())))))); |
1142 | duration_combo = CTK_WIDGET(g_list_nth(children, 1)->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_list_nth(children, 1)->data)), ((ctk_widget_get_type ())))))); |
1143 | if (!combo || !duration_combo) |
1144 | return; |
1145 | |
1146 | if (!ctk_combo_box_get_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), &iter) || |
1147 | !ctk_combo_box_get_active_iter(CTK_COMBO_BOX(duration_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_combo)), ((ctk_combo_box_get_type ())))))), &duration_iter)) { |
1148 | return; |
1149 | } |
1150 | |
1151 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
1152 | ctk_tree_model_get(model, &iter, 0, &is_greater, -1); |
1153 | |
1154 | duration_model = ctk_combo_box_get_model(CTK_COMBO_BOX(duration_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((duration_combo)), ((ctk_combo_box_get_type ()))))))); |
1155 | ctk_tree_model_get(duration_model, &duration_iter, 0, &duration, -1); |
1156 | |
1157 | now = g_date_time_new_now_local (); |
1158 | datetime = now; |
Value stored to 'datetime' is never read | |
1159 | switch (duration) |
1160 | { |
1161 | case DURATION_ONE_HOUR: |
1162 | datetime = g_date_time_add_hours (now, -1); |
1163 | break; |
1164 | case DURATION_ONE_DAY: |
1165 | datetime = g_date_time_add_days (now, -1); |
1166 | break; |
1167 | case DURATION_ONE_WEEK: |
1168 | datetime = g_date_time_add_weeks (now, -1); |
1169 | break; |
1170 | case DURATION_ONE_MONTH: |
1171 | datetime = g_date_time_add_months (now, -1); |
1172 | break; |
1173 | case DURATION_SIX_MONTHS: |
1174 | datetime = g_date_time_add_months (now, -6); |
1175 | break; |
1176 | case DURATION_ONE_YEAR: |
1177 | datetime = g_date_time_add_years (now, -1); |
1178 | break; |
1179 | default: |
1180 | g_assert_not_reached ()do { g_assertion_message_expr (((gchar*) 0), "baul-query-editor.c" , 1180, ((const char*) (__func__)), ((void*)0)); } while (0); |
1181 | } |
1182 | |
1183 | g_date_time_unref (now); |
1184 | timestamp = g_date_time_to_unix (datetime); |
1185 | g_date_time_unref (datetime); |
1186 | |
1187 | baul_query_set_timestamp(query, is_greater ? timestamp: -timestamp); |
1188 | } |
1189 | |
1190 | static void modtime_row_free_data(BaulQueryEditorRow *row) |
1191 | { |
1192 | } |
1193 | |
1194 | static void modtime_add_rows_from_query(BaulQueryEditor *editor, BaulQuery *query) |
1195 | { |
1196 | } |
1197 | |
1198 | |
1199 | static CtkWidget *size_row_create_widgets(BaulQueryEditorRow *row) |
1200 | { |
1201 | CtkWidget *hbox = NULL((void*)0); |
1202 | CtkWidget *combo = NULL((void*)0); |
1203 | CtkWidget *size_combo = NULL((void*)0); |
1204 | CtkCellRenderer *cell = NULL((void*)0); |
1205 | CtkListStore *store = NULL((void*)0); |
1206 | CtkListStore *size_store = NULL((void*)0); |
1207 | CtkTreeIter iter; |
1208 | |
1209 | hbox = ctk_box_new(CTK_ORIENTATION_HORIZONTAL, 7); |
1210 | |
1211 | store = ctk_list_store_new(2, G_TYPE_BOOLEAN((GType) ((5) << (2))), G_TYPE_STRING((GType) ((16) << (2)))); |
1212 | combo = ctk_combo_box_new_with_model(CTK_TREE_MODEL(store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ()))))))); |
1213 | g_object_unref(store); |
1214 | |
1215 | cell = ctk_cell_renderer_text_new(); |
1216 | ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, TRUE(!(0))); |
1217 | ctk_cell_layout_set_attributes(CTK_CELL_LAYOUT(combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_cell_layout_get_type ())))))), cell, "text", 1, |
1218 | NULL((void*)0)); |
1219 | |
1220 | ctk_list_store_append(store, &iter); |
1221 | ctk_list_store_set(store, &iter, 0, FALSE(0), 1, _("Less than or equal to")gettext ("Less than or equal to"), -1); |
1222 | ctk_list_store_append(store, &iter); |
1223 | ctk_list_store_set(store, &iter, 0, TRUE(!(0)), 1, _("Greater than or equal to")gettext ("Greater than or equal to"), -1); |
1224 | |
1225 | ctk_combo_box_set_active(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), 0); |
1226 | |
1227 | size_store = ctk_list_store_new(2, G_TYPE_INT64((GType) ((10) << (2))), G_TYPE_STRING((GType) ((16) << (2)))); |
1228 | size_combo = ctk_combo_box_new_with_model(CTK_TREE_MODEL(size_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_store)), ((ctk_tree_model_get_type ()))))))); |
1229 | g_object_unref(size_store); |
1230 | |
1231 | ctk_cell_layout_pack_start(CTK_CELL_LAYOUT(size_combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_combo)), ((ctk_cell_layout_get_type ())))))), cell, TRUE(!(0))); |
1232 | ctk_cell_layout_set_attributes(CTK_CELL_LAYOUT(size_combo)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_combo)), ((ctk_cell_layout_get_type ())))))), cell, "text", |
1233 | 1, NULL((void*)0)); |
1234 | |
1235 | if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_USE_IEC_UNITS"use-iec-units")) |
1236 | { |
1237 | ctk_list_store_append(size_store, &iter); |
1238 | ctk_list_store_set(size_store, &iter, 0, 10240, 1, _("10 KiB")gettext ("10 KiB"), -1); |
1239 | ctk_list_store_append(size_store, &iter); |
1240 | ctk_list_store_set(size_store, &iter, 0, 102400, 1, _("100 KiB")gettext ("100 KiB"), -1); |
1241 | ctk_list_store_append(size_store, &iter); |
1242 | ctk_list_store_set(size_store, &iter, 0, 512000, 1, _("500 KiB")gettext ("500 KiB"), -1); |
1243 | ctk_list_store_append(size_store, &iter); |
1244 | ctk_list_store_set(size_store, &iter, 0, 1048576, 1, _("1 MiB")gettext ("1 MiB"), -1); |
1245 | ctk_list_store_append(size_store, &iter); |
1246 | ctk_list_store_set(size_store, &iter, 0, 5242880, 1, _("5 MiB")gettext ("5 MiB"), -1); |
1247 | ctk_list_store_append(size_store, &iter); |
1248 | ctk_list_store_set(size_store, &iter, 0, 10485760, 1, _("10 MiB")gettext ("10 MiB"), -1); |
1249 | ctk_list_store_append(size_store, &iter); |
1250 | ctk_list_store_set(size_store, &iter, 0, 104857600, 1, _("100 MiB")gettext ("100 MiB"), -1); |
1251 | ctk_list_store_append(size_store, &iter); |
1252 | ctk_list_store_set(size_store, &iter, 0, 524288000, 1, _("500 MiB")gettext ("500 MiB"), -1); |
1253 | ctk_list_store_append(size_store, &iter); |
1254 | ctk_list_store_set(size_store, &iter, 0, 1073741824, 1, _("1 GiB")gettext ("1 GiB"), -1); |
1255 | ctk_list_store_append(size_store, &iter); |
1256 | ctk_list_store_set(size_store, &iter, 0, 2147483648, 1, _("2 GiB")gettext ("2 GiB"), -1); |
1257 | ctk_list_store_append(size_store, &iter); |
1258 | ctk_list_store_set(size_store, &iter, 0, 4294967296, 1, _("4 GiB")gettext ("4 GiB"), -1); |
1259 | } else { |
1260 | ctk_list_store_append(size_store, &iter); |
1261 | ctk_list_store_set(size_store, &iter, 0, 10000, 1, _("10 KB")gettext ("10 KB"), -1); |
1262 | ctk_list_store_append(size_store, &iter); |
1263 | ctk_list_store_set(size_store, &iter, 0, 100000, 1, _("100 KB")gettext ("100 KB"), -1); |
1264 | ctk_list_store_append(size_store, &iter); |
1265 | ctk_list_store_set(size_store, &iter, 0, 500000, 1, _("500 KB")gettext ("500 KB"), -1); |
1266 | ctk_list_store_append(size_store, &iter); |
1267 | ctk_list_store_set(size_store, &iter, 0, 1000000, 1, _("1 MB")gettext ("1 MB"), -1); |
1268 | ctk_list_store_append(size_store, &iter); |
1269 | ctk_list_store_set(size_store, &iter, 0, 5000000, 1, _("5 MB")gettext ("5 MB"), -1); |
1270 | ctk_list_store_append(size_store, &iter); |
1271 | ctk_list_store_set(size_store, &iter, 0, 10000000, 1, _("10 MB")gettext ("10 MB"), -1); |
1272 | ctk_list_store_append(size_store, &iter); |
1273 | ctk_list_store_set(size_store, &iter, 0, 100000000, 1, _("100 MB")gettext ("100 MB"), -1); |
1274 | ctk_list_store_append(size_store, &iter); |
1275 | ctk_list_store_set(size_store, &iter, 0, 500000000, 1, _("500 MB")gettext ("500 MB"), -1); |
1276 | ctk_list_store_append(size_store, &iter); |
1277 | ctk_list_store_set(size_store, &iter, 0, 1000000000, 1, _("1 GB")gettext ("1 GB"), -1); |
1278 | ctk_list_store_append(size_store, &iter); |
1279 | ctk_list_store_set(size_store, &iter, 0, 2000000000, 1, _("2 GB")gettext ("2 GB"), -1); |
1280 | ctk_list_store_append(size_store, &iter); |
1281 | ctk_list_store_set(size_store, &iter, 0, 4000000000, 1, _("4 GB")gettext ("4 GB"), -1); |
1282 | } |
1283 | |
1284 | ctk_combo_box_set_active(CTK_COMBO_BOX(size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_combo)), ((ctk_combo_box_get_type ())))))), 0); |
1285 | |
1286 | ctk_box_pack_start(CTK_BOX(hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), combo, FALSE(0), FALSE(0), 0); |
1287 | ctk_box_pack_start(CTK_BOX(hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), size_combo, FALSE(0), FALSE(0), 0); |
1288 | ctk_widget_show_all(hbox); |
1289 | |
1290 | ctk_box_pack_start(CTK_BOX(row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), hbox, FALSE(0), FALSE(0), 0); |
1291 | |
1292 | return hbox; |
1293 | } |
1294 | |
1295 | static void size_row_add_to_query(BaulQueryEditorRow *row, BaulQuery *query) |
1296 | { |
1297 | GList *children = NULL((void*)0); |
1298 | CtkWidget *combo = NULL((void*)0); |
1299 | CtkWidget *size_combo = NULL((void*)0); |
1300 | CtkTreeModel *model = NULL((void*)0); |
1301 | CtkTreeModel *size_model = NULL((void*)0); |
1302 | CtkTreeIter iter; |
1303 | CtkTreeIter size_iter; |
1304 | gboolean is_greater = FALSE(0); |
1305 | gint64 size; |
1306 | |
1307 | if (!CTK_IS_CONTAINER(row->type_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (row->type_widget)); GType __t = ((ctk_container_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; }))))) |
1308 | return; |
1309 | |
1310 | children = ctk_container_get_children(CTK_CONTAINER(row->type_widget)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_container_get_type ()))))))); |
1311 | if (g_list_length(children) != 2) |
1312 | return; |
1313 | |
1314 | combo = CTK_WIDGET(g_list_nth(children, 0)->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_list_nth(children, 0)->data)), ((ctk_widget_get_type ())))))); |
1315 | size_combo = CTK_WIDGET(g_list_nth(children, 1)->data)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_list_nth(children, 1)->data)), ((ctk_widget_get_type ())))))); |
1316 | if (!combo || !size_combo) |
1317 | return; |
1318 | |
1319 | if (!ctk_combo_box_get_active_iter(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), &iter) || |
1320 | !ctk_combo_box_get_active_iter(CTK_COMBO_BOX(size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_combo)), ((ctk_combo_box_get_type ())))))), &size_iter)) { |
1321 | return; |
1322 | } |
1323 | |
1324 | model = ctk_combo_box_get_model(CTK_COMBO_BOX(combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ()))))))); |
1325 | ctk_tree_model_get(model, &iter, 0, &is_greater, -1); |
1326 | |
1327 | size_model = ctk_combo_box_get_model(CTK_COMBO_BOX(size_combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((size_combo)), ((ctk_combo_box_get_type ()))))))); |
1328 | ctk_tree_model_get(size_model, &size_iter, 0, &size, -1); |
1329 | |
1330 | baul_query_set_size(query, is_greater ? size : -size); |
1331 | } |
1332 | |
1333 | static void size_row_free_data(BaulQueryEditorRow *row) |
1334 | { |
1335 | } |
1336 | |
1337 | static void size_add_rows_from_query(BaulQueryEditor *editor, BaulQuery *query) |
1338 | { |
1339 | } |
1340 | |
1341 | static CtkWidget * |
1342 | contained_text_row_create_widgets (BaulQueryEditorRow *row) |
1343 | { |
1344 | CtkWidget *entry = ctk_entry_new(); |
1345 | ctk_widget_set_tooltip_text (entry, |
1346 | _("Matches files that contains specified text.")gettext ("Matches files that contains specified text.")); |
1347 | |
1348 | ctk_entry_set_placeholder_text (CTK_ENTRY (entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((entry)), ((ctk_entry_get_type ())))))), |
1349 | _("Matches files that contains specified text.")gettext ("Matches files that contains specified text.")); |
1350 | |
1351 | ctk_widget_show (entry); |
1352 | ctk_box_pack_start (CTK_BOX (row->hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->hbox)), ((ctk_box_get_type ())))))), entry, TRUE(!(0)), TRUE(!(0)), 0); |
1353 | g_signal_connect (entry, "activate", G_CALLBACK (go_search_cb), row->editor)g_signal_connect_data ((entry), ("activate"), (((GCallback) ( go_search_cb))), (row->editor), ((void*)0), (GConnectFlags ) 0); |
1354 | |
1355 | return entry; |
1356 | } |
1357 | |
1358 | static void |
1359 | contained_text_row_add_to_query (BaulQueryEditorRow *row, BaulQuery *query) |
1360 | { |
1361 | CtkEntry *entry = CTK_ENTRY (row->type_widget)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((row->type_widget)), ((ctk_entry_get_type ())))))); |
1362 | const gchar *text = ctk_entry_get_text (entry); |
1363 | |
1364 | baul_query_set_contained_text (query, text); |
1365 | } |
1366 | |
1367 | static void |
1368 | contained_text_row_free_data (BaulQueryEditorRow *row) |
1369 | { |
1370 | } |
1371 | |
1372 | static void |
1373 | contained_text_add_rows_from_query (BaulQueryEditor *editor, BaulQuery *query) |
1374 | { |
1375 | } |
1376 | |
1377 | static BaulQueryEditorRowType |
1378 | get_next_free_type (BaulQueryEditor *editor) |
1379 | { |
1380 | BaulQueryEditorRow *row; |
1381 | BaulQueryEditorRowType type; |
1382 | gboolean found; |
1383 | GList *l; |
1384 | |
1385 | |
1386 | for (type = 0; type < BAUL_QUERY_EDITOR_ROW_LAST; type++) |
1387 | { |
1388 | found = FALSE(0); |
1389 | for (l = editor->details->rows; l != NULL((void*)0); l = l->next) |
1390 | { |
1391 | row = l->data; |
1392 | if (row->type == type) |
1393 | { |
1394 | found = TRUE(!(0)); |
1395 | break; |
1396 | } |
1397 | } |
1398 | if (!found) |
1399 | { |
1400 | return type; |
1401 | } |
1402 | } |
1403 | return BAUL_QUERY_EDITOR_ROW_TYPE; |
1404 | } |
1405 | |
1406 | static void |
1407 | remove_row_cb (CtkButton *clicked_button, BaulQueryEditorRow *row) |
1408 | { |
1409 | BaulQueryEditor *editor; |
1410 | |
1411 | editor = row->editor; |
1412 | ctk_container_remove (CTK_CONTAINER (editor->details->visible_vbox)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->visible_vbox)), ((ctk_container_get_type ())))))), |
1413 | row->hbox); |
1414 | |
1415 | editor->details->rows = g_list_remove (editor->details->rows, row); |
1416 | |
1417 | row_type[row->type].free_data (row); |
1418 | g_free (row); |
1419 | |
1420 | baul_query_editor_changed (editor); |
1421 | } |
1422 | |
1423 | static void |
1424 | create_type_widgets (BaulQueryEditorRow *row) |
1425 | { |
1426 | row->type_widget = row_type[row->type].create_widgets (row); |
1427 | } |
1428 | |
1429 | static void |
1430 | row_type_combo_changed_cb (CtkComboBox *combo_box, BaulQueryEditorRow *row) |
1431 | { |
1432 | BaulQueryEditorRowType type; |
1433 | |
1434 | type = ctk_combo_box_get_active (combo_box); |
1435 | |
1436 | if (type == row->type) |
1437 | { |
1438 | return; |
1439 | } |
1440 | |
1441 | if (row->type_widget != NULL((void*)0)) |
1442 | { |
1443 | ctk_widget_destroy (row->type_widget); |
1444 | row->type_widget = NULL((void*)0); |
1445 | } |
1446 | |
1447 | row_type[row->type].free_data (row); |
1448 | row->data = NULL((void*)0); |
1449 | |
1450 | row->type = type; |
1451 | |
1452 | create_type_widgets (row); |
1453 | |
1454 | baul_query_editor_changed (row->editor); |
1455 | } |
1456 | |
1457 | static BaulQueryEditorRow * |
1458 | baul_query_editor_add_row (BaulQueryEditor *editor, |
1459 | BaulQueryEditorRowType type) |
1460 | { |
1461 | CtkWidget *hbox, *button, *image, *combo; |
1462 | BaulQueryEditorRow *row; |
1463 | int i; |
1464 | |
1465 | row = g_new0 (BaulQueryEditorRow, 1)((BaulQueryEditorRow *) g_malloc0_n ((1), sizeof (BaulQueryEditorRow ))); |
1466 | row->editor = editor; |
1467 | row->type = type; |
1468 | |
1469 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
1470 | row->hbox = hbox; |
1471 | ctk_widget_show (hbox); |
1472 | ctk_box_pack_start (CTK_BOX (editor->details->visible_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->visible_vbox)), ((ctk_box_get_type ())))))), hbox, FALSE(0), FALSE(0), 0); |
1473 | |
1474 | combo = ctk_combo_box_text_new (); |
1475 | row->combo = combo; |
1476 | for (i = 0; i < BAUL_QUERY_EDITOR_ROW_LAST; i++) |
1477 | { |
1478 | ctk_combo_box_text_append_text (CTK_COMBO_BOX_TEXT (combo)((((CtkComboBoxText*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_text_get_type ())))))), gettext (row_type[i].name)); |
1479 | } |
1480 | ctk_widget_show (combo); |
1481 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), combo, FALSE(0), FALSE(0), 0); |
1482 | |
1483 | ctk_combo_box_set_active (CTK_COMBO_BOX (combo)((((CtkComboBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((combo)), ((ctk_combo_box_get_type ())))))), row->type); |
1484 | |
1485 | editor->details->rows = g_list_append (editor->details->rows, row); |
1486 | |
1487 | g_signal_connect (combo, "changed",g_signal_connect_data ((combo), ("changed"), (((GCallback) (row_type_combo_changed_cb ))), (row), ((void*)0), (GConnectFlags) 0) |
1488 | G_CALLBACK (row_type_combo_changed_cb), row)g_signal_connect_data ((combo), ("changed"), (((GCallback) (row_type_combo_changed_cb ))), (row), ((void*)0), (GConnectFlags) 0); |
1489 | |
1490 | create_type_widgets (row); |
1491 | |
1492 | button = ctk_button_new (); |
1493 | image = ctk_image_new_from_icon_name ("remove", |
1494 | CTK_ICON_SIZE_SMALL_TOOLBAR); |
1495 | ctk_container_add (CTK_CONTAINER (button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_container_get_type ())))))), image); |
1496 | ctk_widget_show (image); |
1497 | ctk_button_set_relief (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), CTK_RELIEF_NONE); |
1498 | ctk_widget_show (button); |
1499 | |
1500 | g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) ( remove_row_cb))), (row), ((void*)0), (GConnectFlags) 0) |
1501 | G_CALLBACK (remove_row_cb), row)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( remove_row_cb))), (row), ((void*)0), (GConnectFlags) 0); |
1502 | ctk_widget_set_tooltip_text (button, |
1503 | _("Remove this criterion from the search")gettext ("Remove this criterion from the search")); |
1504 | |
1505 | ctk_box_pack_end (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), button, FALSE(0), FALSE(0), 0); |
1506 | |
1507 | return row; |
1508 | } |
1509 | |
1510 | static void |
1511 | go_search_cb (CtkButton *clicked_button, BaulQueryEditor *editor) |
1512 | { |
1513 | baul_query_editor_changed_force (editor, TRUE(!(0))); |
1514 | } |
1515 | |
1516 | static void |
1517 | add_new_row_cb (CtkButton *clicked_button, BaulQueryEditor *editor) |
1518 | { |
1519 | baul_query_editor_add_row (editor, get_next_free_type (editor)); |
1520 | baul_query_editor_changed (editor); |
1521 | } |
1522 | |
1523 | static void |
1524 | baul_query_editor_init (BaulQueryEditor *editor) |
1525 | { |
1526 | CtkWidget *hbox, *label, *button; |
1527 | char *label_markup; |
1528 | |
1529 | editor->details = g_new0 (BaulQueryEditorDetails, 1)((BaulQueryEditorDetails *) g_malloc0_n ((1), sizeof (BaulQueryEditorDetails ))); |
1530 | editor->details->is_visible = TRUE(!(0)); |
1531 | |
1532 | editor->details->invisible_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); |
1533 | ctk_orientable_set_orientation (CTK_ORIENTABLE (editor)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_orientable_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
1534 | ctk_box_pack_start (CTK_BOX (editor)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_box_get_type ())))))), editor->details->invisible_vbox, |
1535 | FALSE(0), FALSE(0), 0); |
1536 | editor->details->visible_vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6); |
1537 | ctk_orientable_set_orientation (CTK_ORIENTABLE (editor)((((CtkOrientable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_orientable_get_type ())))))), CTK_ORIENTATION_VERTICAL); |
1538 | ctk_box_pack_start (CTK_BOX (editor)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_box_get_type ())))))), editor->details->visible_vbox, |
1539 | FALSE(0), FALSE(0), 0); |
1540 | /* Only show visible vbox */ |
1541 | ctk_widget_show (editor->details->visible_vbox); |
1542 | |
1543 | /* Create invisible part: */ |
1544 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
1545 | ctk_box_pack_start (CTK_BOX (editor->details->invisible_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->invisible_vbox)), ((ctk_box_get_type ())))))), |
1546 | hbox, FALSE(0), FALSE(0), 0); |
1547 | ctk_widget_show (hbox); |
1548 | |
1549 | label = ctk_label_new (""); |
1550 | label_markup = g_strconcat ("<b>", _("Search Folder")gettext ("Search Folder"), "</b>", NULL((void*)0)); |
1551 | ctk_label_set_markup (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), label_markup); |
1552 | g_free (label_markup); |
1553 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), label, FALSE(0), FALSE(0), 0); |
1554 | ctk_widget_show (label); |
1555 | |
1556 | button = ctk_button_new_with_label (_("Edit")gettext ("Edit")); |
1557 | ctk_box_pack_end (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), button, FALSE(0), FALSE(0), 0); |
1558 | ctk_widget_show (button); |
1559 | |
1560 | g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) ( edit_clicked))), (editor), ((void*)0), (GConnectFlags) 0) |
1561 | G_CALLBACK (edit_clicked), editor)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( edit_clicked))), (editor), ((void*)0), (GConnectFlags) 0); |
1562 | |
1563 | ctk_widget_set_tooltip_text (button, |
1564 | _("Edit the saved search")gettext ("Edit the saved search")); |
1565 | } |
1566 | |
1567 | void |
1568 | baul_query_editor_set_default_query (BaulQueryEditor *editor) |
1569 | { |
1570 | if (!editor->details->is_indexed) |
1571 | { |
1572 | baul_query_editor_add_row (editor, BAUL_QUERY_EDITOR_ROW_LOCATION); |
1573 | baul_query_editor_changed (editor); |
1574 | } |
1575 | } |
1576 | |
1577 | static void |
1578 | finish_first_line (BaulQueryEditor *editor, CtkWidget *hbox, gboolean use_go) |
1579 | { |
1580 | CtkWidget *button, *image; |
1581 | |
1582 | button = ctk_button_new (); |
1583 | image = ctk_image_new_from_icon_name ("add", |
1584 | CTK_ICON_SIZE_SMALL_TOOLBAR); |
1585 | ctk_container_add (CTK_CONTAINER (button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_container_get_type ())))))), image); |
1586 | ctk_widget_show (image); |
1587 | ctk_button_set_relief (CTK_BUTTON (button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((button)), ((ctk_button_get_type ())))))), CTK_RELIEF_NONE); |
1588 | ctk_widget_show (button); |
1589 | |
1590 | g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) ( add_new_row_cb))), (editor), ((void*)0), (GConnectFlags) 0) |
1591 | G_CALLBACK (add_new_row_cb), editor)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( add_new_row_cb))), (editor), ((void*)0), (GConnectFlags) 0); |
1592 | |
1593 | ctk_box_pack_end (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), button, FALSE(0), FALSE(0), 0); |
1594 | |
1595 | ctk_widget_set_tooltip_text (button, |
1596 | _("Add a new criterion to this search")gettext ("Add a new criterion to this search")); |
1597 | |
1598 | if (!editor->details->is_indexed) |
1599 | { |
1600 | if (use_go) |
1601 | { |
1602 | button = ctk_button_new_with_label (_("Go")gettext ("Go")); |
1603 | } |
1604 | else |
1605 | { |
1606 | button = ctk_button_new_with_label (_("Reload")gettext ("Reload")); |
1607 | } |
1608 | ctk_widget_show (button); |
1609 | |
1610 | ctk_widget_set_tooltip_text (button, |
1611 | _("Perform or update the search")gettext ("Perform or update the search")); |
1612 | |
1613 | g_signal_connect (button, "clicked",g_signal_connect_data ((button), ("clicked"), (((GCallback) ( go_search_cb))), (editor), ((void*)0), (GConnectFlags) 0) |
1614 | G_CALLBACK (go_search_cb), editor)g_signal_connect_data ((button), ("clicked"), (((GCallback) ( go_search_cb))), (editor), ((void*)0), (GConnectFlags) 0); |
1615 | |
1616 | ctk_box_pack_end (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), button, FALSE(0), FALSE(0), 0); |
1617 | } |
1618 | } |
1619 | |
1620 | static void |
1621 | setup_internal_entry (BaulQueryEditor *editor) |
1622 | { |
1623 | CtkWidget *hbox, *label; |
1624 | char *label_markup; |
1625 | |
1626 | /* Create visible part: */ |
1627 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
1628 | ctk_widget_show (hbox); |
1629 | ctk_box_pack_start (CTK_BOX (editor->details->visible_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->visible_vbox)), ((ctk_box_get_type ())))))), hbox, FALSE(0), FALSE(0), 0); |
1630 | |
1631 | label = ctk_label_new (""); |
1632 | label_markup = g_strconcat ("<b>", _("_Search for:")gettext ("_Search for:"), "</b>", NULL((void*)0)); |
1633 | ctk_label_set_markup_with_mnemonic (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), label_markup); |
1634 | g_free (label_markup); |
1635 | ctk_widget_show (label); |
1636 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), label, FALSE(0), FALSE(0), 0); |
1637 | |
1638 | editor->details->entry = ctk_entry_new (); |
1639 | ctk_label_set_mnemonic_widget (CTK_LABEL (label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((label)), ((ctk_label_get_type ())))))), editor->details->entry); |
1640 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), editor->details->entry, TRUE(!(0)), TRUE(!(0)), 0); |
1641 | |
1642 | g_signal_connect (editor->details->entry, "activate",g_signal_connect_data ((editor->details->entry), ("activate" ), (((GCallback) (entry_activate_cb))), (editor), ((void*)0), (GConnectFlags) 0) |
1643 | G_CALLBACK (entry_activate_cb), editor)g_signal_connect_data ((editor->details->entry), ("activate" ), (((GCallback) (entry_activate_cb))), (editor), ((void*)0), (GConnectFlags) 0); |
1644 | g_signal_connect (editor->details->entry, "changed",g_signal_connect_data ((editor->details->entry), ("changed" ), (((GCallback) (entry_changed_cb))), (editor), ((void*)0), ( GConnectFlags) 0) |
1645 | G_CALLBACK (entry_changed_cb), editor)g_signal_connect_data ((editor->details->entry), ("changed" ), (((GCallback) (entry_changed_cb))), (editor), ((void*)0), ( GConnectFlags) 0); |
1646 | ctk_widget_show (editor->details->entry); |
1647 | |
1648 | finish_first_line (editor, hbox, TRUE(!(0))); |
1649 | } |
1650 | |
1651 | static void |
1652 | setup_external_entry (BaulQueryEditor *editor, CtkWidget *entry) |
1653 | { |
1654 | CtkWidget *hbox, *label; |
1655 | |
1656 | /* Create visible part: */ |
1657 | hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 6); |
1658 | ctk_widget_show (hbox); |
1659 | ctk_box_pack_start (CTK_BOX (editor->details->visible_vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->visible_vbox)), ((ctk_box_get_type ())))))), hbox, FALSE(0), FALSE(0), 0); |
1660 | |
1661 | label = ctk_label_new (_("Search results")gettext ("Search results")); |
1662 | ctk_widget_show (label); |
1663 | ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hbox)), ((ctk_box_get_type ())))))), label, FALSE(0), FALSE(0), 0); |
1664 | |
1665 | editor->details->entry = entry; |
1666 | g_signal_connect (editor->details->entry, "activate",g_signal_connect_data ((editor->details->entry), ("activate" ), (((GCallback) (entry_activate_cb))), (editor), ((void*)0), (GConnectFlags) 0) |
1667 | G_CALLBACK (entry_activate_cb), editor)g_signal_connect_data ((editor->details->entry), ("activate" ), (((GCallback) (entry_activate_cb))), (editor), ((void*)0), (GConnectFlags) 0); |
1668 | g_signal_connect (editor->details->entry, "changed",g_signal_connect_data ((editor->details->entry), ("changed" ), (((GCallback) (entry_changed_cb))), (editor), ((void*)0), ( GConnectFlags) 0) |
1669 | G_CALLBACK (entry_changed_cb), editor)g_signal_connect_data ((editor->details->entry), ("changed" ), (((GCallback) (entry_changed_cb))), (editor), ((void*)0), ( GConnectFlags) 0); |
1670 | |
1671 | finish_first_line (editor, hbox, FALSE(0)); |
1672 | |
1673 | } |
1674 | |
1675 | void |
1676 | baul_query_editor_set_visible (BaulQueryEditor *editor, |
1677 | gboolean visible) |
1678 | { |
1679 | editor->details->is_visible = visible; |
1680 | if (visible) |
1681 | { |
1682 | ctk_widget_show (editor->details->visible_vbox); |
1683 | ctk_widget_hide (editor->details->invisible_vbox); |
1684 | } |
1685 | else |
1686 | { |
1687 | ctk_widget_hide (editor->details->visible_vbox); |
1688 | ctk_widget_show (editor->details->invisible_vbox); |
1689 | } |
1690 | } |
1691 | |
1692 | static gboolean |
1693 | query_is_valid (BaulQueryEditor *editor) |
1694 | { |
1695 | const char *text; |
1696 | |
1697 | text = ctk_entry_get_text (CTK_ENTRY (editor->details->entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->entry)), ((ctk_entry_get_type ()) )))))); |
1698 | |
1699 | return text != NULL((void*)0) && text[0] != '\0'; |
1700 | } |
1701 | |
1702 | static void |
1703 | baul_query_editor_changed_force (BaulQueryEditor *editor, gboolean force_reload) |
1704 | { |
1705 | if (editor->details->change_frozen) |
1706 | { |
1707 | return; |
1708 | } |
1709 | |
1710 | if (query_is_valid (editor)) |
1711 | { |
1712 | BaulQuery *query; |
1713 | |
1714 | query = baul_query_editor_get_query (editor); |
1715 | g_signal_emit (editor, signals[CHANGED], 0, |
1716 | query, editor->details->is_indexed || force_reload); |
1717 | g_object_unref (query); |
1718 | } |
1719 | } |
1720 | |
1721 | static void |
1722 | baul_query_editor_changed (BaulQueryEditor *editor) |
1723 | { |
1724 | baul_query_editor_changed_force (editor, FALSE(0)); |
1725 | } |
1726 | |
1727 | void |
1728 | baul_query_editor_grab_focus (BaulQueryEditor *editor) |
1729 | { |
1730 | if (editor->details->is_visible) |
1731 | { |
1732 | ctk_widget_grab_focus (editor->details->entry); |
1733 | } |
1734 | } |
1735 | |
1736 | BaulQuery * |
1737 | baul_query_editor_get_query (BaulQueryEditor *editor) |
1738 | { |
1739 | const char *query_text; |
1740 | BaulQuery *query; |
1741 | GList *l; |
1742 | BaulQueryEditorRow *row = NULL((void*)0); |
1743 | |
1744 | if (editor == NULL((void*)0) || editor->details == NULL((void*)0) || editor->details->entry == NULL((void*)0)) |
1745 | { |
1746 | return NULL((void*)0); |
1747 | } |
1748 | |
1749 | query_text = ctk_entry_get_text (CTK_ENTRY (editor->details->entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->entry)), ((ctk_entry_get_type ()) )))))); |
1750 | |
1751 | /* Empty string is a NULL query */ |
1752 | if (query_text && query_text[0] == '\0') |
1753 | { |
1754 | return NULL((void*)0); |
1755 | } |
1756 | |
1757 | query = baul_query_new (); |
1758 | baul_query_set_text (query, query_text); |
1759 | |
1760 | for (l = editor->details->rows; l != NULL((void*)0); l = l->next) |
1761 | { |
1762 | row = l->data; |
1763 | |
1764 | row_type[row->type].add_to_query (row, query); |
1765 | } |
1766 | |
1767 | return query; |
1768 | } |
1769 | |
1770 | void |
1771 | baul_query_editor_clear_query (BaulQueryEditor *editor) |
1772 | { |
1773 | editor->details->change_frozen = TRUE(!(0)); |
1774 | ctk_entry_set_text (CTK_ENTRY (editor->details->entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->entry)), ((ctk_entry_get_type ()) ))))), ""); |
1775 | |
1776 | g_free (editor->details->last_set_query_text); |
1777 | editor->details->last_set_query_text = g_strdup (""); |
1778 | |
1779 | editor->details->change_frozen = FALSE(0); |
1780 | } |
1781 | |
1782 | CtkWidget * |
1783 | baul_query_editor_new (gboolean start_hidden, |
1784 | gboolean is_indexed) |
1785 | { |
1786 | CtkWidget *editor; |
1787 | |
1788 | editor = g_object_new (BAUL_TYPE_QUERY_EDITORbaul_query_editor_get_type(), NULL((void*)0)); |
1789 | |
1790 | BAUL_QUERY_EDITOR (editor)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), (baul_query_editor_get_type())))))->details->is_indexed = is_indexed; |
1791 | |
1792 | baul_query_editor_set_visible (BAUL_QUERY_EDITOR (editor)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), (baul_query_editor_get_type()))))), |
1793 | !start_hidden); |
1794 | |
1795 | setup_internal_entry (BAUL_QUERY_EDITOR (editor)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), (baul_query_editor_get_type())))))); |
1796 | |
1797 | return editor; |
1798 | } |
1799 | |
1800 | static void |
1801 | detach_from_external_entry (BaulQueryEditor *editor) |
1802 | { |
1803 | if (editor->details->bar != NULL((void*)0)) |
1804 | { |
1805 | baul_search_bar_return_entry (editor->details->bar); |
1806 | g_signal_handlers_block_by_func (editor->details->entry,g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
1807 | entry_activate_cb,g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
1808 | editor)g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)); |
1809 | g_signal_handlers_block_by_func (editor->details->entry,g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
1810 | entry_changed_cb,g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
1811 | editor)g_signal_handlers_block_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)); |
1812 | } |
1813 | } |
1814 | |
1815 | static void |
1816 | attach_to_external_entry (BaulQueryEditor *editor) |
1817 | { |
1818 | if (editor->details->bar != NULL((void*)0)) |
1819 | { |
1820 | baul_search_bar_borrow_entry (editor->details->bar); |
1821 | g_signal_handlers_unblock_by_func (editor->details->entry,g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
1822 | entry_activate_cb,g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)) |
1823 | editor)g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_activate_cb), (editor)); |
1824 | g_signal_handlers_unblock_by_func (editor->details->entry,g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
1825 | entry_changed_cb,g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)) |
1826 | editor)g_signal_handlers_unblock_matched ((editor->details->entry ), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA ), 0, 0, ((void*)0), (entry_changed_cb), (editor)); |
1827 | |
1828 | editor->details->change_frozen = TRUE(!(0)); |
1829 | ctk_entry_set_text (CTK_ENTRY (editor->details->entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->entry)), ((ctk_entry_get_type ()) ))))), |
1830 | editor->details->last_set_query_text); |
1831 | editor->details->change_frozen = FALSE(0); |
1832 | } |
1833 | } |
1834 | |
1835 | CtkWidget* |
1836 | baul_query_editor_new_with_bar (gboolean start_hidden, |
1837 | gboolean is_indexed, |
1838 | gboolean start_attached, |
1839 | BaulSearchBar *bar, |
1840 | BaulWindowSlot *slot) |
1841 | { |
1842 | CtkWidget *entry; |
1843 | BaulQueryEditor *editor; |
1844 | |
1845 | editor = BAUL_QUERY_EDITOR (g_object_new (BAUL_TYPE_QUERY_EDITOR, NULL))((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((g_object_new (baul_query_editor_get_type(), ((void*)0))) ), (baul_query_editor_get_type()))))); |
1846 | editor->details->is_indexed = is_indexed; |
1847 | |
1848 | baul_query_editor_set_visible (editor, !start_hidden); |
1849 | |
1850 | editor->details->bar = bar; |
1851 | eel_add_weak_pointer (&editor->details->bar); |
1852 | |
1853 | editor->details->slot = slot; |
1854 | |
1855 | entry = baul_search_bar_borrow_entry (bar); |
1856 | setup_external_entry (editor, entry); |
1857 | if (!start_attached) |
1858 | { |
1859 | detach_from_external_entry (editor); |
1860 | } |
1861 | |
1862 | g_signal_connect_object (slot, "active", |
1863 | G_CALLBACK (attach_to_external_entry)((GCallback) (attach_to_external_entry)), |
1864 | editor, G_CONNECT_SWAPPED); |
1865 | g_signal_connect_object (slot, "inactive", |
1866 | G_CALLBACK (detach_from_external_entry)((GCallback) (detach_from_external_entry)), |
1867 | editor, G_CONNECT_SWAPPED); |
1868 | |
1869 | return CTK_WIDGET (editor)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_widget_get_type ())))))); |
1870 | } |
1871 | |
1872 | void |
1873 | baul_query_editor_set_query (BaulQueryEditor *editor, BaulQuery *query) |
1874 | { |
1875 | BaulQueryEditorRowType type; |
1876 | char *text; |
1877 | |
1878 | if (!query) |
1879 | { |
1880 | baul_query_editor_clear_query (editor); |
1881 | return; |
1882 | } |
1883 | |
1884 | text = baul_query_get_text (query); |
1885 | |
1886 | if (!text) |
1887 | { |
1888 | text = g_strdup (""); |
1889 | } |
1890 | |
1891 | editor->details->change_frozen = TRUE(!(0)); |
1892 | ctk_entry_set_text (CTK_ENTRY (editor->details->entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor->details->entry)), ((ctk_entry_get_type ()) ))))), text); |
1893 | |
1894 | for (type = 0; type < BAUL_QUERY_EDITOR_ROW_LAST; type++) |
1895 | { |
1896 | row_type[type].add_rows_from_query (editor, query); |
1897 | } |
1898 | |
1899 | editor->details->change_frozen = FALSE(0); |
1900 | |
1901 | g_free (editor->details->last_set_query_text); |
1902 | editor->details->last_set_query_text = text; |
1903 | } |