Bug Summary

File:src/baul-query-editor.c
Warning:line 1051, column 9
Value stored to 'model' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

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