Bug Summary

File:src/baul-window-manage-views.c
Warning:line 2209, column 104
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error')

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-window-manage-views.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 -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib/llvm-16/lib/clang/16 -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="1.25.0" -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -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.core.SizeofPtr -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/2024-07-10-202347-28295-1 -x c baul-window-manage-views.c
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * Darin Adler <darin@bentspoon.com>
26 */
27
28#include <config.h>
29
30#include <ctk/ctk.h>
31#include <cdk/cdkx.h>
32#include <glib/gi18n.h>
33
34#include <eel/eel-accessibility.h>
35#include <eel/eel-debug.h>
36#include <eel/eel-cdk-extensions.h>
37#include <eel/eel-glib-extensions.h>
38#include <eel/eel-ctk-extensions.h>
39#include <eel/eel-ctk-macros.h>
40#include <eel/eel-stock-dialogs.h>
41#include <eel/eel-string.h>
42#include <eel/eel-vfs-extensions.h>
43
44#include <libbaul-private/baul-debug-log.h>
45#include <libbaul-private/baul-extensions.h>
46#include <libbaul-private/baul-file-attributes.h>
47#include <libbaul-private/baul-file-utilities.h>
48#include <libbaul-private/baul-file.h>
49#include <libbaul-private/baul-global-preferences.h>
50#include <libbaul-private/baul-metadata.h>
51#include <libbaul-private/baul-mime-actions.h>
52#include <libbaul-private/baul-module.h>
53#include <libbaul-private/baul-monitor.h>
54#include <libbaul-private/baul-search-directory.h>
55#include <libbaul-private/baul-view-factory.h>
56#include <libbaul-private/baul-window-info.h>
57#include <libbaul-private/baul-window-slot-info.h>
58#include <libbaul-private/baul-autorun.h>
59
60#include <libbaul-extension/baul-location-widget-provider.h>
61
62#include "baul-window-manage-views.h"
63#include "baul-actions.h"
64#include "baul-application.h"
65#include "baul-location-bar.h"
66#include "baul-search-bar.h"
67#include "baul-pathbar.h"
68#include "baul-window-private.h"
69#include "baul-window-slot.h"
70#include "baul-navigation-window-slot.h"
71#include "baul-trash-bar.h"
72#include "baul-x-content-bar.h"
73#include "baul-navigation-window-pane.h"
74
75/* FIXME bugzilla.gnome.org 41243:
76 * We should use inheritance instead of these special cases
77 * for the desktop window.
78 */
79#include "baul-desktop-window.h"
80
81/* This number controls a maximum character count for a URL that is
82 * displayed as part of a dialog. It's fairly arbitrary -- big enough
83 * to allow most "normal" URIs to display in full, but small enough to
84 * prevent the dialog from getting insanely wide.
85 */
86#define MAX_URI_IN_DIALOG_LENGTH60 60
87
88static void begin_location_change (BaulWindowSlot *slot,
89 GFile *location,
90 GFile *previous_location,
91 GList *new_selection,
92 BaulLocationChangeType type,
93 guint distance,
94 const char *scroll_pos,
95 BaulWindowGoToCallback callback,
96 gpointer user_data);
97static void free_location_change (BaulWindowSlot *slot);
98static void end_location_change (BaulWindowSlot *slot);
99static void cancel_location_change (BaulWindowSlot *slot);
100static void got_file_info_for_view_selection_callback (BaulFile *file,
101 gpointer callback_data);
102static void create_content_view (BaulWindowSlot *slot,
103 const char *view_id);
104static void display_view_selection_failure (BaulWindow *window,
105 BaulFile *file,
106 GFile *location,
107 GError *error);
108static void load_new_location (BaulWindowSlot *slot,
109 GFile *location,
110 GList *selection,
111 gboolean tell_current_content_view,
112 gboolean tell_new_content_view);
113static void location_has_really_changed (BaulWindowSlot *slot);
114static void update_for_new_location (BaulWindowSlot *slot);
115
116void
117baul_window_report_selection_changed (BaulWindowInfo *window)
118{
119 if (window->details->temporarily_ignore_view_signals)
120 {
121 return;
122 }
123
124 g_signal_emit_by_name (window, "selection_changed");
125}
126
127/* set_displayed_location:
128 */
129static void
130set_displayed_location (BaulWindowSlot *slot, GFile *location)
131{
132 gboolean recreate;
133
134 if (slot->current_location_bookmark == NULL((void*)0) || location == NULL((void*)0))
135 {
136 recreate = TRUE(!(0));
137 }
138 else
139 {
140 GFile *bookmark_location;
141
142 bookmark_location = baul_bookmark_get_location (slot->current_location_bookmark);
143 recreate = !g_file_equal (bookmark_location, location);
144 g_object_unref (bookmark_location);
145 }
146
147 if (recreate)
148 {
149 char *name;
150
151 /* We've changed locations, must recreate bookmark for current location. */
152 if (slot->last_location_bookmark != NULL((void*)0))
153 {
154 g_object_unref (slot->last_location_bookmark);
155 }
156 slot->last_location_bookmark = slot->current_location_bookmark;
157 name = g_file_get_basename (location);
158 slot->current_location_bookmark = (location == NULL((void*)0)) ? NULL((void*)0)
159 : baul_bookmark_new (location, name, FALSE(0), NULL((void*)0));
160 g_free (name);
161 }
162}
163
164static void
165check_bookmark_location_matches (BaulBookmark *bookmark, GFile *location)
166{
167 GFile *bookmark_location;
168
169 bookmark_location = baul_bookmark_get_location (bookmark);
170 if (!g_file_equal (location, bookmark_location))
171 {
172 char *bookmark_uri, *uri;
173
174 bookmark_uri = g_file_get_uri (bookmark_location);
175 uri = g_file_get_uri (location);
176 g_warning ("bookmark uri is %s, but expected %s", bookmark_uri, uri);
177 g_free (uri);
178 g_free (bookmark_uri);
179 }
180 g_object_unref (bookmark_location);
181}
182
183/* Debugging function used to verify that the last_location_bookmark
184 * is in the state we expect when we're about to use it to update the
185 * Back or Forward list.
186 */
187static void
188check_last_bookmark_location_matches_slot (BaulWindowSlot *slot)
189{
190 check_bookmark_location_matches (slot->last_location_bookmark,
191 slot->location);
192}
193
194static void
195handle_go_back (BaulNavigationWindowSlot *navigation_slot,
196 GFile *location)
197{
198 BaulWindowSlot *slot;
199 guint i;
200 GList *link;
201 BaulBookmark *bookmark = NULL((void*)0);
202
203 slot = BAUL_WINDOW_SLOT (navigation_slot)((((BaulWindowSlot*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((navigation_slot)), ((baul_window_slot_get_type()))))))
;
204
205 /* Going back. Move items from the back list to the forward list. */
206 g_assert (g_list_length (navigation_slot->back_list) > slot->location_change_distance)do { if (g_list_length (navigation_slot->back_list) > slot
->location_change_distance) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 206, ((const char
*) (__func__)), "g_list_length (navigation_slot->back_list) > slot->location_change_distance"
); } while (0)
;
207 check_bookmark_location_matches (BAUL_BOOKMARK (g_list_nth_data (navigation_slot->back_list,((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_list_nth_data (navigation_slot->back_list, slot->
location_change_distance))), (baul_bookmark_get_type())))))
208 slot->location_change_distance))((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_list_nth_data (navigation_slot->back_list, slot->
location_change_distance))), (baul_bookmark_get_type())))))
,
209 location);
210 g_assert (slot->location != NULL)do { if (slot->location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 210, ((const char
*) (__func__)), "slot->location != NULL"); } while (0)
;
211
212 /* Move current location to Forward list */
213
214 check_last_bookmark_location_matches_slot (slot);
215
216 /* Use the first bookmark in the history list rather than creating a new one. */
217 navigation_slot->forward_list = g_list_prepend (navigation_slot->forward_list,
218 slot->last_location_bookmark);
219 g_object_ref (navigation_slot->forward_list->data)((__typeof__ (navigation_slot->forward_list->data)) (g_object_ref
) (navigation_slot->forward_list->data))
;
220
221 /* Move extra links from Back to Forward list */
222 for (i = 0; i < slot->location_change_distance; ++i)
223 {
224 bookmark = BAUL_BOOKMARK (navigation_slot->back_list->data)((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((navigation_slot->back_list->data)), (baul_bookmark_get_type
())))))
;
225 navigation_slot->back_list =
226 g_list_remove (navigation_slot->back_list, bookmark);
227 navigation_slot->forward_list =
228 g_list_prepend (navigation_slot->forward_list, bookmark);
229 }
230
231 /* One bookmark falls out of back/forward lists and becomes viewed location */
232 link = navigation_slot->back_list;
233 navigation_slot->back_list = g_list_remove_link (navigation_slot->back_list, link);
234 g_object_unref (link->data);
235 g_list_free_1 (link);
236}
237
238static void
239handle_go_forward (BaulNavigationWindowSlot *navigation_slot,
240 GFile *location)
241{
242 BaulWindowSlot *slot;
243 guint i;
244 GList *link;
245 BaulBookmark *bookmark = NULL((void*)0);
246
247 slot = BAUL_WINDOW_SLOT (navigation_slot)((((BaulWindowSlot*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((navigation_slot)), ((baul_window_slot_get_type()))))))
;
248
249 /* Going forward. Move items from the forward list to the back list. */
250 g_assert (g_list_length (navigation_slot->forward_list) > slot->location_change_distance)do { if (g_list_length (navigation_slot->forward_list) >
slot->location_change_distance) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 250, ((const char
*) (__func__)), "g_list_length (navigation_slot->forward_list) > slot->location_change_distance"
); } while (0)
;
251 check_bookmark_location_matches (BAUL_BOOKMARK (g_list_nth_data (navigation_slot->forward_list,((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_list_nth_data (navigation_slot->forward_list, slot->
location_change_distance))), (baul_bookmark_get_type())))))
252 slot->location_change_distance))((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_list_nth_data (navigation_slot->forward_list, slot->
location_change_distance))), (baul_bookmark_get_type())))))
,
253 location);
254 g_assert (slot->location != NULL)do { if (slot->location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 254, ((const char
*) (__func__)), "slot->location != NULL"); } while (0)
;
255
256 /* Move current location to Back list */
257 check_last_bookmark_location_matches_slot (slot);
258
259 /* Use the first bookmark in the history list rather than creating a new one. */
260 navigation_slot->back_list = g_list_prepend (navigation_slot->back_list,
261 slot->last_location_bookmark);
262 g_object_ref (navigation_slot->back_list->data)((__typeof__ (navigation_slot->back_list->data)) (g_object_ref
) (navigation_slot->back_list->data))
;
263
264 /* Move extra links from Forward to Back list */
265 for (i = 0; i < slot->location_change_distance; ++i)
266 {
267 bookmark = BAUL_BOOKMARK (navigation_slot->forward_list->data)((((BaulBookmark*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((navigation_slot->forward_list->data)), (baul_bookmark_get_type
())))))
;
268 navigation_slot->forward_list =
269 g_list_remove (navigation_slot->back_list, bookmark);
270 navigation_slot->back_list =
271 g_list_prepend (navigation_slot->forward_list, bookmark);
272 }
273
274 /* One bookmark falls out of back/forward lists and becomes viewed location */
275 link = navigation_slot->forward_list;
276 navigation_slot->forward_list = g_list_remove_link (navigation_slot->forward_list, link);
277 g_object_unref (link->data);
278 g_list_free_1 (link);
279}
280
281static void
282handle_go_elsewhere (BaulWindowSlot *slot, GFile *location)
283{
284 if (BAUL_IS_NAVIGATION_WINDOW_SLOT (slot)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(slot)); GType __t = ((baul_navigation_window_slot_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; }))))
)
285 {
286 BaulNavigationWindowSlot *navigation_slot;
287
288 navigation_slot = BAUL_NAVIGATION_WINDOW_SLOT (slot)((((BaulNavigationWindowSlot*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((slot)), ((baul_navigation_window_slot_get_type
()))))))
;
289
290 /* Clobber the entire forward list, and move displayed location to back list */
291 baul_navigation_window_slot_clear_forward_list (navigation_slot);
292
293 if (slot->location != NULL((void*)0))
294 {
295 /* If we're returning to the same uri somehow, don't put this uri on back list.
296 * This also avoids a problem where set_displayed_location
297 * didn't update last_location_bookmark since the uri didn't change.
298 */
299 if (!g_file_equal (slot->location, location))
300 {
301 /* Store bookmark for current location in back list, unless there is no current location */
302 check_last_bookmark_location_matches_slot (slot);
303 /* Use the first bookmark in the history list rather than creating a new one. */
304 navigation_slot->back_list = g_list_prepend (navigation_slot->back_list,
305 slot->last_location_bookmark);
306 g_object_ref (navigation_slot->back_list->data)((__typeof__ (navigation_slot->back_list->data)) (g_object_ref
) (navigation_slot->back_list->data))
;
307 }
308 }
309 }
310}
311
312void
313baul_window_update_up_button (BaulWindow *window)
314{
315 BaulWindowSlot *slot;
316 gboolean allowed;
317 GFile *parent;
318
319 slot = window->details->active_pane->active_slot;
320
321 allowed = FALSE(0);
322 if (slot->location != NULL((void*)0))
323 {
324 parent = g_file_get_parent (slot->location);
325 allowed = parent != NULL((void*)0);
326 if (parent != NULL((void*)0))
327 {
328 g_object_unref (parent);
329 }
330 }
331
332 baul_window_allow_up (window, allowed);
333}
334
335static void
336viewed_file_changed_callback (BaulFile *file,
337 BaulWindowSlot *slot)
338{
339 BaulWindow *window;
340 GFile *new_location;
341 gboolean is_in_trash, was_in_trash;
342
343 window = slot->pane->window;
344
345 g_assert (BAUL_IS_FILE (file))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((file)); GType __t = (baul_file_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-window-manage-views.c"
, 345, ((const char*) (__func__)), "BAUL_IS_FILE (file)"); } while
(0)
;
346 g_assert (BAUL_IS_WINDOW_PANE (slot->pane))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot->pane)); GType __t = ((baul_window_pane_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-window-manage-views.c"
, 346, ((const char*) (__func__)), "BAUL_IS_WINDOW_PANE (slot->pane)"
); } while (0)
;
347 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 347, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)")
; } while (0)
;
348
349 g_assert (file == slot->viewed_file)do { if (file == slot->viewed_file) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 349, ((const char
*) (__func__)), "file == slot->viewed_file"); } while (0)
;
350
351 if (!baul_file_is_not_yet_confirmed (file))
352 {
353 slot->viewed_file_seen = TRUE(!(0));
354 }
355
356 was_in_trash = slot->viewed_file_in_trash;
357
358 slot->viewed_file_in_trash = is_in_trash = baul_file_is_in_trash (file);
359
360 /* Close window if the file it's viewing has been deleted or moved to trash. */
361 if (baul_file_is_gone (file) || (is_in_trash && !was_in_trash))
362 {
363 /* Don't close the window in the case where the
364 * file was never seen in the first place.
365 */
366 if (slot->viewed_file_seen)
367 {
368 /* Detecting a file is gone may happen in the
369 * middle of a pending location change, we
370 * need to cancel it before closing the window
371 * or things break.
372 */
373 /* FIXME: It makes no sense that this call is
374 * needed. When the window is destroyed, it
375 * calls baul_window_manage_views_destroy,
376 * which calls free_location_change, which
377 * should be sufficient. Also, if this was
378 * really needed, wouldn't it be needed for
379 * all other baul_window_close callers?
380 */
381 end_location_change (slot);
382
383 if (BAUL_IS_NAVIGATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_navigation_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; }))))
)
384 {
385 /* auto-show existing parent. */
386 GFile *go_to_file, *parent, *location;
387
388 go_to_file = NULL((void*)0);
389 location = baul_file_get_location (file);
390 parent = g_file_get_parent (location);
391 g_object_unref (location);
392 if (parent)
393 {
394 go_to_file = baul_find_existing_uri_in_hierarchy (parent);
395 g_object_unref (parent);
396 }
397
398 if (go_to_file != NULL((void*)0))
399 {
400 /* the path bar URI will be set to go_to_uri immediately
401 * in begin_location_change, but we don't want the
402 * inexistant children to show up anymore */
403 if (slot == slot->pane->active_slot)
404 {
405 /* multiview-TODO also update BaulWindowSlot
406 * [which as of writing doesn't save/store any path bar state]
407 */
408 baul_path_bar_clear_buttons (BAUL_PATH_BAR (BAUL_NAVIGATION_WINDOW_PANE (slot->pane)->path_bar)((((BaulPathBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((slot->pane)), ((baul_navigation_window_pane_get_type
()))))))->path_bar)), ((baul_path_bar_get_type ()))))))
);
409 }
410
411 baul_window_slot_go_to (slot, go_to_file, FALSE)baul_window_slot_open_location_full(slot, go_to_file, BAUL_WINDOW_OPEN_ACCORDING_TO_MODE
, ((0) ? BAUL_WINDOW_OPEN_FLAG_NEW_TAB : 0), ((void*)0), ((void
*)0), ((void*)0))
;
412 g_object_unref (go_to_file);
413 }
414 else
415 {
416 baul_window_slot_go_home (slot, FALSE(0));
417 }
418 }
419 else
420 {
421 baul_window_close (window);
422 }
423 }
424 }
425 else
426 {
427 new_location = baul_file_get_location (file);
428
429 /* If the file was renamed, update location and/or
430 * title. */
431 if (!g_file_equal (new_location,
432 slot->location))
433 {
434 g_object_unref (slot->location);
435 slot->location = new_location;
436 if (slot == slot->pane->active_slot)
437 {
438 baul_window_pane_sync_location_widgets (slot->pane);
439 }
440 }
441 else
442 {
443 /* TODO?
444 * why do we update title & icon at all in this case? */
445 g_object_unref (new_location);
446 }
447
448 baul_window_slot_update_title (slot);
449 baul_window_slot_update_icon (slot);
450 }
451}
452
453static void
454update_history (BaulWindowSlot *slot,
455 BaulLocationChangeType type,
456 GFile *new_location)
457{
458 switch (type)
459 {
460 case BAUL_LOCATION_CHANGE_STANDARD:
461 case BAUL_LOCATION_CHANGE_FALLBACK:
462 baul_window_slot_add_current_location_to_history_list (slot);
463 handle_go_elsewhere (slot, new_location);
464 return;
465 case BAUL_LOCATION_CHANGE_RELOAD:
466 /* for reload there is no work to do */
467 return;
468 case BAUL_LOCATION_CHANGE_BACK:
469 baul_window_slot_add_current_location_to_history_list (slot);
470 handle_go_back (BAUL_NAVIGATION_WINDOW_SLOT (slot)((((BaulNavigationWindowSlot*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((slot)), ((baul_navigation_window_slot_get_type
()))))))
, new_location);
471 return;
472 case BAUL_LOCATION_CHANGE_FORWARD:
473 baul_window_slot_add_current_location_to_history_list (slot);
474 handle_go_forward (BAUL_NAVIGATION_WINDOW_SLOT (slot)((((BaulNavigationWindowSlot*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((slot)), ((baul_navigation_window_slot_get_type
()))))))
, new_location);
475 return;
476 case BAUL_LOCATION_CHANGE_REDIRECT:
477 /* for the redirect case, the caller can do the updating */
478 return;
479 }
480 g_return_if_fail (FALSE)do { if (((0))) { } else { g_return_if_fail_warning (((gchar*
) 0), ((const char*) (__func__)), "FALSE"); return; } } while
(0)
;
481}
482
483static void
484cancel_viewed_file_changed_callback (BaulWindowSlot *slot)
485{
486 BaulFile *file;
487
488 file = slot->viewed_file;
489 if (file != NULL((void*)0))
490 {
491 g_signal_handlers_disconnect_by_func (G_OBJECT (file),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((file)), (((GType
) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (viewed_file_changed_callback
))), (slot))
492 G_CALLBACK (viewed_file_changed_callback),g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((file)), (((GType
) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (viewed_file_changed_callback
))), (slot))
493 slot)g_signal_handlers_disconnect_matched ((((((GObject*) (void *)
g_type_check_instance_cast ((GTypeInstance*) ((file)), (((GType
) ((20) << (2))))))))), (GSignalMatchType) (G_SIGNAL_MATCH_FUNC
| G_SIGNAL_MATCH_DATA), 0, 0, ((void*)0), (((GCallback) (viewed_file_changed_callback
))), (slot))
;
494 baul_file_monitor_remove (file, &slot->viewed_file);
495 }
496}
497
498static void
499new_window_show_callback (CtkWidget *widget,
500 gpointer user_data)
501{
502 BaulWindow *window;
503
504 window = BAUL_WINDOW (user_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((user_data)), (baul_window_get_type())))))
;
505
506 baul_window_close (window);
507
508 g_signal_handlers_disconnect_by_func (widget,g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (new_window_show_callback))), (user_data))
509 G_CALLBACK (new_window_show_callback),g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (new_window_show_callback))), (user_data))
510 user_data)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (((GCallback) (new_window_show_callback))), (user_data))
;
511}
512
513
514void
515baul_window_slot_open_location_full (BaulWindowSlot *slot,
516 GFile *location,
517 BaulWindowOpenMode mode,
518 BaulWindowOpenFlags flags,
519 GList *new_selection,
520 BaulWindowGoToCallback callback,
521 gpointer user_data)
522{
523 BaulWindow *window;
524 BaulWindow *target_window;
525 BaulWindowPane *pane;
526 BaulWindowSlot *target_slot;
527 BaulWindowOpenFlags slot_flags;
528 gboolean existing = FALSE(0);
529 GFile *old_location;
530 char *old_uri, *new_uri;
531 GList *l;
532 gboolean target_navigation = FALSE(0);
533 gboolean target_same = FALSE(0);
534 gboolean is_desktop = FALSE(0);
535 gboolean is_navigation = FALSE(0);
536
537 window = slot->pane->window;
538
539 target_window = NULL((void*)0);
540 target_slot = NULL((void*)0);
541
542 old_uri = baul_window_slot_get_location_uri (slot);
543 if (old_uri == NULL((void*)0))
544 {
545 old_uri = g_strdup ("(none)")g_strdup_inline ("(none)");
546 }
547 new_uri = g_file_get_uri (location);
548 baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER",
549 "window %p open location: old=\"%s\", new=\"%s\"",
550 window,
551 old_uri,
552 new_uri);
553 g_free (old_uri);
554 g_free (new_uri);
555
556 g_assert (!((flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 &&do { if (!((flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0
&& (flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0)
) ; else g_assertion_message_expr (((gchar*) 0), "baul-window-manage-views.c"
, 557, ((const char*) (__func__)), "!((flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 && (flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0)"
); } while (0)
557 (flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0))do { if (!((flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0
&& (flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0)
) ; else g_assertion_message_expr (((gchar*) 0), "baul-window-manage-views.c"
, 557, ((const char*) (__func__)), "!((flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 && (flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0)"
); } while (0)
;
558
559 is_desktop = 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; }))))
;
560 is_navigation = BAUL_IS_NAVIGATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_navigation_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; }))))
;
561 target_same = is_desktop &&
562 !baul_desktop_window_loaded (BAUL_DESKTOP_WINDOW (window)((((BaulDesktopWindow*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((window)), (baul_desktop_window_get_type())
))))
);
563
564 old_location = baul_window_slot_get_location (slot);
565
566 switch (mode)
567 {
568 case BAUL_WINDOW_OPEN_ACCORDING_TO_MODE :
569 if (g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) {
570 /* always use browser: if we're on the desktop the target is a new navigation window,
571 * otherwise it's the same window.
572 */
573 if (is_desktop) {
574 new_uri = g_file_get_uri (location);
575 if (g_str_has_prefix (new_uri, EEL_DESKTOP_URI)(__builtin_constant_p ("x-baul-desktop:")? __extension__ ({ const
char * const __str = (new_uri); const char * const __prefix =
("x-baul-desktop:"); gboolean __result = (0); if (__str == (
(void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (new_uri, "x-baul-desktop:"
) )
)
576 target_same = TRUE(!(0));
577 else
578 target_navigation = TRUE(!(0));
579 g_free (new_uri);
580 } else {
581 target_same = TRUE(!(0));
582 }
583 } else if (flags & BAUL_WINDOW_OPEN_FLAG_NEW_WINDOW) {
584 /* if it's specified to open a new window, and we're not using spatial,
585 * the target is a navigation.
586 */
587 target_navigation = TRUE(!(0));
588 } else if (is_navigation) {
589 target_same = TRUE(!(0));
590 }
591 break;
592 case BAUL_WINDOW_OPEN_IN_NAVIGATION :
593 target_navigation = TRUE(!(0));
594 break;
595 default :
596 g_critical ("Unknown open location mode");
597 g_object_unref (old_location);
598 return;
599 }
600
601 /* now get/create the window according to the mode */
602 if (target_same) {
603 target_window = window;
604 } else if (target_navigation) {
605 target_window = baul_application_create_navigation_window
606 (window->application,
607 ctk_window_get_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
));
608 } else {
609 target_window = baul_application_get_spatial_window
610 (window->application,
611 window,
612 NULL((void*)0),
613 location,
614 ctk_window_get_screen (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
),
615 &existing);
616 }
617
618 /* if the spatial window is already showing, present it and set the
619 * new selection, if present.
620 */
621 if (existing) {
622 target_slot = target_window->details->active_pane->active_slot;
623
624 ctk_window_present (CTK_WINDOW (target_window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((target_window)), ((ctk_window_get_type ()))))))
);
625
626 if (new_selection != NULL((void*)0) && slot->content_view != NULL((void*)0)) {
627 baul_view_set_selection (target_slot->content_view, new_selection);
628 }
629
630 /* call the callback successfully */
631 if (callback != NULL((void*)0)) {
632 callback (window, NULL((void*)0), user_data);
633 }
634
635 return;
636 }
637
638 g_assert (target_window != NULL)do { if (target_window != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 638, ((const char
*) (__func__)), "target_window != NULL"); } while (0)
;
639
640 if ((flags & BAUL_WINDOW_OPEN_FLAG_NEW_TAB) != 0 &&
641 BAUL_IS_NAVIGATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_navigation_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; }))))
)
642 {
643 g_assert (target_window == window)do { if (target_window == window) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 643, ((const char
*) (__func__)), "target_window == window"); } while (0)
;
644
645 int new_slot_position;
646
647 slot_flags = 0;
648
649 new_slot_position = g_settings_get_enum (baul_preferences, BAUL_PREFERENCES_NEW_TAB_POSITION"tabs-open-position");
650 if (new_slot_position == BAUL_NEW_TAB_POSITION_END)
651 {
652 slot_flags = BAUL_WINDOW_OPEN_SLOT_APPEND;
653 }
654
655 target_slot = baul_window_open_slot (window->details->active_pane, slot_flags);
656 }
657
658 if ((flags & BAUL_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0)
659 {
660 if (BAUL_IS_SPATIAL_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); 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; }))))
&& !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; }))))
)
661 {
662 if (ctk_widget_get_visible (CTK_WIDGET (target_window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((target_window)), ((ctk_widget_get_type ()))))))
))
663 {
664 baul_window_close (window);
665 }
666 else
667 {
668 g_signal_connect_object (target_window,
669 "show",
670 G_CALLBACK (new_window_show_callback)((GCallback) (new_window_show_callback)),
671 window,
672 G_CONNECT_AFTER);
673 }
674 }
675 }
676
677 if (target_slot == NULL((void*)0))
678 {
679 if (target_window == window)
680 {
681 target_slot = slot;
682 }
683 else
684 {
685 target_slot = target_window->details->active_pane->active_slot;
686 }
687 }
688
689 if (!(is_desktop && target_same) && (target_window == window && target_slot == slot &&
690 old_location && g_file_equal (old_location, location))) {
691
692 if (callback != NULL((void*)0)) {
693 callback (window, NULL((void*)0), user_data);
694 }
695
696 g_object_unref (old_location);
697 return;
698 }
699
700 begin_location_change (target_slot, location, old_location, new_selection,
701 (is_desktop && target_same) ? BAUL_LOCATION_CHANGE_RELOAD : BAUL_LOCATION_CHANGE_STANDARD, 0, NULL((void*)0), callback, user_data);
702
703 /* Additionally, load this in all slots that have no location, this means
704 we load both panes in e.g. a newly opened dual pane window. */
705 for (l = target_window->details->panes; l != NULL((void*)0); l = l->next)
706 {
707 pane = l->data;
708 slot = pane->active_slot;
709 if (slot->location == NULL((void*)0) && slot->pending_location == NULL((void*)0)) {
710 begin_location_change (slot, location, old_location, new_selection,
711 BAUL_LOCATION_CHANGE_STANDARD, 0, NULL((void*)0), NULL((void*)0), NULL((void*)0));
712 }
713 }
714
715 if (old_location)
716 {
717 g_object_unref (old_location);
718 }
719}
720
721void
722baul_window_slot_open_location (BaulWindowSlot *slot,
723 GFile *location,
724 gboolean close_behind)
725{
726 BaulWindowOpenFlags flags;
727
728 flags = 0;
729 if (close_behind)
730 {
731 flags = BAUL_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
732 }
733
734 baul_window_slot_open_location_full (slot, location,
735 BAUL_WINDOW_OPEN_ACCORDING_TO_MODE,
736 flags, NULL((void*)0), NULL((void*)0), NULL((void*)0));
737}
738
739void
740baul_window_slot_open_location_with_selection (BaulWindowSlot *slot,
741 GFile *location,
742 GList *selection,
743 gboolean close_behind)
744{
745 BaulWindowOpenFlags flags;
746
747 flags = 0;
748 if (close_behind)
749 {
750 flags = BAUL_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
751 }
752 baul_window_slot_open_location_full (slot, location,
753 BAUL_WINDOW_OPEN_ACCORDING_TO_MODE,
754 flags, selection, NULL((void*)0), NULL((void*)0));
755}
756
757
758void
759baul_window_slot_go_home (BaulWindowSlot *slot, gboolean new_tab)
760{
761 GFile *home;
762 BaulWindowOpenFlags flags;
763
764 g_return_if_fail (BAUL_IS_WINDOW_SLOT (slot))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot)); GType __t = ((baul_window_slot_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_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"); return; } } while
(0)
;
765
766 if (new_tab)
767 {
768 flags = BAUL_WINDOW_OPEN_FLAG_NEW_TAB;
769 }
770 else
771 {
772 flags = 0;
773 }
774
775 home = g_file_new_for_path (g_get_home_dir ());
776 baul_window_slot_open_location_full (slot, home,
777 BAUL_WINDOW_OPEN_ACCORDING_TO_MODE,
778 flags, NULL((void*)0), NULL((void*)0), NULL((void*)0));
779 g_object_unref (home);
780}
781
782static char *
783baul_window_slot_get_view_error_label (BaulWindowSlot *slot)
784{
785 const BaulViewInfo *info;
786
787 info = baul_view_factory_lookup (baul_window_slot_get_content_view_id (slot));
788
789 return g_strdup (info->error_label)g_strdup_inline (info->error_label);
790}
791
792static char *
793baul_window_slot_get_view_startup_error_label (BaulWindowSlot *slot)
794{
795 const BaulViewInfo *info;
796
797 info = baul_view_factory_lookup (baul_window_slot_get_content_view_id (slot));
798
799 return g_strdup (info->startup_error_label)g_strdup_inline (info->startup_error_label);
800}
801
802static void
803report_current_content_view_failure_to_user (BaulWindowSlot *slot)
804{
805 BaulWindow *window;
806 char *message;
807
808 window = slot->pane->window;
809
810 message = baul_window_slot_get_view_startup_error_label (slot);
811 eel_show_error_dialog (message,
812 _("You can choose another view or go to a different location.")gettext ("You can choose another view or go to a different location."
)
,
813 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
814 g_free (message);
815}
816
817static void
818report_nascent_content_view_failure_to_user (BaulWindowSlot *slot,
819 BaulView *view)
820{
821 BaulWindow *window;
822 char *message;
823
824 window = slot->pane->window;
825
826 /* TODO? why are we using the current view's error label here, instead of the next view's?
827 * This behavior has already been present in pre-slot days.
828 */
829 message = baul_window_slot_get_view_error_label (slot);
830 eel_show_error_dialog (message,
831 _("The location cannot be displayed with this viewer.")gettext ("The location cannot be displayed with this viewer."
)
,
832 CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
833 g_free (message);
834}
835
836
837const char *
838baul_window_slot_get_content_view_id (BaulWindowSlot *slot)
839{
840 if (slot->content_view == NULL((void*)0))
841 {
842 return NULL((void*)0);
843 }
844 return baul_view_get_view_id (slot->content_view);
845}
846
847gboolean
848baul_window_slot_content_view_matches_iid (BaulWindowSlot *slot,
849 const char *iid)
850{
851 if (slot->content_view == NULL((void*)0))
852 {
853 return FALSE(0);
854 }
855 return g_strcmp0 (baul_view_get_view_id (slot->content_view), iid) == 0;
856}
857
858static gboolean
859report_callback (BaulWindowSlot *slot,
860 GError *error)
861{
862 if (slot->open_callback != NULL((void*)0)) {
863 slot->open_callback (slot->pane->window, error, slot->open_callback_user_data);
864 slot->open_callback = NULL((void*)0);
865 slot->open_callback_user_data = NULL((void*)0);
866
867 return TRUE(!(0));
868 }
869
870 return FALSE(0);
871}
872
873/*
874 * begin_location_change
875 *
876 * Change a window's location.
877 * @window: The BaulWindow whose location should be changed.
878 * @location: A url specifying the location to load
879 * @previous_location: The url that was previously shown in the window that initialized the change, if any
880 * @new_selection: The initial selection to present after loading the location
881 * @type: Which type of location change is this? Standard, back, forward, or reload?
882 * @distance: If type is back or forward, the index into the back or forward chain. If
883 * type is standard or reload, this is ignored, and must be 0.
884 * @scroll_pos: The file to scroll to when the location is loaded.
885 * @callback: function to be called when the location is changed.
886 * @user_data: data for @callback.
887 *
888 * This is the core function for changing the location of a window. Every change to the
889 * location begins here.
890 */
891static void
892begin_location_change (BaulWindowSlot *slot,
893 GFile *location,
894 GFile *previous_location,
895 GList *new_selection,
896 BaulLocationChangeType type,
897 guint distance,
898 const char *scroll_pos,
899 BaulWindowGoToCallback callback,
900 gpointer user_data)
901{
902 BaulWindow *window;
903 BaulDirectory *directory;
904 gboolean force_reload;
905 GFile *parent;
906
907 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 907, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
908 g_assert (location != NULL)do { if (location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 908, ((const char
*) (__func__)), "location != NULL"); } while (0)
;
909 g_assert (type == BAUL_LOCATION_CHANGE_BACKdo { if (type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD
|| distance == 0) ; else g_assertion_message_expr (((gchar*)
0), "baul-window-manage-views.c", 911, ((const char*) (__func__
)), "type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD || distance == 0"
); } while (0)
910 || type == BAUL_LOCATION_CHANGE_FORWARDdo { if (type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD
|| distance == 0) ; else g_assertion_message_expr (((gchar*)
0), "baul-window-manage-views.c", 911, ((const char*) (__func__
)), "type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD || distance == 0"
); } while (0)
911 || distance == 0)do { if (type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD
|| distance == 0) ; else g_assertion_message_expr (((gchar*)
0), "baul-window-manage-views.c", 911, ((const char*) (__func__
)), "type == BAUL_LOCATION_CHANGE_BACK || type == BAUL_LOCATION_CHANGE_FORWARD || distance == 0"
); } while (0)
;
912
913 /* If there is no new selection and the new location is
914 * a (grand)parent of the old location then we automatically
915 * select the folder the previous location was in */
916 if (new_selection == NULL((void*)0) && previous_location != NULL((void*)0) &&
917 g_file_has_prefix (previous_location, location)) {
918 GFile *from_folder;
919
920 from_folder = g_object_ref (previous_location)((__typeof__ (previous_location)) (g_object_ref) (previous_location
))
;
921 parent = g_file_get_parent (from_folder);
922 while (parent != NULL((void*)0) && !g_file_equal (parent, location)) {
923 g_object_unref (from_folder);
924 from_folder = parent;
925 parent = g_file_get_parent (from_folder);
926 }
927 if (parent != NULL((void*)0)) {
928 new_selection = g_list_prepend (NULL((void*)0), g_object_ref(from_folder)((__typeof__ (from_folder)) (g_object_ref) (from_folder)));
929 }
930 g_object_unref (from_folder);
931 g_object_unref (parent);
932 }
933
934 window = slot->pane->window;
935 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 935, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)")
; } while (0)
;
936 g_object_ref (window)((__typeof__ (window)) (g_object_ref) (window));
937
938 end_location_change (slot);
939
940 baul_window_slot_set_allow_stop (slot, TRUE(!(0)));
941 baul_window_slot_set_status (slot, " ");
942
943 g_assert (slot->pending_location == NULL)do { if (slot->pending_location == ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 943, ((const char
*) (__func__)), "slot->pending_location == NULL"); } while
(0)
;
944 g_assert (slot->pending_selection == NULL)do { if (slot->pending_selection == ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 944, ((const char
*) (__func__)), "slot->pending_selection == NULL"); } while
(0)
;
945
946 slot->pending_location = g_object_ref (location)((__typeof__ (location)) (g_object_ref) (location));
947 slot->location_change_type = type;
948 slot->location_change_distance = distance;
949 slot->tried_mount = FALSE(0);
950 slot->pending_selection = g_list_copy_deep (new_selection, (GCopyFunc) g_object_ref, NULL((void*)0));
951
952 slot->pending_scroll_to = g_strdup (scroll_pos)g_strdup_inline (scroll_pos);
953
954 slot->open_callback = callback;
955 slot->open_callback_user_data = user_data;
956
957 directory = baul_directory_get (location);
958
959 /* The code to force a reload is here because if we do it
960 * after determining an initial view (in the components), then
961 * we end up fetching things twice.
962 */
963 if (type == BAUL_LOCATION_CHANGE_RELOAD)
964 {
965 force_reload = TRUE(!(0));
966 }
967 else if (!baul_monitor_active ())
968 {
969 force_reload = TRUE(!(0));
970 }
971 else
972 {
973 force_reload = !baul_directory_is_local (directory);
974 }
975
976 if (force_reload)
977 {
978 BaulFile *file;
979
980 baul_directory_force_reload (directory);
981 file = baul_directory_get_corresponding_file (directory);
982 baul_file_invalidate_all_attributes (file);
983 baul_file_unref (file);
984 }
985
986 baul_directory_unref (directory);
987
988 /* Set current_bookmark scroll pos */
989 if (slot->current_location_bookmark != NULL((void*)0) &&
990 slot->content_view != NULL((void*)0))
991 {
992 char *current_pos;
993
994 current_pos = baul_view_get_first_visible_file (slot->content_view);
995 baul_bookmark_set_scroll_pos (slot->current_location_bookmark, current_pos);
996 g_free (current_pos);
997 }
998
999 /* Get the info needed for view selection */
1000
1001 slot->determine_view_file = baul_file_get (location);
1002 g_assert (slot->determine_view_file != NULL)do { if (slot->determine_view_file != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 1002, ((const char
*) (__func__)), "slot->determine_view_file != NULL"); } while
(0)
;
1003
1004 /* if the currently viewed file is marked gone while loading the new location,
1005 * this ensures that the window isn't destroyed */
1006 cancel_viewed_file_changed_callback (slot);
1007
1008 baul_file_call_when_ready (slot->determine_view_file,
1009 BAUL_FILE_ATTRIBUTE_INFO |
1010 BAUL_FILE_ATTRIBUTE_MOUNT,
1011 got_file_info_for_view_selection_callback,
1012 slot);
1013
1014 g_object_unref (window);
1015}
1016
1017static void
1018setup_new_spatial_window (BaulWindowSlot *slot, BaulFile *file)
1019{
1020 BaulWindow *window;
1021 char *scroll_string;
1022 gboolean maximized, sticky, above;
1023
1024 window = slot->pane->window;
1025
1026 if (BAUL_IS_SPATIAL_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); 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; }))))
&& !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; }))))
)
1027 {
1028 char *show_hidden_file_setting;
1029 char *geometry_string;
1030
1031 /* load show hidden state */
1032 show_hidden_file_setting = baul_file_get_metadata
1033 (file, BAUL_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES"baul-window-show-hidden-files",
1034 NULL((void*)0));
1035 if (show_hidden_file_setting != NULL((void*)0))
1036 {
1037 CtkAction *action;
1038
1039 if (strcmp (show_hidden_file_setting, "1") == 0)
1040 {
1041 window->details->show_hidden_files_mode = BAUL_WINDOW_SHOW_HIDDEN_FILES_ENABLE;
1042 }
1043 else
1044 {
1045 window->details->show_hidden_files_mode = BAUL_WINDOW_SHOW_HIDDEN_FILES_DISABLE;
1046 }
1047
1048 /* Update the UI, since we initialize it to the default */
1049 action = ctk_action_group_get_action (window->details->main_action_group, BAUL_ACTION_SHOW_HIDDEN_FILES"Show Hidden Files");
1050 ctk_action_block_activate (action);
1051 ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((action)), ((ctk_toggle_action_get_type ()))))))
,
1052 window->details->show_hidden_files_mode == BAUL_WINDOW_SHOW_HIDDEN_FILES_ENABLE);
1053 ctk_action_unblock_activate (action);
1054 }
1055 else
1056 {
1057 BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
->details->show_hidden_files_mode = BAUL_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
1058 }
1059 g_free (show_hidden_file_setting);
1060
1061 /* load the saved window geometry */
1062 maximized = baul_file_get_boolean_metadata
1063 (file, BAUL_METADATA_KEY_WINDOW_MAXIMIZED"baul-window-maximized", FALSE(0));
1064 if (maximized)
1065 {
1066 ctk_window_maximize (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1067 }
1068 else
1069 {
1070 ctk_window_unmaximize (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1071 }
1072
1073 sticky = baul_file_get_boolean_metadata
1074 (file, BAUL_METADATA_KEY_WINDOW_STICKY"baul-window-sticky", FALSE(0));
1075 if (sticky)
1076 {
1077 ctk_window_stick (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1078 }
1079 else
1080 {
1081 ctk_window_unstick (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1082 }
1083
1084 above = baul_file_get_boolean_metadata
1085 (file, BAUL_METADATA_KEY_WINDOW_KEEP_ABOVE"baul-window-keep-above", FALSE(0));
1086 if (above)
1087 {
1088 ctk_window_set_keep_above (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, TRUE(!(0)));
1089 }
1090 else
1091 {
1092 ctk_window_set_keep_above (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
, FALSE(0));
1093 }
1094
1095 geometry_string = baul_file_get_metadata
1096 (file, BAUL_METADATA_KEY_WINDOW_GEOMETRY"baul-window-geometry", NULL((void*)0));
1097 if (geometry_string != NULL((void*)0))
1098 {
1099 eel_ctk_window_set_initial_geometry_from_string
1100 (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
,
1101 geometry_string,
1102 BAUL_SPATIAL_WINDOW_MIN_WIDTH100,
1103 BAUL_SPATIAL_WINDOW_MIN_HEIGHT100,
1104 FALSE(0));
1105 }
1106 g_free (geometry_string);
1107
1108 if (slot->pending_selection == NULL((void*)0))
1109 {
1110 /* If there is no pending selection, then load the saved scroll position. */
1111 scroll_string = baul_file_get_metadata
1112 (file, BAUL_METADATA_KEY_WINDOW_SCROLL_POSITION"baul-window-scroll-position",
1113 NULL((void*)0));
1114 }
1115 else
1116 {
1117 /* If there is a pending selection, we want to scroll to an item in
1118 * the pending selection list. */
1119 scroll_string = g_file_get_uri (slot->pending_selection->data);
1120 }
1121
1122 /* scroll_string might be NULL if there was no saved scroll position. */
1123 if (scroll_string != NULL((void*)0))
1124 {
1125 slot->pending_scroll_to = scroll_string;
1126 }
1127 }
1128}
1129
1130typedef struct
1131{
1132 GCancellable *cancellable;
1133 BaulWindowSlot *slot;
1134} MountNotMountedData;
1135
1136static void
1137mount_not_mounted_callback (GObject *source_object,
1138 GAsyncResult *res,
1139 gpointer user_data)
1140{
1141 MountNotMountedData *data;
1142 BaulWindowSlot *slot;
1143 GError *error;
1144 GCancellable *cancellable;
1145
1146 data = user_data;
1147 slot = data->slot;
1148 cancellable = data->cancellable;
1149 g_free (data);
1150
1151 if (g_cancellable_is_cancelled (cancellable))
1
Assuming the condition is false
2
Taking false branch
1152 {
1153 /* Cancelled, don't call back */
1154 g_object_unref (cancellable);
1155 return;
1156 }
1157
1158 slot->mount_cancellable = NULL((void*)0);
1159
1160 slot->determine_view_file = baul_file_get (slot->pending_location);
1161
1162 error = NULL((void*)0);
1163 if (!g_file_mount_enclosing_volume_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_object)), ((g_file_get_type ()))))))
, res, &error)
)
3
Assuming the condition is true
4
Taking true branch
1164 {
1165 slot->mount_error = error;
1166 got_file_info_for_view_selection_callback (slot->determine_view_file, slot);
5
Calling 'got_file_info_for_view_selection_callback'
1167 slot->mount_error = NULL((void*)0);
1168 g_error_free (error);
1169 }
1170 else
1171 {
1172 baul_file_invalidate_all_attributes (slot->determine_view_file);
1173 baul_file_call_when_ready (slot->determine_view_file,
1174 BAUL_FILE_ATTRIBUTE_INFO,
1175 got_file_info_for_view_selection_callback,
1176 slot);
1177 }
1178
1179 g_object_unref (cancellable);
1180}
1181
1182static void
1183got_file_info_for_view_selection_callback (BaulFile *file,
1184 gpointer callback_data)
1185{
1186 GError *error;
1187 char *view_id;
1188 BaulWindow *window;
1189 BaulWindowSlot *slot;
1190 GFile *location;
1191 MountNotMountedData *data;
1192 slot = callback_data;
1193 g_assert (BAUL_IS_WINDOW_SLOT (slot))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot)); GType __t = ((baul_window_slot_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-window-manage-views.c"
, 1193, ((const char*) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"
); } while (0)
;
6
Taking false branch
7
Assuming field 'g_class' is null
8
Assuming the condition is true
9
Taking true branch
10
Loop condition is false. Exiting loop
1194 g_assert (slot->determine_view_file == file)do { if (slot->determine_view_file == file) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 1194, ((const char
*) (__func__)), "slot->determine_view_file == file"); } while
(0)
;
11
Taking true branch
12
Loop condition is false. Exiting loop
1195
1196 window = slot->pane->window;
1197 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1197, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
13
Assuming '__inst' is non-null
14
Taking false branch
15
Assuming field 'g_class' is null
16
Assuming the condition is true
17
Taking true branch
18
Loop condition is false. Exiting loop
1198
1199 slot->determine_view_file = NULL((void*)0);
1200
1201 if (slot->mount_error)
19
Assuming field 'mount_error' is null
20
Taking false branch
1202 {
1203 error = slot->mount_error;
1204 }
1205 else
1206 {
1207 error = baul_file_get_file_info_error (file);
21
Value assigned to 'error'
1208 }
1209
1210 if (error && error->domain == G_IO_ERRORg_io_error_quark() && error->code == G_IO_ERROR_NOT_MOUNTED &&
22
Assuming 'error' is null
1211 !slot->tried_mount)
1212 {
1213 GMountOperation *mount_op;
1214
1215 slot->tried_mount = TRUE(!(0));
1216
1217 mount_op = ctk_mount_operation_new (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_window_get_type ()))))))
);
1218 g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
1219 location = baul_file_get_location (file);
1220 data = g_new0 (MountNotMountedData, 1)((MountNotMountedData *) g_malloc0_n ((1), sizeof (MountNotMountedData
)))
;
1221 data->cancellable = g_cancellable_new ();
1222 data->slot = slot;
1223 slot->mount_cancellable = data->cancellable;
1224 g_file_mount_enclosing_volume (location, 0, mount_op, slot->mount_cancellable,
1225 mount_not_mounted_callback, data);
1226 g_object_unref (location);
1227 g_object_unref (mount_op);
1228
1229 baul_file_unref (file);
1230
1231 return;
1232 }
1233
1234 location = slot->pending_location;
1235
1236 view_id = NULL((void*)0);
1237
1238 if (error
22.1
'error' is equal to NULL
== NULL((void*)0) ||
1239 (error->domain == G_IO_ERRORg_io_error_quark() && error->code == G_IO_ERROR_NOT_SUPPORTED))
1240 {
1241 char *mimetype;
1242
1243 /* We got the information we need, now pick what view to use: */
1244
1245 mimetype = baul_file_get_mime_type (file);
1246
1247 /* If fallback, don't use view from metadata */
1248 if (slot->location_change_type != BAUL_LOCATION_CHANGE_FALLBACK)
23
Assuming field 'location_change_type' is equal to BAUL_LOCATION_CHANGE_FALLBACK
24
Taking false branch
1249 {
1250 /* Look in metadata for view */
1251 view_id = baul_file_get_metadata
1252 (file, BAUL_METADATA_KEY_DEFAULT_VIEW"baul-default-view", NULL((void*)0));
1253 if (view_id != NULL((void*)0) &&
1254 !baul_view_factory_view_supports_uri (view_id,
1255 location,
1256 baul_file_get_file_type (file),
1257 mimetype))
1258 {
1259 g_free (view_id);
1260 view_id = NULL((void*)0);
1261 }
1262 }
1263
1264 /* Otherwise, use default */
1265 if (view_id
24.1
'view_id' is equal to NULL
== NULL((void*)0))
25
Taking true branch
1266 {
1267 char *uri;
1268 uri = baul_file_get_uri (file);
1269
1270 /* Use same view settings for search results as the current folder */
1271 if (eel_uri_is_search (uri))
26
Assuming the condition is false
27
Taking false branch
1272 {
1273 view_id = g_strdup (baul_view_get_view_id (slot->content_view))g_strdup_inline (baul_view_get_view_id (slot->content_view
))
;
1274 }
1275 else
1276 {
1277 view_id = baul_global_preferences_get_default_folder_viewer_preference_as_iid ();
1278 }
1279
1280 g_free (uri);
1281
1282 if (view_id != NULL((void*)0) &&
28
Assuming 'view_id' is equal to NULL
1283 !baul_view_factory_view_supports_uri (view_id,
1284 location,
1285 baul_file_get_file_type (file),
1286 mimetype))
1287 {
1288 g_free (view_id);
1289 view_id = NULL((void*)0);
1290 }
1291 }
1292
1293 g_free (mimetype);
1294 }
1295
1296 if (view_id
28.1
'view_id' is equal to NULL
!= NULL((void*)0))
29
Taking false branch
1297 {
1298 if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
) && BAUL_IS_SPATIAL_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); 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; }))))
)
1299 {
1300 /* We now have the metadata to set up the window position, etc */
1301 setup_new_spatial_window (slot, file);
1302 }
1303 create_content_view (slot, view_id);
1304 g_free (view_id);
1305
1306 report_callback (slot, NULL((void*)0));
1307 }
1308 else
1309 {
1310 if (!report_callback (slot, error)) {
30
Taking true branch
1311 display_view_selection_failure (window, file,
32
Calling 'display_view_selection_failure'
1312 location, error);
31
Passing null pointer value via 4th parameter 'error'
1313 }
1314
1315 if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
1316 {
1317 BaulApplication *app;
1318
1319 /* Destroy never-had-a-chance-to-be-seen window. This case
1320 * happens when a new window cannot display its initial URI.
1321 */
1322 /* if this is the only window, we don't want to quit, so we redirect it to home */
1323 app = BAUL_APPLICATION (g_application_get_default ())((((BaulApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((g_application_get_default ())), (baul_application_get_type
())))))
;
1324
1325 if (g_list_length (ctk_application_get_windows (CTK_APPLICATION (app)((((CtkApplication*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((app)), ((ctk_application_get_type ()))))))
)) == 1) {
1326
1327 /* the user could have typed in a home directory that doesn't exist,
1328 in which case going home would cause an infinite loop, so we
1329 better test for that */
1330
1331 if (!baul_is_root_directory (location))
1332 {
1333 if (!baul_is_home_directory (location))
1334 {
1335 baul_window_slot_go_home (slot, FALSE(0));
1336 }
1337 else
1338 {
1339 GFile *root;
1340
1341 root = g_file_new_for_path ("/");
1342 /* the last fallback is to go to a known place that can't be deleted! */
1343 baul_window_slot_go_to (slot, location, FALSE)baul_window_slot_open_location_full(slot, location, BAUL_WINDOW_OPEN_ACCORDING_TO_MODE
, ((0) ? BAUL_WINDOW_OPEN_FLAG_NEW_TAB : 0), ((void*)0), ((void
*)0), ((void*)0))
;
1344 g_object_unref (root);
1345 }
1346 }
1347 else
1348 {
1349 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1350 }
1351 }
1352 else
1353 {
1354 /* Since this is a window, destroying it will also unref it. */
1355 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
1356 }
1357 }
1358 else
1359 {
1360 /* Clean up state of already-showing window */
1361 end_location_change (slot);
1362
1363 /* TODO? shouldn't we call
1364 * cancel_viewed_file_changed_callback (slot);
1365 * at this point, or in end_location_change()
1366 */
1367 /* We're missing a previous location (if opened location
1368 * in a new tab) so close it and return */
1369 if (slot->location == NULL((void*)0))
1370 {
1371 baul_window_slot_close (slot);
1372 }
1373 else
1374 {
1375 BaulFile *viewed_file;
1376
1377 /* We disconnected this, so we need to re-connect it */
1378 viewed_file = baul_file_get (slot->location);
1379 baul_window_slot_set_viewed_file (slot, viewed_file);
1380 baul_file_monitor_add (viewed_file, &slot->viewed_file, 0);
1381 g_signal_connect_object (viewed_file, "changed",
1382 G_CALLBACK (viewed_file_changed_callback)((GCallback) (viewed_file_changed_callback)), slot, 0);
1383 baul_file_unref (viewed_file);
1384
1385 /* Leave the location bar showing the bad location that the user
1386 * typed (or maybe achieved by dragging or something). Many times
1387 * the mistake will just be an easily-correctable typo. The user
1388 * can choose "Refresh" to get the original URI back in the location bar.
1389 */
1390 }
1391 }
1392 }
1393
1394 baul_file_unref (file);
1395}
1396
1397/* Load a view into the window, either reusing the old one or creating
1398 * a new one. This happens when you want to load a new location, or just
1399 * switch to a different view.
1400 * If pending_location is set we're loading a new location and
1401 * pending_location/selection will be used. If not, we're just switching
1402 * view, and the current location will be used.
1403 */
1404static void
1405create_content_view (BaulWindowSlot *slot,
1406 const char *view_id)
1407{
1408 BaulWindow *window;
1409 BaulView *view;
1410 GList *selection;
1411
1412 window = slot->pane->window;
1413
1414 /* FIXME bugzilla.gnome.org 41243:
1415 * We should use inheritance instead of these special cases
1416 * for the desktop window.
1417 */
1418 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; }))))
)
1419 {
1420 /* We force the desktop to use a desktop_icon_view. It's simpler
1421 * to fix it here than trying to make it pick the right view in
1422 * the first place.
1423 */
1424 view_id = BAUL_DESKTOP_ICON_VIEW_IID"OAFIID:Baul_File_Manager_Desktop_Icon_View";
1425 }
1426
1427 if (slot->content_view != NULL((void*)0) &&
1428 g_strcmp0 (baul_view_get_view_id (slot->content_view),
1429 view_id) == 0)
1430 {
1431 /* reuse existing content view */
1432 view = slot->content_view;
1433 slot->new_content_view = view;
1434 g_object_ref (view)((__typeof__ (view)) (g_object_ref) (view));
1435 }
1436 else
1437 {
1438 /* create a new content view */
1439 view = baul_view_factory_create (view_id,
1440 BAUL_WINDOW_SLOT_INFO (slot)((((BaulWindowSlotInfo*) (void *) g_type_check_instance_cast (
(GTypeInstance*) ((slot)), ((baul_window_slot_info_get_type (
)))))))
);
1441
1442 eel_accessibility_set_name (view, _("Content View")gettext ("Content View"));
1443 eel_accessibility_set_description (view, _("View of the current folder")gettext ("View of the current folder"));
1444
1445 slot->new_content_view = view;
1446 baul_window_slot_connect_content_view (slot, slot->new_content_view);
1447 }
1448
1449 /* Actually load the pending location and selection: */
1450
1451 if (slot->pending_location != NULL((void*)0))
1452 {
1453 load_new_location (slot,
1454 slot->pending_location,
1455 slot->pending_selection,
1456 FALSE(0),
1457 TRUE(!(0)));
1458
1459 g_list_free_full (slot->pending_selection, g_object_unref);
1460 slot->pending_selection = NULL((void*)0);
1461 }
1462 else if (slot->location != NULL((void*)0))
1463 {
1464 selection = baul_view_get_selection (slot->content_view);
1465 load_new_location (slot,
1466 slot->location,
1467 selection,
1468 FALSE(0),
1469 TRUE(!(0)));
1470 g_list_free_full (selection, g_object_unref);
1471 }
1472 else
1473 {
1474 /* Something is busted, there was no location to load.
1475 Just load the homedir. */
1476 baul_window_slot_go_home (slot, FALSE(0));
1477
1478 }
1479}
1480
1481static void
1482load_new_location (BaulWindowSlot *slot,
1483 GFile *location,
1484 GList *selection,
1485 gboolean tell_current_content_view,
1486 gboolean tell_new_content_view)
1487{
1488 BaulWindow *window;
1489 GList *selection_copy;
1490 BaulView *view;
1491 char *uri;
1492
1493 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 1493, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
1494 g_assert (location != NULL)do { if (location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 1494, ((const char
*) (__func__)), "location != NULL"); } while (0)
;
1495
1496 window = slot->pane->window;
1497 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1497, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
1498
1499 selection_copy = g_list_copy_deep (selection, (GCopyFunc) g_object_ref, NULL((void*)0));
1500
1501 view = NULL((void*)0);
1502
1503 /* Note, these may recurse into report_load_underway */
1504 if (slot->content_view != NULL((void*)0) && tell_current_content_view)
1505 {
1506 view = slot->content_view;
1507 uri = g_file_get_uri (location);
1508 baul_view_load_location (slot->content_view, uri);
1509 g_free (uri);
1510 }
1511
1512 if (slot->new_content_view != NULL((void*)0) && tell_new_content_view &&
1513 (!tell_current_content_view ||
1514 slot->new_content_view != slot->content_view) )
1515 {
1516 view = slot->new_content_view;
1517 uri = g_file_get_uri (location);
1518 baul_view_load_location (slot->new_content_view, uri);
1519 g_free (uri);
1520 }
1521 if (view != NULL((void*)0))
1522 {
1523 /* slot->new_content_view might have changed here if
1524 report_load_underway was called from load_location */
1525 baul_view_set_selection (view, selection_copy);
1526 }
1527
1528 g_list_free_full (selection_copy, g_object_unref);
1529}
1530
1531/* A view started to load the location its viewing, either due to
1532 * a load_location request, or some internal reason. Expect
1533 * a matching load_compete later
1534 */
1535void
1536baul_window_report_load_underway (BaulWindow *window,
1537 BaulView *view)
1538{
1539 BaulWindowSlot *slot;
1540
1541 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1541, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
1542
1543 if (window->details->temporarily_ignore_view_signals)
1544 {
1545 return;
1546 }
1547
1548 slot = baul_window_get_slot_for_view (window, view);
1549 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 1549, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
1550
1551 if (view == slot->new_content_view)
1552 {
1553 location_has_really_changed (slot);
1554 }
1555 else
1556 {
1557 baul_window_slot_set_allow_stop (slot, TRUE(!(0)));
1558 }
1559}
1560
1561static void
1562baul_window_emit_location_change (BaulWindow *window,
1563 GFile *location)
1564{
1565 char *uri;
1566
1567 uri = g_file_get_uri (location);
1568 g_signal_emit_by_name (window, "loading_uri", uri);
1569 g_free (uri);
1570}
1571
1572/* reports location change to window's "loading-uri" clients, i.e.
1573 * sidebar panels [used when switching tabs]. It will emit the pending
1574 * location, or the existing location if none is pending.
1575 */
1576void
1577baul_window_report_location_change (BaulWindow *window)
1578{
1579 BaulWindowSlot *slot;
1580 GFile *location;
1581
1582 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1582, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
1583
1584 slot = window->details->active_pane->active_slot;
1585 g_assert (BAUL_IS_WINDOW_SLOT (slot))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot)); GType __t = ((baul_window_slot_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-window-manage-views.c"
, 1585, ((const char*) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"
); } while (0)
;
1586
1587 location = NULL((void*)0);
1588
1589 if (slot->pending_location != NULL((void*)0))
1590 {
1591 location = slot->pending_location;
1592 }
1593
1594 if (location == NULL((void*)0) && slot->location != NULL((void*)0))
1595 {
1596 location = slot->location;
1597 }
1598
1599 if (location != NULL((void*)0))
1600 {
1601 baul_window_emit_location_change (window, location);
1602 }
1603}
1604
1605/* This is called when we have decided we can actually change to the new view/location situation. */
1606static void
1607location_has_really_changed (BaulWindowSlot *slot)
1608{
1609 BaulWindow *window;
1610 GFile *location_copy;
1611
1612 window = slot->pane->window;
1613
1614 if (slot->new_content_view != NULL((void*)0))
1615 {
1616 CtkWidget *widget;
1617
1618 widget = baul_view_get_widget (slot->new_content_view);
1619 /* Switch to the new content view. */
1620 if (ctk_widget_get_parent (widget) == NULL((void*)0))
1621 {
1622 if (slot->content_view != NULL((void*)0))
1623 {
1624 baul_window_slot_disconnect_content_view (slot, slot->content_view);
1625 }
1626 baul_window_slot_set_content_view_widget (slot, slot->new_content_view);
1627 }
1628 g_object_unref (slot->new_content_view);
1629 slot->new_content_view = NULL((void*)0);
1630 }
1631
1632 if (slot->pending_location != NULL((void*)0))
1633 {
1634 /* Tell the window we are finished. */
1635 update_for_new_location (slot);
1636 }
1637
1638 location_copy = NULL((void*)0);
1639 if (slot->location != NULL((void*)0))
1640 {
1641 location_copy = g_object_ref (slot->location)((__typeof__ (slot->location)) (g_object_ref) (slot->location
))
;
1642 }
1643
1644 free_location_change (slot);
1645
1646 if (location_copy != NULL((void*)0))
1647 {
1648 if (slot == baul_window_get_active_slot (window))
1649 {
1650 baul_window_emit_location_change (window, location_copy);
1651 }
1652
1653 g_object_unref (location_copy);
1654 }
1655}
1656
1657static void
1658slot_add_extension_extra_widgets (BaulWindowSlot *slot)
1659{
1660 GList *providers, *l;
1661 char *uri;
1662 CtkWidget *widget = NULL((void*)0);
1663
1664 providers = baul_extensions_get_for_type (BAUL_TYPE_LOCATION_WIDGET_PROVIDER(baul_location_widget_provider_get_type ()));
1665
1666 uri = g_file_get_uri (slot->location);
1667 for (l = providers; l != NULL((void*)0); l = l->next)
1668 {
1669 BaulLocationWidgetProvider *provider;
1670
1671 provider = BAUL_LOCATION_WIDGET_PROVIDER (l->data)((((BaulLocationWidgetProvider*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((l->data)), ((baul_location_widget_provider_get_type
()))))))
;
1672 widget = baul_location_widget_provider_get_widget (provider, uri, CTK_WIDGET (slot->pane->window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((slot->pane->window)), ((ctk_widget_get_type ()))))
))
);
1673 if (widget != NULL((void*)0))
1674 {
1675 baul_window_slot_add_extra_location_widget (slot, widget);
1676 }
1677 }
1678 g_free (uri);
1679
1680 baul_module_extension_list_free (providers);
1681}
1682
1683static void
1684baul_window_slot_show_x_content_bar (BaulWindowSlot *slot, GMount *mount, const char **x_content_types)
1685{
1686 unsigned int n;
1687
1688 g_assert (BAUL_IS_WINDOW_SLOT (slot))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot)); GType __t = ((baul_window_slot_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-window-manage-views.c"
, 1688, ((const char*) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"
); } while (0)
;
1689
1690 for (n = 0; x_content_types[n] != NULL((void*)0); n++)
1691 {
1692 GAppInfo *default_app;
1693
1694 /* skip blank media; the burn:/// location will provide it's own cluebar */
1695 if (g_str_has_prefix (x_content_types[n], "x-content/blank-")(__builtin_constant_p ("x-content/blank-")? __extension__ ({ const
char * const __str = (x_content_types[n]); const char * const
__prefix = ("x-content/blank-"); gboolean __result = (0); if
(__str == ((void*)0) || __prefix == ((void*)0)) __result = (
g_str_has_prefix) (__str, __prefix); else { const size_t __str_len
= strlen (((__str) + !(__str))); const size_t __prefix_len =
strlen (((__prefix) + !(__prefix))); if (__str_len >= __prefix_len
) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix
)), __prefix_len) == 0; } __result; }) : (g_str_has_prefix) (
x_content_types[n], "x-content/blank-") )
)
1696 {
1697 continue;
1698 }
1699
1700 /* don't show the cluebar for windows software */
1701 if (g_content_type_is_a (x_content_types[n], "x-content/win32-software"))
1702 {
1703 continue;
1704 }
1705
1706 /* only show the cluebar if a default app is available */
1707 default_app = g_app_info_get_default_for_type (x_content_types[n], FALSE(0));
1708 if (default_app != NULL((void*)0))
1709 {
1710 CtkWidget *bar;
1711 bar = baul_x_content_bar_new (mount, x_content_types[n]);
1712 ctk_widget_show (bar);
1713 baul_window_slot_add_extra_location_widget (slot, bar);
1714 g_object_unref (default_app);
1715 }
1716 }
1717}
1718
1719static void
1720baul_window_slot_show_trash_bar (BaulWindowSlot *slot,
1721 BaulWindow *window)
1722{
1723 CtkWidget *bar;
1724
1725 bar = baul_trash_bar_new (window);
1726 ctk_widget_show (bar);
1727
1728 baul_window_slot_add_extra_location_widget (slot, bar);
1729}
1730
1731typedef struct
1732{
1733 BaulWindowSlot *slot;
1734 GCancellable *cancellable;
1735 GMount *mount;
1736} FindMountData;
1737
1738static void
1739found_content_type_cb (const char **x_content_types, FindMountData *data)
1740{
1741 BaulWindowSlot *slot;
1742
1743 if (g_cancellable_is_cancelled (data->cancellable))
1744 {
1745 goto out;
1746 }
1747
1748 slot = data->slot;
1749
1750 if (x_content_types != NULL((void*)0) && x_content_types[0] != NULL((void*)0))
1751 {
1752 baul_window_slot_show_x_content_bar (slot, data->mount, x_content_types);
1753 }
1754
1755 slot->find_mount_cancellable = NULL((void*)0);
1756
1757out:
1758 g_object_unref (data->mount);
1759 g_object_unref (data->cancellable);
1760 g_free (data);
1761}
1762
1763static void
1764found_mount_cb (GObject *source_object,
1765 GAsyncResult *res,
1766 gpointer user_data)
1767{
1768 FindMountData *data = user_data;
1769 GMount *mount;
1770
1771 if (g_cancellable_is_cancelled (data->cancellable))
1772 {
1773 goto out;
1774 }
1775
1776 mount = g_file_find_enclosing_mount_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((source_object)), ((g_file_get_type ()))))))
,
1777 res,
1778 NULL((void*)0));
1779 if (mount != NULL((void*)0))
1780 {
1781 data->mount = mount;
1782 baul_autorun_get_x_content_types_for_mount_async (mount,
1783 (BaulAutorunGetContent)found_content_type_cb,
1784 data->cancellable,
1785 data);
1786 return;
1787 }
1788
1789 data->slot->find_mount_cancellable = NULL((void*)0);
1790
1791out:
1792 g_object_unref (data->cancellable);
1793 g_free (data);
1794}
1795
1796/* Handle the changes for the BaulWindow itself. */
1797static void
1798update_for_new_location (BaulWindowSlot *slot)
1799{
1800 BaulWindow *window;
1801 GFile *new_location;
1802 BaulFile *file;
1803 gboolean location_really_changed;
1804 FindMountData *data;
1805
1806 window = slot->pane->window;
1807
1808 new_location = slot->pending_location;
1809 slot->pending_location = NULL((void*)0);
1810
1811 set_displayed_location (slot, new_location);
1812
1813 update_history (slot, slot->location_change_type, new_location);
1814
1815 location_really_changed =
1816 slot->location == NULL((void*)0) ||
1817 !g_file_equal (slot->location, new_location);
1818
1819 /* Set the new location. */
1820 if (slot->location)
1821 {
1822 g_object_unref (slot->location);
1823 }
1824 slot->location = new_location;
1825
1826 /* Create a BaulFile for this location, so we can catch it
1827 * if it goes away.
1828 */
1829 cancel_viewed_file_changed_callback (slot);
1830 file = baul_file_get (slot->location);
1831 baul_window_slot_set_viewed_file (slot, file);
1832 slot->viewed_file_seen = !baul_file_is_not_yet_confirmed (file);
1833 slot->viewed_file_in_trash = baul_file_is_in_trash (file);
1834 baul_file_monitor_add (file, &slot->viewed_file, 0);
1835 g_signal_connect_object (file, "changed",
1836 G_CALLBACK (viewed_file_changed_callback)((GCallback) (viewed_file_changed_callback)), slot, 0);
1837 baul_file_unref (file);
1838
1839 if (slot == window->details->active_pane->active_slot)
1840 {
1841 /* Check if we can go up. */
1842 baul_window_update_up_button (window);
1843
1844 baul_window_sync_zoom_widgets (window);
1845
1846 /* Set up the content view menu for this new location. */
1847 baul_window_load_view_as_menus (window);
1848
1849 /* Load menus from baul extensions for this location */
1850 baul_window_load_extension_menus (window);
1851 }
1852
1853 if (location_really_changed)
1854 {
1855 BaulDirectory *directory;
1856
1857 baul_window_slot_remove_extra_location_widgets (slot);
1858
1859 directory = baul_directory_get (slot->location);
1860
1861 baul_window_slot_update_query_editor (slot);
1862
1863 if (baul_directory_is_in_trash (directory))
1864 {
1865 baul_window_slot_show_trash_bar (slot, window);
1866 }
1867
1868 /* need the mount to determine if we should put up the x-content cluebar */
1869 if (slot->find_mount_cancellable != NULL((void*)0))
1870 {
1871 g_cancellable_cancel (slot->find_mount_cancellable);
1872 slot->find_mount_cancellable = NULL((void*)0);
1873 }
1874
1875 data = g_new (FindMountData, 1)((FindMountData *) g_malloc_n ((1), sizeof (FindMountData)));
1876 data->slot = slot;
1877 data->cancellable = g_cancellable_new ();
1878 data->mount = NULL((void*)0);
1879
1880 slot->find_mount_cancellable = data->cancellable;
1881 g_file_find_enclosing_mount_async (slot->location,
1882 G_PRIORITY_DEFAULT0,
1883 data->cancellable,
1884 found_mount_cb,
1885 data);
1886
1887 baul_directory_unref (directory);
1888
1889 slot_add_extension_extra_widgets (slot);
1890 }
1891
1892 baul_window_slot_update_title (slot);
1893 baul_window_slot_update_icon (slot);
1894
1895 if (slot == slot->pane->active_slot)
1896 {
1897 baul_window_pane_sync_location_widgets (slot->pane);
1898
1899 if (location_really_changed)
1900 {
1901 baul_window_pane_sync_search_widgets (slot->pane);
1902 }
1903
1904 if (BAUL_IS_NAVIGATION_WINDOW (window)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) (
(window)); GType __t = (baul_navigation_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; }))))
&&
1905 slot->pane == window->details->active_pane)
1906 {
1907 baul_navigation_window_load_extension_toolbar_items (BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast
((GTypeInstance*) ((window)), (baul_navigation_window_get_type
())))))
);
1908 }
1909 }
1910}
1911
1912/* A location load previously announced by load_underway
1913 * has been finished */
1914void
1915baul_window_report_load_complete (BaulWindow *window,
1916 BaulView *view)
1917{
1918 BaulWindowSlot *slot;
1919
1920 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1920, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
1921
1922 if (window->details->temporarily_ignore_view_signals)
1923 {
1924 return;
1925 }
1926
1927 slot = baul_window_get_slot_for_view (window, view);
1928 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 1928, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
1929
1930 /* Only handle this if we're expecting it.
1931 * Don't handle it if its from an old view we've switched from */
1932 if (view == slot->content_view)
1933 {
1934 if (slot->pending_scroll_to != NULL((void*)0))
1935 {
1936 baul_view_scroll_to_file (slot->content_view,
1937 slot->pending_scroll_to);
1938 }
1939 end_location_change (slot);
1940 }
1941}
1942
1943static void
1944end_location_change (BaulWindowSlot *slot)
1945{
1946 BaulWindow *window;
1947 char *uri;
1948
1949 window = slot->pane->window;
1950
1951 uri = baul_window_slot_get_location_uri (slot);
1952 if (uri)
1953 {
1954 baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER",
1955 "finished loading window %p: %s", window, uri);
1956 g_free (uri);
1957 }
1958
1959 baul_window_slot_set_allow_stop (slot, FALSE(0));
1960
1961 /* Now we can free pending_scroll_to, since the load_complete
1962 * callback already has been emitted.
1963 */
1964 g_free (slot->pending_scroll_to);
1965 slot->pending_scroll_to = NULL((void*)0);
1966
1967 free_location_change (slot);
1968}
1969
1970static void
1971free_location_change (BaulWindowSlot *slot)
1972{
1973 BaulWindow *window;
1974
1975 window = slot->pane->window;
1976 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 1976, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
1977
1978 if (slot->pending_location)
1979 {
1980 g_object_unref (slot->pending_location);
1981 }
1982 slot->pending_location = NULL((void*)0);
1983
1984 g_list_free_full (slot->pending_selection, g_object_unref);
1985 slot->pending_selection = NULL((void*)0);
1986
1987 /* Don't free pending_scroll_to, since thats needed until
1988 * the load_complete callback.
1989 */
1990
1991 if (slot->mount_cancellable != NULL((void*)0))
1992 {
1993 g_cancellable_cancel (slot->mount_cancellable);
1994 slot->mount_cancellable = NULL((void*)0);
1995 }
1996
1997 if (slot->determine_view_file != NULL((void*)0))
1998 {
1999 baul_file_cancel_call_when_ready
2000 (slot->determine_view_file,
2001 got_file_info_for_view_selection_callback, slot);
2002 slot->determine_view_file = NULL((void*)0);
2003 }
2004
2005 if (slot->new_content_view != NULL((void*)0))
2006 {
2007 window->details->temporarily_ignore_view_signals = TRUE(!(0));
2008 baul_view_stop_loading (slot->new_content_view);
2009 window->details->temporarily_ignore_view_signals = FALSE(0);
2010
2011 baul_window_slot_disconnect_content_view (slot, slot->new_content_view);
2012 g_object_unref (slot->new_content_view);
2013 slot->new_content_view = NULL((void*)0);
2014 }
2015}
2016
2017static void
2018cancel_location_change (BaulWindowSlot *slot)
2019{
2020 if (slot->pending_location != NULL((void*)0)
2021 && slot->location != NULL((void*)0)
2022 && slot->content_view != NULL((void*)0))
2023 {
2024 GList *selection;
2025
2026 /* No need to tell the new view - either it is the
2027 * same as the old view, in which case it will already
2028 * be told, or it is the very pending change we wish
2029 * to cancel.
2030 */
2031 selection = baul_view_get_selection (slot->content_view);
2032 load_new_location (slot,
2033 slot->location,
2034 selection,
2035 TRUE(!(0)),
2036 FALSE(0));
2037 g_list_free_full (selection, g_object_unref);
2038 }
2039
2040 end_location_change (slot);
2041}
2042
2043void
2044baul_window_report_view_failed (BaulWindow *window,
2045 BaulView *view)
2046{
2047 BaulWindowSlot *slot;
2048 gboolean do_close_window;
2049 GFile *fallback_load_location;
2050
2051 if (window->details->temporarily_ignore_view_signals)
2052 {
2053 return;
2054 }
2055
2056 slot = baul_window_get_slot_for_view (window, view);
2057 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 2057, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
2058
2059 g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged.");
2060
2061 do_close_window = FALSE(0);
2062 fallback_load_location = NULL((void*)0);
2063
2064 if (view == slot->content_view)
2065 {
2066 baul_window_slot_disconnect_content_view (slot, view);
2067 baul_window_slot_set_content_view_widget (slot, NULL((void*)0));
2068
2069 report_current_content_view_failure_to_user (slot);
2070 }
2071 else
2072 {
2073 /* Only report error on first try */
2074 if (slot->location_change_type != BAUL_LOCATION_CHANGE_FALLBACK)
2075 {
2076 report_nascent_content_view_failure_to_user (slot, view);
2077
2078 fallback_load_location = g_object_ref (slot->pending_location)((__typeof__ (slot->pending_location)) (g_object_ref) (slot
->pending_location))
;
2079 }
2080 else
2081 {
2082 if (!ctk_widget_get_visible (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
))
2083 {
2084 do_close_window = TRUE(!(0));
2085 }
2086 }
2087 }
2088
2089 cancel_location_change (slot);
2090
2091 if (fallback_load_location != NULL((void*)0))
2092 {
2093 /* We loose the pending selection change here, but who cares... */
2094 begin_location_change (slot, fallback_load_location, NULL((void*)0), NULL((void*)0),
2095 BAUL_LOCATION_CHANGE_FALLBACK, 0, NULL((void*)0), NULL((void*)0), NULL((void*)0));
2096 g_object_unref (fallback_load_location);
2097 }
2098
2099 if (do_close_window)
2100 {
2101 ctk_widget_destroy (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((ctk_widget_get_type ()))))))
);
2102 }
2103}
2104
2105static void
2106display_view_selection_failure (BaulWindow *window, BaulFile *file,
2107 GFile *location, GError *error)
2108{
2109 char *full_uri_for_display;
2110 char *uri_for_display;
2111 char *error_message;
2112 char *detail_message;
2113 char *scheme_string;
2114
2115 /* Some sort of failure occurred. How 'bout we tell the user? */
2116 full_uri_for_display = g_file_get_parse_name (location);
2117 /* Truncate the URI so it doesn't get insanely wide. Note that even
2118 * though the dialog uses wrapped text, if the URI doesn't contain
2119 * white space then the text-wrapping code is too stupid to wrap it.
2120 */
2121 uri_for_display = eel_str_middle_truncate
2122 (full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH60);
2123 g_free (full_uri_for_display);
2124
2125 error_message = NULL((void*)0);
2126 detail_message = NULL((void*)0);
2127 if (error
32.1
'error' is equal to NULL
== NULL((void*)0))
33
Taking true branch
2128 {
2129 if (baul_file_is_directory (file))
34
Assuming the condition is false
35
Taking false branch
2130 {
2131 error_message = g_strdup_printf
2132 (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2133 uri_for_display);
2134 detail_message = g_strdupg_strdup_inline (gettext ("Baul has no installed viewer capable of displaying the folder."
))
2135 (_("Baul has no installed viewer capable of displaying the folder."))g_strdup_inline (gettext ("Baul has no installed viewer capable of displaying the folder."
))
;
2136 }
2137 else
2138 {
2139 error_message = g_strdup_printf
2140 (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2141 uri_for_display);
2142 detail_message = g_strdupg_strdup_inline (gettext ("The location is not a folder."))
2143 (_("The location is not a folder."))g_strdup_inline (gettext ("The location is not a folder."));
2144 }
2145 }
2146 else if (error->domain == G_IO_ERRORg_io_error_quark())
2147 {
2148 switch (error->code)
2149 {
2150 case G_IO_ERROR_NOT_FOUND:
2151 error_message = g_strdup_printf
2152 (_("Could not find \"%s\".")gettext ("Could not find \"%s\"."),
2153 uri_for_display);
2154 detail_message = g_strdupg_strdup_inline (gettext ("Please check the spelling and try again."
))
2155 (_("Please check the spelling and try again."))g_strdup_inline (gettext ("Please check the spelling and try again."
))
;
2156 break;
2157 case G_IO_ERROR_NOT_SUPPORTED:
2158 scheme_string = g_file_get_uri_scheme (location);
2159
2160 error_message = g_strdup_printf (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2161 uri_for_display);
2162 if (scheme_string != NULL((void*)0))
2163 {
2164 detail_message = g_strdup_printf (_("Baul cannot handle \"%s\" locations.")gettext ("Baul cannot handle \"%s\" locations."),
2165 scheme_string);
2166 }
2167 else
2168 {
2169 detail_message = g_strdup (_("Baul cannot handle this kind of location."))g_strdup_inline (gettext ("Baul cannot handle this kind of location."
))
;
2170 }
2171 g_free (scheme_string);
2172 break;
2173 case G_IO_ERROR_NOT_MOUNTED:
2174 error_message = g_strdup_printf (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2175 uri_for_display);
2176 detail_message = g_strdup (_("Unable to mount the location."))g_strdup_inline (gettext ("Unable to mount the location."));
2177 break;
2178
2179 case G_IO_ERROR_PERMISSION_DENIED:
2180 error_message = g_strdup_printf (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2181 uri_for_display);
2182 detail_message = g_strdup (_("Access was denied."))g_strdup_inline (gettext ("Access was denied."));
2183 break;
2184
2185 case G_IO_ERROR_HOST_NOT_FOUND:
2186 /* This case can be hit for user-typed strings like "foo" due to
2187 * the code that guesses web addresses when there's no initial "/".
2188 * But this case is also hit for legiticafe web addresses when
2189 * the proxy is set up wrong.
2190 */
2191 error_message = g_strdup_printf (_("Could not display \"%s\", because the host could not be found.")gettext ("Could not display \"%s\", because the host could not be found."
)
,
2192 uri_for_display);
2193 detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct."))g_strdup_inline (gettext ("Check that the spelling is correct and that your proxy settings are correct."
))
;
2194 break;
2195 case G_IO_ERROR_CANCELLED:
2196 case G_IO_ERROR_FAILED_HANDLED:
2197 g_free (uri_for_display);
2198 return;
2199
2200 default:
2201 break;
2202 }
2203 }
2204
2205 if (error_message == NULL((void*)0))
36
Assuming 'error_message' is equal to NULL
37
Taking true branch
2206 {
2207 error_message = g_strdup_printf (_("Could not display \"%s\".")gettext ("Could not display \"%s\"."),
2208 uri_for_display);
2209 detail_message = g_strdup_printf (_("Error: %s\nPlease select another viewer and try again.")gettext ("Error: %s\nPlease select another viewer and try again."
)
, error->message);
38
Access to field 'message' results in a dereference of a null pointer (loaded from variable 'error')
2210 }
2211
2212 eel_show_error_dialog (error_message, detail_message, NULL((void*)0));
2213
2214 g_free (uri_for_display);
2215 g_free (error_message);
2216 g_free (detail_message);
2217}
2218
2219
2220void
2221baul_window_slot_stop_loading (BaulWindowSlot *slot)
2222{
2223 BaulWindow *window;
2224
2225 window = BAUL_WINDOW (slot->pane->window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((slot->pane->window)), (baul_window_get_type())))))
;
2226 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 2226, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
2227
2228 baul_view_stop_loading (slot->content_view);
2229
2230 if (slot->new_content_view != NULL((void*)0))
2231 {
2232 window->details->temporarily_ignore_view_signals = TRUE(!(0));
2233 baul_view_stop_loading (slot->new_content_view);
2234 window->details->temporarily_ignore_view_signals = FALSE(0);
2235 }
2236
2237 cancel_location_change (slot);
2238}
2239
2240void
2241baul_window_slot_set_content_view (BaulWindowSlot *slot,
2242 const char *id)
2243{
2244 BaulWindow *window;
2245 BaulFile *file;
2246 char *uri;
2247
2248 g_assert (slot != NULL)do { if (slot != ((void*)0)) ; else g_assertion_message_expr (
((gchar*) 0), "baul-window-manage-views.c", 2248, ((const char
*) (__func__)), "slot != NULL"); } while (0)
;
2249 g_assert (slot->location != NULL)do { if (slot->location != ((void*)0)) ; else g_assertion_message_expr
(((gchar*) 0), "baul-window-manage-views.c", 2249, ((const char
*) (__func__)), "slot->location != NULL"); } while (0)
;
2250 g_assert (id != NULL)do { if (id != ((void*)0)) ; else g_assertion_message_expr ((
(gchar*) 0), "baul-window-manage-views.c", 2250, ((const char
*) (__func__)), "id != NULL"); } while (0)
;
2251
2252 window = slot->pane->window;
2253 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 2253, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
2254
2255 uri = baul_window_slot_get_location_uri (slot);
2256 baul_debug_log (FALSE(0), BAUL_DEBUG_LOG_DOMAIN_USER"USER",
2257 "change view of window %p: \"%s\" to \"%s\"",
2258 window, uri, id);
2259 g_free (uri);
2260
2261 if (baul_window_slot_content_view_matches_iid (slot, id))
2262 {
2263 return;
2264 }
2265
2266 end_location_change (slot);
2267
2268 file = baul_file_get (slot->location);
2269 baul_file_set_metadata
2270 (file, BAUL_METADATA_KEY_DEFAULT_VIEW"baul-default-view", NULL((void*)0), id);
2271 baul_file_unref (file);
2272
2273 baul_window_slot_set_allow_stop (slot, TRUE(!(0)));
2274
2275 if (baul_view_get_selection_count (slot->content_view) == 0)
2276 {
2277 /* If there is no selection, queue a scroll to the same icon that
2278 * is currently visible */
2279 slot->pending_scroll_to = baul_view_get_first_visible_file (slot->content_view);
2280 }
2281 slot->location_change_type = BAUL_LOCATION_CHANGE_RELOAD;
2282
2283 create_content_view (slot, id);
2284}
2285
2286void
2287baul_window_manage_views_close_slot (BaulWindowPane *pane,
2288 BaulWindowSlot *slot)
2289{
2290 if (slot->content_view != NULL((void*)0))
2291 {
2292 baul_window_slot_disconnect_content_view (slot, slot->content_view);
2293 }
2294
2295 free_location_change (slot);
2296 cancel_viewed_file_changed_callback (slot);
2297}
2298
2299void
2300baul_navigation_window_back_or_forward (BaulNavigationWindow *window,
2301 gboolean back, guint distance, gboolean new_tab)
2302{
2303 BaulWindowSlot *slot;
2304 BaulNavigationWindowSlot *navigation_slot;
2305 GList *list;
2306 GFile *location;
2307 guint len;
2308 BaulBookmark *bookmark;
2309
2310 slot = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (baul_window_get_type())))))
->details->active_pane->active_slot;
2311 navigation_slot = (BaulNavigationWindowSlot *) slot;
2312 list = back ? navigation_slot->back_list : navigation_slot->forward_list;
2313
2314 len = (guint) g_list_length (list);
2315
2316 /* If we can't move in the direction at all, just return. */
2317 if (len == 0)
2318 return;
2319
2320 /* If the distance to move is off the end of the list, go to the end
2321 of the list. */
2322 if (distance >= len)
2323 distance = len - 1;
2324
2325 bookmark = g_list_nth_data (list, distance);
2326 location = baul_bookmark_get_location (bookmark);
2327
2328 if (new_tab)
2329 {
2330 baul_window_slot_open_location_full (slot, location,
2331 BAUL_WINDOW_OPEN_ACCORDING_TO_MODE,
2332 BAUL_WINDOW_OPEN_FLAG_NEW_TAB,
2333 NULL((void*)0), NULL((void*)0), NULL((void*)0));
2334 }
2335 else
2336 {
2337 GFile *old_location;
2338 char *scroll_pos;
2339
2340 old_location = baul_window_slot_get_location (slot);
2341 scroll_pos = baul_bookmark_get_scroll_pos (bookmark);
2342 begin_location_change
2343 (slot,
2344 location, old_location, NULL((void*)0),
2345 back ? BAUL_LOCATION_CHANGE_BACK : BAUL_LOCATION_CHANGE_FORWARD,
2346 distance,
2347 scroll_pos,
2348 NULL((void*)0), NULL((void*)0));
2349
2350 if (old_location) {
2351 g_object_unref (old_location);
2352 }
2353
2354 g_free (scroll_pos);
2355 }
2356
2357 g_object_unref (location);
2358}
2359
2360/* reload the contents of the window */
2361void
2362baul_window_slot_reload (BaulWindowSlot *slot)
2363{
2364 GFile *location;
2365 char *current_pos;
2366 GList *selection;
2367
2368 g_assert (BAUL_IS_WINDOW_SLOT (slot))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((slot)); GType __t = ((baul_window_slot_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-window-manage-views.c"
, 2368, ((const char*) (__func__)), "BAUL_IS_WINDOW_SLOT (slot)"
); } while (0)
;
2369
2370 if (slot->location == NULL((void*)0))
2371 {
2372 return;
2373 }
2374
2375 /* peek_slot_field (window, location) can be free'd during the processing
2376 * of begin_location_change, so make a copy
2377 */
2378 location = g_object_ref (slot->location)((__typeof__ (slot->location)) (g_object_ref) (slot->location
))
;
2379 current_pos = NULL((void*)0);
2380 selection = NULL((void*)0);
2381 if (slot->content_view != NULL((void*)0))
2382 {
2383 current_pos = baul_view_get_first_visible_file (slot->content_view);
2384 selection = baul_view_get_selection (slot->content_view);
2385 }
2386 begin_location_change
2387 (slot, location, location, selection,
2388 BAUL_LOCATION_CHANGE_RELOAD, 0, current_pos,
2389 NULL((void*)0), NULL((void*)0));
2390 g_free (current_pos);
2391 g_object_unref (location);
2392 g_list_free_full (selection, g_object_unref);
2393}
2394
2395void
2396baul_window_reload (BaulWindow *window)
2397{
2398 g_assert (BAUL_IS_WINDOW (window))do { if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((window)); GType __t = (baul_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-window-manage-views.c"
, 2398, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)"
); } while (0)
;
2399
2400 baul_window_slot_reload (window->details->active_pane->active_slot);
2401}
2402