static void real_sync_title (NautilusWindow *window, NautilusWindowSlot *slot) { NautilusNavigationWindow *navigation_window; NautilusNavigationWindowPane *pane; NautilusNotebook *notebook; char *full_title; char *window_title; navigation_window = NAUTILUS_NAVIGATION_WINDOW (window); EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, sync_title, (window, slot)); if (slot == window->details->active_pane->active_slot) { /* if spatial mode is default, we keep "File Browser" in the window title * to recognize browser windows. Otherwise, we default to the directory name. */ if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) { full_title = g_strdup_printf (_("%s - File Browser"), slot->title); window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH); g_free (full_title); } else { window_title = eel_str_middle_truncate (slot->title, MAX_TITLE_LENGTH); } gtk_window_set_title (GTK_WINDOW (window), window_title); g_free (window_title); } pane = NAUTILUS_NAVIGATION_WINDOW_PANE (slot->pane); notebook = NAUTILUS_NOTEBOOK (pane->notebook); nautilus_notebook_sync_tab_label (notebook, slot); }
/* FIXME remove when gtknotebook's func for this becomes public, bug #.... */ static NautilusNotebook * find_notebook_at_pointer (gint abs_x, gint abs_y) { GdkWindow *win_at_pointer, *toplevel_win; gpointer toplevel = NULL; gint x, y; /* FIXME multi-head */ win_at_pointer = gdk_window_at_pointer (&x, &y); if (win_at_pointer == NULL) { /* We are outside all windows containing a notebook */ return NULL; } toplevel_win = gdk_window_get_toplevel (win_at_pointer); /* get the GtkWidget which owns the toplevel GdkWindow */ gdk_window_get_user_data (toplevel_win, &toplevel); /* toplevel should be an NautilusWindow */ if (toplevel != NULL && NAUTILUS_IS_NAVIGATION_WINDOW (toplevel)) { return NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW (toplevel)->notebook); } return NULL; }
static gboolean nautilus_navigation_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { NautilusNavigationWindow *window; int i; window = NAUTILUS_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 (nautilus_navigation_window_parent_class)->key_press_event (widget, event); }
static void nautilus_navigation_window_unrealize (GtkWidget *widget) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (widget); GTK_WIDGET_CLASS (parent_class)->unrealize (widget); }
static void always_use_browser_changed (gpointer callback_data) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (callback_data); nautilus_navigation_window_update_spatial_menu_item (window); }
static gboolean refresh_go_menu_idle_callback (gpointer data) { g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (data)); refresh_go_menu (NAUTILUS_NAVIGATION_WINDOW (data)); /* Don't call this again (unless rescheduled) */ return FALSE; }
static void action_search_callback (GtkAction *action, gpointer user_data) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (user_data); nautilus_navigation_window_show_search (window); }
static void side_pane_close_requested_callback (GtkWidget *widget, gpointer user_data) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (user_data); nautilus_navigation_window_hide_sidebar (window); }
static void remember_focus_widget (NautilusNavigationWindow *window) { NautilusNavigationWindow *navigation_window; GtkWidget *focus_widget; navigation_window = NAUTILUS_NAVIGATION_WINDOW (window); focus_widget = gtk_window_get_focus (GTK_WINDOW (window)); if (focus_widget != NULL && !nautilus_navigation_window_is_in_temporary_navigation_bar (focus_widget, navigation_window) && !nautilus_navigation_window_is_in_temporary_search_bar (focus_widget, navigation_window)) { nautilus_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 *) &(NAUTILUS_NAVIGATION_WINDOW (window)->details->last_focus_widget)); } }
static void nautilus_navigation_window_finalize (GObject *object) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (object); nautilus_navigation_window_remove_go_menu_callback (window); G_OBJECT_CLASS (parent_class)->finalize (object); }
static void real_sync_allow_stop (NautilusWindow *window, NautilusWindowSlot *slot) { NautilusNavigationWindow *navigation_window; NautilusNotebook *notebook; navigation_window = NAUTILUS_NAVIGATION_WINDOW (window); nautilus_navigation_window_set_spinner_active (navigation_window, slot->allow_stop); notebook = NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW_PANE (slot->pane)->notebook); nautilus_notebook_sync_loading (notebook, slot); }
/** * nautilus_navigation_window_show: * @widget: a #GtkWidget. * * Call parent and then show/hide window items * base on user prefs. */ static void nautilus_navigation_window_show (GtkWidget *widget) { NautilusNavigationWindow *window; gboolean show_location_bar; gboolean always_use_location_entry; GList *walk; window = NAUTILUS_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 (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_TOOLBAR)) { nautilus_navigation_window_show_toolbar (window); } else { nautilus_navigation_window_hide_toolbar (window); } show_location_bar = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_LOCATION_BAR); always_use_location_entry = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); for (walk = NAUTILUS_WINDOW(window)->details->panes; walk; walk = walk->next) { NautilusNavigationWindowPane *pane = walk->data; if (show_location_bar) { nautilus_navigation_window_pane_show_location_bar (pane, FALSE); } else { nautilus_navigation_window_pane_hide_location_bar (pane, FALSE); } if (always_use_location_entry) { nautilus_navigation_window_pane_set_bar_mode (pane, NAUTILUS_BAR_NAVIGATION); } else { nautilus_navigation_window_pane_set_bar_mode (pane, NAUTILUS_BAR_PATH); } } if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) { nautilus_navigation_window_show_sidebar (window); } else { nautilus_navigation_window_hide_sidebar (window); } if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_STATUS_BAR)) { nautilus_navigation_window_show_status_bar (window); } else { nautilus_navigation_window_hide_status_bar (window); } GTK_WIDGET_CLASS (parent_class)->show (widget); }
static void action_show_hide_statusbar_callback (GtkAction *action, gpointer user_data) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (user_data); if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) { nautilus_navigation_window_show_status_bar (window); } else { nautilus_navigation_window_hide_status_bar (window); } }
static void always_use_location_entry_changed (gpointer callback_data) { NautilusNavigationWindow *window; GList *walk; gboolean use_entry; window = NAUTILUS_NAVIGATION_WINDOW (callback_data); use_entry = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY); for (walk = NAUTILUS_WINDOW(window)->details->panes; walk; walk = walk->next) { nautilus_navigation_window_pane_always_use_location_entry (walk->data, use_entry); } }
static void nautilus_zoom_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NautilusZoomAction *zoom; zoom = NAUTILUS_ZOOM_ACTION (object); switch (prop_id) { case PROP_WINDOW: zoom->priv->window = NAUTILUS_NAVIGATION_WINDOW (g_value_get_object (value)); break; } }
void nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window, NautilusSidebar *sidebar_panel) { const char *sidebar_id; char *label; char *tooltip; char *default_id; GdkPixbuf *icon; g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window)); g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar_panel)); g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar)); g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL); label = nautilus_sidebar_get_tab_label (sidebar_panel); tooltip = nautilus_sidebar_get_tab_tooltip (sidebar_panel); nautilus_side_pane_add_panel (window->sidebar, GTK_WIDGET (sidebar_panel), label, tooltip); g_free (tooltip); g_free (label); icon = nautilus_sidebar_get_tab_icon (sidebar_panel); nautilus_side_pane_set_panel_image (NAUTILUS_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 = nautilus_sidebar_get_sidebar_id (sidebar_panel); default_id = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW); if (sidebar_id && default_id && !strcmp (sidebar_id, default_id)) { nautilus_side_pane_show_panel (window->sidebar, GTK_WIDGET (sidebar_panel)); } g_free (default_id); }
static void real_prompt_for_location (NautilusWindow *window, const char *initial) { NautilusNavigationWindowPane *pane; remember_focus_widget (NAUTILUS_NAVIGATION_WINDOW (window)); pane = NAUTILUS_NAVIGATION_WINDOW_PANE (window->details->active_pane); nautilus_navigation_window_pane_show_location_bar_temporarily (pane); nautilus_navigation_window_pane_show_navigation_bar_temporarily (pane); if (initial) { nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (pane->navigation_bar), initial); } }
static void side_panel_image_changed_callback (NautilusSidebar *side_panel, gpointer callback_data) { NautilusWindow *window; GdkPixbuf *icon; window = NAUTILUS_WINDOW (callback_data); icon = nautilus_sidebar_get_tab_icon (side_panel); nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar, GTK_WIDGET (side_panel), icon); if (icon != NULL) { g_object_unref (icon); } }
static void side_pane_size_allocate_callback (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (user_data); if (allocation->width != window->details->side_pane_width) { window->details->side_pane_width = allocation->width; if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH)) { eel_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, allocation->width <= 1 ? 0 : allocation->width); } } }
static void nautilus_navigation_window_destroy (GtkObject *object) { NautilusNavigationWindow *window; window = NAUTILUS_NAVIGATION_WINDOW (object); nautilus_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; GTK_OBJECT_CLASS (parent_class)->destroy (object); }
static gboolean nautilus_navigation_window_button_press_event (GtkWidget *widget, GdkEventButton *event) { NautilusNavigationWindow *window; gboolean handled; handled = FALSE; window = NAUTILUS_NAVIGATION_WINDOW (widget); if (mouse_extra_buttons && (event->button == mouse_back_button)) { nautilus_navigation_window_go_back (window); handled = TRUE; } else if (mouse_extra_buttons && (event->button == mouse_forward_button)) { nautilus_navigation_window_go_forward (window); handled = TRUE; } else if (GTK_WIDGET_CLASS (nautilus_navigation_window_parent_class)->button_press_event) { handled = GTK_WIDGET_CLASS (nautilus_navigation_window_parent_class)->button_press_event (widget, event); } else { handled = FALSE; } return handled; }
static void nautilus_navigation_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NautilusNavigationAction *nav; nav = NAUTILUS_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 = NAUTILUS_NAVIGATION_WINDOW (g_value_get_object (value)); break; } }
static void action_forward_callback (GtkAction *action, gpointer user_data) { nautilus_navigation_window_go_forward (NAUTILUS_NAVIGATION_WINDOW (user_data)); }
static void real_window_close (NautilusWindow *window) { nautilus_navigation_window_save_geometry (NAUTILUS_NAVIGATION_WINDOW (window)); }