Bug Summary

File:src/baul-spatial-window.c
Warning:line 710, column 9
This statement is never executed

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-spatial-window.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-21/lib/clang/21 -D HAVE_CONFIG_H -I . -I .. -I .. -I ../libbaul-private -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cail-3.0 -I /usr/include/libxml2 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/cairo -I /usr/include/cdk-pixbuf-2.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/atk-1.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/harfbuzz -I /usr/include/gio-unix-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glycin-2 -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -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.2.0" -D G_DISABLE_DEPRECATED -D CDK_PIXBUF_DISABLE_DEPRECATED -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../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 security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -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/2026-07-29-124201-27423-1 -x c baul-spatial-window.c
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3/*
4 * Baul
5 *
6 * Copyright (C) 1999, 2000 Red Hat, Inc.
7 * Copyright (C) 1999, 2000, 2001 Eazel, Inc.
8 *
9 * Baul is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * Baul is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
22 *
23 * Authors: Elliot Lee <sopwith@redhat.com>
24 * John Sullivan <sullivan@eazel.com>
25 *
26 */
27
28/* baul-window.c: Implementation of the main window object */
29
30#include <config.h>
31
32#include <cdk/cdkkeysyms.h>
33#include <cdk/cdkx.h>
34#include <ctk/ctk.h>
35#include <glib/gi18n.h>
36
37#include <eel/eel-ctk-extensions.h>
38#include <eel/eel-ctk-macros.h>
39#include <eel/eel-string.h>
40
41#include <libbaul-private/baul-dnd.h>
42#include <libbaul-private/baul-file-utilities.h>
43#include <libbaul-private/baul-ui-utilities.h>
44#include <libbaul-private/baul-file-attributes.h>
45#include <libbaul-private/baul-global-preferences.h>
46#include <libbaul-private/baul-metadata.h>
47#include <libbaul-private/baul-mime-actions.h>
48#include <libbaul-private/baul-program-choosing.h>
49#include <libbaul-private/baul-search-directory.h>
50#include <libbaul-private/baul-search-engine.h>
51#include <libbaul-private/baul-signaller.h>
52
53#include "baul-spatial-window.h"
54#include "baul-window-private.h"
55#include "baul-window-bookmarks.h"
56#include "baul-actions.h"
57#include "baul-application.h"
58#include "baul-desktop-window.h"
59#include "baul-bookmarks-window.h"
60#include "baul-location-dialog.h"
61#include "baul-query-editor.h"
62#include "baul-search-bar.h"
63#include "baul-window-manage-views.h"
64
65#define MAX_TITLE_LENGTH180 180
66#define MAX_SHORTNAME_PATH16 16
67
68#define SPATIAL_ACTION_PLACES"Places" "Places"
69#define SPATIAL_ACTION_GO_TO_LOCATION"Go to Location" "Go to Location"
70#define SPATIAL_ACTION_CLOSE_PARENT_FOLDERS"Close Parent Folders" "Close Parent Folders"
71#define SPATIAL_ACTION_CLOSE_ALL_FOLDERS"Close All Folders" "Close All Folders"
72#define MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER"/MenuBar/Other Menus/Places/Bookmarks Placeholder" "/MenuBar/Other Menus/Places/Bookmarks Placeholder"
73
74struct _BaulSpatialWindowPrivate
75{
76 CtkActionGroup *spatial_action_group; /* owned by ui_manager */
77 char *last_geometry;
78 guint save_geometry_timeout_id;
79
80 gboolean saved_data_on_close;
81 CtkWidget *content_box;
82 CtkWidget *location_button;
83 CtkWidget *location_label;
84 CtkWidget *location_icon;
85};
86
87static const CtkTargetEntry location_button_drag_types[] =
88{
89 { BAUL_ICON_DND_CAFE_ICON_LIST_TYPE"x-special/cafe-icon-list", 0, BAUL_ICON_DND_CAFE_ICON_LIST },
90 { BAUL_ICON_DND_URI_LIST_TYPE"text/uri-list", 0, BAUL_ICON_DND_URI_LIST },
91};
92
93G_DEFINE_TYPE_WITH_PRIVATE (BaulSpatialWindow, baul_spatial_window, BAUL_TYPE_WINDOW)static void baul_spatial_window_init (BaulSpatialWindow *self
); static void baul_spatial_window_class_init (BaulSpatialWindowClass
*klass); static GType baul_spatial_window_get_type_once (void
); static gpointer baul_spatial_window_parent_class = ((void*
)0); static gint BaulSpatialWindow_private_offset; static void
baul_spatial_window_class_intern_init (gpointer klass) { baul_spatial_window_parent_class
= g_type_class_peek_parent (klass); if (BaulSpatialWindow_private_offset
!= 0) g_type_class_adjust_private_offset (klass, &BaulSpatialWindow_private_offset
); baul_spatial_window_class_init ((BaulSpatialWindowClass*) klass
); } __attribute__ ((__unused__)) static inline gpointer baul_spatial_window_get_instance_private
(BaulSpatialWindow *self) { return (((gpointer) ((guint8*) (
self) + (glong) (BaulSpatialWindow_private_offset)))); } GType
baul_spatial_window_get_type (void) { static GType static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*)
0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= baul_spatial_window_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType baul_spatial_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(baul_window_get_type(), g_intern_static_string ("BaulSpatialWindow"
), sizeof (BaulSpatialWindowClass), (GClassInitFunc)(void (*)
(void)) baul_spatial_window_class_intern_init, sizeof (BaulSpatialWindow
), (GInstanceInitFunc)(void (*)(void)) baul_spatial_window_init
, (GTypeFlags) 0); { {{ BaulSpatialWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (BaulSpatialWindowPrivate)); };} }
return g_define_type_id; }
94
95static void baul_spatial_window_save_geometry (BaulSpatialWindow *window,
96 BaulFile *viewed_file);
97
98static gboolean
99save_window_geometry_timeout (gpointer callback_data)
100{
101 BaulSpatialWindow *window;
102 BaulWindowSlot *slot;
103
104 window = BAUL_SPATIAL_WINDOW (callback_data)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((callback_data)), (baul_spatial_window_get_type
())))))
;
105 slot = baul_window_get_active_slot (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
);
106
107 if (slot != NULL((void*)0))
108 {
109 baul_spatial_window_save_geometry (window, slot->viewed_file);
110 }
111
112 window->details->save_geometry_timeout_id = 0;
113
114 return FALSE(0);
115}
116
117static gboolean
118baul_spatial_window_configure_event (CtkWidget *widget,
119 CdkEventConfigure *event)
120{
121 BaulSpatialWindow *window;
122
123 window = BAUL_SPATIAL_WINDOW (widget)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), (baul_spatial_window_get_type())
))))
;
124
125 CTK_WIDGET_CLASS (baul_spatial_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), ((ctk_widget_get_type
()))))))
->configure_event (widget, event);
126
127 /* Only save the geometry if the user hasn't resized the window
128 * for a second. Otherwise delay the callback another second.
129 */
130 if (window->details->save_geometry_timeout_id != 0)
131 {
132 g_source_remove (window->details->save_geometry_timeout_id);
133 }
134
135 window->details->save_geometry_timeout_id =
136 g_timeout_add_seconds (1, save_window_geometry_timeout, window);
137
138 return FALSE(0);
139}
140
141static void
142baul_spatial_window_unrealize (CtkWidget *widget)
143{
144 BaulSpatialWindow *window;
145 BaulWindowSlot *slot;
146
147 window = BAUL_SPATIAL_WINDOW (widget)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((widget)), (baul_spatial_window_get_type())
))))
;
148 slot = baul_window_get_active_slot (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
);
149
150 CTK_WIDGET_CLASS (baul_spatial_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), ((ctk_widget_get_type
()))))))
->unrealize (widget);
151
152 if (window->details->save_geometry_timeout_id != 0)
153 {
154 g_source_remove (window->details->save_geometry_timeout_id);
155 window->details->save_geometry_timeout_id = 0;
156
157 if (slot != NULL((void*)0))
158 {
159 baul_spatial_window_save_geometry (window, slot->viewed_file);
160 }
161 }
162}
163
164static gboolean
165baul_spatial_window_state_event (CtkWidget *widget,
166 CdkEventWindowState *event)
167{
168 BaulWindow *window;
169 BaulWindowSlot *slot;
170 BaulFile *viewed_file;
171
172 window = BAUL_WINDOW (widget)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (baul_window_get_type())))))
;
173 slot = window->details->active_pane->active_slot;
174 viewed_file = slot->viewed_file;
175
176 if (!BAUL_IS_DESKTOP_WINDOW (widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(widget)); GType __t = (baul_desktop_window_get_type()); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
177 {
178
179 if (event->changed_mask & CDK_WINDOW_STATE_MAXIMIZED &&
180 viewed_file != NULL((void*)0))
181 {
182 baul_file_set_boolean_metadata (viewed_file,
183 BAUL_METADATA_KEY_WINDOW_MAXIMIZED"baul-window-maximized",
184 FALSE(0),
185 event->new_window_state & CDK_WINDOW_STATE_MAXIMIZED);
186 }
187
188 if (event->changed_mask & CDK_WINDOW_STATE_STICKY &&
189 viewed_file != NULL((void*)0))
190 {
191 baul_file_set_boolean_metadata (viewed_file,
192 BAUL_METADATA_KEY_WINDOW_STICKY"baul-window-sticky",
193 FALSE(0),
194 event->new_window_state & CDK_WINDOW_STATE_STICKY);
195 }
196
197 if (event->changed_mask & CDK_WINDOW_STATE_ABOVE &&
198 viewed_file != NULL((void*)0))
199 {
200 baul_file_set_boolean_metadata (viewed_file,
201 BAUL_METADATA_KEY_WINDOW_KEEP_ABOVE"baul-window-keep-above",
202 FALSE(0),
203 event->new_window_state & CDK_WINDOW_STATE_ABOVE);
204 }
205
206 }
207
208 if (CTK_WIDGET_CLASS (baul_spatial_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), ((ctk_widget_get_type
()))))))
->window_state_event != NULL((void*)0))
209 {
210 return CTK_WIDGET_CLASS (baul_spatial_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), ((ctk_widget_get_type
()))))))
->window_state_event (widget, event);
211 }
212
213 return FALSE(0);
214}
215
216static void
217baul_spatial_window_finalize (GObject *object)
218{
219 BaulSpatialWindow *window;
220
221 window = BAUL_SPATIAL_WINDOW (object)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((object)), (baul_spatial_window_get_type())
))))
;
222
223 g_free (window->details->last_geometry);
224
225 G_OBJECT_CLASS (baul_spatial_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
226}
227
228static void
229baul_spatial_window_save_geometry (BaulSpatialWindow *window,
230 BaulFile *viewed_file)
231{
232 char *geometry_string;
233
234 if (viewed_file == NULL((void*)0))
235 {
236 /* We never showed a file */
237 return;
238 }
239
240 if (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
) &&
241 ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
) &&
242 !BAUL_IS_DESKTOP_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_desktop_window_get_type()); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
&&
243 !(cdk_window_get_state (ctk_widget_get_window (CTK_WIDGET(window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
)) & CDK_WINDOW_STATE_MAXIMIZED)) {
244
245 geometry_string = eel_ctk_window_get_geometry_string (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
246
247 if (!g_strcmp0 (window->details->last_geometry, geometry_string)) {
248 /* Don't save geometry if it's the same as before. */
249 g_free (geometry_string);
250 return;
251 }
252
253 g_free (window->details->last_geometry);
254 window->details->last_geometry = geometry_string;
255
256 baul_file_set_metadata (viewed_file,
257 BAUL_METADATA_KEY_WINDOW_GEOMETRY"baul-window-geometry",
258 NULL((void*)0),
259 geometry_string);
260 }
261}
262
263static void
264baul_spatial_window_save_scroll_position (BaulSpatialWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)),
265 BaulWindowSlot *slot)
266{
267 char *scroll_string;
268
269 if (slot->content_view == NULL((void*)0) ||
270 slot->viewed_file == NULL((void*)0))
271 {
272 return;
273 }
274
275 scroll_string = baul_view_get_first_visible_file (slot->content_view);
276 baul_file_set_metadata (slot->viewed_file,
277 BAUL_METADATA_KEY_WINDOW_SCROLL_POSITION"baul-window-scroll-position",
278 NULL((void*)0),
279 scroll_string);
280 g_free (scroll_string);
281}
282
283static void
284baul_spatial_window_save_show_hidden_files_mode (BaulSpatialWindow *window,
285 BaulFile *viewed_file)
286{
287 BaulWindowShowHiddenFilesMode mode;
288
289 if (viewed_file == NULL((void*)0)) {
290 return;
291 }
292
293 mode = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
->details->show_hidden_files_mode;
294
295 if (mode != BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) {
296 char *show_hidden_file_setting;
297
298 if (mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_ENABLE) {
299 show_hidden_file_setting = "1";
300 } else {
301 show_hidden_file_setting = "0";
302 }
303 baul_file_set_metadata (viewed_file,
304 BAUL_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES"baul-window-show-hidden-files",
305 NULL((void*)0),
306 show_hidden_file_setting);
307 }
308}
309
310static void
311baul_spatial_window_show (CtkWidget *widget)
312{
313 BaulWindow *window;
314 BaulWindowSlot *slot;
315 GFile *location;
316
317 window = BAUL_WINDOW (widget)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), (baul_window_get_type())))))
;
318 slot = baul_window_get_active_slot (window);
319
320 CTK_WIDGET_CLASS (baul_spatial_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), ((ctk_widget_get_type
()))))))
->show (widget);
321
322 if (slot != NULL((void*)0) && slot->query_editor != NULL((void*)0))
323 {
324 baul_query_editor_grab_focus (BAUL_QUERY_EDITOR (slot->query_editor)((((BaulQueryEditor*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((slot->query_editor)), (baul_query_editor_get_type()))
)))
);
325 }
326
327 location = baul_window_slot_get_location (slot);
328 g_return_if_fail (location != NULL)do { if ((location != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "location != NULL"
); return; } } while (0)
;
329
330 while (location != NULL((void*)0)) {
331 BaulFile *file;
332
333 file = baul_file_get (location);
334
335 if (!baul_file_check_if_ready (file, BAUL_FILE_ATTRIBUTE_INFO)) {
336 baul_file_call_when_ready (file,
337 BAUL_FILE_ATTRIBUTE_INFO,
338 NULL((void*)0),
339 NULL((void*)0));
340 }
341
342 location = g_file_get_parent (location);
343 }
344
345 if (location) {
346 g_object_unref (location);
347 }
348}
349
350static void
351action_close_parent_folders_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
352 gpointer user_data)
353{
354 baul_application_close_parent_windows (BAUL_SPATIAL_WINDOW (user_data)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((user_data)), (baul_spatial_window_get_type
())))))
);
355}
356
357static void
358action_close_all_folders_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
359 gpointer user_data G_GNUC_UNUSED__attribute__ ((__unused__)))
360{
361 baul_application_close_all_spatial_windows ();
362}
363
364static void
365real_prompt_for_location (BaulWindow *window,
366 const char *initial)
367{
368 CtkWidget *dialog;
369
370 dialog = baul_location_dialog_new (window);
371 if (initial != NULL((void*)0))
372 {
373 baul_location_dialog_set_location (BAUL_LOCATION_DIALOG (dialog)((((BaulLocationDialog*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((dialog)), ((baul_location_dialog_get_type (
)))))))
,
374 initial);
375 }
376
377 ctk_widget_show (dialog);
378}
379
380static BaulIconInfo *
381real_get_icon (BaulWindow *window,
382 BaulWindowSlot *slot)
383{
384 return baul_file_get_icon (slot->viewed_file,
385 48, ctk_widget_get_scale_factor (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
),
386 BAUL_FILE_ICON_FLAGS_IGNORE_VISITING |
387 BAUL_FILE_ICON_FLAGS_USE_MOUNT_ICON);
388}
389
390static void
391sync_window_title (BaulWindow *window)
392{
393 BaulWindowSlot *slot;
394
395 slot = baul_window_get_active_slot (window);
396
397 /* Don't change desktop's title, it would override the one already defined */
398 if (BAUL_IS_DESKTOP_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_desktop_window_get_type()); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
)
399 return;
400
401 if (slot->title == NULL((void*)0) || slot->title[0] == '\0')
402 {
403 ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, _("Baul")gettext ("Baul"));
404 }
405 else
406 {
407 char *window_title;
408
409 window_title = eel_str_middle_truncate (slot->title, MAX_TITLE_LENGTH180);
410 ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, window_title);
411 g_free (window_title);
412 }
413}
414
415static void
416real_sync_title (BaulWindow *window,
417 BaulWindowSlot *slot)
418{
419 g_assert (slot == baul_window_get_active_slot (window))do { if (slot == baul_window_get_active_slot (window)) ; else
g_assertion_message_expr (((gchar*) 0), "baul-spatial-window.c"
, 419, ((const char*) (__func__)), "slot == baul_window_get_active_slot (window)"
); } while (0)
;
420
421 sync_window_title (window);
422}
423
424static void
425real_get_min_size (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)),
426 guint *min_width,
427 guint *min_height)
428{
429 if (min_width)
430 {
431 *min_width = BAUL_SPATIAL_WINDOW_MIN_WIDTH100;
432 }
433 if (min_height)
434 {
435 *min_height = BAUL_SPATIAL_WINDOW_MIN_HEIGHT100;
436 }
437}
438
439static void
440real_get_default_size (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)),
441 guint *default_width,
442 guint *default_height)
443{
444 if (default_width)
445 {
446 *default_width = BAUL_SPATIAL_WINDOW_DEFAULT_WIDTH500;
447 }
448 if (default_height)
449 {
450 *default_height = BAUL_SPATIAL_WINDOW_DEFAULT_HEIGHT300;
451 }
452}
453
454static void
455real_sync_allow_stop (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)),
456 BaulWindowSlot *slot G_GNUC_UNUSED__attribute__ ((__unused__)))
457{
458}
459
460static void
461real_set_allow_up (BaulWindow *window, gboolean allow)
462{
463 BaulSpatialWindow *spatial;
464 CtkAction *action;
465
466 spatial = BAUL_SPATIAL_WINDOW (window)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), (baul_spatial_window_get_type())
))))
;
467
468 action = ctk_action_group_get_action (spatial->details->spatial_action_group,
469 SPATIAL_ACTION_CLOSE_PARENT_FOLDERS"Close Parent Folders");
470 ctk_action_set_sensitive (action, allow);
471
472 BAUL_WINDOW_CLASS (baul_spatial_window_parent_class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), (baul_window_get_type
())))))
->set_allow_up (window, allow);
473}
474
475static BaulWindowSlot *
476real_open_slot (BaulWindowPane *pane,
477 BaulWindowOpenSlotFlags flags G_GNUC_UNUSED__attribute__ ((__unused__)))
478{
479 BaulWindowSlot *slot;
480 GList *slots;
481
482 g_assert (baul_window_get_active_slot (pane->window) == NULL)do { if (baul_window_get_active_slot (pane->window) == ((void
*)0)) ; else g_assertion_message_expr (((gchar*) 0), "baul-spatial-window.c"
, 482, ((const char*) (__func__)), "baul_window_get_active_slot (pane->window) == NULL"
); } while (0)
;
483
484 slots = baul_window_get_slots (pane->window);
485 g_assert (slots == NULL)do { if (slots == ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-spatial-window.c", 485, ((const char*) (
__func__)), "slots == NULL"); } while (0)
;
486 g_list_free (slots);
487
488 slot = g_object_new (BAUL_TYPE_WINDOW_SLOT(baul_window_slot_get_type()), NULL((void*)0));
489 slot->pane = pane;
490 ctk_container_add (CTK_CONTAINER (BAUL_SPATIAL_WINDOW (pane->window)->details->content_box)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((BaulSpatialWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((pane->window)), (baul_spatial_window_get_type
())))))->details->content_box)), ((ctk_container_get_type
()))))))
,
491 slot->content_box);
492 ctk_widget_show (slot->content_box);
493 return slot;
494}
495
496static void
497save_spatial_data (BaulSpatialWindow *window,
498 BaulWindowSlot *slot)
499{
500 baul_spatial_window_save_geometry (window, slot->viewed_file);
501 baul_spatial_window_save_scroll_position (window, slot);
502 baul_spatial_window_save_show_hidden_files_mode (window, slot->viewed_file);
503}
504
505static void
506real_close_slot (BaulWindowPane *pane,
507 BaulWindowSlot *slot)
508{
509 BaulSpatialWindow *window;
510
511 window = BAUL_SPATIAL_WINDOW (pane->window)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((pane->window)), (baul_spatial_window_get_type
())))))
;
512
513 /* Save spatial data for close if we didn't already */
514 if (!window->details->saved_data_on_close) {
515 save_spatial_data (window, slot);
516 }
517
518 BAUL_WINDOW_CLASS (baul_spatial_window_parent_class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), (baul_window_get_type
())))))
->close_slot (pane, slot);
519}
520
521static void
522real_window_close (BaulWindow *window)
523{
524 BaulWindowSlot *slot;
525 BaulSpatialWindow *self;
526
527 self = BAUL_SPATIAL_WINDOW (window)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), (baul_spatial_window_get_type())
))))
;
528
529 /* We're closing the window, save the geometry. */
530 /* Note that we do this in window close, not slot close, because slot
531 * close is too late, by then the widgets have been unrealized.
532 * This is for the close by WM case, if you're closing via Ctrl-W that
533 * means we close the slots first and this is not an issue */
534 slot = baul_window_get_active_slot (window);
535
536 if (slot != NULL((void*)0)) {
537 save_spatial_data (self, slot);
538 self->details->saved_data_on_close = TRUE(!(0));
539 }
540
541 if (BAUL_WINDOW_CLASS (baul_spatial_window_parent_class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), (baul_window_get_type
())))))
->close != NULL((void*)0)) {
542 BAUL_WINDOW_CLASS (baul_spatial_window_parent_class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((baul_spatial_window_parent_class)), (baul_window_get_type
())))))
->close (window);
543 }
544}
545
546static void
547location_menu_item_activated_callback (CtkWidget *menu_item,
548 BaulWindow *window)
549{
550 BaulWindowSlot *slot;
551 GFile *current;
552 GFile *dest;
553 CdkEvent *event;
554
555 slot = baul_window_get_active_slot (window);
556 current = baul_window_slot_get_location (slot);
557 dest = g_object_get_data (G_OBJECT (menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu_item)), (((GType) ((20) << (2))))))))
, "location");
558
559 event = ctk_get_current_event();
560
561 if (!g_file_equal (current, dest))
562 {
563 GFile *child;
564 gboolean close_behind;
565 GList *selection;
566
567 close_behind = FALSE(0);
568 selection = NULL((void*)0);
569
570 child = g_object_get_data (G_OBJECT(menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu_item)), (((GType) ((20) << (2))))))))
, "child_location");
571 if (child != NULL((void*)0)) {
572 selection = g_list_prepend (NULL((void*)0), g_object_ref (child)((__typeof__ (child)) (g_object_ref) (child)));
573 }
574
575 if (event != NULL((void*)0) && ((CdkEventAny *) event)->type == CDK_BUTTON_RELEASE &&
576 (((CdkEventButton *) event)->button == 2 ||
577 (((CdkEventButton *) event)->state & CDK_SHIFT_MASK) != 0)) {
578 close_behind = TRUE(!(0));
579 }
580
581 baul_window_slot_open_location_with_selection
582 (slot, dest, selection, close_behind);
583
584 g_list_free_full (selection, g_object_unref);
585 }
586
587 if (event != NULL((void*)0)) {
588 cdk_event_free (event);
589 }
590
591 g_object_unref (current);
592}
593
594static void
595menu_deactivate_callback (CtkWidget *menu G_GNUC_UNUSED__attribute__ ((__unused__)),
596 gpointer data)
597{
598 GMainLoop *loop;
599
600 loop = data;
601
602 if (g_main_loop_is_running (loop))
603 {
604 g_main_loop_quit (loop);
605 }
606}
607
608static gboolean
609location_button_pressed_callback (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)),
610 CdkEventButton *event,
611 BaulWindow *window)
612{
613 BaulWindowSlot *slot;
614 BaulView *view;
615
616 slot = baul_window_get_active_slot (window);
617 view = slot->content_view;
618
619 if (event->button == 3 && view != NULL((void*)0))
620 {
621 baul_view_pop_up_location_context_menu (view, event, NULL((void*)0));
622 }
623
624 return FALSE(0);
625}
626
627static void
628location_button_clicked_callback (CtkWidget *widget,
629 BaulSpatialWindow *window)
630{
631 BaulWindowSlot *slot;
632 CtkWidget *popup, *menu_item, *first_item = NULL((void*)0);
633 cairo_surface_t *surface = NULL((void*)0);
634 GFile *location;
635 GFile *child_location;
636 GMainLoop *loop;
637
638 slot = baul_window_get_active_slot (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
);
639
640 popup = ctk_menu_new ();
641
642 ctk_menu_set_reserve_toggle_size (CTK_MENU (popup)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((ctk_menu_get_type ()))))))
, FALSE(0));
643
644 first_item = NULL((void*)0);
645
646 location = baul_window_slot_get_location (slot);
647 g_return_if_fail (location != NULL)do { if ((location != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "location != NULL"
); return; } } while (0)
;
648
649 child_location = NULL((void*)0);
650 while (location != NULL((void*)0)) {
651 BaulFile *file;
652 char *name;
653
654 file = baul_file_get (location);
655
656 name = baul_file_get_display_name (file);
657
658 surface = NULL((void*)0);
659
660 surface = baul_file_get_icon_surface (file,
661 baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU),
662 TRUE(!(0)),
663 ctk_widget_get_scale_factor (widget),
664 BAUL_FILE_ICON_FLAGS_IGNORE_VISITING);
665
666 if (surface != NULL((void*)0))
667 {
668 menu_item = eel_image_menu_item_new_from_surface (surface, name);
669 cairo_surface_destroy (surface);
670 }
671 else
672 {
673 menu_item = eel_image_menu_item_new_from_icon ("document-open", name);
674 }
675
676 if (first_item == NULL((void*)0)) {
677 first_item = menu_item;
678 }
679
680 ctk_widget_show (menu_item);
681 g_signal_connect (menu_item, "activate",g_signal_connect_data ((menu_item), ("activate"), (((GCallback
) (location_menu_item_activated_callback))), (window), ((void
*)0), (GConnectFlags) 0)
682 G_CALLBACK (location_menu_item_activated_callback),g_signal_connect_data ((menu_item), ("activate"), (((GCallback
) (location_menu_item_activated_callback))), (window), ((void
*)0), (GConnectFlags) 0)
683 window)g_signal_connect_data ((menu_item), ("activate"), (((GCallback
) (location_menu_item_activated_callback))), (window), ((void
*)0), (GConnectFlags) 0)
;
684
685 g_object_set_data_full (G_OBJECT (menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu_item)), (((GType) ((20) << (2))))))))
,
686 "location",
687 g_object_ref (location)((__typeof__ (location)) (g_object_ref) (location)),
688 (GDestroyNotify)g_object_unref);
689
690 if (child_location) {
691 g_object_set_data_full (G_OBJECT (menu_item)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((menu_item)), (((GType) ((20) << (2))))))))
,
692 "child_location",
693 g_object_ref (child_location)((__typeof__ (child_location)) (g_object_ref) (child_location
))
,
694 (GDestroyNotify)g_object_unref);
695 }
696
697 ctk_menu_shell_prepend (CTK_MENU_SHELL (popup)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((ctk_menu_shell_get_type ()))))))
, menu_item);
698
699 if (child_location) {
700 g_object_unref (child_location);
701 }
702 child_location = location;
703 location = g_file_get_parent (location);
704 }
705
706 if (child_location) {
707 g_object_unref (child_location);
708 }
709 if (location) {
710 g_object_unref (location);
This statement is never executed
711 }
712
713 ctk_menu_set_screen (CTK_MENU (popup)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((ctk_menu_get_type ()))))))
, ctk_widget_get_screen (widget));
714
715 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
716
717 g_signal_connect (popup, "deactivate",g_signal_connect_data ((popup), ("deactivate"), (((GCallback)
(menu_deactivate_callback))), (loop), ((void*)0), (GConnectFlags
) 0)
718 G_CALLBACK (menu_deactivate_callback),g_signal_connect_data ((popup), ("deactivate"), (((GCallback)
(menu_deactivate_callback))), (loop), ((void*)0), (GConnectFlags
) 0)
719 loop)g_signal_connect_data ((popup), ("deactivate"), (((GCallback)
(menu_deactivate_callback))), (loop), ((void*)0), (GConnectFlags
) 0)
;
720
721 ctk_grab_add (popup);
722 ctk_menu_popup_at_widget (CTK_MENU (popup)((((CtkMenu*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((ctk_menu_get_type ()))))))
,
723 widget,
724 CDK_GRAVITY_SOUTH_WEST,
725 CDK_GRAVITY_NORTH_WEST,
726 NULL((void*)0));
727
728 ctk_menu_shell_select_item (CTK_MENU_SHELL (popup)((((CtkMenuShell*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((popup)), ((ctk_menu_shell_get_type ()))))))
, first_item);
729 g_main_loop_run (loop);
730 ctk_grab_remove (popup);
731 g_main_loop_unref (loop);
732 g_object_ref_sink (popup)((__typeof__ (popup)) (g_object_ref_sink) (popup));
733 g_object_unref (popup);
734}
735
736static int
737get_dnd_icon_size (BaulSpatialWindow *window)
738{
739 BaulWindowSlot *active_slot;
740 BaulView *view;
741 BaulZoomLevel zoom_level;
742
743 active_slot = baul_window_get_active_slot (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
);
744 view = active_slot->content_view;
745
746 if (view == NULL((void*)0))
747 {
748 return BAUL_ICON_SIZE_STANDARD48;
749 }
750 else
751 {
752 zoom_level = baul_view_get_zoom_level (view);
753 return baul_get_icon_size_for_zoom_level (zoom_level);
754 }
755}
756
757static void
758location_button_drag_begin_callback (CtkWidget *widget,
759 CdkDragContext *context,
760 BaulSpatialWindow *window)
761{
762 BaulWindowSlot *slot;
763 cairo_surface_t *surface;
764
765 slot = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
->details->active_pane->active_slot;
766
767 surface = baul_file_get_icon_surface (slot->viewed_file,
768 get_dnd_icon_size (window),
769 FALSE(0),
770 ctk_widget_get_scale_factor (widget),
771 BAUL_FILE_ICON_FLAGS_IGNORE_VISITING | BAUL_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT);
772
773 ctk_drag_set_icon_surface (context, surface);
774
775 cairo_surface_destroy (surface);
776}
777
778/* build CAFE icon list, which only contains the window's URI.
779 * If we just used URIs, moving the folder to trash
780 * wouldn't work */
781static void
782get_data_binder (BaulDragEachSelectedItemDataGet iteratee,
783 gpointer iterator_context,
784 gpointer data)
785{
786 BaulSpatialWindow *window;
787 BaulWindowSlot *slot;
788 char *location;
789 int icon_size;
790
791 g_assert (BAUL_IS_SPATIAL_WINDOW (iterator_context))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((iterator_context)); GType __t = (baul_spatial_window_get_type
()); gboolean __r; if (!__inst) __r = (0); else if (__inst->
g_class && __inst->g_class->g_type == __t) __r =
(!(0)); else __r = g_type_check_instance_is_a (__inst, __t);
__r; }))))) ; else g_assertion_message_expr (((gchar*) 0), "baul-spatial-window.c"
, 791, ((const char*) (__func__)), "BAUL_IS_SPATIAL_WINDOW (iterator_context)"
); } while (0)
;
792 window = BAUL_SPATIAL_WINDOW (iterator_context)((((BaulSpatialWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((iterator_context)), (baul_spatial_window_get_type
())))))
;
793
794 slot = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
->details->active_pane->active_slot;
795
796 location = baul_window_slot_get_location_uri (slot);
797 icon_size = get_dnd_icon_size (window);
798
799 iteratee (location,
800 0,
801 0,
802 icon_size,
803 icon_size,
804 data);
805
806 g_free (location);
807}
808
809static void
810location_button_drag_data_get_callback (CtkWidget *widget,
811 CdkDragContext *context,
812 CtkSelectionData *selection_data,
813 guint info,
814 guint time,
815 BaulSpatialWindow *window)
816{
817 baul_drag_drag_data_get (widget, context, selection_data,
818 info, time, window, get_data_binder);
819}
820
821void
822baul_spatial_window_set_location_button (BaulSpatialWindow *window,
823 GFile *location)
824{
825 if (location != NULL((void*)0))
826 {
827 BaulFile *file;
828 char *name;
829 GError *error;
830
831 file = baul_file_get (location);
832
833 /* FIXME: monitor for name change... */
834 name = baul_file_get_display_name (file);
835 ctk_label_set_label (CTK_LABEL (window->details->location_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_label)), ((ctk_label_get_type
()))))))
,
836 name);
837 g_free (name);
838 ctk_widget_set_sensitive (window->details->location_button, TRUE(!(0)));
839
840 error = baul_file_get_file_info_error (file);
841 if (error == NULL((void*)0))
842 {
843 cairo_surface_t *surface;
844
845 surface = baul_file_get_icon_surface (file,
846 baul_get_icon_size_for_stock_size (CTK_ICON_SIZE_MENU),
847 TRUE(!(0)),
848 ctk_widget_get_scale_factor (window->details->location_button),
849 BAUL_FILE_ICON_FLAGS_IGNORE_VISITING);
850
851 if (surface != NULL((void*)0))
852 {
853 ctk_image_set_from_surface (CTK_IMAGE (window->details->location_icon)((((CtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_icon)), ((ctk_image_get_type
()))))))
, surface);
854 cairo_surface_destroy (surface);
855 }
856 else
857 {
858 ctk_image_set_from_icon_name (CTK_IMAGE (window->details->location_icon)((((CtkImage*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_icon)), ((ctk_image_get_type
()))))))
,
859 "document-open", CTK_ICON_SIZE_MENU);
860 }
861 }
862 g_object_unref (file);
863
864 }
865 else
866 {
867 ctk_label_set_label (CTK_LABEL (window->details->location_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_label)), ((ctk_label_get_type
()))))))
,
868 "");
869 ctk_widget_set_sensitive (window->details->location_button, FALSE(0));
870 }
871}
872
873static void
874action_go_to_location_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
875 gpointer user_data)
876{
877 BaulWindow *window;
878
879 window = BAUL_WINDOW (user_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (baul_window_get_type())))))
;
880
881 baul_window_prompt_for_location (window, NULL((void*)0));
882}
883
884static void
885action_add_bookmark_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
886 gpointer user_data)
887{
888 BaulWindow *window;
889
890 window = BAUL_WINDOW (user_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (baul_window_get_type())))))
;
891
892 if (!BAUL_IS_DESKTOP_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_desktop_window_get_type()); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; }))))
) /* don't bookmark x-baul-desktop:/// */
893 {
894 baul_window_add_bookmark_for_current_location (window);
895 }
896}
897
898static void
899action_edit_bookmarks_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
900 gpointer user_data)
901{
902 baul_window_edit_bookmarks (BAUL_WINDOW (user_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (baul_window_get_type())))))
);
903}
904
905static void
906action_search_callback (CtkAction *action G_GNUC_UNUSED__attribute__ ((__unused__)),
907 gpointer user_data)
908{
909 BaulWindow *window;
910 char *uri;
911 GFile *f;
912
913 window = BAUL_WINDOW (user_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (baul_window_get_type())))))
;
914
915 uri = baul_search_directory_generate_new_uri ();
916 f = g_file_new_for_uri (uri);
917 baul_window_go_to (window, f);
918 g_object_unref (f);
919 g_free (uri);
920}
921
922static const CtkActionEntry spatial_entries[] =
923{
924 /* name, icon name, label */ { SPATIAL_ACTION_PLACES"Places", NULL((void*)0), N_("_Places")("_Places") },
925 /* name, icon name, label */ {
926 SPATIAL_ACTION_GO_TO_LOCATION"Go to Location", NULL((void*)0), N_("Open _Location...")("Open _Location..."),
927 "<control>L", N_("Specify a location to open")("Specify a location to open"),
928 G_CALLBACK (action_go_to_location_callback)((GCallback) (action_go_to_location_callback))
929 },
930 /* name, icon name, label */ {
931 SPATIAL_ACTION_CLOSE_PARENT_FOLDERS"Close Parent Folders", NULL((void*)0), N_("Close P_arent Folders")("Close P_arent Folders"),
932 "<control><shift>W", N_("Close this folder's parents")("Close this folder's parents"),
933 G_CALLBACK (action_close_parent_folders_callback)((GCallback) (action_close_parent_folders_callback))
934 },
935 /* name, icon name, label */ {
936 SPATIAL_ACTION_CLOSE_ALL_FOLDERS"Close All Folders", NULL((void*)0), N_("Clos_e All Folders")("Clos_e All Folders"),
937 "<control>Q", N_("Close all folder windows")("Close all folder windows"),
938 G_CALLBACK (action_close_all_folders_callback)((GCallback) (action_close_all_folders_callback))
939 },
940 /* name, icon name, label */ { "Add Bookmark", "list-add", N_("_Add Bookmark")("_Add Bookmark"),
941 "<control>d", N_("Add a bookmark for the current location to this menu")("Add a bookmark for the current location to this menu"),
942 G_CALLBACK (action_add_bookmark_callback)((GCallback) (action_add_bookmark_callback))
943 },
944 /* name, icon name, label */ { "Edit Bookmarks", NULL((void*)0), N_("_Edit Bookmarks...")("_Edit Bookmarks..."),
945 "<control>b", N_("Display a window that allows editing the bookmarks in this menu")("Display a window that allows editing the bookmarks in this menu"
)
,
946 G_CALLBACK (action_edit_bookmarks_callback)((GCallback) (action_edit_bookmarks_callback))
947 },
948 /* name, icon name, label */ { "Search", "edit-find", N_("_Search for Files...")("_Search for Files..."),
949 "<control>F", N_("Locate documents and folders on this computer by name or content")("Locate documents and folders on this computer by name or content"
)
,
950 G_CALLBACK (action_search_callback)((GCallback) (action_search_callback))
951 },
952};
953
954static void
955baul_spatial_window_init (BaulSpatialWindow *window)
956{
957 CtkWidget *arrow;
958 CtkWidget *hbox, *vbox;
959 CtkActionGroup *action_group;
960 CtkUIManager *ui_manager;
961 CtkTargetList *targets;
962 const char *ui;
963 BaulWindow *win;
964 BaulWindowPane *pane;
965
966 window->details = baul_spatial_window_get_instance_private (window);
967
968 win = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
;
969
970 ctk_widget_set_hexpand (win->details->statusbar, TRUE(!(0)));
971 ctk_grid_attach (CTK_GRID (win->details->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((win->details->grid)), ((ctk_grid_get_type ()))))))
,
972 win->details->statusbar,
973 0, 5, 1, 1);
974 ctk_widget_show (win->details->statusbar);
975
976 pane = baul_window_pane_new (win);
977 win->details->panes = g_list_prepend (win->details->panes, pane);
978
979 vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0);
980 ctk_box_set_homogeneous (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((ctk_box_get_type ()))))))
, TRUE(!(0)));
981 ctk_widget_set_hexpand (vbox, TRUE(!(0)));
982 ctk_widget_set_vexpand (vbox, TRUE(!(0)));
983 ctk_grid_attach (CTK_GRID (BAUL_WINDOW (window)->details->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))->details->grid
)), ((ctk_grid_get_type ()))))))
,
984 vbox,
985 0, 1, 1, 3);
986
987 ctk_widget_show (vbox);
988 window->details->content_box = vbox;
989
990 window->details->location_button = ctk_button_new ();
991 g_signal_connect (window->details->location_button,g_signal_connect_data ((window->details->location_button
), ("button-press-event"), (((GCallback) (location_button_pressed_callback
))), (window), ((void*)0), (GConnectFlags) 0)
992 "button-press-event",g_signal_connect_data ((window->details->location_button
), ("button-press-event"), (((GCallback) (location_button_pressed_callback
))), (window), ((void*)0), (GConnectFlags) 0)
993 G_CALLBACK (location_button_pressed_callback),g_signal_connect_data ((window->details->location_button
), ("button-press-event"), (((GCallback) (location_button_pressed_callback
))), (window), ((void*)0), (GConnectFlags) 0)
994 window)g_signal_connect_data ((window->details->location_button
), ("button-press-event"), (((GCallback) (location_button_pressed_callback
))), (window), ((void*)0), (GConnectFlags) 0)
;
995 ctk_button_set_relief (CTK_BUTTON (window->details->location_button)((((CtkButton*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_button)), ((ctk_button_get_type
()))))))
,
996 CTK_RELIEF_NORMAL);
997
998 ctk_widget_show (window->details->location_button);
999 hbox = ctk_box_new (CTK_ORIENTATION_HORIZONTAL, 3);
1000 ctk_container_add (CTK_CONTAINER (window->details->location_button)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_button)), ((ctk_container_get_type
()))))))
,
1001 hbox);
1002 ctk_widget_show (hbox);
1003
1004 window->details->location_icon = ctk_image_new_from_icon_name ("document-open", CTK_ICON_SIZE_MENU);
1005 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, window->details->location_icon, FALSE(0), FALSE(0), 0);
1006 ctk_widget_show (window->details->location_icon);
1007
1008 window->details->location_label = ctk_label_new ("");
1009 ctk_label_set_ellipsize (CTK_LABEL (window->details->location_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_label)), ((ctk_label_get_type
()))))))
, PANGO_ELLIPSIZE_END);
1010 ctk_label_set_max_width_chars (CTK_LABEL (window->details->location_label)((((CtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->details->location_label)), ((ctk_label_get_type
()))))))
, MAX_SHORTNAME_PATH16);
1011 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, window->details->location_label,
1012 FALSE(0), FALSE(0), 0);
1013 ctk_widget_show (window->details->location_label);
1014
1015 arrow = ctk_image_new_from_icon_name ("pan-down-symbolic", CTK_ICON_SIZE_BUTTON);
1016 ctk_box_pack_start (CTK_BOX (hbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox)), ((ctk_box_get_type ()))))))
, arrow, FALSE(0), FALSE(0), 0);
1017 ctk_widget_show (arrow);
1018
1019 ctk_drag_source_set (window->details->location_button,
1020 CDK_BUTTON1_MASK | CDK_BUTTON2_MASK, location_button_drag_types,
1021 G_N_ELEMENTS (location_button_drag_types)(sizeof (location_button_drag_types) / sizeof ((location_button_drag_types
)[0]))
,
1022 CDK_ACTION_MOVE | CDK_ACTION_COPY | CDK_ACTION_LINK | CDK_ACTION_ASK);
1023 g_signal_connect (window->details->location_button,g_signal_connect_data ((window->details->location_button
), ("drag_begin"), (((GCallback) (location_button_drag_begin_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1024 "drag_begin",g_signal_connect_data ((window->details->location_button
), ("drag_begin"), (((GCallback) (location_button_drag_begin_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1025 G_CALLBACK (location_button_drag_begin_callback),g_signal_connect_data ((window->details->location_button
), ("drag_begin"), (((GCallback) (location_button_drag_begin_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1026 window)g_signal_connect_data ((window->details->location_button
), ("drag_begin"), (((GCallback) (location_button_drag_begin_callback
))), (window), ((void*)0), (GConnectFlags) 0)
;
1027 g_signal_connect (window->details->location_button,g_signal_connect_data ((window->details->location_button
), ("drag_data_get"), (((GCallback) (location_button_drag_data_get_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1028 "drag_data_get",g_signal_connect_data ((window->details->location_button
), ("drag_data_get"), (((GCallback) (location_button_drag_data_get_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1029 G_CALLBACK (location_button_drag_data_get_callback),g_signal_connect_data ((window->details->location_button
), ("drag_data_get"), (((GCallback) (location_button_drag_data_get_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1030 window)g_signal_connect_data ((window->details->location_button
), ("drag_data_get"), (((GCallback) (location_button_drag_data_get_callback
))), (window), ((void*)0), (GConnectFlags) 0)
;
1031
1032 targets = ctk_drag_source_get_target_list (window->details->location_button);
1033 ctk_target_list_add_text_targets (targets, BAUL_ICON_DND_TEXT);
1034
1035 ctk_widget_set_sensitive (window->details->location_button, FALSE(0));
1036 g_signal_connect (window->details->location_button,g_signal_connect_data ((window->details->location_button
), ("clicked"), (((GCallback) (location_button_clicked_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1037 "clicked",g_signal_connect_data ((window->details->location_button
), ("clicked"), (((GCallback) (location_button_clicked_callback
))), (window), ((void*)0), (GConnectFlags) 0)
1038 G_CALLBACK (location_button_clicked_callback), window)g_signal_connect_data ((window->details->location_button
), ("clicked"), (((GCallback) (location_button_clicked_callback
))), (window), ((void*)0), (GConnectFlags) 0)
;
1039 ctk_box_pack_start (CTK_BOX (BAUL_WINDOW (window)->details->statusbar)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))->details->statusbar
)), ((ctk_box_get_type ()))))))
,
1040 window->details->location_button,
1041 FALSE(0), TRUE(!(0)), 0);
1042
1043 ctk_box_reorder_child (CTK_BOX (BAUL_WINDOW (window)->details->statusbar)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))->details->statusbar
)), ((ctk_box_get_type ()))))))
,
1044 window->details->location_button, 0);
1045
1046 action_group = ctk_action_group_new ("SpatialActions");
1047 ctk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE"baul");
1048 window->details->spatial_action_group = action_group;
1049 ctk_action_group_add_actions (action_group,
1050 spatial_entries, G_N_ELEMENTS (spatial_entries)(sizeof (spatial_entries) / sizeof ((spatial_entries)[0])),
1051 window);
1052
1053 ui_manager = baul_window_get_ui_manager (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
);
1054 ctk_ui_manager_insert_action_group (ui_manager, action_group, 0);
1055 g_object_unref (action_group); /* owned by ui manager */
1056
1057 ui = baul_ui_string_get ("baul-spatial-window-ui.xml");
1058 ctk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL((void*)0));
1059
1060 baul_window_set_active_pane (win, pane);
1061}
1062
1063static void
1064baul_spatial_window_class_init (BaulSpatialWindowClass *klass)
1065{
1066 CtkBindingSet *binding_set;
1067 BaulWindowClass *nclass = BAUL_WINDOW_CLASS (klass)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (baul_window_get_type())))))
;
1068 CtkWidgetClass *wclass = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((ctk_widget_get_type ()))))))
;
1069
1070 nclass->window_type = BAUL_WINDOW_SPATIAL;
1071 nclass->bookmarks_placeholder = MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER"/MenuBar/Other Menus/Places/Bookmarks Placeholder";
1072 nclass->prompt_for_location = real_prompt_for_location;
1073 nclass->get_icon = real_get_icon;
1074 nclass->sync_title = real_sync_title;
1075 nclass->get_min_size = real_get_min_size;
1076 nclass->get_default_size = real_get_default_size;
1077 nclass->sync_allow_stop = real_sync_allow_stop;
1078 nclass->set_allow_up = real_set_allow_up;
1079 nclass->open_slot = real_open_slot;
1080 nclass->close = real_window_close;
1081 nclass->close_slot = real_close_slot;
1082
1083 wclass->show = baul_spatial_window_show;
1084 wclass->configure_event = baul_spatial_window_configure_event;
1085 wclass->unrealize = baul_spatial_window_unrealize;
1086 wclass->window_state_event = baul_spatial_window_state_event;
1087
1088 G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
->finalize = baul_spatial_window_finalize;
1089
1090 binding_set = ctk_binding_set_by_class (klass);
1091 ctk_binding_entry_add_signal (binding_set, CDK_KEY_BackSpace0xff08, CDK_SHIFT_MASK,
1092 "go_up", 1,
1093 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)));
1094 ctk_binding_entry_add_signal (binding_set, CDK_KEY_Up0xff52, CDK_SHIFT_MASK | CDK_MOD1_MASK,
1095 "go_up", 1,
1096 G_TYPE_BOOLEAN((GType) ((5) << (2))), TRUE(!(0)));
1097}