| File: | src/baul-navigation-window.c |
| Warning: | line 602, column 5 Value stored to 'handled' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
| 2 | |
| 3 | /* |
| 4 | * Baul |
| 5 | * |
| 6 | * Copyright (C) 1999, 2000 Red Hat, Inc. |
| 7 | * Copyright (C) 1999, 2000, 2001 Eazel, Inc. |
| 8 | * Copyright (C) 2003 Ximian, Inc. |
| 9 | * |
| 10 | * Baul is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * Baul is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public |
| 21 | * License along with this program; if not, write to the Free |
| 22 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 23 | * |
| 24 | * Authors: Elliot Lee <sopwith@redhat.com> |
| 25 | * John Sullivan <sullivan@eazel.com> |
| 26 | * |
| 27 | */ |
| 28 | |
| 29 | /* baul-window.c: Implementation of the main window object */ |
| 30 | |
| 31 | #include <config.h> |
| 32 | #include <math.h> |
| 33 | |
| 34 | #include <gdk-pixbuf/gdk-pixbuf.h> |
| 35 | #include <cdk/cdkx.h> |
| 36 | #include <ctk/ctk.h> |
| 37 | #include <glib/gi18n.h> |
| 38 | #ifdef HAVE_X11_XF86KEYSYM_H1 |
| 39 | #include <X11/XF86keysym.h> |
| 40 | #endif |
| 41 | #include <sys/time.h> |
| 42 | |
| 43 | #include <eel/eel-ctk-extensions.h> |
| 44 | #include <eel/eel-ctk-macros.h> |
| 45 | #include <eel/eel-string.h> |
| 46 | |
| 47 | #include <libbaul-private/baul-file-utilities.h> |
| 48 | #include <libbaul-private/baul-file-attributes.h> |
| 49 | #include <libbaul-private/baul-global-preferences.h> |
| 50 | #include <libbaul-private/baul-icon-info.h> |
| 51 | #include <libbaul-private/baul-metadata.h> |
| 52 | #include <libbaul-private/baul-mime-actions.h> |
| 53 | #include <libbaul-private/baul-program-choosing.h> |
| 54 | #include <libbaul-private/baul-sidebar.h> |
| 55 | #include <libbaul-private/baul-view-factory.h> |
| 56 | #include <libbaul-private/baul-clipboard.h> |
| 57 | #include <libbaul-private/baul-module.h> |
| 58 | #include <libbaul-private/baul-sidebar-provider.h> |
| 59 | #include <libbaul-private/baul-search-directory.h> |
| 60 | #include <libbaul-private/baul-signaller.h> |
| 61 | |
| 62 | #include "baul-navigation-window.h" |
| 63 | #include "baul-window-private.h" |
| 64 | #include "baul-actions.h" |
| 65 | #include "baul-application.h" |
| 66 | #include "baul-bookmarks-window.h" |
| 67 | #include "baul-location-bar.h" |
| 68 | #include "baul-query-editor.h" |
| 69 | #include "baul-search-bar.h" |
| 70 | #include "baul-navigation-window-slot.h" |
| 71 | #include "baul-notebook.h" |
| 72 | #include "baul-window-manage-views.h" |
| 73 | #include "baul-navigation-window-pane.h" |
| 74 | |
| 75 | #define MAX_TITLE_LENGTH180 180 |
| 76 | |
| 77 | #define MENU_PATH_BOOKMARKS_PLACEHOLDER"/MenuBar/Other Menus/Bookmarks/Bookmarks Placeholder" "/MenuBar/Other Menus/Bookmarks/Bookmarks Placeholder" |
| 78 | |
| 79 | /* Forward and back buttons on the mouse */ |
| 80 | static gboolean mouse_extra_buttons = TRUE(!(0)); |
| 81 | static int mouse_forward_button = 9; |
| 82 | static int mouse_back_button = 8; |
| 83 | |
| 84 | static void add_sidebar_panels (BaulNavigationWindow *window); |
| 85 | static void side_panel_image_changed_callback (BaulSidebar *side_panel, |
| 86 | gpointer callback_data); |
| 87 | static void always_use_location_entry_changed (gpointer callback_data); |
| 88 | static void always_use_browser_changed (gpointer callback_data); |
| 89 | static void mouse_back_button_changed (gpointer callback_data); |
| 90 | static void mouse_forward_button_changed (gpointer callback_data); |
| 91 | static void use_extra_mouse_buttons_changed (gpointer callback_data); |
| 92 | static BaulWindowSlot *create_extra_pane (BaulNavigationWindow *window); |
| 93 | |
| 94 | |
| 95 | G_DEFINE_TYPE_WITH_PRIVATE (BaulNavigationWindow, baul_navigation_window, BAUL_TYPE_WINDOW)static void baul_navigation_window_init (BaulNavigationWindow *self); static void baul_navigation_window_class_init (BaulNavigationWindowClass *klass); static GType baul_navigation_window_get_type_once ( void); static gpointer baul_navigation_window_parent_class = ( (void*)0); static gint BaulNavigationWindow_private_offset; static void baul_navigation_window_class_intern_init (gpointer klass ) { baul_navigation_window_parent_class = g_type_class_peek_parent (klass); if (BaulNavigationWindow_private_offset != 0) g_type_class_adjust_private_offset (klass, &BaulNavigationWindow_private_offset); baul_navigation_window_class_init ((BaulNavigationWindowClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer baul_navigation_window_get_instance_private (BaulNavigationWindow *self) { return (((gpointer) ((guint8* ) (self) + (glong) (BaulNavigationWindow_private_offset)))); } GType baul_navigation_window_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); (void ) (0 ? (gpointer) * (&static_g_define_type_id) : ((void*) 0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = baul_navigation_window_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); 0 ? (void) (*( &static_g_define_type_id) = (g_define_type_id)) : (void) 0 ; g_once_init_leave_pointer ((&static_g_define_type_id), ( gpointer) (guintptr) (g_define_type_id)); })) ; } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType baul_navigation_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple (baul_window_get_type(), g_intern_static_string ("BaulNavigationWindow" ), sizeof (BaulNavigationWindowClass), (GClassInitFunc)(void ( *)(void)) baul_navigation_window_class_intern_init, sizeof (BaulNavigationWindow ), (GInstanceInitFunc)(void (*)(void)) baul_navigation_window_init , (GTypeFlags) 0); { {{ BaulNavigationWindow_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (BaulNavigationWindowPrivate )); };} } return g_define_type_id; } |
| 96 | #define parent_classbaul_navigation_window_parent_class baul_navigation_window_parent_class |
| 97 | |
| 98 | static const struct |
| 99 | { |
| 100 | unsigned int keyval; |
| 101 | const char *action; |
| 102 | } extra_navigation_window_keybindings [] = |
| 103 | { |
| 104 | #ifdef HAVE_X11_XF86KEYSYM_H1 |
| 105 | { XF86XK_Back0x1008ff26, BAUL_ACTION_BACK"Back" }, |
| 106 | { XF86XK_Forward0x1008ff27, BAUL_ACTION_FORWARD"Forward" } |
| 107 | #endif |
| 108 | }; |
| 109 | |
| 110 | static void |
| 111 | baul_navigation_window_init (BaulNavigationWindow *window) |
| 112 | { |
| 113 | CtkUIManager *ui_manager; |
| 114 | CtkWidget *toolbar; |
| 115 | BaulWindow *win; |
| 116 | BaulNavigationWindowPane *pane; |
| 117 | CtkWidget *hpaned; |
| 118 | CtkWidget *vbox; |
| 119 | |
| 120 | win = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type()))))); |
| 121 | |
| 122 | window->details = baul_navigation_window_get_instance_private (window); |
| 123 | |
| 124 | CtkStyleContext *context; |
| 125 | |
| 126 | context = ctk_widget_get_style_context (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))); |
| 127 | ctk_style_context_add_class (context, "baul-navigation-window"); |
| 128 | |
| 129 | pane = baul_navigation_window_pane_new (win); |
| 130 | win->details->panes = g_list_prepend (win->details->panes, pane); |
| 131 | |
| 132 | window->details->header_size_group = ctk_size_group_new (CTK_SIZE_GROUP_VERTICAL); |
| 133 | |
| 134 | window->details->content_paned = ctk_paned_new (CTK_ORIENTATION_HORIZONTAL); |
| 135 | ctk_widget_set_hexpand (window->details->content_paned, TRUE(!(0))); |
| 136 | ctk_widget_set_vexpand (window->details->content_paned, TRUE(!(0))); |
| 137 | ctk_grid_attach (CTK_GRID (BAUL_WINDOW (window)->details->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->grid )), ((ctk_grid_get_type ())))))), |
| 138 | window->details->content_paned, |
| 139 | 0, 3, 1, 1); |
| 140 | ctk_widget_show (window->details->content_paned); |
| 141 | |
| 142 | vbox = ctk_box_new (CTK_ORIENTATION_VERTICAL, 0); |
| 143 | ctk_paned_pack2 (CTK_PANED (window->details->content_paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->content_paned)), ((ctk_paned_get_type ())))))), vbox, |
| 144 | TRUE(!(0)), FALSE(0)); |
| 145 | ctk_widget_show (vbox); |
| 146 | |
| 147 | hpaned = ctk_paned_new (CTK_ORIENTATION_HORIZONTAL); |
| 148 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), hpaned, TRUE(!(0)), TRUE(!(0)), 0); |
| 149 | ctk_widget_show (hpaned); |
| 150 | window->details->split_view_hpane = hpaned; |
| 151 | |
| 152 | ctk_box_pack_start (CTK_BOX (vbox)((((CtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((vbox)), ((ctk_box_get_type ())))))), win->details->statusbar, FALSE(0), FALSE(0), 0); |
| 153 | ctk_widget_show (win->details->statusbar); |
| 154 | |
| 155 | baul_navigation_window_pane_setup (pane); |
| 156 | |
| 157 | ctk_paned_pack1 (CTK_PANED(hpaned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((hpaned)), ((ctk_paned_get_type ())))))), pane->widget, TRUE(!(0)), FALSE(0)); |
| 158 | ctk_widget_show (pane->widget); |
| 159 | |
| 160 | /* this has to be done after the location bar has been set up, |
| 161 | * but before menu stuff is being called */ |
| 162 | baul_window_set_active_pane (win, BAUL_WINDOW_PANE (pane)((((BaulWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane)), ((baul_window_pane_get_type()))))))); |
| 163 | |
| 164 | baul_navigation_window_initialize_actions (window); |
| 165 | |
| 166 | baul_navigation_window_initialize_menus (window); |
| 167 | |
| 168 | ui_manager = baul_window_get_ui_manager (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))); |
| 169 | toolbar = ctk_ui_manager_get_widget (ui_manager, "/Toolbar"); |
| 170 | ctk_style_context_add_class (ctk_widget_get_style_context (toolbar), CTK_STYLE_CLASS_PRIMARY_TOOLBAR"primary-toolbar"); |
| 171 | window->details->toolbar = toolbar; |
| 172 | ctk_widget_set_hexpand (toolbar, TRUE(!(0))); |
| 173 | ctk_grid_attach (CTK_GRID (BAUL_WINDOW (window)->details->grid)((((CtkGrid*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->grid )), ((ctk_grid_get_type ())))))), |
| 174 | toolbar, |
| 175 | 0, 1, 1, 1); |
| 176 | ctk_widget_show (toolbar); |
| 177 | |
| 178 | baul_navigation_window_initialize_toolbars (window); |
| 179 | |
| 180 | /* Set initial sensitivity of some buttons & menu items |
| 181 | * now that they're all created. |
| 182 | */ |
| 183 | baul_navigation_window_allow_back (window, FALSE(0)); |
| 184 | baul_navigation_window_allow_forward (window, FALSE(0)); |
| 185 | |
| 186 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "always-use-location-entry" ), (((GCallback) (always_use_location_entry_changed))), (window ), ((void*)0), G_CONNECT_SWAPPED) |
| 187 | "changed::" BAUL_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY,g_signal_connect_data ((baul_preferences), ("changed::" "always-use-location-entry" ), (((GCallback) (always_use_location_entry_changed))), (window ), ((void*)0), G_CONNECT_SWAPPED) |
| 188 | G_CALLBACK(always_use_location_entry_changed),g_signal_connect_data ((baul_preferences), ("changed::" "always-use-location-entry" ), (((GCallback) (always_use_location_entry_changed))), (window ), ((void*)0), G_CONNECT_SWAPPED) |
| 189 | window)g_signal_connect_data ((baul_preferences), ("changed::" "always-use-location-entry" ), (((GCallback) (always_use_location_entry_changed))), (window ), ((void*)0), G_CONNECT_SWAPPED); |
| 190 | |
| 191 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "always-use-browser" ), (((GCallback) (always_use_browser_changed))), (window), (( void*)0), G_CONNECT_SWAPPED) |
| 192 | "changed::" BAUL_PREFERENCES_ALWAYS_USE_BROWSER,g_signal_connect_data ((baul_preferences), ("changed::" "always-use-browser" ), (((GCallback) (always_use_browser_changed))), (window), (( void*)0), G_CONNECT_SWAPPED) |
| 193 | G_CALLBACK(always_use_browser_changed),g_signal_connect_data ((baul_preferences), ("changed::" "always-use-browser" ), (((GCallback) (always_use_browser_changed))), (window), (( void*)0), G_CONNECT_SWAPPED) |
| 194 | window)g_signal_connect_data ((baul_preferences), ("changed::" "always-use-browser" ), (((GCallback) (always_use_browser_changed))), (window), (( void*)0), G_CONNECT_SWAPPED); |
| 195 | } |
| 196 | |
| 197 | static void |
| 198 | always_use_location_entry_changed (gpointer callback_data) |
| 199 | { |
| 200 | BaulNavigationWindow *window; |
| 201 | GList *walk; |
| 202 | gboolean use_entry; |
| 203 | |
| 204 | window = BAUL_NAVIGATION_WINDOW (callback_data)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((callback_data)), (baul_navigation_window_get_type ()))))); |
| 205 | |
| 206 | use_entry = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY"always-use-location-entry"); |
| 207 | |
| 208 | for (walk = BAUL_WINDOW(window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->panes; walk; walk = walk->next) |
| 209 | { |
| 210 | baul_navigation_window_pane_always_use_location_entry (walk->data, use_entry); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | static void |
| 215 | always_use_browser_changed (gpointer callback_data) |
| 216 | { |
| 217 | BaulNavigationWindow *window; |
| 218 | |
| 219 | window = BAUL_NAVIGATION_WINDOW (callback_data)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((callback_data)), (baul_navigation_window_get_type ()))))); |
| 220 | |
| 221 | baul_navigation_window_update_spatial_menu_item (window); |
| 222 | } |
| 223 | |
| 224 | /* Sanity check: highest mouse button value I could find was 14. 5 is our |
| 225 | * lower threshold (well-documented to be the one of the button events for the |
| 226 | * scrollwheel), so it's hardcoded in the functions below. However, if you have |
| 227 | * a button that registers higher and want to map it, file a bug and |
| 228 | * we'll move the bar. Makes you wonder why the X guys don't have |
| 229 | * defined values for these like the XKB stuff, huh? |
| 230 | */ |
| 231 | #define UPPER_MOUSE_LIMIT14 14 |
| 232 | |
| 233 | static void |
| 234 | mouse_back_button_changed (gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 235 | { |
| 236 | int new_back_button; |
| 237 | |
| 238 | new_back_button = g_settings_get_int (baul_preferences, BAUL_PREFERENCES_MOUSE_BACK_BUTTON"mouse-back-button"); |
| 239 | |
| 240 | /* Bounds checking */ |
| 241 | if (new_back_button < 6 || new_back_button > UPPER_MOUSE_LIMIT14) |
| 242 | return; |
| 243 | |
| 244 | mouse_back_button = new_back_button; |
| 245 | } |
| 246 | |
| 247 | static void |
| 248 | mouse_forward_button_changed (gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 249 | { |
| 250 | int new_forward_button; |
| 251 | |
| 252 | new_forward_button = g_settings_get_int (baul_preferences, BAUL_PREFERENCES_MOUSE_FORWARD_BUTTON"mouse-forward-button"); |
| 253 | |
| 254 | /* Bounds checking */ |
| 255 | if (new_forward_button < 6 || new_forward_button > UPPER_MOUSE_LIMIT14) |
| 256 | return; |
| 257 | |
| 258 | mouse_forward_button = new_forward_button; |
| 259 | } |
| 260 | |
| 261 | static void |
| 262 | use_extra_mouse_buttons_changed (gpointer callback_data G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 263 | { |
| 264 | mouse_extra_buttons = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS"mouse-use-extra-buttons"); |
| 265 | } |
| 266 | |
| 267 | void |
| 268 | baul_navigation_window_unset_focus_widget (BaulNavigationWindow *window) |
| 269 | { |
| 270 | if (window->details->last_focus_widget != NULL((void*)0)) |
| 271 | { |
| 272 | g_object_remove_weak_pointer (G_OBJECT (window->details->last_focus_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->last_focus_widget)), (((GType) (( 20) << (2)))))))), |
| 273 | (gpointer *) &window->details->last_focus_widget); |
| 274 | window->details->last_focus_widget = NULL((void*)0); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | gboolean |
| 279 | baul_navigation_window_is_in_temporary_navigation_bar (CtkWidget *widget, |
| 280 | BaulNavigationWindow *window) |
| 281 | { |
| 282 | GList *walk; |
| 283 | gboolean is_in_any = FALSE(0); |
| 284 | |
| 285 | for (walk = BAUL_WINDOW(window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->panes; walk; walk = walk->next) |
| 286 | { |
| 287 | BaulNavigationWindowPane *pane = walk->data; |
| 288 | if(ctk_widget_get_ancestor (widget, BAUL_TYPE_LOCATION_BARbaul_location_bar_get_type()) != NULL((void*)0) && |
| 289 | pane->temporary_navigation_bar) |
| 290 | is_in_any = TRUE(!(0)); |
| 291 | } |
| 292 | return is_in_any; |
| 293 | } |
| 294 | |
| 295 | gboolean |
| 296 | baul_navigation_window_is_in_temporary_search_bar (CtkWidget *widget, |
| 297 | BaulNavigationWindow *window) |
| 298 | { |
| 299 | GList *walk; |
| 300 | gboolean is_in_any = FALSE(0); |
| 301 | |
| 302 | for (walk = BAUL_WINDOW(window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->panes; walk; walk = walk->next) |
| 303 | { |
| 304 | BaulNavigationWindowPane *pane = walk->data; |
| 305 | if(ctk_widget_get_ancestor (widget, BAUL_TYPE_SEARCH_BARbaul_search_bar_get_type()) != NULL((void*)0) && |
| 306 | pane->temporary_search_bar) |
| 307 | is_in_any = TRUE(!(0)); |
| 308 | } |
| 309 | return is_in_any; |
| 310 | } |
| 311 | |
| 312 | static void |
| 313 | remember_focus_widget (BaulNavigationWindow *window) |
| 314 | { |
| 315 | BaulNavigationWindow *navigation_window; |
| 316 | CtkWidget *focus_widget; |
| 317 | |
| 318 | navigation_window = BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ()))))); |
| 319 | |
| 320 | focus_widget = ctk_window_get_focus (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); |
| 321 | if (focus_widget != NULL((void*)0) && |
| 322 | !baul_navigation_window_is_in_temporary_navigation_bar (focus_widget, navigation_window) && |
| 323 | !baul_navigation_window_is_in_temporary_search_bar (focus_widget, navigation_window)) |
| 324 | { |
| 325 | baul_navigation_window_unset_focus_widget (navigation_window); |
| 326 | |
| 327 | navigation_window->details->last_focus_widget = focus_widget; |
| 328 | g_object_add_weak_pointer (G_OBJECT (focus_widget)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((focus_widget)), (((GType) ((20) << (2)))))))), |
| 329 | (gpointer *) &(BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ())))))->details->last_focus_widget)); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | void |
| 334 | baul_navigation_window_restore_focus_widget (BaulNavigationWindow *window) |
| 335 | { |
| 336 | if (window->details->last_focus_widget != NULL((void*)0)) |
| 337 | { |
| 338 | if (BAUL_IS_VIEW (window->details->last_focus_widget)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (window->details->last_focus_widget)); GType __t = ((baul_view_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; }))))) |
| 339 | { |
| 340 | baul_view_grab_focus (BAUL_VIEW (window->details->last_focus_widget)((((BaulView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->last_focus_widget)), ((baul_view_get_type ()))))))); |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | ctk_widget_grab_focus (window->details->last_focus_widget); |
| 345 | } |
| 346 | |
| 347 | baul_navigation_window_unset_focus_widget (window); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | static void |
| 352 | side_pane_close_requested_callback (CtkWidget *widget G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 353 | gpointer user_data) |
| 354 | { |
| 355 | BaulNavigationWindow *window; |
| 356 | |
| 357 | window = BAUL_NAVIGATION_WINDOW (user_data)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((user_data)), (baul_navigation_window_get_type ()))))); |
| 358 | |
| 359 | baul_navigation_window_hide_sidebar (window); |
| 360 | } |
| 361 | |
| 362 | static void |
| 363 | side_pane_size_allocate_callback (CtkWidget *widget, |
| 364 | CtkAllocation *allocation, |
| 365 | gpointer user_data) |
| 366 | { |
| 367 | BaulNavigationWindow *window; |
| 368 | gint scale; |
| 369 | |
| 370 | window = BAUL_NAVIGATION_WINDOW (user_data)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((user_data)), (baul_navigation_window_get_type ()))))); |
| 371 | scale = ctk_widget_get_scale_factor (widget); |
| 372 | |
| 373 | allocation->width = allocation->width / scale; |
| 374 | if (allocation->width != window->details->side_pane_width) |
| 375 | { |
| 376 | window->details->side_pane_width = allocation->width; |
| 377 | g_settings_set_int (baul_window_state, |
| 378 | BAUL_WINDOW_STATE_SIDEBAR_WIDTH"sidebar-width", |
| 379 | allocation->width <= 1 ? 0 : allocation->width); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | static void |
| 384 | setup_side_pane_width (BaulNavigationWindow *window) |
| 385 | { |
| 386 | gint scale; |
| 387 | |
| 388 | g_return_if_fail (window->sidebar != NULL)do { if ((window->sidebar != ((void*)0))) { } else { g_return_if_fail_warning (((gchar*) 0), ((const char*) (__func__)), "window->sidebar != NULL" ); return; } } while (0); |
| 389 | |
| 390 | scale = ctk_widget_get_scale_factor (CTK_WIDGET (window->sidebar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->sidebar)), ((ctk_widget_get_type ()))))))); |
| 391 | window->details->side_pane_width = |
| 392 | g_settings_get_int (baul_window_state, |
| 393 | BAUL_WINDOW_STATE_SIDEBAR_WIDTH"sidebar-width") * scale; |
| 394 | |
| 395 | ctk_paned_set_position (CTK_PANED (window->details->content_paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->content_paned)), ((ctk_paned_get_type ())))))), |
| 396 | window->details->side_pane_width); |
| 397 | } |
| 398 | |
| 399 | static void |
| 400 | set_current_side_panel (BaulNavigationWindow *window, |
| 401 | BaulSidebar *panel) |
| 402 | { |
| 403 | if (window->details->current_side_panel) |
| 404 | { |
| 405 | baul_sidebar_is_visible_changed (window->details->current_side_panel, |
| 406 | FALSE(0)); |
| 407 | eel_remove_weak_pointer (&window->details->current_side_panel); |
| 408 | } |
| 409 | |
| 410 | if (panel != NULL((void*)0)) |
| 411 | { |
| 412 | baul_sidebar_is_visible_changed (panel, TRUE(!(0))); |
| 413 | } |
| 414 | window->details->current_side_panel = panel; |
| 415 | eel_add_weak_pointer (&window->details->current_side_panel); |
| 416 | } |
| 417 | |
| 418 | static void |
| 419 | side_pane_switch_page_callback (BaulSidePane *side_pane G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 420 | CtkWidget *widget, |
| 421 | BaulNavigationWindow *window) |
| 422 | { |
| 423 | const char *id; |
| 424 | BaulSidebar *sidebar; |
| 425 | |
| 426 | sidebar = BAUL_SIDEBAR (widget)((((BaulSidebar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((widget)), ((baul_sidebar_get_type ())))))); |
| 427 | |
| 428 | if (sidebar == NULL((void*)0)) |
| 429 | { |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | set_current_side_panel (window, sidebar); |
| 434 | |
| 435 | id = baul_sidebar_get_sidebar_id (sidebar); |
| 436 | g_settings_set_string (baul_window_state, BAUL_WINDOW_STATE_SIDE_PANE_VIEW"side-pane-view", id); |
| 437 | } |
| 438 | |
| 439 | static void |
| 440 | baul_navigation_window_set_up_sidebar (BaulNavigationWindow *window) |
| 441 | { |
| 442 | CtkWidget *title; |
| 443 | |
| 444 | window->sidebar = baul_side_pane_new (); |
| 445 | |
| 446 | title = baul_side_pane_get_title (window->sidebar); |
| 447 | ctk_size_group_add_widget (window->details->header_size_group, |
| 448 | title); |
| 449 | |
| 450 | ctk_paned_pack1 (CTK_PANED (window->details->content_paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->content_paned)), ((ctk_paned_get_type ())))))), |
| 451 | CTK_WIDGET (window->sidebar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->sidebar)), ((ctk_widget_get_type ())))))), |
| 452 | FALSE(0), FALSE(0)); |
| 453 | |
| 454 | setup_side_pane_width (window); |
| 455 | g_signal_connect (window->sidebar,g_signal_connect_data ((window->sidebar), ("size_allocate" ), (((GCallback) (side_pane_size_allocate_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 456 | "size_allocate",g_signal_connect_data ((window->sidebar), ("size_allocate" ), (((GCallback) (side_pane_size_allocate_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 457 | G_CALLBACK (side_pane_size_allocate_callback),g_signal_connect_data ((window->sidebar), ("size_allocate" ), (((GCallback) (side_pane_size_allocate_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 458 | window)g_signal_connect_data ((window->sidebar), ("size_allocate" ), (((GCallback) (side_pane_size_allocate_callback))), (window ), ((void*)0), (GConnectFlags) 0); |
| 459 | |
| 460 | add_sidebar_panels (window); |
| 461 | |
| 462 | g_signal_connect (window->sidebar,g_signal_connect_data ((window->sidebar), ("close_requested" ), (((GCallback) (side_pane_close_requested_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 463 | "close_requested",g_signal_connect_data ((window->sidebar), ("close_requested" ), (((GCallback) (side_pane_close_requested_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 464 | G_CALLBACK (side_pane_close_requested_callback),g_signal_connect_data ((window->sidebar), ("close_requested" ), (((GCallback) (side_pane_close_requested_callback))), (window ), ((void*)0), (GConnectFlags) 0) |
| 465 | window)g_signal_connect_data ((window->sidebar), ("close_requested" ), (((GCallback) (side_pane_close_requested_callback))), (window ), ((void*)0), (GConnectFlags) 0); |
| 466 | |
| 467 | g_signal_connect (window->sidebar,g_signal_connect_data ((window->sidebar), ("switch_page"), (((GCallback) (side_pane_switch_page_callback))), (window), ( (void*)0), (GConnectFlags) 0) |
| 468 | "switch_page",g_signal_connect_data ((window->sidebar), ("switch_page"), (((GCallback) (side_pane_switch_page_callback))), (window), ( (void*)0), (GConnectFlags) 0) |
| 469 | G_CALLBACK (side_pane_switch_page_callback),g_signal_connect_data ((window->sidebar), ("switch_page"), (((GCallback) (side_pane_switch_page_callback))), (window), ( (void*)0), (GConnectFlags) 0) |
| 470 | window)g_signal_connect_data ((window->sidebar), ("switch_page"), (((GCallback) (side_pane_switch_page_callback))), (window), ( (void*)0), (GConnectFlags) 0); |
| 471 | |
| 472 | ctk_widget_show (CTK_WIDGET (window->sidebar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->sidebar)), ((ctk_widget_get_type ()))))))); |
| 473 | } |
| 474 | |
| 475 | static void |
| 476 | baul_navigation_window_tear_down_sidebar (BaulNavigationWindow *window) |
| 477 | { |
| 478 | GList *node, *next; |
| 479 | BaulSidebar *sidebar_panel = NULL((void*)0); |
| 480 | |
| 481 | g_signal_handlers_disconnect_by_func (window->sidebar,g_signal_handlers_disconnect_matched ((window->sidebar), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (side_pane_switch_page_callback), (window )) |
| 482 | side_pane_switch_page_callback,g_signal_handlers_disconnect_matched ((window->sidebar), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (side_pane_switch_page_callback), (window )) |
| 483 | window)g_signal_handlers_disconnect_matched ((window->sidebar), ( GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA) , 0, 0, ((void*)0), (side_pane_switch_page_callback), (window )); |
| 484 | |
| 485 | for (node = window->sidebar_panels; node != NULL((void*)0); node = next) |
| 486 | { |
| 487 | next = node->next; |
| 488 | |
| 489 | sidebar_panel = BAUL_SIDEBAR (node->data)((((BaulSidebar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((node->data)), ((baul_sidebar_get_type ())))))); |
| 490 | |
| 491 | baul_navigation_window_remove_sidebar_panel (window, |
| 492 | sidebar_panel); |
| 493 | } |
| 494 | |
| 495 | ctk_widget_destroy (CTK_WIDGET (window->sidebar)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->sidebar)), ((ctk_widget_get_type ()))))))); |
| 496 | window->sidebar = NULL((void*)0); |
| 497 | } |
| 498 | |
| 499 | static gboolean |
| 500 | baul_navigation_window_state_event (CtkWidget *widget, |
| 501 | CdkEventWindowState *event) |
| 502 | { |
| 503 | if (event->changed_mask & CDK_WINDOW_STATE_MAXIMIZED) |
| 504 | { |
| 505 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_MAXIMIZED"maximized", |
| 506 | event->new_window_state & CDK_WINDOW_STATE_MAXIMIZED); |
| 507 | } |
| 508 | |
| 509 | if (CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->window_state_event != NULL((void*)0)) |
| 510 | { |
| 511 | return CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->window_state_event (widget, event); |
| 512 | } |
| 513 | |
| 514 | return FALSE(0); |
| 515 | } |
| 516 | |
| 517 | static gboolean |
| 518 | baul_navigation_window_key_press_event (CtkWidget *widget, |
| 519 | CdkEventKey *event) |
| 520 | { |
| 521 | BaulNavigationWindow *window; |
| 522 | int i; |
| 523 | |
| 524 | window = BAUL_NAVIGATION_WINDOW (widget)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), (baul_navigation_window_get_type ()))))); |
| 525 | |
| 526 | if (event->state & CDK_CONTROL_MASK) |
| 527 | { |
| 528 | GSettings *settings = g_settings_new ("org.cafe.baul.preferences"); |
| 529 | gboolean handled = FALSE(0); |
| 530 | |
| 531 | if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs")) |
| 532 | { |
| 533 | BaulWindow *baulwin; |
| 534 | BaulWindowSlot *slot; |
| 535 | BaulNavigationWindowPane *pane; |
| 536 | BaulNotebook *baulnotebook; |
| 537 | CtkNotebook *notebook; |
| 538 | int pages; |
| 539 | int page_num; |
| 540 | |
| 541 | baulwin = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type()))))); |
| 542 | slot = baul_window_get_active_slot (baulwin); |
| 543 | pane = BAUL_NAVIGATION_WINDOW_PANE (slot->pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((slot->pane)), ((baul_navigation_window_pane_get_type ())))))); |
| 544 | baulnotebook = BAUL_NOTEBOOK (pane->notebook)((((BaulNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane->notebook)), ((baul_notebook_get_type ())))))); |
| 545 | notebook = CTK_NOTEBOOK (baulnotebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((baulnotebook)), ((ctk_notebook_get_type ())))))); |
| 546 | pages = ctk_notebook_get_n_pages (notebook); |
| 547 | page_num = ctk_notebook_get_current_page (notebook); |
| 548 | |
| 549 | if (event->keyval == CDK_KEY_ISO_Left_Tab0xfe20) |
| 550 | { |
| 551 | if (page_num != 0) |
| 552 | ctk_notebook_prev_page (notebook); |
| 553 | else |
| 554 | ctk_notebook_set_current_page (notebook, (pages - 1)); |
| 555 | handled = TRUE(!(0)); |
| 556 | } |
| 557 | if (event->keyval == CDK_KEY_Tab0xff09) |
| 558 | { |
| 559 | if (page_num != (pages -1)) |
| 560 | ctk_notebook_next_page (notebook); |
| 561 | else |
| 562 | ctk_notebook_set_current_page (notebook, 0); |
| 563 | handled = TRUE(!(0)); |
| 564 | } |
| 565 | } |
| 566 | g_object_unref (settings); |
| 567 | |
| 568 | if (handled) |
| 569 | return TRUE(!(0)); |
| 570 | } |
| 571 | |
| 572 | for (i = 0; i < G_N_ELEMENTS (extra_navigation_window_keybindings)(sizeof (extra_navigation_window_keybindings) / sizeof ((extra_navigation_window_keybindings )[0])); i++) |
| 573 | { |
| 574 | if (extra_navigation_window_keybindings[i].keyval == event->keyval) |
| 575 | { |
| 576 | CtkAction *action; |
| 577 | |
| 578 | action = ctk_action_group_get_action (window->details->navigation_action_group, |
| 579 | extra_navigation_window_keybindings[i].action); |
| 580 | |
| 581 | g_assert (action != NULL)do { if (action != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "baul-navigation-window.c", 581, ((const char *) (__func__)), "action != NULL"); } while (0); |
| 582 | if (ctk_action_is_sensitive (action)) |
| 583 | { |
| 584 | ctk_action_activate (action); |
| 585 | return TRUE(!(0)); |
| 586 | } |
| 587 | |
| 588 | break; |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return CTK_WIDGET_CLASS (baul_navigation_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->key_press_event (widget, event); |
| 593 | } |
| 594 | |
| 595 | static gboolean |
| 596 | baul_navigation_window_button_press_event (CtkWidget *widget, |
| 597 | CdkEventButton *event) |
| 598 | { |
| 599 | BaulNavigationWindow *window; |
| 600 | gboolean handled; |
| 601 | |
| 602 | handled = FALSE(0); |
Value stored to 'handled' is never read | |
| 603 | window = BAUL_NAVIGATION_WINDOW (widget)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), (baul_navigation_window_get_type ()))))); |
| 604 | |
| 605 | if (mouse_extra_buttons && (event->button == mouse_back_button)) |
| 606 | { |
| 607 | baul_navigation_window_go_back (window); |
| 608 | handled = TRUE(!(0)); |
| 609 | } |
| 610 | else if (mouse_extra_buttons && (event->button == mouse_forward_button)) |
| 611 | { |
| 612 | baul_navigation_window_go_forward (window); |
| 613 | handled = TRUE(!(0)); |
| 614 | } |
| 615 | else if (CTK_WIDGET_CLASS (baul_navigation_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->button_press_event) |
| 616 | { |
| 617 | handled = CTK_WIDGET_CLASS (baul_navigation_window_parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->button_press_event (widget, event); |
| 618 | } |
| 619 | else |
| 620 | { |
| 621 | handled = FALSE(0); |
| 622 | } |
| 623 | return handled; |
| 624 | } |
| 625 | |
| 626 | static void |
| 627 | baul_navigation_window_destroy (CtkWidget *object) |
| 628 | { |
| 629 | BaulNavigationWindow *window; |
| 630 | |
| 631 | window = BAUL_NAVIGATION_WINDOW (object)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (baul_navigation_window_get_type ()))))); |
| 632 | |
| 633 | baul_navigation_window_unset_focus_widget (window); |
| 634 | |
| 635 | window->sidebar = NULL((void*)0); |
| 636 | g_list_foreach (window->sidebar_panels, (GFunc)g_object_unref, NULL((void*)0)); |
| 637 | g_list_free (window->sidebar_panels); |
| 638 | window->sidebar_panels = NULL((void*)0); |
| 639 | |
| 640 | window->details->content_paned = NULL((void*)0); |
| 641 | window->details->split_view_hpane = NULL((void*)0); |
| 642 | |
| 643 | CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->destroy (object); |
| 644 | } |
| 645 | |
| 646 | static void |
| 647 | baul_navigation_window_finalize (GObject *object) |
| 648 | { |
| 649 | BaulNavigationWindow *window; |
| 650 | |
| 651 | window = BAUL_NAVIGATION_WINDOW (object)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), (baul_navigation_window_get_type ()))))); |
| 652 | |
| 653 | baul_navigation_window_remove_go_menu_callback (window); |
| 654 | |
| 655 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_browser_changed), (window)) |
| 656 | always_use_browser_changed,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_browser_changed), (window)) |
| 657 | window)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_browser_changed), (window)); |
| 658 | g_signal_handlers_disconnect_by_func (baul_preferences,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_location_entry_changed), (window)) |
| 659 | always_use_location_entry_changed,g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_location_entry_changed), (window)) |
| 660 | window)g_signal_handlers_disconnect_matched ((baul_preferences), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (always_use_location_entry_changed), (window)); |
| 661 | |
| 662 | G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
| 663 | } |
| 664 | |
| 665 | /* |
| 666 | * Main API |
| 667 | */ |
| 668 | |
| 669 | void |
| 670 | baul_navigation_window_add_sidebar_panel (BaulNavigationWindow *window, |
| 671 | BaulSidebar *sidebar_panel) |
| 672 | { |
| 673 | const char *sidebar_id; |
| 674 | char *label; |
| 675 | char *tooltip; |
| 676 | char *default_id; |
| 677 | GdkPixbuf *icon; |
| 678 | |
| 679 | g_return_if_fail (BAUL_IS_NAVIGATION_WINDOW (window))do { if (((((__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; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "BAUL_IS_NAVIGATION_WINDOW (window)" ); return; } } while (0); |
| 680 | g_return_if_fail (BAUL_IS_SIDEBAR (sidebar_panel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((sidebar_panel)); GType __t = ((baul_sidebar_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_SIDEBAR (sidebar_panel)" ); return; } } while (0); |
| 681 | g_return_if_fail (BAUL_IS_SIDE_PANE (window->sidebar))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((window->sidebar)); GType __t = (baul_side_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_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "BAUL_IS_SIDE_PANE (window->sidebar)" ); return; } } while (0); |
| 682 | g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL)do { if ((g_list_find (window->sidebar_panels, sidebar_panel ) == ((void*)0))) { } else { g_return_if_fail_warning (((gchar *) 0), ((const char*) (__func__)), "g_list_find (window->sidebar_panels, sidebar_panel) == NULL" ); return; } } while (0); |
| 683 | |
| 684 | label = baul_sidebar_get_tab_label (sidebar_panel); |
| 685 | tooltip = baul_sidebar_get_tab_tooltip (sidebar_panel); |
| 686 | baul_side_pane_add_panel (window->sidebar, |
| 687 | CTK_WIDGET (sidebar_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidebar_panel)), ((ctk_widget_get_type ())))))), |
| 688 | label, |
| 689 | tooltip); |
| 690 | g_free (tooltip); |
| 691 | g_free (label); |
| 692 | |
| 693 | icon = baul_sidebar_get_tab_icon (sidebar_panel); |
| 694 | baul_side_pane_set_panel_image (BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ())))))->sidebar, |
| 695 | CTK_WIDGET (sidebar_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidebar_panel)), ((ctk_widget_get_type ())))))), |
| 696 | icon); |
| 697 | if (icon) |
| 698 | { |
| 699 | g_object_unref (icon); |
| 700 | } |
| 701 | |
| 702 | g_signal_connect (sidebar_panel, "tab_icon_changed",g_signal_connect_data ((sidebar_panel), ("tab_icon_changed"), ((GCallback)side_panel_image_changed_callback), (window), (( void*)0), (GConnectFlags) 0) |
| 703 | (GCallback)side_panel_image_changed_callback, window)g_signal_connect_data ((sidebar_panel), ("tab_icon_changed"), ((GCallback)side_panel_image_changed_callback), (window), (( void*)0), (GConnectFlags) 0); |
| 704 | |
| 705 | window->sidebar_panels = g_list_prepend (window->sidebar_panels, |
| 706 | g_object_ref (sidebar_panel)((__typeof__ (sidebar_panel)) (g_object_ref) (sidebar_panel))); |
| 707 | |
| 708 | /* Show if default */ |
| 709 | sidebar_id = baul_sidebar_get_sidebar_id (sidebar_panel); |
| 710 | default_id = g_settings_get_string (baul_window_state, BAUL_WINDOW_STATE_SIDE_PANE_VIEW"side-pane-view"); |
| 711 | if (sidebar_id && default_id && !strcmp (sidebar_id, default_id)) |
| 712 | { |
| 713 | baul_side_pane_show_panel (window->sidebar, |
| 714 | CTK_WIDGET (sidebar_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidebar_panel)), ((ctk_widget_get_type ()))))))); |
| 715 | } |
| 716 | g_free (default_id); |
| 717 | } |
| 718 | |
| 719 | void |
| 720 | baul_navigation_window_remove_sidebar_panel (BaulNavigationWindow *window, |
| 721 | BaulSidebar *sidebar_panel) |
| 722 | { |
| 723 | g_return_if_fail (BAUL_IS_NAVIGATION_WINDOW (window))do { if (((((__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; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "BAUL_IS_NAVIGATION_WINDOW (window)" ); return; } } while (0); |
| 724 | g_return_if_fail (BAUL_IS_SIDEBAR (sidebar_panel))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((sidebar_panel)); GType __t = ((baul_sidebar_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_SIDEBAR (sidebar_panel)" ); return; } } while (0); |
| 725 | |
| 726 | if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL((void*)0)) |
| 727 | { |
| 728 | return; |
| 729 | } |
| 730 | |
| 731 | g_signal_handlers_disconnect_by_func (sidebar_panel, side_panel_image_changed_callback, window)g_signal_handlers_disconnect_matched ((sidebar_panel), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (side_panel_image_changed_callback), (window)); |
| 732 | |
| 733 | baul_side_pane_remove_panel (window->sidebar, |
| 734 | CTK_WIDGET (sidebar_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sidebar_panel)), ((ctk_widget_get_type ()))))))); |
| 735 | window->sidebar_panels = g_list_remove (window->sidebar_panels, sidebar_panel); |
| 736 | g_object_unref (sidebar_panel); |
| 737 | } |
| 738 | |
| 739 | void |
| 740 | baul_navigation_window_go_back (BaulNavigationWindow *window) |
| 741 | { |
| 742 | baul_navigation_window_back_or_forward (window, TRUE(!(0)), 0, FALSE(0)); |
| 743 | } |
| 744 | |
| 745 | void |
| 746 | baul_navigation_window_go_forward (BaulNavigationWindow *window) |
| 747 | { |
| 748 | baul_navigation_window_back_or_forward (window, FALSE(0), 0, FALSE(0)); |
| 749 | } |
| 750 | |
| 751 | void |
| 752 | baul_navigation_window_allow_back (BaulNavigationWindow *window, gboolean allow) |
| 753 | { |
| 754 | CtkAction *action; |
| 755 | |
| 756 | action = ctk_action_group_get_action (window->details->navigation_action_group, |
| 757 | BAUL_ACTION_BACK"Back"); |
| 758 | |
| 759 | ctk_action_set_sensitive (action, allow); |
| 760 | } |
| 761 | |
| 762 | void |
| 763 | baul_navigation_window_allow_forward (BaulNavigationWindow *window, gboolean allow) |
| 764 | { |
| 765 | CtkAction *action; |
| 766 | |
| 767 | action = ctk_action_group_get_action (window->details->navigation_action_group, |
| 768 | BAUL_ACTION_FORWARD"Forward"); |
| 769 | |
| 770 | ctk_action_set_sensitive (action, allow); |
| 771 | } |
| 772 | |
| 773 | static void |
| 774 | real_sync_title (BaulWindow *window, |
| 775 | BaulWindowSlot *slot) |
| 776 | { |
| 777 | BaulNavigationWindowPane *pane; |
| 778 | BaulNotebook *notebook; |
| 779 | |
| 780 | EEL_CALL_PARENT (BAUL_WINDOW_CLASS,do { if (((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class)), (baul_window_get_type ())))))->sync_title != ((void*)0)) { (* ((((BaulWindowClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class )), (baul_window_get_type())))))->sync_title) (window, slot ); } } while (0) |
| 781 | sync_title, (window, slot))do { if (((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class)), (baul_window_get_type ())))))->sync_title != ((void*)0)) { (* ((((BaulWindowClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class )), (baul_window_get_type())))))->sync_title) (window, slot ); } } while (0); |
| 782 | |
| 783 | if (slot == window->details->active_pane->active_slot) |
| 784 | { |
| 785 | char *window_title; |
| 786 | |
| 787 | /* if spatial mode is default, we keep "File Browser" in the window title |
| 788 | * to recognize browser windows. Otherwise, we default to the directory name. |
| 789 | */ |
| 790 | if (!g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_BROWSER"always-use-browser")) |
| 791 | { |
| 792 | char *full_title; |
| 793 | |
| 794 | full_title = g_strdup_printf (_("%s - File Browser")gettext ("%s - File Browser"), slot->title); |
| 795 | window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH180); |
| 796 | g_free (full_title); |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | window_title = eel_str_middle_truncate (slot->title, MAX_TITLE_LENGTH180); |
| 801 | } |
| 802 | |
| 803 | ctk_window_set_title (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ())))))), window_title); |
| 804 | g_free (window_title); |
| 805 | } |
| 806 | |
| 807 | pane = BAUL_NAVIGATION_WINDOW_PANE (slot->pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((slot->pane)), ((baul_navigation_window_pane_get_type ())))))); |
| 808 | notebook = BAUL_NOTEBOOK (pane->notebook)((((BaulNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane->notebook)), ((baul_notebook_get_type ())))))); |
| 809 | baul_notebook_sync_tab_label (notebook, slot); |
| 810 | } |
| 811 | |
| 812 | static BaulIconInfo * |
| 813 | real_get_icon (BaulWindow *window, |
| 814 | BaulWindowSlot *slot) |
| 815 | { |
| 816 | return baul_file_get_icon (slot->viewed_file, |
| 817 | 48, ctk_widget_get_scale_factor (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ()))))))), |
| 818 | BAUL_FILE_ICON_FLAGS_IGNORE_VISITING | |
| 819 | BAUL_FILE_ICON_FLAGS_USE_MOUNT_ICON); |
| 820 | } |
| 821 | |
| 822 | static void |
| 823 | real_sync_allow_stop (BaulWindow *window, |
| 824 | BaulWindowSlot *slot) |
| 825 | { |
| 826 | BaulNavigationWindow *navigation_window; |
| 827 | BaulNotebook *notebook; |
| 828 | |
| 829 | navigation_window = BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ()))))); |
| 830 | baul_navigation_window_set_spinner_active (navigation_window, slot->allow_stop); |
| 831 | |
| 832 | notebook = BAUL_NOTEBOOK (BAUL_NAVIGATION_WINDOW_PANE (slot->pane)->notebook)((((BaulNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((slot->pane)), ((baul_navigation_window_pane_get_type ()))))))->notebook)), ((baul_notebook_get_type ())))))); |
| 833 | baul_notebook_sync_loading (notebook, slot); |
| 834 | } |
| 835 | |
| 836 | static void |
| 837 | real_prompt_for_location (BaulWindow *window, const char *initial) |
| 838 | { |
| 839 | BaulNavigationWindowPane *pane; |
| 840 | |
| 841 | remember_focus_widget (BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ())))))); |
| 842 | |
| 843 | pane = BAUL_NAVIGATION_WINDOW_PANE (window->details->active_pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window->details->active_pane)), (( baul_navigation_window_pane_get_type())))))); |
| 844 | |
| 845 | baul_navigation_window_pane_show_location_bar_temporarily (pane); |
| 846 | baul_navigation_window_pane_show_navigation_bar_temporarily (pane); |
| 847 | |
| 848 | if (initial) |
| 849 | { |
| 850 | baul_location_bar_set_location (BAUL_LOCATION_BAR (pane->navigation_bar)((((BaulLocationBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane->navigation_bar)), (baul_location_bar_get_type() ))))), |
| 851 | initial); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | void |
| 856 | baul_navigation_window_show_search (BaulNavigationWindow *window) |
| 857 | { |
| 858 | BaulNavigationWindowPane *pane; |
| 859 | |
| 860 | pane = BAUL_NAVIGATION_WINDOW_PANE (BAUL_WINDOW (window)->details->active_pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_window_get_type())))))-> details->active_pane)), ((baul_navigation_window_pane_get_type ())))))); |
| 861 | if (!baul_navigation_window_pane_search_bar_showing (pane)) |
| 862 | { |
| 863 | remember_focus_widget (window); |
| 864 | |
| 865 | baul_navigation_window_pane_show_location_bar_temporarily (pane); |
| 866 | baul_navigation_window_pane_set_bar_mode (pane, BAUL_BAR_SEARCH); |
| 867 | pane->temporary_search_bar = TRUE(!(0)); |
| 868 | baul_search_bar_clear (BAUL_SEARCH_BAR (pane->search_bar)((((BaulSearchBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane->search_bar)), (baul_search_bar_get_type())))))); |
| 869 | } |
| 870 | |
| 871 | baul_search_bar_grab_focus (BAUL_SEARCH_BAR (pane->search_bar)((((BaulSearchBar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane->search_bar)), (baul_search_bar_get_type())))))); |
| 872 | } |
| 873 | |
| 874 | void |
| 875 | baul_navigation_window_hide_search (BaulNavigationWindow *window) |
| 876 | { |
| 877 | BaulNavigationWindowPane *pane = BAUL_NAVIGATION_WINDOW_PANE (BAUL_WINDOW (window)->details->active_pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_window_get_type())))))-> details->active_pane)), ((baul_navigation_window_pane_get_type ())))))); |
| 878 | if (baul_navigation_window_pane_search_bar_showing (pane)) |
| 879 | { |
| 880 | if (baul_navigation_window_pane_hide_temporary_bars (pane)) |
| 881 | { |
| 882 | baul_navigation_window_restore_focus_widget (window); |
| 883 | } |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | /* This updates the UI state of the search button, but does not |
| 888 | in itself trigger a search action */ |
| 889 | void |
| 890 | baul_navigation_window_set_search_button (BaulNavigationWindow *window, |
| 891 | gboolean state) |
| 892 | { |
| 893 | CtkAction *action; |
| 894 | |
| 895 | action = ctk_action_group_get_action (window->details->navigation_action_group, |
| 896 | "Search"); |
| 897 | |
| 898 | /* Block callback so we don't activate the action and thus focus the |
| 899 | search entry */ |
| 900 | g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "blocked", GINT_TO_POINTER (1)((gpointer) (glong) (1))); |
| 901 | ctk_toggle_action_set_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))), state); |
| 902 | g_object_set_data (G_OBJECT (action)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), (((GType) ((20) << (2)))))))), "blocked", NULL((void*)0)); |
| 903 | } |
| 904 | |
| 905 | static void |
| 906 | side_panel_image_changed_callback (BaulSidebar *side_panel, |
| 907 | gpointer callback_data) |
| 908 | { |
| 909 | BaulWindow *window; |
| 910 | GdkPixbuf *icon; |
| 911 | |
| 912 | window = BAUL_WINDOW (callback_data)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((callback_data)), (baul_window_get_type()))))); |
| 913 | |
| 914 | icon = baul_sidebar_get_tab_icon (side_panel); |
| 915 | baul_side_pane_set_panel_image (BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ())))))->sidebar, |
| 916 | CTK_WIDGET (side_panel)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((side_panel)), ((ctk_widget_get_type ())))))), |
| 917 | icon); |
| 918 | if (icon != NULL((void*)0)) |
| 919 | { |
| 920 | g_object_unref (icon); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | /** |
| 925 | * add_sidebar_panels: |
| 926 | * @window: A BaulNavigationWindow |
| 927 | * |
| 928 | * Adds all sidebars available |
| 929 | * |
| 930 | */ |
| 931 | static void |
| 932 | add_sidebar_panels (BaulNavigationWindow *window) |
| 933 | { |
| 934 | CtkWidget *current; |
| 935 | GList *providers; |
| 936 | GList *p; |
| 937 | BaulSidebar *sidebar_panel = NULL((void*)0); |
| 938 | |
| 939 | g_assert (BAUL_IS_NAVIGATION_WINDOW (window))do { if ((((__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; }))))) ; else g_assertion_message_expr (((gchar*) 0), "baul-navigation-window.c" , 939, ((const char*) (__func__)), "BAUL_IS_NAVIGATION_WINDOW (window)" ); } while (0); |
| 940 | |
| 941 | if (window->sidebar == NULL((void*)0)) |
| 942 | { |
| 943 | return; |
| 944 | } |
| 945 | |
| 946 | providers = baul_module_get_extensions_for_type (BAUL_TYPE_SIDEBAR_PROVIDER(baul_sidebar_provider_get_type ())); |
| 947 | |
| 948 | for (p = providers; p != NULL((void*)0); p = p->next) |
| 949 | { |
| 950 | BaulSidebarProvider *provider; |
| 951 | |
| 952 | provider = BAUL_SIDEBAR_PROVIDER (p->data)((((BaulSidebarProvider*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((p->data)), ((baul_sidebar_provider_get_type ())))))); |
| 953 | |
| 954 | sidebar_panel = baul_sidebar_provider_create (provider, |
| 955 | BAUL_WINDOW_INFO (window)((((BaulWindowInfo*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((baul_window_info_get_type ()))))))); |
| 956 | baul_navigation_window_add_sidebar_panel (window, |
| 957 | sidebar_panel); |
| 958 | |
| 959 | g_object_unref (sidebar_panel); |
| 960 | } |
| 961 | |
| 962 | baul_module_extension_list_free (providers); |
| 963 | |
| 964 | current = baul_side_pane_get_current_panel (window->sidebar); |
| 965 | set_current_side_panel |
| 966 | (window, |
| 967 | BAUL_SIDEBAR (current)((((BaulSidebar*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((current)), ((baul_sidebar_get_type ()))))))); |
| 968 | } |
| 969 | |
| 970 | gboolean |
| 971 | baul_navigation_window_toolbar_showing (BaulNavigationWindow *window) |
| 972 | { |
| 973 | if (window->details->toolbar != NULL((void*)0)) |
| 974 | { |
| 975 | return ctk_widget_get_visible (window->details->toolbar); |
| 976 | } |
| 977 | /* If we're not visible yet we haven't changed visibility, so its TRUE */ |
| 978 | return TRUE(!(0)); |
| 979 | } |
| 980 | |
| 981 | void |
| 982 | baul_navigation_window_hide_status_bar (BaulNavigationWindow *window) |
| 983 | { |
| 984 | ctk_widget_hide (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->statusbar); |
| 985 | |
| 986 | baul_navigation_window_update_show_hide_menu_items (window); |
| 987 | |
| 988 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_STATUS_BAR"start-with-status-bar", FALSE(0)); |
| 989 | } |
| 990 | |
| 991 | void |
| 992 | baul_navigation_window_show_status_bar (BaulNavigationWindow *window) |
| 993 | { |
| 994 | ctk_widget_show (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->statusbar); |
| 995 | |
| 996 | baul_navigation_window_update_show_hide_menu_items (window); |
| 997 | |
| 998 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_STATUS_BAR"start-with-status-bar", TRUE(!(0))); |
| 999 | } |
| 1000 | |
| 1001 | gboolean |
| 1002 | baul_navigation_window_status_bar_showing (BaulNavigationWindow *window) |
| 1003 | { |
| 1004 | if (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->statusbar != NULL((void*)0)) |
| 1005 | { |
| 1006 | return ctk_widget_get_visible (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->statusbar); |
| 1007 | } |
| 1008 | /* If we're not visible yet we haven't changed visibility, so its TRUE */ |
| 1009 | return TRUE(!(0)); |
| 1010 | } |
| 1011 | |
| 1012 | |
| 1013 | void |
| 1014 | baul_navigation_window_hide_toolbar (BaulNavigationWindow *window) |
| 1015 | { |
| 1016 | ctk_widget_hide (window->details->toolbar); |
| 1017 | baul_navigation_window_update_show_hide_menu_items (window); |
| 1018 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_TOOLBAR"start-with-toolbar", FALSE(0)); |
| 1019 | } |
| 1020 | |
| 1021 | void |
| 1022 | baul_navigation_window_show_toolbar (BaulNavigationWindow *window) |
| 1023 | { |
| 1024 | ctk_widget_show (window->details->toolbar); |
| 1025 | baul_navigation_window_update_show_hide_menu_items (window); |
| 1026 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_TOOLBAR"start-with-toolbar", TRUE(!(0))); |
| 1027 | } |
| 1028 | |
| 1029 | void |
| 1030 | baul_navigation_window_hide_sidebar (BaulNavigationWindow *window) |
| 1031 | { |
| 1032 | if (window->sidebar == NULL((void*)0)) |
| 1033 | { |
| 1034 | return; |
| 1035 | } |
| 1036 | |
| 1037 | baul_navigation_window_tear_down_sidebar (window); |
| 1038 | baul_navigation_window_update_show_hide_menu_items (window); |
| 1039 | |
| 1040 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_SIDEBAR"start-with-sidebar", FALSE(0)); |
| 1041 | } |
| 1042 | |
| 1043 | void |
| 1044 | baul_navigation_window_show_sidebar (BaulNavigationWindow *window) |
| 1045 | { |
| 1046 | if (window->sidebar != NULL((void*)0)) |
| 1047 | { |
| 1048 | return; |
| 1049 | } |
| 1050 | |
| 1051 | baul_navigation_window_set_up_sidebar (window); |
| 1052 | baul_navigation_window_update_show_hide_menu_items (window); |
| 1053 | g_settings_set_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_SIDEBAR"start-with-sidebar", TRUE(!(0))); |
| 1054 | } |
| 1055 | |
| 1056 | gboolean |
| 1057 | baul_navigation_window_sidebar_showing (BaulNavigationWindow *window) |
| 1058 | { |
| 1059 | g_return_val_if_fail (BAUL_IS_NAVIGATION_WINDOW (window), FALSE)do { if (((((__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; })))))) { } else { g_return_if_fail_warning (((gchar*) 0 ), ((const char*) (__func__)), "BAUL_IS_NAVIGATION_WINDOW (window)" ); return ((0)); } } while (0); |
| 1060 | |
| 1061 | return (window->sidebar != NULL((void*)0)) |
| 1062 | && ctk_widget_get_visible (ctk_paned_get_child1 (CTK_PANED (window->details->content_paned)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->content_paned)), ((ctk_paned_get_type ())))))))); |
| 1063 | } |
| 1064 | |
| 1065 | /** |
| 1066 | * baul_navigation_window_get_base_page_index: |
| 1067 | * @window: Window to get index from |
| 1068 | * |
| 1069 | * Returns the index of the base page in the history list. |
| 1070 | * Base page is not the currently displayed page, but the page |
| 1071 | * that acts as the base from which the back and forward commands |
| 1072 | * navigate from. |
| 1073 | */ |
| 1074 | gint |
| 1075 | baul_navigation_window_get_base_page_index (BaulNavigationWindow *window) |
| 1076 | { |
| 1077 | BaulNavigationWindowSlot *slot; |
| 1078 | gint forward_count; |
| 1079 | |
| 1080 | slot = BAUL_NAVIGATION_WINDOW_SLOT (BAUL_WINDOW (window)->details->active_pane->active_slot)((((BaulNavigationWindowSlot*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_window_get_type())))))-> details->active_pane->active_slot)), ((baul_navigation_window_slot_get_type ())))))); |
| 1081 | |
| 1082 | forward_count = g_list_length (slot->forward_list); |
| 1083 | |
| 1084 | /* If forward is empty, the base it at the top of the list */ |
| 1085 | if (forward_count == 0) |
| 1086 | { |
| 1087 | return 0; |
| 1088 | } |
| 1089 | |
| 1090 | /* The forward count indicate the relative postion of the base page |
| 1091 | * in the history list |
| 1092 | */ |
| 1093 | return forward_count; |
| 1094 | } |
| 1095 | |
| 1096 | /** |
| 1097 | * baul_navigation_window_show: |
| 1098 | * @widget: a #CtkWidget. |
| 1099 | * |
| 1100 | * Call parent and then show/hide window items |
| 1101 | * base on user prefs. |
| 1102 | */ |
| 1103 | static void |
| 1104 | baul_navigation_window_show (CtkWidget *widget) |
| 1105 | { |
| 1106 | BaulNavigationWindow *window; |
| 1107 | gboolean show_location_bar; |
| 1108 | gboolean always_use_location_entry; |
| 1109 | GList *walk; |
| 1110 | |
| 1111 | window = BAUL_NAVIGATION_WINDOW (widget)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((widget)), (baul_navigation_window_get_type ()))))); |
| 1112 | |
| 1113 | /* Initially show or hide views based on preferences; once the window is displayed |
| 1114 | * these can be controlled on a per-window basis from View menu items. |
| 1115 | */ |
| 1116 | |
| 1117 | if (g_settings_get_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_TOOLBAR"start-with-toolbar")) |
| 1118 | { |
| 1119 | baul_navigation_window_show_toolbar (window); |
| 1120 | } |
| 1121 | else |
| 1122 | { |
| 1123 | baul_navigation_window_hide_toolbar (window); |
| 1124 | } |
| 1125 | |
| 1126 | show_location_bar = g_settings_get_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_LOCATION_BAR"start-with-location-bar"); |
| 1127 | always_use_location_entry = g_settings_get_boolean (baul_preferences, BAUL_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY"always-use-location-entry"); |
| 1128 | for (walk = BAUL_WINDOW(window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->panes; walk; walk = walk->next) |
| 1129 | { |
| 1130 | BaulNavigationWindowPane *pane = walk->data; |
| 1131 | if (show_location_bar) |
| 1132 | { |
| 1133 | baul_navigation_window_pane_show_location_bar (pane, FALSE(0)); |
| 1134 | } |
| 1135 | else |
| 1136 | { |
| 1137 | baul_navigation_window_pane_hide_location_bar (pane, FALSE(0)); |
| 1138 | } |
| 1139 | |
| 1140 | if (always_use_location_entry) |
| 1141 | { |
| 1142 | baul_navigation_window_pane_set_bar_mode (pane, BAUL_BAR_NAVIGATION); |
| 1143 | } |
| 1144 | else |
| 1145 | { |
| 1146 | baul_navigation_window_pane_set_bar_mode (pane, BAUL_BAR_PATH); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | if (g_settings_get_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_SIDEBAR"start-with-sidebar")) |
| 1151 | { |
| 1152 | baul_navigation_window_show_sidebar (window); |
| 1153 | } |
| 1154 | else |
| 1155 | { |
| 1156 | baul_navigation_window_hide_sidebar (window); |
| 1157 | } |
| 1158 | |
| 1159 | if (g_settings_get_boolean (baul_window_state, BAUL_WINDOW_STATE_START_WITH_STATUS_BAR"start-with-status-bar")) |
| 1160 | { |
| 1161 | baul_navigation_window_show_status_bar (window); |
| 1162 | } |
| 1163 | else |
| 1164 | { |
| 1165 | baul_navigation_window_hide_status_bar (window); |
| 1166 | } |
| 1167 | |
| 1168 | CTK_WIDGET_CLASS (parent_class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((baul_navigation_window_parent_class)), ((ctk_widget_get_type ()))))))->show (widget); |
| 1169 | } |
| 1170 | |
| 1171 | static void |
| 1172 | baul_navigation_window_save_geometry (BaulNavigationWindow *window) |
| 1173 | { |
| 1174 | gboolean is_maximized; |
| 1175 | |
| 1176 | 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-navigation-window.c" , 1176, ((const char*) (__func__)), "BAUL_IS_WINDOW (window)" ); } while (0); |
| 1177 | |
| 1178 | if (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) |
| 1179 | { |
| 1180 | char *geometry_string; |
| 1181 | |
| 1182 | geometry_string = eel_ctk_window_get_geometry_string (CTK_WINDOW (window)((((CtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_window_get_type ()))))))); |
| 1183 | is_maximized = cdk_window_get_state (ctk_widget_get_window (CTK_WIDGET (window)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), ((ctk_widget_get_type ())))))))) |
| 1184 | & CDK_WINDOW_STATE_MAXIMIZED; |
| 1185 | |
| 1186 | if (!is_maximized) |
| 1187 | { |
| 1188 | g_settings_set_string (baul_window_state, |
| 1189 | BAUL_WINDOW_STATE_GEOMETRY"geometry", |
| 1190 | geometry_string); |
| 1191 | } |
| 1192 | g_free (geometry_string); |
| 1193 | |
| 1194 | g_settings_set_boolean (baul_window_state, |
| 1195 | BAUL_WINDOW_STATE_MAXIMIZED"maximized", |
| 1196 | is_maximized); |
| 1197 | } |
| 1198 | } |
| 1199 | |
| 1200 | static void |
| 1201 | real_window_close (BaulWindow *window) |
| 1202 | { |
| 1203 | baul_navigation_window_save_geometry (BAUL_NAVIGATION_WINDOW (window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window)), (baul_navigation_window_get_type ())))))); |
| 1204 | } |
| 1205 | |
| 1206 | static void |
| 1207 | real_get_min_size (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1208 | guint *min_width, |
| 1209 | guint *min_height) |
| 1210 | { |
| 1211 | if (min_width) |
| 1212 | { |
| 1213 | *min_width = BAUL_NAVIGATION_WINDOW_MIN_WIDTH200; |
| 1214 | } |
| 1215 | if (min_height) |
| 1216 | { |
| 1217 | *min_height = BAUL_NAVIGATION_WINDOW_MIN_HEIGHT200; |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | static void |
| 1222 | real_get_default_size (BaulWindow *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1223 | guint *default_width, |
| 1224 | guint *default_height) |
| 1225 | { |
| 1226 | if (default_width) |
| 1227 | { |
| 1228 | *default_width = BAUL_NAVIGATION_WINDOW_DEFAULT_WIDTH800; |
| 1229 | } |
| 1230 | |
| 1231 | if (default_height) |
| 1232 | { |
| 1233 | *default_height = BAUL_NAVIGATION_WINDOW_DEFAULT_HEIGHT550; |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | static BaulWindowSlot * |
| 1238 | real_open_slot (BaulWindowPane *pane, |
| 1239 | BaulWindowOpenSlotFlags flags) |
| 1240 | { |
| 1241 | BaulWindowSlot *slot; |
| 1242 | |
| 1243 | slot = (BaulWindowSlot *) g_object_new (BAUL_TYPE_NAVIGATION_WINDOW_SLOT(baul_navigation_window_slot_get_type()), NULL((void*)0)); |
| 1244 | slot->pane = pane; |
| 1245 | |
| 1246 | baul_navigation_window_pane_add_slot_in_tab (BAUL_NAVIGATION_WINDOW_PANE (pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pane)), ((baul_navigation_window_pane_get_type ())))))), slot, flags); |
| 1247 | ctk_widget_show (slot->content_box); |
| 1248 | |
| 1249 | return slot; |
| 1250 | } |
| 1251 | |
| 1252 | static void |
| 1253 | real_close_slot (BaulWindowPane *pane, |
| 1254 | BaulWindowSlot *slot) |
| 1255 | { |
| 1256 | int page_num; |
| 1257 | CtkNotebook *notebook; |
| 1258 | |
| 1259 | notebook = CTK_NOTEBOOK (BAUL_NAVIGATION_WINDOW_PANE (pane)->notebook)((((CtkNotebook*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pane)), ((baul_navigation_window_pane_get_type ()))))))->notebook)), ((ctk_notebook_get_type ())))))); |
| 1260 | |
| 1261 | page_num = ctk_notebook_page_num (notebook, slot->content_box); |
| 1262 | g_assert (page_num >= 0)do { if (page_num >= 0) ; else g_assertion_message_expr (( (gchar*) 0), "baul-navigation-window.c", 1262, ((const char*) (__func__)), "page_num >= 0"); } while (0); |
| 1263 | |
| 1264 | baul_navigation_window_pane_remove_page (BAUL_NAVIGATION_WINDOW_PANE (pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pane)), ((baul_navigation_window_pane_get_type ())))))), page_num); |
| 1265 | |
| 1266 | ctk_notebook_set_show_tabs (notebook, |
| 1267 | ctk_notebook_get_n_pages (notebook) > 1); |
| 1268 | |
| 1269 | EEL_CALL_PARENT (BAUL_WINDOW_CLASS,do { if (((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class)), (baul_window_get_type ())))))->close_slot != ((void*)0)) { (* ((((BaulWindowClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class )), (baul_window_get_type())))))->close_slot) (pane, slot) ; } } while (0) |
| 1270 | close_slot, (pane, slot))do { if (((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class)), (baul_window_get_type ())))))->close_slot != ((void*)0)) { (* ((((BaulWindowClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((baul_navigation_window_parent_class )), (baul_window_get_type())))))->close_slot) (pane, slot) ; } } while (0); |
| 1271 | } |
| 1272 | |
| 1273 | static void |
| 1274 | baul_navigation_window_class_init (BaulNavigationWindowClass *class) |
| 1275 | { |
| 1276 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->window_type = BAUL_WINDOW_NAVIGATION; |
| 1277 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->bookmarks_placeholder = MENU_PATH_BOOKMARKS_PLACEHOLDER"/MenuBar/Other Menus/Bookmarks/Bookmarks Placeholder"; |
| 1278 | |
| 1279 | G_OBJECT_CLASS (class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (((GType) ((20) << (2))))))))->finalize = baul_navigation_window_finalize; |
| 1280 | |
| 1281 | CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ()))))))->destroy = baul_navigation_window_destroy; |
| 1282 | CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ()))))))->show = baul_navigation_window_show; |
| 1283 | CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ()))))))->window_state_event = baul_navigation_window_state_event; |
| 1284 | CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ()))))))->key_press_event = baul_navigation_window_key_press_event; |
| 1285 | CTK_WIDGET_CLASS (class)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), ((ctk_widget_get_type ()))))))->button_press_event = baul_navigation_window_button_press_event; |
| 1286 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->sync_allow_stop = real_sync_allow_stop; |
| 1287 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->prompt_for_location = real_prompt_for_location; |
| 1288 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->sync_title = real_sync_title; |
| 1289 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->get_icon = real_get_icon; |
| 1290 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->get_min_size = real_get_min_size; |
| 1291 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->get_default_size = real_get_default_size; |
| 1292 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->close = real_window_close; |
| 1293 | |
| 1294 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->open_slot = real_open_slot; |
| 1295 | BAUL_WINDOW_CLASS (class)((((BaulWindowClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((class)), (baul_window_get_type())))))->close_slot = real_close_slot; |
| 1296 | |
| 1297 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-back-button" ), (((GCallback) (mouse_back_button_changed))), (((void*)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1298 | "changed::" BAUL_PREFERENCES_MOUSE_BACK_BUTTON,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-back-button" ), (((GCallback) (mouse_back_button_changed))), (((void*)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1299 | G_CALLBACK(mouse_back_button_changed),g_signal_connect_data ((baul_preferences), ("changed::" "mouse-back-button" ), (((GCallback) (mouse_back_button_changed))), (((void*)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1300 | NULL)g_signal_connect_data ((baul_preferences), ("changed::" "mouse-back-button" ), (((GCallback) (mouse_back_button_changed))), (((void*)0)), ((void*)0), G_CONNECT_SWAPPED); |
| 1301 | |
| 1302 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-forward-button" ), (((GCallback) (mouse_forward_button_changed))), (((void*)0 )), ((void*)0), G_CONNECT_SWAPPED) |
| 1303 | "changed::" BAUL_PREFERENCES_MOUSE_FORWARD_BUTTON,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-forward-button" ), (((GCallback) (mouse_forward_button_changed))), (((void*)0 )), ((void*)0), G_CONNECT_SWAPPED) |
| 1304 | G_CALLBACK(mouse_forward_button_changed),g_signal_connect_data ((baul_preferences), ("changed::" "mouse-forward-button" ), (((GCallback) (mouse_forward_button_changed))), (((void*)0 )), ((void*)0), G_CONNECT_SWAPPED) |
| 1305 | NULL)g_signal_connect_data ((baul_preferences), ("changed::" "mouse-forward-button" ), (((GCallback) (mouse_forward_button_changed))), (((void*)0 )), ((void*)0), G_CONNECT_SWAPPED); |
| 1306 | |
| 1307 | g_signal_connect_swapped (baul_preferences,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-use-extra-buttons" ), (((GCallback) (use_extra_mouse_buttons_changed))), (((void *)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1308 | "changed::" BAUL_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS,g_signal_connect_data ((baul_preferences), ("changed::" "mouse-use-extra-buttons" ), (((GCallback) (use_extra_mouse_buttons_changed))), (((void *)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1309 | G_CALLBACK(use_extra_mouse_buttons_changed),g_signal_connect_data ((baul_preferences), ("changed::" "mouse-use-extra-buttons" ), (((GCallback) (use_extra_mouse_buttons_changed))), (((void *)0)), ((void*)0), G_CONNECT_SWAPPED) |
| 1310 | NULL)g_signal_connect_data ((baul_preferences), ("changed::" "mouse-use-extra-buttons" ), (((GCallback) (use_extra_mouse_buttons_changed))), (((void *)0)), ((void*)0), G_CONNECT_SWAPPED); |
| 1311 | } |
| 1312 | |
| 1313 | static BaulWindowSlot * |
| 1314 | create_extra_pane (BaulNavigationWindow *window) |
| 1315 | { |
| 1316 | BaulWindow *win; |
| 1317 | BaulNavigationWindowPane *pane; |
| 1318 | BaulWindowSlot *slot; |
| 1319 | CtkPaned *paned; |
| 1320 | |
| 1321 | win = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type()))))); |
| 1322 | |
| 1323 | /* New pane */ |
| 1324 | pane = baul_navigation_window_pane_new (win); |
| 1325 | win->details->panes = g_list_append (win->details->panes, pane); |
| 1326 | |
| 1327 | baul_navigation_window_pane_setup (pane); |
| 1328 | |
| 1329 | paned = CTK_PANED (window->details->split_view_hpane)((((CtkPaned*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window->details->split_view_hpane)), ((ctk_paned_get_type ())))))); |
| 1330 | if (ctk_paned_get_child1 (paned) == NULL((void*)0)) |
| 1331 | { |
| 1332 | ctk_paned_pack1 (paned, pane->widget, TRUE(!(0)), FALSE(0)); |
| 1333 | } |
| 1334 | else |
| 1335 | { |
| 1336 | ctk_paned_pack2 (paned, pane->widget, TRUE(!(0)), FALSE(0)); |
| 1337 | } |
| 1338 | |
| 1339 | /* slot */ |
| 1340 | slot = baul_window_open_slot (BAUL_WINDOW_PANE (pane)((((BaulWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane)), ((baul_window_pane_get_type())))))), |
| 1341 | BAUL_WINDOW_OPEN_SLOT_APPEND); |
| 1342 | BAUL_WINDOW_PANE (pane)((((BaulWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pane)), ((baul_window_pane_get_type()))))))->active_slot = slot; |
| 1343 | |
| 1344 | return slot; |
| 1345 | } |
| 1346 | |
| 1347 | void |
| 1348 | baul_navigation_window_split_view_on (BaulNavigationWindow *window) |
| 1349 | { |
| 1350 | BaulWindow *win; |
| 1351 | BaulNavigationWindowPane *pane; |
| 1352 | BaulWindowSlot *slot, *old_active_slot; |
| 1353 | GFile *location; |
| 1354 | CtkAction *action; |
| 1355 | |
| 1356 | win = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type()))))); |
| 1357 | |
| 1358 | old_active_slot = baul_window_get_active_slot (win); |
| 1359 | slot = create_extra_pane (window); |
| 1360 | pane = BAUL_NAVIGATION_WINDOW_PANE (slot->pane)((((BaulNavigationWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((slot->pane)), ((baul_navigation_window_pane_get_type ())))))); |
| 1361 | |
| 1362 | location = NULL((void*)0); |
| 1363 | if (old_active_slot != NULL((void*)0)) |
| 1364 | { |
| 1365 | location = baul_window_slot_get_location (old_active_slot); |
| 1366 | if (location != NULL((void*)0)) |
| 1367 | { |
| 1368 | if (g_file_has_uri_scheme (location, "x-baul-search")) |
| 1369 | { |
| 1370 | g_object_unref (location); |
| 1371 | location = NULL((void*)0); |
| 1372 | } |
| 1373 | } |
| 1374 | } |
| 1375 | if (location == NULL((void*)0)) |
| 1376 | { |
| 1377 | location = g_file_new_for_path (g_get_home_dir ()); |
| 1378 | } |
| 1379 | |
| 1380 | 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)); |
| 1381 | g_object_unref (location); |
| 1382 | |
| 1383 | action = ctk_action_group_get_action (BAUL_NAVIGATION_WINDOW (BAUL_WINDOW_PANE (pane)->window)((((BaulNavigationWindow*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((((((BaulWindowPane*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((pane)), ((baul_window_pane_get_type()))) )))->window)), (baul_navigation_window_get_type())))))->details->navigation_action_group, |
| 1384 | BAUL_ACTION_SHOW_HIDE_LOCATION_BAR"Show Hide Location Bar"); |
| 1385 | if (ctk_toggle_action_get_active (CTK_TOGGLE_ACTION (action)((((CtkToggleAction*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((action)), ((ctk_toggle_action_get_type ())))))))) |
| 1386 | { |
| 1387 | baul_navigation_window_pane_show_location_bar (pane, TRUE(!(0))); |
| 1388 | } |
| 1389 | else |
| 1390 | { |
| 1391 | baul_navigation_window_pane_hide_location_bar (pane, TRUE(!(0))); |
| 1392 | } |
| 1393 | } |
| 1394 | |
| 1395 | void |
| 1396 | baul_navigation_window_split_view_off (BaulNavigationWindow *window) |
| 1397 | { |
| 1398 | BaulWindow *win; |
| 1399 | GList *l, *next; |
| 1400 | BaulWindowPane *active_pane; |
| 1401 | BaulWindowPane *pane = NULL((void*)0); |
| 1402 | |
| 1403 | win = BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type()))))); |
| 1404 | |
| 1405 | g_return_if_fail (win)do { if ((win)) { } else { g_return_if_fail_warning (((gchar* ) 0), ((const char*) (__func__)), "win"); return; } } while ( 0); |
| 1406 | |
| 1407 | active_pane = win->details->active_pane; |
| 1408 | |
| 1409 | /* delete all panes except the first (main) pane */ |
| 1410 | for (l = win->details->panes; l != NULL((void*)0); l = next) |
| 1411 | { |
| 1412 | next = l->next; |
| 1413 | pane = l->data; |
| 1414 | if (pane != active_pane) |
| 1415 | { |
| 1416 | baul_window_close_pane (pane); |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | baul_navigation_window_update_show_hide_menu_items (window); |
| 1421 | baul_navigation_window_update_split_view_actions_sensitivity (window); |
| 1422 | } |
| 1423 | |
| 1424 | gboolean |
| 1425 | baul_navigation_window_split_view_showing (BaulNavigationWindow *window) |
| 1426 | { |
| 1427 | return g_list_length (BAUL_WINDOW (window)((((BaulWindow*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((window)), (baul_window_get_type())))))->details->panes) > 1; |
| 1428 | } |