static void real_sync_location_widgets (CajaWindowPane *pane) { CajaNavigationWindowSlot *navigation_slot; CajaNavigationWindowPane *navigation_pane; CajaWindowSlot *slot; slot = pane->active_slot; navigation_pane = CAJA_NAVIGATION_WINDOW_PANE (pane); /* Change the location bar and path bar to match the current location. */ if (slot->location != NULL) { char *uri; /* this may be NULL if we just created the slot */ uri = caja_window_slot_get_location_uri (slot); caja_location_bar_set_location (CAJA_LOCATION_BAR (navigation_pane->navigation_bar), uri); g_free (uri); caja_path_bar_set_path (CAJA_PATH_BAR (navigation_pane->path_bar), slot->location); } /* Update window global UI if this is the active pane */ if (pane == pane->window->details->active_pane) { caja_window_update_up_button (pane->window); /* Check if the back and forward buttons need enabling or disabling. */ navigation_slot = CAJA_NAVIGATION_WINDOW_SLOT (pane->window->details->active_pane->active_slot); caja_navigation_window_allow_back (CAJA_NAVIGATION_WINDOW (pane->window), navigation_slot->back_list != NULL); caja_navigation_window_allow_forward (CAJA_NAVIGATION_WINDOW (pane->window), navigation_slot->forward_list != NULL); } }
static gboolean caja_navigation_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { CajaNavigationWindow *window; int i; window = CAJA_NAVIGATION_WINDOW (widget); for (i = 0; i < G_N_ELEMENTS (extra_navigation_window_keybindings); i++) { if (extra_navigation_window_keybindings[i].keyval == event->keyval) { GtkAction *action; action = gtk_action_group_get_action (window->details->navigation_action_group, extra_navigation_window_keybindings[i].action); g_assert (action != NULL); if (gtk_action_is_sensitive (action)) { gtk_action_activate (action); return TRUE; } break; } } return GTK_WIDGET_CLASS (caja_navigation_window_parent_class)->key_press_event (widget, event); }
static gboolean caja_navigation_window_button_press_event (GtkWidget *widget, GdkEventButton *event) { CajaNavigationWindow *window; gboolean handled; handled = FALSE; window = CAJA_NAVIGATION_WINDOW (widget); if (mouse_extra_buttons && (event->button == mouse_back_button)) { caja_navigation_window_go_back (window); handled = TRUE; } else if (mouse_extra_buttons && (event->button == mouse_forward_button)) { caja_navigation_window_go_forward (window); handled = TRUE; } else if (GTK_WIDGET_CLASS (caja_navigation_window_parent_class)->button_press_event) { handled = GTK_WIDGET_CLASS (caja_navigation_window_parent_class)->button_press_event (widget, event); } else { handled = FALSE; } return handled; }
static void path_bar_location_changed_callback (GtkWidget *widget, GFile *location, CajaNavigationWindowPane *pane) { CajaNavigationWindowSlot *slot; CajaWindowPane *win_pane; int i; g_assert (CAJA_IS_NAVIGATION_WINDOW_PANE (pane)); win_pane = CAJA_WINDOW_PANE(pane); slot = CAJA_NAVIGATION_WINDOW_SLOT (win_pane->active_slot); /* check whether we already visited the target location */ i = bookmark_list_get_uri_index (slot->back_list, location); if (i >= 0) { caja_navigation_window_back_or_forward (CAJA_NAVIGATION_WINDOW (win_pane->window), TRUE, i, FALSE); } else { caja_window_slot_go_to (win_pane->active_slot, location, FALSE); } }
void caja_navigation_window_pane_set_bar_mode (CajaNavigationWindowPane *pane, CajaBarMode mode) { gboolean use_entry; GtkWidget *focus_widget; CajaNavigationWindow *window; switch (mode) { case CAJA_BAR_PATH: gtk_widget_show (pane->path_bar); gtk_widget_hide (pane->navigation_bar); gtk_widget_hide (pane->search_bar); break; case CAJA_BAR_NAVIGATION: gtk_widget_show (pane->navigation_bar); gtk_widget_hide (pane->path_bar); gtk_widget_hide (pane->search_bar); break; case CAJA_BAR_SEARCH: gtk_widget_show (pane->search_bar); gtk_widget_hide (pane->path_bar); gtk_widget_hide (pane->navigation_bar); break; } if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH) { use_entry = (mode == CAJA_BAR_NAVIGATION); g_signal_handlers_block_by_func (pane->location_button, G_CALLBACK (location_button_toggled_cb), pane); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pane->location_button), use_entry); g_signal_handlers_unblock_by_func (pane->location_button, G_CALLBACK (location_button_toggled_cb), pane); } window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window); focus_widget = gtk_window_get_focus (GTK_WINDOW (window)); if (focus_widget != NULL && !caja_navigation_window_is_in_temporary_navigation_bar (focus_widget, window) && !caja_navigation_window_is_in_temporary_search_bar (focus_widget, window)) { if (mode == CAJA_BAR_NAVIGATION || mode == CAJA_BAR_PATH) { caja_navigation_window_set_search_button (window, FALSE); } else { caja_navigation_window_set_search_button (window, TRUE); } } }
static void always_use_browser_changed (gpointer callback_data) { CajaNavigationWindow *window; window = CAJA_NAVIGATION_WINDOW (callback_data); caja_navigation_window_update_spatial_menu_item (window); }
static void navigation_bar_cancel_callback (GtkWidget *widget, CajaNavigationWindowPane *pane) { if (caja_navigation_window_pane_hide_temporary_bars (pane)) { caja_navigation_window_restore_focus_widget (CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window)); } }
static void side_pane_close_requested_callback (GtkWidget *widget, gpointer user_data) { CajaNavigationWindow *window; window = CAJA_NAVIGATION_WINDOW (user_data); caja_navigation_window_hide_sidebar (window); }
void caja_navigation_window_pane_show_location_bar (CajaNavigationWindowPane *pane, gboolean save_preference) { gtk_widget_show(pane->location_bar); caja_navigation_window_update_show_hide_menu_items(CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window)); if (save_preference) { g_settings_set_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_LOCATION_BAR, TRUE); } }
static void remember_focus_widget (CajaNavigationWindow *window) { CajaNavigationWindow *navigation_window; GtkWidget *focus_widget; navigation_window = CAJA_NAVIGATION_WINDOW (window); focus_widget = gtk_window_get_focus (GTK_WINDOW (window)); if (focus_widget != NULL && !caja_navigation_window_is_in_temporary_navigation_bar (focus_widget, navigation_window) && !caja_navigation_window_is_in_temporary_search_bar (focus_widget, navigation_window)) { caja_navigation_window_unset_focus_widget (navigation_window); navigation_window->details->last_focus_widget = focus_widget; g_object_add_weak_pointer (G_OBJECT (focus_widget), (gpointer *) &(CAJA_NAVIGATION_WINDOW (window)->details->last_focus_widget)); } }
static void real_sync_allow_stop (CajaWindow *window, CajaWindowSlot *slot) { CajaNavigationWindow *navigation_window; CajaNotebook *notebook; navigation_window = CAJA_NAVIGATION_WINDOW (window); caja_navigation_window_set_spinner_active (navigation_window, slot->allow_stop); notebook = CAJA_NOTEBOOK (CAJA_NAVIGATION_WINDOW_PANE (slot->pane)->notebook); caja_notebook_sync_loading (notebook, slot); }
void caja_navigation_window_add_sidebar_panel (CajaNavigationWindow *window, CajaSidebar *sidebar_panel) { const char *sidebar_id; char *label; char *tooltip; char *default_id; GdkPixbuf *icon; g_return_if_fail (CAJA_IS_NAVIGATION_WINDOW (window)); g_return_if_fail (CAJA_IS_SIDEBAR (sidebar_panel)); g_return_if_fail (CAJA_IS_SIDE_PANE (window->sidebar)); g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL); label = caja_sidebar_get_tab_label (sidebar_panel); tooltip = caja_sidebar_get_tab_tooltip (sidebar_panel); caja_side_pane_add_panel (window->sidebar, GTK_WIDGET (sidebar_panel), label, tooltip); g_free (tooltip); g_free (label); icon = caja_sidebar_get_tab_icon (sidebar_panel); caja_side_pane_set_panel_image (CAJA_NAVIGATION_WINDOW (window)->sidebar, GTK_WIDGET (sidebar_panel), icon); if (icon) { g_object_unref (icon); } g_signal_connect (sidebar_panel, "tab_icon_changed", (GCallback)side_panel_image_changed_callback, window); window->sidebar_panels = g_list_prepend (window->sidebar_panels, g_object_ref (sidebar_panel)); /* Show if default */ sidebar_id = caja_sidebar_get_sidebar_id (sidebar_panel); default_id = g_settings_get_string (caja_window_state, CAJA_WINDOW_STATE_SIDE_PANE_VIEW); if (sidebar_id && default_id && !strcmp (sidebar_id, default_id)) { caja_side_pane_show_panel (window->sidebar, GTK_WIDGET (sidebar_panel)); } g_free (default_id); }
static void navigation_bar_location_changed_callback (GtkWidget *widget, const char *uri, CajaNavigationWindowPane *pane) { GFile *location; if (caja_navigation_window_pane_hide_temporary_bars (pane)) { caja_navigation_window_restore_focus_widget (CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window)); } location = g_file_new_for_uri (uri); caja_window_slot_go_to (CAJA_WINDOW_PANE (pane)->active_slot, location, FALSE); g_object_unref (location); }
static void always_use_location_entry_changed (gpointer callback_data) { CajaNavigationWindow *window; GList *walk; gboolean use_entry; window = CAJA_NAVIGATION_WINDOW (callback_data); use_entry = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); for (walk = CAJA_WINDOW(window)->details->panes; walk; walk = walk->next) { caja_navigation_window_pane_always_use_location_entry (walk->data, use_entry); } }
static void side_pane_size_allocate_callback (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data) { CajaNavigationWindow *window; window = CAJA_NAVIGATION_WINDOW (user_data); if (allocation->width != window->details->side_pane_width) { window->details->side_pane_width = allocation->width; g_settings_set_int (caja_window_state, CAJA_WINDOW_STATE_SIDEBAR_WIDTH, allocation->width <= 1 ? 0 : allocation->width); } }
static void caja_zoom_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { CajaZoomAction *zoom; zoom = CAJA_ZOOM_ACTION (object); switch (prop_id) { case PROP_WINDOW: zoom->priv->window = CAJA_NAVIGATION_WINDOW (g_value_get_object (value)); break; } }
static void side_panel_image_changed_callback (CajaSidebar *side_panel, gpointer callback_data) { CajaWindow *window; GdkPixbuf *icon; window = CAJA_WINDOW (callback_data); icon = caja_sidebar_get_tab_icon (side_panel); caja_side_pane_set_panel_image (CAJA_NAVIGATION_WINDOW (window)->sidebar, GTK_WIDGET (side_panel), icon); if (icon != NULL) { g_object_unref (icon); } }
static void caja_navigation_window_finalize (GObject *object) { CajaNavigationWindow *window; window = CAJA_NAVIGATION_WINDOW (object); caja_navigation_window_remove_go_menu_callback (window); g_signal_handlers_disconnect_by_func (caja_preferences, always_use_browser_changed, window); g_signal_handlers_disconnect_by_func (caja_preferences, always_use_location_entry_changed, window); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void real_prompt_for_location (CajaWindow *window, const char *initial) { CajaNavigationWindowPane *pane; remember_focus_widget (CAJA_NAVIGATION_WINDOW (window)); pane = CAJA_NAVIGATION_WINDOW_PANE (window->details->active_pane); caja_navigation_window_pane_show_location_bar_temporarily (pane); caja_navigation_window_pane_show_navigation_bar_temporarily (pane); if (initial) { caja_navigation_bar_set_location (CAJA_NAVIGATION_BAR (pane->navigation_bar), initial); } }
caja_navigation_window_destroy (GtkObject *object) #endif { CajaNavigationWindow *window; window = CAJA_NAVIGATION_WINDOW (object); caja_navigation_window_unset_focus_widget (window); window->sidebar = NULL; g_list_foreach (window->sidebar_panels, (GFunc)g_object_unref, NULL); g_list_free (window->sidebar_panels); window->sidebar_panels = NULL; window->details->content_paned = NULL; window->details->split_view_hpane = NULL; #if GTK_CHECK_VERSION (3, 0, 0) GTK_WIDGET_CLASS (parent_class)->destroy (object); #else GTK_OBJECT_CLASS (parent_class)->destroy (object); #endif }
static void caja_navigation_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { CajaNavigationAction *nav; nav = CAJA_NAVIGATION_ACTION (object); switch (prop_id) { case PROP_ARROW_TOOLTIP: g_free (nav->priv->arrow_tooltip); nav->priv->arrow_tooltip = g_value_dup_string (value); break; case PROP_DIRECTION: nav->priv->direction = g_value_get_int (value); break; case PROP_WINDOW: nav->priv->window = CAJA_NAVIGATION_WINDOW (g_value_get_object (value)); break; } }
void caja_navigation_window_pane_setup (CajaNavigationWindowPane *pane) { GtkWidget *hbox; CajaEntry *entry; GtkSizeGroup *header_size_group; pane->widget = gtk_vbox_new (FALSE, 0); hbox = gtk_hbox_new (FALSE, 12); pane->location_bar = hbox; gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); gtk_box_pack_start (GTK_BOX (pane->widget), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); /* the header size group ensures that the location bar has the same height as the sidebar header */ header_size_group = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window)->details->header_size_group; gtk_size_group_add_widget (header_size_group, pane->location_bar); pane->location_button = location_button_create (pane); gtk_box_pack_start (GTK_BOX (hbox), pane->location_button, FALSE, FALSE, 0); gtk_widget_show (pane->location_button); pane->path_bar = g_object_new (CAJA_TYPE_PATH_BAR, NULL); gtk_widget_show (pane->path_bar); g_signal_connect_object (pane->path_bar, "path_clicked", G_CALLBACK (path_bar_location_changed_callback), pane, 0); g_signal_connect_object (pane->path_bar, "path_set", G_CALLBACK (path_bar_path_set_callback), pane, 0); gtk_box_pack_start (GTK_BOX (hbox), pane->path_bar, TRUE, TRUE, 0); pane->navigation_bar = caja_location_bar_new (pane); g_signal_connect_object (pane->navigation_bar, "location_changed", G_CALLBACK (navigation_bar_location_changed_callback), pane, 0); g_signal_connect_object (pane->navigation_bar, "cancel", G_CALLBACK (navigation_bar_cancel_callback), pane, 0); entry = caja_location_bar_get_entry (CAJA_LOCATION_BAR (pane->navigation_bar)); g_signal_connect (entry, "focus-in-event", G_CALLBACK (navigation_bar_focus_in_callback), pane); gtk_box_pack_start (GTK_BOX (hbox), pane->navigation_bar, TRUE, TRUE, 0); pane->search_bar = caja_search_bar_new (); g_signal_connect_object (pane->search_bar, "activate", G_CALLBACK (search_bar_activate_callback), pane, 0); g_signal_connect_object (pane->search_bar, "cancel", G_CALLBACK (search_bar_cancel_callback), pane, 0); g_signal_connect_object (pane->search_bar, "focus-in", G_CALLBACK (search_bar_focus_in_callback), pane, 0); gtk_box_pack_start (GTK_BOX (hbox), pane->search_bar, TRUE, TRUE, 0); pane->notebook = g_object_new (CAJA_TYPE_NOTEBOOK, NULL); gtk_box_pack_start (GTK_BOX (pane->widget), pane->notebook, TRUE, TRUE, 0); g_signal_connect (pane->notebook, "tab-close-request", G_CALLBACK (notebook_tab_close_requested), pane); g_signal_connect_after (pane->notebook, "button_press_event", G_CALLBACK (notebook_button_press_cb), pane); g_signal_connect (pane->notebook, "popup-menu", G_CALLBACK (notebook_popup_menu_cb), pane); g_signal_connect (pane->notebook, "switch-page", G_CALLBACK (notebook_switch_page_cb), pane); gtk_notebook_set_show_tabs (GTK_NOTEBOOK (pane->notebook), FALSE); gtk_notebook_set_show_border (GTK_NOTEBOOK (pane->notebook), FALSE); gtk_widget_show (pane->notebook); gtk_container_set_border_width (GTK_CONTAINER (pane->notebook), 0); /* Ensure that the view has some minimal size and that other parts * of the UI (like location bar and tabs) don't request more and * thus affect the default position of the split view paned. */ gtk_widget_set_size_request (pane->widget, 60, 60); }
/** * caja_navigation_window_show: * @widget: a #GtkWidget. * * Call parent and then show/hide window items * base on user prefs. */ static void caja_navigation_window_show (GtkWidget *widget) { CajaNavigationWindow *window; gboolean show_location_bar; gboolean always_use_location_entry; GList *walk; window = CAJA_NAVIGATION_WINDOW (widget); /* Initially show or hide views based on preferences; once the window is displayed * these can be controlled on a per-window basis from View menu items. */ if (g_settings_get_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_TOOLBAR)) { caja_navigation_window_show_toolbar (window); } else { caja_navigation_window_hide_toolbar (window); } show_location_bar = g_settings_get_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_LOCATION_BAR); always_use_location_entry = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); for (walk = CAJA_WINDOW(window)->details->panes; walk; walk = walk->next) { CajaNavigationWindowPane *pane = walk->data; if (show_location_bar) { caja_navigation_window_pane_show_location_bar (pane, FALSE); } else { caja_navigation_window_pane_hide_location_bar (pane, FALSE); } if (always_use_location_entry) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_NAVIGATION); } else { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH); } } if (g_settings_get_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_SIDEBAR)) { caja_navigation_window_show_sidebar (window); } else { caja_navigation_window_hide_sidebar (window); } if (g_settings_get_boolean (caja_window_state, CAJA_WINDOW_STATE_START_WITH_STATUS_BAR)) { caja_navigation_window_show_status_bar (window); } else { caja_navigation_window_hide_status_bar (window); } GTK_WIDGET_CLASS (parent_class)->show (widget); }
static void real_window_close (CajaWindow *window) { caja_navigation_window_save_geometry (CAJA_NAVIGATION_WINDOW (window)); }
gboolean caja_navigation_window_pane_hide_temporary_bars (CajaNavigationWindowPane *pane) { CajaWindowSlot *slot; CajaDirectory *directory; gboolean success; g_assert (CAJA_IS_NAVIGATION_WINDOW_PANE (pane)); slot = CAJA_WINDOW_PANE(pane)->active_slot; success = FALSE; if (pane->temporary_location_bar) { if (caja_navigation_window_pane_location_bar_showing (pane)) { caja_navigation_window_pane_hide_location_bar (pane, FALSE); } pane->temporary_location_bar = FALSE; success = TRUE; } if (pane->temporary_navigation_bar) { directory = caja_directory_get (slot->location); if (CAJA_IS_SEARCH_DIRECTORY (directory)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_SEARCH); } else { if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH); } } pane->temporary_navigation_bar = FALSE; success = TRUE; caja_directory_unref (directory); } if (pane->temporary_search_bar) { CajaNavigationWindow *window; if (!g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY)) { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_PATH); } else { caja_navigation_window_pane_set_bar_mode (pane, CAJA_BAR_NAVIGATION); } window = CAJA_NAVIGATION_WINDOW (CAJA_WINDOW_PANE (pane)->window); caja_navigation_window_set_search_button (window, FALSE); pane->temporary_search_bar = FALSE; success = TRUE; } return success; }