[nautilus] all: merge NautilusNavigationWindow into NautilusWindow
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] all: merge NautilusNavigationWindow into NautilusWindow
- Date: Thu, 17 Feb 2011 21:38:47 +0000 (UTC)
commit df516e1f09ded17bea6a4fc4fd8b974f61e799b4
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Feb 17 16:26:33 2011 -0500
all: merge NautilusNavigationWindow into NautilusWindow
src/Makefile.am | 3 -
src/nautilus-application.c | 31 +-
src/nautilus-application.h | 8 +-
src/nautilus-bookmarks-window.c | 6 +-
src/nautilus-connect-server-dialog-nonmain.c | 6 +-
src/nautilus-desktop-window.c | 2 +-
src/nautilus-desktop-window.h | 6 +-
src/nautilus-icon-view.c | 33 +-
src/nautilus-location-bar.c | 17 +-
src/nautilus-location-bar.h | 1 -
src/nautilus-mime-actions.c | 3 +-
src/nautilus-navigation-action.c | 26 +-
src/nautilus-navigation-window-menus.c | 817 ----------------------
src/nautilus-navigation-window.c | 961 --------------------------
src/nautilus-navigation-window.h | 91 ---
src/nautilus-notebook.c | 4 +-
src/nautilus-places-sidebar.c | 12 +-
src/nautilus-view.c | 123 ++--
src/nautilus-window-manage-views.c | 10 +-
src/nautilus-window-manage-views.h | 1 -
src/nautilus-window-menus.c | 760 ++++++++++++++++++++-
src/nautilus-window-pane.c | 28 +-
src/nautilus-window-private.h | 59 +-
src/nautilus-window.c | 885 +++++++++++++++++++++---
src/nautilus-window.h | 29 +-
25 files changed, 1705 insertions(+), 2217 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a955be..253489a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -102,9 +102,6 @@ nautilus_SOURCES = \
nautilus-navigation-action.h \
nautilus-navigation-state.c \
nautilus-navigation-state.h \
- nautilus-navigation-window-menus.c \
- nautilus-navigation-window.c \
- nautilus-navigation-window.h \
nautilus-notebook.c \
nautilus-notebook.h \
nautilus-pathbar.c \
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index d437d2e..052682b 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -39,9 +39,9 @@
#include "nautilus-icon-view.h"
#include "nautilus-image-properties-page.h"
#include "nautilus-list-view.h"
-#include "nautilus-navigation-window.h"
#include "nautilus-progress-ui-handler.h"
#include "nautilus-self-check-functions.h"
+#include "nautilus-window.h"
#include "nautilus-window-bookmarks.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-private.h"
@@ -509,9 +509,9 @@ open_window (NautilusApplication *application,
DEBUG ("Opening new window at uri %s", uri);
- window = nautilus_application_create_navigation_window (application,
- startup_id,
- screen);
+ window = nautilus_application_create_window (application,
+ startup_id,
+ screen);
nautilus_window_go_to (window, location);
g_object_unref (location);
@@ -705,7 +705,7 @@ nautilus_application_close_desktop (void)
}
void
-nautilus_application_close_all_navigation_windows (NautilusApplication *self)
+nautilus_application_close_all_windows (NautilusApplication *self)
{
GList *list_copy;
GList *l;
@@ -744,7 +744,6 @@ nautilus_window_delete_event_callback (GtkWidget *widget,
static NautilusWindow *
create_window (NautilusApplication *application,
- GType window_type,
const char *startup_id,
GdkScreen *screen)
{
@@ -752,10 +751,10 @@ create_window (NautilusApplication *application,
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
- window = NAUTILUS_WINDOW (gtk_widget_new (window_type,
- "app", application,
- "screen", screen,
- NULL));
+ window = g_object_new (NAUTILUS_TYPE_WINDOW,
+ "app", application,
+ "screen", screen,
+ NULL);
if (startup_id) {
gtk_window_set_startup_id (GTK_WINDOW (window), startup_id);
@@ -793,9 +792,9 @@ another_navigation_window_already_showing (NautilusApplication *application,
}
NautilusWindow *
-nautilus_application_create_navigation_window (NautilusApplication *application,
- const char *startup_id,
- GdkScreen *screen)
+nautilus_application_create_window (NautilusApplication *application,
+ const char *startup_id,
+ GdkScreen *screen)
{
NautilusWindow *window;
char *geometry_string;
@@ -803,7 +802,7 @@ nautilus_application_create_navigation_window (NautilusApplication *application,
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
- window = create_window (application, NAUTILUS_TYPE_NAVIGATION_WINDOW, startup_id, screen);
+ window = create_window (application, startup_id, screen);
maximized = g_settings_get_boolean
(nautilus_window_state, NAUTILUS_WINDOW_STATE_MAXIMIZED);
@@ -824,8 +823,8 @@ nautilus_application_create_navigation_window (NautilusApplication *application,
eel_gtk_window_set_initial_geometry_from_string
(GTK_WINDOW (window),
geometry_string,
- NAUTILUS_NAVIGATION_WINDOW_MIN_WIDTH,
- NAUTILUS_NAVIGATION_WINDOW_MIN_HEIGHT,
+ NAUTILUS_WINDOW_MIN_WIDTH,
+ NAUTILUS_WINDOW_MIN_HEIGHT,
another_navigation_window_already_showing (application, window));
}
g_free (geometry_string);
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index edbd589..13bedd3 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -71,10 +71,10 @@ NautilusApplication *nautilus_application_dup_singleton (void);
void nautilus_application_quit (NautilusApplication *self);
-NautilusWindow * nautilus_application_create_navigation_window (NautilusApplication *application,
- const char *startup_id,
- GdkScreen *screen);
+NautilusWindow * nautilus_application_create_window (NautilusApplication *application,
+ const char *startup_id,
+ GdkScreen *screen);
-void nautilus_application_close_all_navigation_windows (NautilusApplication *self);
+void nautilus_application_close_all_windows (NautilusApplication *self);
#endif /* __NAUTILUS_APPLICATION_H__ */
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index 94c69c4..4005f9b 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -28,12 +28,14 @@
#include <config.h>
#include "nautilus-bookmarks-window.h"
#include "nautilus-window.h"
-#include "nautilus-navigation-window.h"
+
#include <libnautilus-private/nautilus-undo.h>
#include <libnautilus-private/nautilus-global-preferences.h>
+#include <libnautilus-private/nautilus-undo-signal-handlers.h>
+
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gnome-extensions.h>
-#include <libnautilus-private/nautilus-undo-signal-handlers.h>
+
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
diff --git a/src/nautilus-connect-server-dialog-nonmain.c b/src/nautilus-connect-server-dialog-nonmain.c
index 1e60c10..ed6824d 100644
--- a/src/nautilus-connect-server-dialog-nonmain.c
+++ b/src/nautilus-connect-server-dialog-nonmain.c
@@ -79,9 +79,9 @@ nautilus_connect_server_dialog_display_location_async (NautilusConnectServerDial
application = nautilus_application_dup_singleton ();
- window = nautilus_application_create_navigation_window (application,
- NULL,
- gtk_widget_get_screen (widget));
+ window = nautilus_application_create_window (application,
+ NULL,
+ gtk_widget_get_screen (widget));
nautilus_window_go_to_full (window, location,
window_go_to_cb, self);
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 39d08e2..4d12e73 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -45,7 +45,7 @@ struct NautilusDesktopWindowDetails {
};
G_DEFINE_TYPE (NautilusDesktopWindow, nautilus_desktop_window,
- NAUTILUS_TYPE_NAVIGATION_WINDOW);
+ NAUTILUS_TYPE_WINDOW);
static void
nautilus_desktop_window_init (NautilusDesktopWindow *window)
diff --git a/src/nautilus-desktop-window.h b/src/nautilus-desktop-window.h
index 3a572d8..d0d4b3e 100644
--- a/src/nautilus-desktop-window.h
+++ b/src/nautilus-desktop-window.h
@@ -28,7 +28,7 @@
#ifndef NAUTILUS_DESKTOP_WINDOW_H
#define NAUTILUS_DESKTOP_WINDOW_H
-#include "nautilus-navigation-window.h"
+#include "nautilus-window.h"
#include "nautilus-application.h"
#define NAUTILUS_TYPE_DESKTOP_WINDOW nautilus_desktop_window_get_type()
@@ -46,13 +46,13 @@
typedef struct NautilusDesktopWindowDetails NautilusDesktopWindowDetails;
typedef struct {
- NautilusNavigationWindow parent_spot;
+ NautilusWindow parent_spot;
NautilusDesktopWindowDetails *details;
gboolean affect_desktop_on_next_location_change;
} NautilusDesktopWindow;
typedef struct {
- NautilusNavigationWindowClass parent_spot;
+ NautilusWindowClass parent_spot;
} NautilusDesktopWindowClass;
GType nautilus_desktop_window_get_type (void);
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index 11023d0..e2ba952 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -1804,7 +1804,6 @@ icon_container_activate_alternate_callback (NautilusIconContainer *container,
GdkEventButton *button_event;
GdkEventKey *key_event;
gboolean open_in_tab;
- NautilusWindow *window;
NautilusWindowOpenFlags flags;
g_assert (NAUTILUS_IS_ICON_VIEW (icon_view));
@@ -1812,24 +1811,20 @@ icon_container_activate_alternate_callback (NautilusIconContainer *container,
open_in_tab = FALSE;
- window = nautilus_view_get_nautilus_window (NAUTILUS_VIEW (icon_view));
-
- if (nautilus_window_get_window_type (window) == NAUTILUS_WINDOW_NAVIGATION) {
- event = gtk_get_current_event ();
- if (event->type == GDK_BUTTON_PRESS ||
- event->type == GDK_BUTTON_RELEASE ||
- event->type == GDK_2BUTTON_PRESS ||
- event->type == GDK_3BUTTON_PRESS) {
- button_event = (GdkEventButton *) event;
- open_in_tab = (button_event->state & GDK_SHIFT_MASK) == 0;
- } else if (event->type == GDK_KEY_PRESS ||
- event->type == GDK_KEY_RELEASE) {
- key_event = (GdkEventKey *) event;
- open_in_tab = !((key_event->state & GDK_SHIFT_MASK) != 0 &&
- (key_event->state & GDK_CONTROL_MASK) != 0);
- } else {
- open_in_tab = TRUE;
- }
+ event = gtk_get_current_event ();
+ if (event->type == GDK_BUTTON_PRESS ||
+ event->type == GDK_BUTTON_RELEASE ||
+ event->type == GDK_2BUTTON_PRESS ||
+ event->type == GDK_3BUTTON_PRESS) {
+ button_event = (GdkEventButton *) event;
+ open_in_tab = (button_event->state & GDK_SHIFT_MASK) == 0;
+ } else if (event->type == GDK_KEY_PRESS ||
+ event->type == GDK_KEY_RELEASE) {
+ key_event = (GdkEventKey *) event;
+ open_in_tab = !((key_event->state & GDK_SHIFT_MASK) != 0 &&
+ (key_event->state & GDK_CONTROL_MASK) != 0);
+ } else {
+ open_in_tab = TRUE;
}
flags = NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND;
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index cacbf06..d1c7234 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -94,10 +94,10 @@ static const GtkTargetEntry drop_types [] = {
G_DEFINE_TYPE (NautilusLocationBar, nautilus_location_bar,
GTK_TYPE_HBOX);
-static NautilusNavigationWindow *
+static NautilusWindow *
nautilus_location_bar_get_window (GtkWidget *bar)
{
- return NAUTILUS_NAVIGATION_WINDOW (gtk_widget_get_ancestor (bar, NAUTILUS_TYPE_WINDOW));
+ return NAUTILUS_WINDOW (gtk_widget_get_ancestor (bar, NAUTILUS_TYPE_WINDOW));
}
/**
@@ -151,8 +151,7 @@ drag_data_received_callback (GtkWidget *widget,
char **names;
NautilusApplication *application;
int name_count;
- NautilusWindow *new_window;
- NautilusNavigationWindow *window;
+ NautilusWindow *new_window, *window;
GdkScreen *screen;
gboolean new_windows_for_extras;
char *prompt;
@@ -217,7 +216,7 @@ drag_data_received_callback (GtkWidget *widget,
screen = gtk_window_get_screen (GTK_WINDOW (window));
for (i = 1; names[i] != NULL; ++i) {
- new_window = nautilus_application_create_navigation_window (application, NULL, screen);
+ new_window = nautilus_application_create_window (application, NULL, screen);
location = g_file_new_for_uri (names[i]);
nautilus_window_go_to (new_window, location);
g_object_unref (location);
@@ -299,10 +298,10 @@ static gboolean
label_button_pressed_callback (GtkWidget *widget,
GdkEventButton *event)
{
- NautilusNavigationWindow *window;
- NautilusWindowSlot *slot;
- NautilusView *view;
- GtkWidget *label;
+ NautilusWindow *window;
+ NautilusWindowSlot *slot;
+ NautilusView *view;
+ GtkWidget *label;
if (event->button != 3) {
return FALSE;
diff --git a/src/nautilus-location-bar.h b/src/nautilus-location-bar.h
index 4e98320..4794d18 100644
--- a/src/nautilus-location-bar.h
+++ b/src/nautilus-location-bar.h
@@ -30,7 +30,6 @@
#ifndef NAUTILUS_LOCATION_BAR_H
#define NAUTILUS_LOCATION_BAR_H
-#include "nautilus-navigation-window.h"
#include <libnautilus-private/nautilus-entry.h>
#include <gtk/gtk.h>
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 5981713..9fa48b7 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -1826,8 +1826,7 @@ activate_files (ActivateParameters *parameters)
if (open_in_app_parameters != NULL ||
unhandled_open_in_app_uris != NULL) {
if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0 &&
- window != NULL &&
- nautilus_window_get_window_type (window) == NAUTILUS_WINDOW_SPATIAL) {
+ window != NULL) {
nautilus_window_close (window);
}
}
diff --git a/src/nautilus-navigation-action.c b/src/nautilus-navigation-action.c
index 24de506..6b955ec 100644
--- a/src/nautilus-navigation-action.c
+++ b/src/nautilus-navigation-action.c
@@ -32,7 +32,7 @@
#include "nautilus-navigation-action.h"
-#include "nautilus-navigation-window.h"
+#include "nautilus-window.h"
#include <gtk/gtk.h>
#include <eel/eel-gtk-extensions.h>
@@ -42,7 +42,7 @@ G_DEFINE_TYPE (NautilusNavigationAction, nautilus_navigation_action, GTK_TYPE_AC
struct NautilusNavigationActionPrivate
{
- NautilusNavigationWindow *window;
+ NautilusWindow *window;
NautilusNavigationDirection direction;
char *arrow_tooltip;
@@ -75,33 +75,33 @@ should_open_in_new_tab (void)
static void
activate_back_or_forward_menu_item (GtkMenuItem *menu_item,
- NautilusNavigationWindow *window,
+ NautilusWindow *window,
gboolean back)
{
int index;
g_assert (GTK_IS_MENU_ITEM (menu_item));
- g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menu_item), "user_data"));
- nautilus_navigation_window_back_or_forward (window, back, index, should_open_in_new_tab ());
+ nautilus_window_back_or_forward (window, back, index, should_open_in_new_tab ());
}
static void
-activate_back_menu_item_callback (GtkMenuItem *menu_item, NautilusNavigationWindow *window)
+activate_back_menu_item_callback (GtkMenuItem *menu_item,
+ NautilusWindow *window)
{
activate_back_or_forward_menu_item (menu_item, window, TRUE);
}
static void
-activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusNavigationWindow *window)
+activate_forward_menu_item_callback (GtkMenuItem *menu_item, NautilusWindow *window)
{
activate_back_or_forward_menu_item (menu_item, window, FALSE);
}
static void
-fill_menu (NautilusNavigationWindow *window,
+fill_menu (NautilusWindow *window,
GtkWidget *menu,
gboolean back)
{
@@ -110,9 +110,7 @@ fill_menu (NautilusNavigationWindow *window,
int index;
GList *list;
- g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
-
- slot = nautilus_window_get_active_slot (NAUTILUS_WINDOW (window));
+ slot = nautilus_window_get_active_slot (window);
list = back ? slot->back_list : slot->forward_list;
index = 0;
@@ -137,7 +135,7 @@ show_menu (NautilusNavigationAction *self,
guint button,
guint32 event_time)
{
- NautilusNavigationWindow *window;
+ NautilusWindow *window;
GtkWidget *menu;
window = self->priv->window;
@@ -317,7 +315,7 @@ nautilus_navigation_action_set_property (GObject *object,
nav->priv->direction = g_value_get_int (value);
break;
case PROP_WINDOW:
- nav->priv->window = NAUTILUS_NAVIGATION_WINDOW (g_value_get_object (value));
+ nav->priv->window = g_value_get_object (value);
break;
}
}
@@ -381,7 +379,7 @@ nautilus_navigation_action_class_init (NautilusNavigationActionClass *class)
g_param_spec_object ("window",
"Window",
"The navigation window",
- NAUTILUS_TYPE_NAVIGATION_WINDOW,
+ NAUTILUS_TYPE_WINDOW,
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof(NautilusNavigationActionPrivate));
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
index 1951a10..c8707c9 100644
--- a/src/nautilus-notebook.c
+++ b/src/nautilus-notebook.c
@@ -28,7 +28,7 @@
#include "nautilus-notebook.h"
-#include "nautilus-navigation-window.h"
+#include "nautilus-window.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-private.h"
#include "nautilus-window-slot.h"
@@ -117,7 +117,7 @@ find_notebook_at_pointer (gint abs_x, gint abs_y)
gdk_window_get_user_data (toplevel_win, &toplevel);
/* toplevel should be an NautilusWindow */
- if (toplevel != NULL && NAUTILUS_IS_NAVIGATION_WINDOW (toplevel))
+ if (toplevel != NULL && NAUTILUS_IS_WINDOW (toplevel))
{
return NAUTILUS_NOTEBOOK (NAUTILUS_WINDOW (toplevel)->details->active_pane->notebook);
}
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index dd4c380..1006831 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -1751,9 +1751,9 @@ volume_mounted_cb (GVolume *volume,
cur = NAUTILUS_WINDOW (sidebar->window);
app = nautilus_application_dup_singleton ();
- new = nautilus_application_create_navigation_window (app,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (cur)));
+ new = nautilus_application_create_window (app,
+ NULL,
+ gtk_window_get_screen (GTK_WINDOW (cur)));
nautilus_window_go_to (new, location);
g_object_unref (app);
@@ -1828,9 +1828,9 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
cur = NAUTILUS_WINDOW (sidebar->window);
app = nautilus_application_dup_singleton ();
- new = nautilus_application_create_navigation_window (app,
- NULL,
- gtk_window_get_screen (GTK_WINDOW (cur)));
+ new = nautilus_application_create_window (app,
+ NULL,
+ gtk_window_get_screen (GTK_WINDOW (cur)));
nautilus_window_go_to (new, location);
g_object_unref (app);
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index d26398f..eed84d8 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -7570,7 +7570,7 @@ clipboard_targets_received (GtkClipboard *clipboard,
static gboolean
should_show_empty_trash (NautilusView *view)
{
- return (showing_trash_directory (view) || nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION);
+ return (showing_trash_directory (view));
}
static gboolean
@@ -8265,21 +8265,15 @@ real_update_location_menu (NautilusView *view)
char *tip;
show_open_folder_window = FALSE;
- show_open_in_new_tab = FALSE;
+ show_open_in_new_tab = TRUE;
- if (nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
- if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
- label = _("Open in New _Window");
- } else {
- label = _("Browse in New _Window");
- show_open_folder_window = TRUE;
- }
-
- show_open_in_new_tab = TRUE;
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ label = _("Open in New _Window");
} else {
- label = g_strdup (ngettext ("_Browse Folder",
- "_Browse Folders", 1));
+ label = _("Browse in New _Window");
+ show_open_folder_window = TRUE;
}
+
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_LOCATION_OPEN_ALTERNATE);
g_object_set (action,
@@ -8580,31 +8574,26 @@ real_update_menus (NautilusView *view)
!(nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_DESKTOP &&
g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER));
show_open_folder_window = FALSE;
- if (nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
- if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
- if (selection_count == 0 || selection_count == 1) {
- label_with_underscore = g_strdup (_("Open in New _Window"));
- } else {
- label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
- "Open in %'d New _Windows",
- selection_count),
- selection_count);
- }
+
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (selection_count == 0 || selection_count == 1) {
+ label_with_underscore = g_strdup (_("Open in New _Window"));
} else {
- if (selection_count == 0 || selection_count == 1) {
- label_with_underscore = g_strdup (_("Browse in New _Window"));
- } else {
- label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Window",
- "Browse in %'d New _Windows",
- selection_count),
- selection_count);
- }
- show_open_folder_window = show_open_alternate;
+ label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Window",
+ "Open in %'d New _Windows",
+ selection_count),
+ selection_count);
}
} else {
- label_with_underscore = g_strdup (ngettext ("_Browse Folder",
- "_Browse Folders",
- selection_count));
+ if (selection_count == 0 || selection_count == 1) {
+ label_with_underscore = g_strdup (_("Browse in New _Window"));
+ } else {
+ label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Window",
+ "Browse in %'d New _Windows",
+ selection_count),
+ selection_count);
+ }
+ show_open_folder_window = show_open_alternate;
}
action = gtk_action_group_get_action (view->details->dir_action_group,
@@ -8617,51 +8606,33 @@ real_update_menus (NautilusView *view)
gtk_action_set_sensitive (action, selection_count != 0);
gtk_action_set_visible (action, show_open_alternate);
- /* Open in New Tab action */
- if (nautilus_window_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) {
-
- if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
- if (selection_count == 0 || selection_count == 1) {
- label_with_underscore = g_strdup (_("Open in New _Tab"));
- } else {
- label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
- "Open in %'d New _Tabs",
- selection_count),
- selection_count);
- }
+ if (g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
+ if (selection_count == 0 || selection_count == 1) {
+ label_with_underscore = g_strdup (_("Open in New _Tab"));
} else {
- if (selection_count == 0 || selection_count == 1) {
- label_with_underscore = g_strdup (_("Browse in New _Tab"));
- } else {
- label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Tab",
- "Browse in %'d New _Tabs",
- selection_count),
- selection_count);
- }
+ label_with_underscore = g_strdup_printf (ngettext("Open in %'d New _Tab",
+ "Open in %'d New _Tabs",
+ selection_count),
+ selection_count);
}
- action = gtk_action_group_get_action (view->details->dir_action_group,
- NAUTILUS_ACTION_OPEN_IN_NEW_TAB);
- gtk_action_set_sensitive (action, selection_count != 0);
- gtk_action_set_visible (action, show_open_alternate);
- g_object_set (action, "label",
- label_with_underscore,
- NULL);
- g_free (label_with_underscore);
} else {
- action = gtk_action_group_get_action (view->details->dir_action_group,
- NAUTILUS_ACTION_OPEN_IN_NEW_TAB);
- gtk_action_set_visible (action, FALSE);
- }
-
- /* next pane actions, only in navigation mode */
- if (nautilus_window_get_window_type (view->details->window) != NAUTILUS_WINDOW_NAVIGATION) {
- action = gtk_action_group_get_action (view->details->dir_action_group,
- NAUTILUS_ACTION_COPY_TO_NEXT_PANE);
- gtk_action_set_visible (action, FALSE);
- action = gtk_action_group_get_action (view->details->dir_action_group,
- NAUTILUS_ACTION_MOVE_TO_NEXT_PANE);
- gtk_action_set_visible (action, FALSE);
+ if (selection_count == 0 || selection_count == 1) {
+ label_with_underscore = g_strdup (_("Browse in New _Tab"));
+ } else {
+ label_with_underscore = g_strdup_printf (ngettext("Browse in %'d New _Tab",
+ "Browse in %'d New _Tabs",
+ selection_count),
+ selection_count);
+ }
}
+ action = gtk_action_group_get_action (view->details->dir_action_group,
+ NAUTILUS_ACTION_OPEN_IN_NEW_TAB);
+ gtk_action_set_sensitive (action, selection_count != 0);
+ gtk_action_set_visible (action, show_open_alternate);
+ g_object_set (action, "label",
+ label_with_underscore,
+ NULL);
+ g_free (label_with_underscore);
action = gtk_action_group_get_action (view->details->dir_action_group,
NAUTILUS_ACTION_OPEN_FOLDER_WINDOW);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 6bce2da..7b571d7 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -484,7 +484,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
if (target_same) {
target_window = window;
} else if (target_navigation) {
- target_window = nautilus_application_create_navigation_window
+ target_window = nautilus_application_create_window
(app,
NULL,
gtk_window_get_screen (GTK_WINDOW (window)));
@@ -1761,8 +1761,10 @@ nautilus_window_manage_views_close_slot (NautilusWindowPane *pane,
}
void
-nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
- gboolean back, guint distance, gboolean new_tab)
+nautilus_window_back_or_forward (NautilusWindow *window,
+ gboolean back,
+ guint distance,
+ gboolean new_tab)
{
NautilusWindowSlot *slot;
GList *list;
@@ -1770,7 +1772,7 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
guint len;
NautilusBookmark *bookmark;
- slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot;
+ slot = window->details->active_pane->active_slot;
list = back ? slot->back_list : slot->forward_list;
len = (guint) g_list_length (list);
diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h
index df9bc9e..1a9c415 100644
--- a/src/nautilus-window-manage-views.h
+++ b/src/nautilus-window-manage-views.h
@@ -29,7 +29,6 @@
#include "nautilus-window.h"
#include "nautilus-window-pane.h"
-#include "nautilus-navigation-window.h"
void nautilus_window_manage_views_close_slot (NautilusWindowPane *pane,
NautilusWindowSlot *slot);
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 0036e53..1e028a4 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -33,6 +33,8 @@
#include "nautilus-application.h"
#include "nautilus-connect-server-dialog.h"
#include "nautilus-file-management-properties.h"
+#include "nautilus-navigation-action.h"
+#include "nautilus-notebook.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-bookmarks.h"
#include "nautilus-window-private.h"
@@ -41,7 +43,10 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
+
#include <eel/eel-gtk-extensions.h>
+#include <eel/eel-stock-dialogs.h>
+
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
@@ -479,20 +484,6 @@ disconnect_proxy_cb (GtkUIManager *manager,
}
static void
-connect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
- NautilusWindow *window)
-{
- if (GTK_IS_MENU_ITEM (proxy)) {
- g_signal_connect (proxy, "select",
- G_CALLBACK (menu_item_select_cb), window);
- g_signal_connect (proxy, "deselect",
- G_CALLBACK (menu_item_deselect_cb), window);
- }
-}
-
-static void
trash_state_changed_cb (NautilusTrashMonitor *monitor,
gboolean state,
NautilusWindow *window)
@@ -525,6 +516,502 @@ nautilus_window_initialize_trash_icon_monitor (NautilusWindow *window)
G_CALLBACK (trash_state_changed_cb), window);
}
+#define MENU_PATH_HISTORY_PLACEHOLDER "/MenuBar/Other Menus/Go/History Placeholder"
+
+#define RESPONSE_FORGET 1000
+#define MENU_ITEM_MAX_WIDTH_CHARS 32
+
+enum {
+ SIDEBAR_PLACES,
+ SIDEBAR_TREE
+};
+
+static void
+action_close_all_windows_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusApplication *app;
+
+ app = nautilus_application_dup_singleton ();
+ nautilus_application_close_all_windows (app);
+
+ g_object_unref (app);
+}
+
+static void
+action_back_callback (GtkAction *action,
+ gpointer user_data)
+{
+ nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data),
+ TRUE, 0, nautilus_event_should_open_in_new_tab ());
+}
+
+static void
+action_forward_callback (GtkAction *action,
+ gpointer user_data)
+{
+ nautilus_window_back_or_forward (NAUTILUS_WINDOW (user_data),
+ FALSE, 0, nautilus_event_should_open_in_new_tab ());
+}
+
+static void
+forget_history_if_yes (GtkDialog *dialog, int response, gpointer callback_data)
+{
+ if (response == RESPONSE_FORGET) {
+ nautilus_forget_history ();
+ }
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
+forget_history_if_confirmed (NautilusWindow *window)
+{
+ GtkDialog *dialog;
+
+ dialog = eel_create_question_dialog (_("Are you sure you want to clear the list "
+ "of locations you have visited?"),
+ NULL,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_CLEAR, RESPONSE_FORGET,
+ GTK_WINDOW (window));
+
+ gtk_widget_show (GTK_WIDGET (dialog));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (forget_history_if_yes), NULL);
+
+ gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
+}
+
+static void
+action_clear_history_callback (GtkAction *action,
+ gpointer user_data)
+{
+ forget_history_if_confirmed (NAUTILUS_WINDOW (user_data));
+}
+
+static void
+action_split_view_switch_next_pane_callback(GtkAction *action,
+ gpointer user_data)
+{
+ nautilus_window_pane_grab_focus (nautilus_window_get_next_pane (NAUTILUS_WINDOW (user_data)));
+}
+
+static void
+action_split_view_same_location_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+ NautilusWindowPane *next_pane;
+ GFile *location;
+
+ window = NAUTILUS_WINDOW (user_data);
+ next_pane = nautilus_window_get_next_pane (window);
+
+ if (!next_pane) {
+ return;
+ }
+ location = nautilus_window_slot_get_location (next_pane->active_slot);
+ if (location) {
+ nautilus_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE);
+ g_object_unref (location);
+ }
+}
+
+static void
+action_show_hide_sidebar_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ nautilus_window_show_sidebar (window);
+ } else {
+ nautilus_window_hide_sidebar (window);
+ }
+}
+
+static void
+action_split_view_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+ gboolean is_active;
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ is_active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (is_active != nautilus_window_split_view_showing (window)) {
+ NautilusWindow *nautilus_window;
+
+ if (is_active) {
+ nautilus_window_split_view_on (window);
+ } else {
+ nautilus_window_split_view_off (window);
+ }
+ nautilus_window = NAUTILUS_WINDOW (window);
+ if (nautilus_window->details->active_pane && nautilus_window->details->active_pane->active_slot) {
+ nautilus_view_update_menus (nautilus_window->details->active_pane->active_slot->content_view);
+ }
+ }
+}
+
+
+/* TODO: bind all of this with g_settings_bind and GBinding */
+static guint
+sidebar_id_to_value (const gchar *sidebar_id)
+{
+ guint retval = SIDEBAR_PLACES;
+
+ if (g_strcmp0 (sidebar_id, NAUTILUS_WINDOW_SIDEBAR_TREE) == 0)
+ retval = SIDEBAR_TREE;
+
+ return retval;
+}
+
+void
+nautilus_window_update_show_hide_menu_items (NautilusWindow *window)
+{
+ GtkAction *action;
+ guint current_value;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ NAUTILUS_ACTION_SHOW_HIDE_EXTRA_PANE);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+ nautilus_window_split_view_showing (window));
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ "Sidebar Places");
+ current_value = sidebar_id_to_value (window->details->sidebar_id);
+ gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), current_value);
+}
+
+static void
+action_add_bookmark_callback (GtkAction *action,
+ gpointer user_data)
+{
+ nautilus_window_add_bookmark_for_current_location (NAUTILUS_WINDOW (user_data));
+}
+
+static void
+action_edit_bookmarks_callback (GtkAction *action,
+ gpointer user_data)
+{
+ nautilus_window_edit_bookmarks (NAUTILUS_WINDOW (user_data));
+}
+
+static void
+connect_proxy_cb (GtkActionGroup *action_group,
+ GtkAction *action,
+ GtkWidget *proxy,
+ NautilusWindow *window)
+{
+ GtkLabel *label;
+
+ if (!GTK_IS_MENU_ITEM (proxy))
+ return;
+
+ label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
+
+ gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS);
+
+ g_signal_connect (proxy, "select",
+ G_CALLBACK (menu_item_select_cb), window);
+ g_signal_connect (proxy, "deselect",
+ G_CALLBACK (menu_item_deselect_cb), window);
+}
+
+static const char* icon_entries[] = {
+ "/MenuBar/Other Menus/Go/Home",
+ "/MenuBar/Other Menus/Go/Computer",
+ "/MenuBar/Other Menus/Go/Go to Templates",
+ "/MenuBar/Other Menus/Go/Go to Trash",
+ "/MenuBar/Other Menus/Go/Go to Network",
+ "/MenuBar/Other Menus/Go/Go to Location"
+};
+
+/**
+ * refresh_go_menu:
+ *
+ * Refresh list of bookmarks at end of Go menu to match centralized history list.
+ * @window: The NautilusWindow whose Go menu will be refreshed.
+ **/
+static void
+nautilus_window_initialize_go_menu (NautilusWindow *window)
+{
+ GtkUIManager *ui_manager;
+ GtkWidget *menuitem;
+ int i;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
+
+ for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) {
+ menuitem = gtk_ui_manager_get_widget (
+ ui_manager,
+ icon_entries[i]);
+
+ gtk_image_menu_item_set_always_show_image (
+ GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
+ }
+}
+
+void
+nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window)
+{
+ NautilusWindow *win;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gboolean have_multiple_panes;
+ gboolean next_pane_is_in_same_location;
+ GFile *active_pane_location;
+ GFile *next_pane_location;
+ NautilusWindowPane *next_pane;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ action_group = window->details->main_action_group;
+ win = NAUTILUS_WINDOW (window);
+
+ /* collect information */
+ have_multiple_panes = (win->details->panes && win->details->panes->next);
+ if (win->details->active_pane->active_slot) {
+ active_pane_location = nautilus_window_slot_get_location (win->details->active_pane->active_slot);
+ }
+ else {
+ active_pane_location = NULL;
+ }
+ next_pane = nautilus_window_get_next_pane (win);
+ if (next_pane && next_pane->active_slot) {
+ next_pane_location = nautilus_window_slot_get_location (next_pane->active_slot);
+ next_pane_is_in_same_location = (active_pane_location && next_pane_location &&
+ g_file_equal (active_pane_location, next_pane_location));
+ }
+ else {
+ next_pane_location = NULL;
+ next_pane_is_in_same_location = FALSE;
+ }
+
+ /* switch to next pane */
+ action = gtk_action_group_get_action (action_group, "SplitViewNextPane");
+ gtk_action_set_sensitive (action, have_multiple_panes);
+
+ /* same location */
+ action = gtk_action_group_get_action (action_group, "SplitViewSameLocation");
+ gtk_action_set_sensitive (action, have_multiple_panes && !next_pane_is_in_same_location);
+
+ /* clean up */
+ if (active_pane_location) {
+ g_object_unref (active_pane_location);
+ }
+ if (next_pane_location) {
+ g_object_unref (next_pane_location);
+ }
+}
+
+static void
+action_new_window_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusApplication *application;
+ NautilusWindow *current_window, *new_window;
+
+ current_window = NAUTILUS_WINDOW (user_data);
+ application = nautilus_application_dup_singleton ();
+
+ new_window = nautilus_application_create_window (
+ application,
+ NULL,
+ gtk_window_get_screen (GTK_WINDOW (current_window)));
+ nautilus_window_slot_go_home (nautilus_window_get_active_slot (new_window), FALSE);
+
+ g_object_unref (application);
+}
+
+static void
+action_new_tab_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+ nautilus_window_new_tab (window);
+}
+
+static void
+action_go_to_location_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ nautilus_window_prompt_for_location (window, NULL);
+}
+
+/* The ctrl-f Keyboard shortcut always enables, rather than toggles
+ the search mode */
+static void
+action_show_search_callback (GtkAction *action,
+ gpointer user_data)
+{
+ GtkAction *search_action;
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ search_action =
+ gtk_action_group_get_action (window->details->main_action_group,
+ NAUTILUS_ACTION_SEARCH);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (search_action))) {
+ /* Already visible, just show it */
+ nautilus_window_show_search (window);
+ } else {
+ /* Otherwise, enable */
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (search_action),
+ TRUE);
+ }
+}
+
+static void
+action_show_hide_search_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ /* This is used when toggling the action for updating the UI
+ state only, not actually activating the action */
+ if (g_object_get_data (G_OBJECT (action), "blocked") != NULL) {
+ return;
+ }
+
+ window = NAUTILUS_WINDOW (user_data);
+
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ nautilus_window_show_search (window);
+ } else {
+ NautilusWindowSlot *slot;
+ GFile *location = NULL;
+
+ slot = NAUTILUS_WINDOW (window)->details->active_pane->active_slot;
+
+ /* Use the location bar as the return location */
+ if (slot->query_editor == NULL){
+ location = nautilus_window_slot_get_location (slot);
+ /* Use the search location as the return location */
+ } else {
+ NautilusQuery *query;
+ char *uri;
+
+ query = nautilus_query_editor_get_query (slot->query_editor);
+ if (query != NULL) {
+ uri = nautilus_query_get_location (query);
+ if (uri != NULL) {
+ location = g_file_new_for_uri (uri);
+ g_free (uri);
+ }
+ g_object_unref (query);
+ }
+ }
+
+ /* Last try: use the home directory as the return location */
+ if (location == NULL) {
+ location = g_file_new_for_path (g_get_home_dir ());
+ }
+
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), location);
+ g_object_unref (location);
+
+ nautilus_window_hide_search (window);
+ }
+}
+
+static void
+action_tabs_previous_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindowPane *pane;
+
+ pane = NAUTILUS_WINDOW (user_data)->details->active_pane;
+ nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
+}
+
+static void
+action_tabs_next_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindowPane *pane;
+
+ pane = NAUTILUS_WINDOW (user_data)->details->active_pane;
+ nautilus_notebook_set_current_page_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
+}
+
+static void
+action_tabs_move_left_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindowPane *pane;
+
+ pane = NAUTILUS_WINDOW (user_data)->details->active_pane;
+ nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), -1);
+}
+
+static void
+action_tabs_move_right_callback (GtkAction *action,
+ gpointer user_data)
+{
+ NautilusWindowPane *pane;
+
+ pane = NAUTILUS_WINDOW (user_data)->details->active_pane;
+ nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (pane->notebook), 1);
+}
+
+static void
+action_tab_change_action_activate_callback (GtkAction *action, gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = NAUTILUS_WINDOW (user_data);
+ if (window && window->details->active_pane) {
+ GtkNotebook *notebook;
+ notebook = GTK_NOTEBOOK (window->details->active_pane->notebook);
+ if (notebook) {
+ int num;
+ num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (action), "num"));
+ if (num < gtk_notebook_get_n_pages (notebook)) {
+ gtk_notebook_set_current_page (notebook, num);
+ }
+ }
+ }
+}
+
+static void
+sidebar_radio_entry_changed_cb (GtkAction *action,
+ GtkRadioAction *current,
+ gpointer user_data)
+{
+ gint current_value;
+
+ current_value = gtk_radio_action_get_current_value (current);
+
+ if (current_value == SIDEBAR_PLACES) {
+ g_settings_set_string (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_SIDE_PANE_VIEW,
+ NAUTILUS_WINDOW_SIDEBAR_PLACES);
+ } else if (current_value == SIDEBAR_TREE) {
+ g_settings_set_string (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_SIDE_PANE_VIEW,
+ NAUTILUS_WINDOW_SIDEBAR_TREE);
+ }
+}
+
static const GtkActionEntry main_entries[] = {
/* name, stock id, label */ { "File", NULL, N_("_File") },
/* name, stock id, label */ { "Edit", NULL, N_("_Edit") },
@@ -611,6 +1098,58 @@ static const GtkActionEntry main_entries[] = {
/* label, accelerator */ N_("_Trash"), NULL,
/* tooltip */ N_("Open your personal trash folder"),
G_CALLBACK (action_go_to_trash_callback) },
+ /* name, stock id, label */ { "Go", NULL, N_("_Go") },
+ /* name, stock id, label */ { "Bookmarks", NULL, N_("_Bookmarks") },
+ /* name, stock id, label */ { "Tabs", NULL, N_("_Tabs") },
+ /* name, stock id, label */ { "New Window", "window-new", N_("New _Window"),
+ "<control>N", N_("Open another Nautilus window for the displayed location"),
+ G_CALLBACK (action_new_window_callback) },
+ /* name, stock id, label */ { "New Tab", "tab-new", N_("New _Tab"),
+ "<control>T", N_("Open another tab for the displayed location"),
+ G_CALLBACK (action_new_tab_callback) },
+ /* name, stock id, label */ { "Close All Windows", NULL, N_("Close _All Windows"),
+ "<control>Q", N_("Close all Navigation windows"),
+ G_CALLBACK (action_close_all_windows_callback) },
+ /* name, stock id, label */ { NAUTILUS_ACTION_BACK, GTK_STOCK_GO_BACK, N_("_Back"),
+ "<alt>Left", N_("Go to the previous visited location"),
+ G_CALLBACK (action_back_callback) },
+ /* name, stock id, label */ { NAUTILUS_ACTION_FORWARD, GTK_STOCK_GO_FORWARD, N_("_Forward"),
+ "<alt>Right", N_("Go to the next visited location"),
+ G_CALLBACK (action_forward_callback) },
+ /* name, stock id, label */ { "Go to Location", NULL, N_("_Location..."),
+ "<control>L", N_("Specify a location to open"),
+ G_CALLBACK (action_go_to_location_callback) },
+ /* name, stock id, label */ { "Clear History", NULL, N_("Clea_r History"),
+ NULL, N_("Clear contents of Go menu and Back/Forward lists"),
+ G_CALLBACK (action_clear_history_callback) },
+ /* name, stock id, label */ { "SplitViewNextPane", NULL, N_("S_witch to Other Pane"),
+ "F6", N_("Move focus to the other pane in a split view window"),
+ G_CALLBACK (action_split_view_switch_next_pane_callback) },
+ /* name, stock id, label */ { "SplitViewSameLocation", NULL, N_("Sa_me Location as Other Pane"),
+ NULL, N_("Go to the same location as in the extra pane"),
+ G_CALLBACK (action_split_view_same_location_callback) },
+ /* name, stock id, label */ { "Add Bookmark", GTK_STOCK_ADD, N_("_Add Bookmark"),
+ "<control>d", N_("Add a bookmark for the current location to this menu"),
+ G_CALLBACK (action_add_bookmark_callback) },
+ /* name, stock id, label */ { "Edit Bookmarks", NULL, N_("_Edit Bookmarks..."),
+ "<control>b", N_("Display a window that allows editing the bookmarks in this menu"),
+ G_CALLBACK (action_edit_bookmarks_callback) },
+ { "TabsPrevious", NULL, N_("_Previous Tab"), "<control>Page_Up",
+ N_("Activate previous tab"),
+ G_CALLBACK (action_tabs_previous_callback) },
+ { "TabsNext", NULL, N_("_Next Tab"), "<control>Page_Down",
+ N_("Activate next tab"),
+ G_CALLBACK (action_tabs_next_callback) },
+ { "TabsMoveLeft", NULL, N_("Move Tab _Left"), "<shift><control>Page_Up",
+ N_("Move current tab to left"),
+ G_CALLBACK (action_tabs_move_left_callback) },
+ { "TabsMoveRight", NULL, N_("Move Tab _Right"), "<shift><control>Page_Down",
+ N_("Move current tab to right"),
+ G_CALLBACK (action_tabs_move_right_callback) },
+ { "ShowSearch", NULL, N_("S_how Search"), "<control>f",
+ N_("Show search"),
+ G_CALLBACK (action_show_search_callback) },
+ { "Sidebar List", NULL, N_("Sidebar") }
};
static const GtkToggleActionEntry main_toggle_entries[] = {
@@ -619,8 +1158,154 @@ static const GtkToggleActionEntry main_toggle_entries[] = {
/* tooltip */ N_("Toggle the display of hidden files in the current window"),
G_CALLBACK (action_show_hidden_files_callback),
TRUE },
+ /* name, stock id */ { "Show Hide Toolbar", NULL,
+ /* label, accelerator */ N_("_Main Toolbar"), NULL,
+ /* tooltip */ N_("Change the visibility of this window's main toolbar"),
+ NULL,
+ /* is_active */ TRUE },
+ /* name, stock id */ { "Show Hide Sidebar", NULL,
+ /* label, accelerator */ N_("_Show Sidebar"), "F9",
+ /* tooltip */ N_("Change the visibility of this window's side pane"),
+ G_CALLBACK (action_show_hide_sidebar_callback),
+ /* is_active */ TRUE },
+ /* name, stock id */ { "Show Hide Statusbar", NULL,
+ /* label, accelerator */ N_("St_atusbar"), NULL,
+ /* tooltip */ N_("Change the visibility of this window's statusbar"),
+ NULL,
+ /* is_active */ TRUE },
+ /* name, stock id */ { "Search", "edit-find-symbolic",
+ /* label, accelerator */ N_("_Search for Files..."),
+ /* Accelerator is in ShowSearch */"",
+ /* tooltip */ N_("Search documents and folders by name"),
+ G_CALLBACK (action_show_hide_search_callback),
+ /* is_active */ FALSE },
+ /* name, stock id */ { NAUTILUS_ACTION_SHOW_HIDE_EXTRA_PANE, NULL,
+ /* label, accelerator */ N_("E_xtra Pane"), "F3",
+ /* tooltip */ N_("Open an extra folder view side-by-side"),
+ G_CALLBACK (action_split_view_callback),
+ /* is_active */ FALSE },
+};
+
+static const GtkRadioActionEntry main_radio_entries[] = {
+ { "Sidebar Places", NULL,
+ N_("Places"), NULL, N_("Select Places as the default sidebar"),
+ SIDEBAR_PLACES },
+ { "Sidebar Tree", NULL,
+ N_("Tree"), NULL, N_("Select Tree as the default sidebar"),
+ SIDEBAR_TREE }
};
+GtkActionGroup *
+nautilus_window_create_toolbar_action_group (NautilusWindow *window)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+
+ action_group = gtk_action_group_new ("ToolbarActions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+
+ action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
+ "name", NAUTILUS_ACTION_BACK,
+ "label", _("_Back"),
+ "stock_id", GTK_STOCK_GO_BACK,
+ "tooltip", _("Go to the previous visited location"),
+ "arrow-tooltip", _("Back history"),
+ "window", window,
+ "direction", NAUTILUS_NAVIGATION_DIRECTION_BACK,
+ NULL);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (action_back_callback), window);
+ gtk_action_group_add_action (action_group, action);
+
+ g_object_unref (action);
+
+ action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION,
+ "name", NAUTILUS_ACTION_FORWARD,
+ "label", _("_Forward"),
+ "stock_id", GTK_STOCK_GO_FORWARD,
+ "tooltip", _("Go to the next visited location"),
+ "arrow-tooltip", _("Forward history"),
+ "window", window,
+ "direction", NAUTILUS_NAVIGATION_DIRECTION_FORWARD,
+ NULL);
+ g_signal_connect (action, "activate",
+ G_CALLBACK (action_forward_callback), window);
+ gtk_action_group_add_action (action_group, action);
+
+ g_object_unref (action);
+
+ action = GTK_ACTION
+ (gtk_toggle_action_new ("Search",
+ _("Search"),
+ _("Search documents and folders by name"),
+ NULL));
+ g_signal_connect (action, "activate",
+ G_CALLBACK (action_show_hide_search_callback), window);
+ gtk_action_group_add_action (action_group, action);
+ gtk_action_set_icon_name (GTK_ACTION (action), "edit-find-symbolic");
+ gtk_action_set_is_important (GTK_ACTION (action), TRUE);
+
+ g_object_unref (action);
+
+ nautilus_navigation_state_add_group (window->details->nav_state,
+ action_group);
+
+ return action_group;
+}
+
+static void
+window_menus_set_bindings (NautilusWindow *window)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ NAUTILUS_ACTION_SHOW_HIDE_TOOLBAR);
+
+ g_settings_bind (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_START_WITH_TOOLBAR,
+ action,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ NAUTILUS_ACTION_SHOW_HIDE_STATUSBAR);
+
+ g_settings_bind (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_START_WITH_STATUS_BAR,
+ action,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ NAUTILUS_ACTION_SHOW_HIDE_SIDEBAR);
+
+ g_settings_bind (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR,
+ action,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+}
+
+void
+nautilus_window_initialize_actions (NautilusWindow *window)
+{
+ GtkActionGroup *action_group;
+ const gchar *nav_state_actions[] = {
+ NAUTILUS_ACTION_BACK, NAUTILUS_ACTION_FORWARD, NULL
+ };
+
+ action_group = window->details->main_action_group;
+ window->details->nav_state = nautilus_navigation_state_new (action_group,
+ nav_state_actions);
+
+ window_menus_set_bindings (window);
+ nautilus_window_update_show_hide_menu_items (window);
+
+ g_signal_connect (window, "loading_uri",
+ G_CALLBACK (nautilus_window_update_split_view_actions_sensitivity),
+ NULL);
+}
+
/**
* nautilus_window_initialize_menus
*
@@ -634,7 +1319,12 @@ nautilus_window_initialize_menus (NautilusWindow *window)
GtkUIManager *ui_manager;
GtkAction *action;
const char *ui;
-
+ gint i;
+
+ window->details->ui_manager = gtk_ui_manager_new ();
+ ui_manager = window->details->ui_manager;
+
+ /* shell actions */
action_group = gtk_action_group_new ("ShellActions");
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
window->details->main_action_group = action_group;
@@ -644,6 +1334,10 @@ nautilus_window_initialize_menus (NautilusWindow *window)
gtk_action_group_add_toggle_actions (action_group,
main_toggle_entries, G_N_ELEMENTS (main_toggle_entries),
window);
+ gtk_action_group_add_radio_actions (action_group,
+ main_radio_entries, G_N_ELEMENTS (main_radio_entries),
+ 0, G_CALLBACK (sidebar_radio_entry_changed_cb),
+ window);
action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_UP);
g_object_set (action, "short_label", _("_Up"), NULL);
@@ -662,8 +1356,32 @@ nautilus_window_initialize_menus (NautilusWindow *window)
G_CALLBACK(show_hidden_files_preference_callback),
window);
- window->details->ui_manager = gtk_ui_manager_new ();
- ui_manager = window->details->ui_manager;
+ /* Alt+N for the first 10 tabs */
+ for (i = 0; i < 10; ++i) {
+ gchar action_name[80];
+ gchar accelerator[80];
+
+ snprintf(action_name, sizeof (action_name), "Tab%d", i);
+ action = gtk_action_new (action_name, NULL, NULL, NULL);
+ g_object_set_data (G_OBJECT (action), "num", GINT_TO_POINTER (i));
+ g_signal_connect (action, "activate",
+ G_CALLBACK (action_tab_change_action_activate_callback), window);
+ snprintf(accelerator, sizeof (accelerator), "<alt>%d", (i+1)%10);
+ gtk_action_group_add_action_with_accel (action_group, action, accelerator);
+ g_object_unref (action);
+ gtk_ui_manager_add_ui (ui_manager,
+ gtk_ui_manager_new_merge_id (ui_manager),
+ "/",
+ action_name,
+ action_name,
+ GTK_UI_MANAGER_ACCELERATOR,
+ FALSE);
+
+ }
+
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ g_object_unref (action_group); /* owned by ui_manager */
+
gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (ui_manager));
@@ -671,14 +1389,16 @@ nautilus_window_initialize_menus (NautilusWindow *window)
G_CALLBACK (connect_proxy_cb), window);
g_signal_connect (ui_manager, "disconnect_proxy",
G_CALLBACK (disconnect_proxy_cb), window);
-
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
- g_object_unref (action_group); /* owned by ui manager */
+ /* add the UI */
ui = nautilus_ui_string_get ("nautilus-shell-ui.xml");
gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
+ ui = nautilus_ui_string_get ("nautilus-navigation-window-ui.xml");
+ gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL);
+
nautilus_window_initialize_trash_icon_monitor (window);
+ nautilus_window_initialize_go_menu (window);
}
static GList *
diff --git a/src/nautilus-window-pane.c b/src/nautilus-window-pane.c
index 03496f1..9853d55 100644
--- a/src/nautilus-window-pane.c
+++ b/src/nautilus-window-pane.c
@@ -153,7 +153,7 @@ search_bar_cancel_callback (GtkWidget *widget,
nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
nautilus_window_pane_hide_search_bar (pane);
- nautilus_navigation_window_restore_focus_widget (NAUTILUS_NAVIGATION_WINDOW (pane->window));
+ nautilus_window_restore_focus_widget (pane->window);
}
static void
@@ -163,7 +163,7 @@ navigation_bar_cancel_callback (GtkWidget *widget,
nautilus_toolbar_set_show_location_entry (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
nautilus_window_pane_hide_temporary_bars (pane);
- nautilus_navigation_window_restore_focus_widget (NAUTILUS_NAVIGATION_WINDOW (pane->window));
+ nautilus_window_restore_focus_widget (pane->window);
}
static void
@@ -177,7 +177,7 @@ navigation_bar_location_changed_callback (GtkWidget *widget,
nautilus_window_pane_hide_search_bar (pane);
nautilus_window_pane_hide_temporary_bars (pane);
- nautilus_navigation_window_restore_focus_widget (NAUTILUS_NAVIGATION_WINDOW (pane->window));
+ nautilus_window_restore_focus_widget (pane->window);
location = g_file_new_for_uri (uri);
nautilus_window_slot_go_to (pane->active_slot, location, FALSE);
@@ -197,7 +197,7 @@ path_bar_location_changed_callback (GtkWidget *widget,
/* check whether we already visited the target location */
i = bookmark_list_get_uri_index (slot->back_list, location);
if (i >= 0) {
- nautilus_navigation_window_back_or_forward (NAUTILUS_NAVIGATION_WINDOW (pane->window), TRUE, i, FALSE);
+ nautilus_window_back_or_forward (pane->window, TRUE, i, FALSE);
} else {
nautilus_window_slot_go_to (pane->active_slot, location, FALSE);
}
@@ -500,7 +500,7 @@ real_set_active (NautilusWindowPane *pane,
gboolean is_active)
{
if (is_active) {
- nautilus_navigation_state_set_master (NAUTILUS_NAVIGATION_WINDOW (pane->window)->details->nav_state,
+ nautilus_navigation_state_set_master (pane->window->details->nav_state,
pane->action_group);
}
@@ -512,16 +512,16 @@ static void
nautilus_window_pane_setup (NautilusWindowPane *pane)
{
GtkSizeGroup *header_size_group;
- NautilusNavigationWindow *window;
+ NautilusWindow *window;
GtkActionGroup *action_group;
pane->widget = gtk_vbox_new (FALSE, 0);
- window = NAUTILUS_NAVIGATION_WINDOW (pane->window);
+ window = pane->window;
header_size_group = window->details->header_size_group;
/* build the toolbar */
- action_group = nautilus_navigation_window_create_toolbar_action_group (window);
+ action_group = nautilus_window_create_toolbar_action_group (window);
pane->tool_bar = nautilus_toolbar_new (action_group);
pane->action_group = action_group;
@@ -716,9 +716,9 @@ nautilus_window_pane_sync_location_widgets (NautilusWindowPane *pane)
/* Check if the back and forward buttons need enabling or disabling. */
active_slot = pane->window->details->active_pane->active_slot;
- nautilus_navigation_window_allow_back (NAUTILUS_NAVIGATION_WINDOW (pane->window),
+ nautilus_window_allow_back (pane->window,
active_slot->back_list != NULL);
- nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (pane->window),
+ nautilus_window_allow_forward (pane->window,
active_slot->forward_list != NULL);
}
}
@@ -779,7 +779,7 @@ nautilus_window_pane_slot_close (NautilusWindowPane *pane,
nautilus_window_close_pane (pane);
nautilus_window_set_active_pane (window, next_pane);
- nautilus_navigation_window_update_show_hide_menu_items (NAUTILUS_NAVIGATION_WINDOW (window));
+ nautilus_window_update_show_hide_menu_items (window);
} else {
nautilus_window_close (window);
}
@@ -801,10 +801,10 @@ nautilus_window_pane_hide_search_bar (NautilusWindowPane *pane)
nautilus_toolbar_set_show_search_bar (NAUTILUS_TOOLBAR (pane->tool_bar), FALSE);
if (pane->temporary_search_bar) {
- NautilusNavigationWindow *window;
+ NautilusWindow *window;
- window = NAUTILUS_NAVIGATION_WINDOW (NAUTILUS_WINDOW_PANE (pane)->window);
- nautilus_navigation_window_set_search_button (window, FALSE);
+ window = pane->window;
+ nautilus_window_set_search_button (window, FALSE);
pane->temporary_search_bar = FALSE;
gtk_widget_hide (pane->tool_bar);
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index 34bbf62..792aba8 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -32,13 +32,10 @@
#include "nautilus-window-slot.h"
#include "nautilus-window-pane.h"
#include "nautilus-navigation-state.h"
-#include "nautilus-navigation-window.h"
#include "nautilus-bookmark-list.h"
#include <libnautilus-private/nautilus-directory.h>
-struct _NautilusNavigationWindowPane;
-
/* FIXME bugzilla.gnome.org 42575: Migrate more fields into here. */
struct NautilusWindowDetails
{
@@ -89,12 +86,9 @@ struct NautilusWindowDetails
gboolean initiated_unmount;
NautilusApplication *application;
-};
-struct _NautilusNavigationWindowDetails {
GtkWidget *content_paned;
GtkWidget *content_box;
- GtkActionGroup *navigation_action_group; /* owned by ui_manager */
NautilusNavigationState *nav_state;
GtkSizeGroup *header_size_group;
@@ -147,15 +141,10 @@ struct _NautilusNavigationWindowDetails {
* are turned off, you can see an icon or two at this size. See bug 5946.
*/
-#define NAUTILUS_SPATIAL_WINDOW_MIN_WIDTH 100
-#define NAUTILUS_SPATIAL_WINDOW_MIN_HEIGHT 100
-#define NAUTILUS_SPATIAL_WINDOW_DEFAULT_WIDTH 500
-#define NAUTILUS_SPATIAL_WINDOW_DEFAULT_HEIGHT 300
-
-#define NAUTILUS_NAVIGATION_WINDOW_MIN_WIDTH 200
-#define NAUTILUS_NAVIGATION_WINDOW_MIN_HEIGHT 200
-#define NAUTILUS_NAVIGATION_WINDOW_DEFAULT_WIDTH 800
-#define NAUTILUS_NAVIGATION_WINDOW_DEFAULT_HEIGHT 550
+#define NAUTILUS_WINDOW_MIN_WIDTH 200
+#define NAUTILUS_WINDOW_MIN_HEIGHT 200
+#define NAUTILUS_WINDOW_DEFAULT_WIDTH 800
+#define NAUTILUS_WINDOW_DEFAULT_HEIGHT 550
typedef void (*NautilusBookmarkFailedCallback) (NautilusWindow *window,
NautilusBookmark *bookmark);
@@ -208,25 +197,25 @@ void nautilus_window_sync_title (NautilusWindow *window,
NautilusWindowSlot *slot);
void nautilus_window_sync_zoom_widgets (NautilusWindow *window);
-/* Navigation window menus */
-GtkActionGroup *nautilus_navigation_window_create_toolbar_action_group (NautilusNavigationWindow *window);
-void nautilus_navigation_window_initialize_actions (NautilusNavigationWindow *window);
-void nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window);
-void nautilus_navigation_window_remove_bookmarks_menu_callback (NautilusNavigationWindow *window);
-
-void nautilus_navigation_window_remove_bookmarks_menu_items (NautilusNavigationWindow *window);
-void nautilus_navigation_window_update_show_hide_menu_items (NautilusNavigationWindow *window);
-void nautilus_navigation_window_update_spatial_menu_item (NautilusNavigationWindow *window);
-
-/* Navigation window toolbar */
-void nautilus_navigation_window_activate_spinner (NautilusNavigationWindow *window);
-void nautilus_navigation_window_initialize_toolbars (NautilusNavigationWindow *window);
-void nautilus_navigation_window_load_extension_toolbar_items (NautilusNavigationWindow *window);
-void nautilus_navigation_window_set_spinner_active (NautilusNavigationWindow *window,
- gboolean active);
-void nautilus_navigation_window_go_back (NautilusNavigationWindow *window);
-void nautilus_navigation_window_go_forward (NautilusNavigationWindow *window);
-void nautilus_window_close_pane (NautilusWindowPane *pane);
-void nautilus_navigation_window_update_split_view_actions_sensitivity (NautilusNavigationWindow *window);
+/* window menus */
+GtkActionGroup *nautilus_window_create_toolbar_action_group (NautilusWindow *window);
+void nautilus_window_initialize_actions (NautilusWindow *window);
+void nautilus_window_initialize_menus (NautilusWindow *window);
+void nautilus_window_remove_bookmarks_menu_callback (NautilusWindow *window);
+
+void nautilus_window_remove_bookmarks_menu_items (NautilusWindow *window);
+void nautilus_window_update_show_hide_menu_items (NautilusWindow *window);
+void nautilus_window_update_spatial_menu_item (NautilusWindow *window);
+
+/* window toolbar */
+void nautilus_window_activate_spinner (NautilusWindow *window);
+void nautilus_window_initialize_toolbars (NautilusWindow *window);
+void nautilus_window_load_extension_toolbar_items (NautilusWindow *window);
+void nautilus_window_set_spinner_active (NautilusWindow *window,
+ gboolean active);
+void nautilus_window_go_back (NautilusWindow *window);
+void nautilus_window_go_forward (NautilusWindow *window);
+void nautilus_window_close_pane (NautilusWindowPane *pane);
+void nautilus_window_update_split_view_actions_sensitivity (NautilusWindow *window);
#endif /* NAUTILUS_WINDOW_PRIVATE_H */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 6561e42..edf2da2 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -34,9 +34,13 @@
#include "nautilus-actions.h"
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
+#include "nautilus-location-bar.h"
#include "nautilus-mime-actions.h"
+#include "nautilus-notebook.h"
+#include "nautilus-places-sidebar.h"
#include "nautilus-search-bar.h"
#include "nautilus-src-marshal.h"
+#include "nautilus-tree-sidebar.h"
#include "nautilus-view-factory.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-bookmarks.h"
@@ -44,7 +48,7 @@
#include "nautilus-zoom-control.h"
#include <eel/eel-debug.h>
-#include <eel/eel-gtk-macros.h>
+#include <eel/eel-gtk-extensions.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
@@ -63,6 +67,10 @@
#include <libnautilus-private/nautilus-undo.h>
#include <libnautilus-private/nautilus-search-directory.h>
#include <libnautilus-private/nautilus-signaller.h>
+
+#define DEBUG_FLAG NAUTILUS_DEBUG_WINDOW
+#include <libnautilus-private/nautilus-debug.h>
+
#include <math.h>
#include <sys/time.h>
@@ -77,6 +85,28 @@
#define NAUTILUS_MENU_PATH_SHORT_LIST_PLACEHOLDER "/MenuBar/View/View Choices/Short List"
#define NAUTILUS_MENU_PATH_AFTER_SHORT_LIST_SEPARATOR "/MenuBar/View/View Choices/After Short List"
+#define MAX_TITLE_LENGTH 180
+
+#define MENU_PATH_BOOKMARKS_PLACEHOLDER "/MenuBar/Other Menus/Bookmarks/Bookmarks Placeholder"
+
+/* Forward and back buttons on the mouse */
+static gboolean mouse_extra_buttons = TRUE;
+static int mouse_forward_button = 9;
+static int mouse_back_button = 8;
+
+static void mouse_back_button_changed (gpointer callback_data);
+static void mouse_forward_button_changed (gpointer callback_data);
+static void use_extra_mouse_buttons_changed (gpointer callback_data);
+
+/* Sanity check: highest mouse button value I could find was 14. 5 is our
+ * lower threshold (well-documented to be the one of the button events for the
+ * scrollwheel), so it's hardcoded in the functions below. However, if you have
+ * a button that registers higher and want to map it, file a bug and
+ * we'll move the bar. Makes you wonder why the X guys don't have
+ * defined values for these like the XKB stuff, huh?
+ */
+#define UPPER_MOUSE_LIMIT 14
+
enum {
ARG_0,
ARG_APP
@@ -123,58 +153,13 @@ static const struct {
{ XF86XK_Start, NAUTILUS_ACTION_GO_HOME },
{ XF86XK_Stop, NAUTILUS_ACTION_STOP },
{ XF86XK_ZoomIn, NAUTILUS_ACTION_ZOOM_IN },
- { XF86XK_ZoomOut, NAUTILUS_ACTION_ZOOM_OUT }
+ { XF86XK_ZoomOut, NAUTILUS_ACTION_ZOOM_OUT },
+ { XF86XK_Back, NAUTILUS_ACTION_BACK },
+ { XF86XK_Forward, NAUTILUS_ACTION_FORWARD }
+
#endif
};
-static void
-nautilus_window_init (NautilusWindow *window)
-{
- GtkWidget *table;
- GtkWidget *menu;
- GtkWidget *statusbar;
-
- window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_WINDOW, NautilusWindowDetails);
-
- window->details->panes = NULL;
- window->details->active_pane = NULL;
-
- window->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
-
- /* Set initial window title */
- gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
-
- gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
-
- table = gtk_table_new (1, 6, FALSE);
- window->details->table = table;
- gtk_widget_show (table);
- gtk_container_add (GTK_CONTAINER (window), table);
-
- statusbar = gtk_statusbar_new ();
- gtk_widget_set_name (statusbar, "statusbar-noborder");
- window->details->statusbar = statusbar;
- window->details->help_message_cid = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (statusbar), "help_message");
- /* Statusbar is packed in the subclasses */
-
- nautilus_window_initialize_menus (window);
-
- menu = gtk_ui_manager_get_widget (window->details->ui_manager, "/MenuBar");
- window->details->menubar = menu;
- gtk_widget_show (menu);
- gtk_table_attach (GTK_TABLE (table),
- menu,
- /* X direction */ /* Y direction */
- 0, 1, 0, 1,
- GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0,
- 0, 0);
-
- /* Register to menu provider extension signal managing menu updates */
- g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
- G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
-}
-
/* Unconditionally synchronize the GtkUIManager of WINDOW. */
static void
nautilus_window_ui_update (NautilusWindow *window)
@@ -270,9 +255,8 @@ nautilus_window_new_tab (NautilusWindow *window)
}
}
-static void
-real_set_allow_up (NautilusWindow *window,
- gboolean allow)
+void
+nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
{
GtkAction *action;
@@ -286,15 +270,6 @@ real_set_allow_up (NautilusWindow *window,
gtk_action_set_sensitive (action, allow);
}
-void
-nautilus_window_allow_up (NautilusWindow *window, gboolean allow)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- set_allow_up, (window, allow));
-}
-
static void
update_cursor (NautilusWindow *window)
{
@@ -318,6 +293,7 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
{
GtkAction *action;
gboolean allow_stop;
+ NautilusNotebook *notebook;
g_assert (NAUTILUS_IS_WINDOW (window));
@@ -335,19 +311,76 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
update_cursor (window);
}
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- sync_allow_stop, (window, slot));
+
+ notebook = NAUTILUS_NOTEBOOK (slot->pane->notebook);
+ nautilus_notebook_sync_loading (notebook, slot);
+ }
+}
+
+static gboolean
+nautilus_window_is_in_temporary_bars (GtkWidget *widget,
+ NautilusWindow *window)
+{
+ GList *walk;
+ gboolean is_in_any = FALSE;
+ NautilusWindowPane *pane;
+
+ for (walk = window->details->panes; walk; walk = walk->next) {
+ pane = walk->data;
+
+ if ((gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_LOCATION_BAR) != NULL &&
+ pane->temporary_navigation_bar) ||
+ (gtk_widget_get_ancestor (widget, NAUTILUS_TYPE_SEARCH_BAR) != NULL &&
+ pane->temporary_search_bar))
+ is_in_any = TRUE;
+ }
+
+ return is_in_any;
+}
+
+static void
+nautilus_window_unset_focus_widget (NautilusWindow *window)
+{
+ if (window->details->last_focus_widget != NULL) {
+ g_object_remove_weak_pointer (G_OBJECT (window->details->last_focus_widget),
+ (gpointer *) &window->details->last_focus_widget);
+ window->details->last_focus_widget = NULL;
+ }
+}
+
+static void
+remember_focus_widget (NautilusWindow *window)
+{
+ GtkWidget *focus_widget;
+
+ focus_widget = gtk_window_get_focus (GTK_WINDOW (window));
+ if (focus_widget != NULL &&
+ !nautilus_window_is_in_temporary_bars (focus_widget, window)) {
+ nautilus_window_unset_focus_widget (window);
+
+ window->details->last_focus_widget = focus_widget;
+ g_object_add_weak_pointer (G_OBJECT (focus_widget),
+ (gpointer *) &(window->details->last_focus_widget));
}
}
void
nautilus_window_prompt_for_location (NautilusWindow *window,
const char *initial)
-{
+{
+ NautilusWindowPane *pane;
+
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- prompt_for_location, (window, initial));
+
+ remember_focus_widget (window);
+
+ pane = window->details->active_pane;
+ nautilus_window_pane_ensure_location_bar (pane);
+
+ if (initial) {
+ nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (pane->location_bar),
+ initial);
+ }
}
/* Code should never force the window taller than this size.
@@ -383,9 +416,9 @@ nautilus_window_set_initial_window_geometry (NautilusWindow *window)
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
-
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- get_default_size, (window, &default_width, &default_height));
+
+ default_width = NAUTILUS_WINDOW_DEFAULT_WIDTH;
+ default_height = NAUTILUS_WINDOW_DEFAULT_HEIGHT;
gtk_window_set_default_size (GTK_WINDOW (window),
MIN (default_width,
@@ -453,6 +486,11 @@ nautilus_window_destroy (GtkWidget *object)
window = NAUTILUS_WINDOW (object);
+ nautilus_window_unset_focus_widget (window);
+
+ window->details->content_paned = NULL;
+ window->details->split_view_hpane = NULL;
+
/* close all panes safely */
panes_copy = g_list_copy (window->details->panes);
g_list_foreach (panes_copy, (GFunc) nautilus_window_close_pane, NULL);
@@ -472,6 +510,9 @@ nautilus_window_finalize (GObject *object)
window = NAUTILUS_WINDOW (object);
+ g_free (window->details->sidebar_id);
+ g_clear_object (&window->details->nav_state);
+
nautilus_window_remove_trash_monitor_callback (window);
free_stored_viewers (window);
@@ -582,14 +623,39 @@ nautilus_window_view_visible (NautilusWindow *window,
nautilus_window_show_window (window);
}
+static void
+nautilus_window_save_geometry (NautilusWindow *window)
+{
+ char *geometry_string;
+ gboolean is_maximized;
+
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ if (gtk_widget_get_window (GTK_WIDGET (window))) {
+ geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window));
+ is_maximized = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (window)))
+ & GDK_WINDOW_STATE_MAXIMIZED;
+
+ if (!is_maximized) {
+ g_settings_set_string
+ (nautilus_window_state, NAUTILUS_WINDOW_STATE_GEOMETRY,
+ geometry_string);
+ }
+ g_free (geometry_string);
+
+ g_settings_set_boolean
+ (nautilus_window_state, NAUTILUS_WINDOW_STATE_MAXIMIZED,
+ is_maximized);
+ }
+}
+
void
nautilus_window_close (NautilusWindow *window)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- close, (window));
-
+ nautilus_window_save_geometry (window);
+
gtk_widget_destroy (GTK_WIDGET (window));
}
@@ -602,11 +668,11 @@ nautilus_window_open_slot (NautilusWindowPane *pane,
g_assert (NAUTILUS_IS_WINDOW_PANE (pane));
g_assert (NAUTILUS_IS_WINDOW (pane->window));
- slot = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, pane->window,
- open_slot, (pane, flags));
+ slot = (NautilusWindowSlot *) g_object_new (NAUTILUS_TYPE_WINDOW_SLOT, NULL);
+ slot->pane = pane;
- g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
- g_assert (pane->window == slot->pane->window);
+ nautilus_window_pane_add_slot_in_tab (pane, slot, flags);
+ gtk_widget_show (slot->content_box);
pane->slots = g_list_append (pane->slots, slot);
@@ -642,18 +708,12 @@ nautilus_window_close_pane (NautilusWindowPane *pane)
g_object_unref (pane);
}
-static void
-real_close_slot (NautilusWindowPane *pane,
- NautilusWindowSlot *slot)
-{
- nautilus_window_manage_views_close_slot (pane, slot);
- cancel_view_as_callback (slot);
-}
-
void
nautilus_window_close_slot (NautilusWindowSlot *slot)
{
NautilusWindowPane *pane;
+ int page_num;
+ GtkNotebook *notebook;
g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
g_assert (NAUTILUS_IS_WINDOW_PANE(slot->pane));
@@ -661,9 +721,18 @@ nautilus_window_close_slot (NautilusWindowSlot *slot)
/* save pane because slot is not valid anymore after this call */
pane = slot->pane;
+ notebook = GTK_NOTEBOOK (pane->notebook);
+
+ page_num = gtk_notebook_page_num (notebook, slot->content_box);
+ g_assert (page_num >= 0);
+
+ nautilus_window_pane_remove_page (pane, page_num);
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, slot->pane->window,
- close_slot, (slot->pane, slot));
+ gtk_notebook_set_show_tabs (notebook,
+ gtk_notebook_get_n_pages (notebook) > 1);
+
+ nautilus_window_manage_views_close_slot (pane, slot);
+ cancel_view_as_callback (slot);
g_object_run_dispose (G_OBJECT (slot));
slot->pane = NULL;
@@ -775,16 +844,14 @@ nautilus_window_get_preferred_width (GtkWidget *widget,
gint *natural_width)
{
GdkScreen *screen;
- gint max_w, min_w, min_h, default_w, default_h;
- NautilusWindow *window = NAUTILUS_WINDOW (widget);
+ gint max_w, min_w, default_w;
screen = gtk_window_get_screen (GTK_WINDOW (widget));
max_w = get_max_forced_width (screen);
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- get_min_size, (window, &min_w, &min_h));
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- get_default_size, (window, &default_w, &default_h));
+ min_w = NAUTILUS_WINDOW_MIN_WIDTH;
+
+ default_w = NAUTILUS_WINDOW_DEFAULT_WIDTH;
*minimal_width = MIN (min_w, max_w);
*natural_width = MIN (default_w, max_w);
@@ -796,16 +863,15 @@ nautilus_window_get_preferred_height (GtkWidget *widget,
gint *natural_height)
{
GdkScreen *screen;
- gint max_h, min_w, min_h, default_w, default_h;
- NautilusWindow *window = NAUTILUS_WINDOW (widget);
+ gint max_h, min_h, default_h;
screen = gtk_window_get_screen (GTK_WINDOW (widget));
max_h = get_max_forced_height (screen);
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- get_min_size, (window, &min_w, &min_h));
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- get_default_size, (window, &default_w, &default_h));
+
+ min_h = NAUTILUS_WINDOW_MIN_HEIGHT;
+
+ default_h = NAUTILUS_WINDOW_DEFAULT_HEIGHT;
*minimal_height = MIN (min_h, max_h);
*natural_height = MIN (default_h, max_h);
@@ -1162,7 +1228,7 @@ load_view_as_menus_callback (NautilusFile *file,
NautilusWindowSlot *slot;
slot = callback_data;
- window = NAUTILUS_WINDOW (slot->pane->window);
+ window = slot->pane->window;
if (slot == window->details->active_pane->active_slot) {
load_view_as_menu (window);
@@ -1200,8 +1266,30 @@ void
nautilus_window_sync_title (NautilusWindow *window,
NautilusWindowSlot *slot)
{
- EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- sync_title, (window, slot));
+ NautilusWindowPane *pane;
+ NautilusNotebook *notebook;
+ char *full_title;
+ char *window_title;
+
+ 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 (!g_settings_get_boolean (nautilus_preferences, 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 = slot->pane;
+ notebook = NAUTILUS_NOTEBOOK (pane->notebook);
+ nautilus_notebook_sync_tab_label (notebook, slot);
}
void
@@ -1335,7 +1423,13 @@ nautilus_window_show (GtkWidget *widget)
window = NAUTILUS_WINDOW (widget);
- GTK_WIDGET_CLASS (nautilus_window_parent_class)->show (widget);
+ if (g_settings_get_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR)) {
+ nautilus_window_show_sidebar (window);
+ } else {
+ nautilus_window_hide_sidebar (window);
+ }
+
+ GTK_WIDGET_CLASS (nautilus_window_parent_class)->show (widget);
nautilus_window_ui_update (window);
}
@@ -1441,11 +1535,11 @@ nautilus_forget_history (void)
window_node != NULL;
window_node = window_node->next) {
- NautilusNavigationWindow *window;
+ NautilusWindow *window;
- window = NAUTILUS_NAVIGATION_WINDOW (window_node->data);
+ window = window_node->data;
- for (walk = NAUTILUS_WINDOW (window_node->data)->details->panes; walk; walk = walk->next) {
+ for (walk = window->details->panes; walk; walk = walk->next) {
NautilusWindowPane *pane = walk->data;
for (l = pane->slots; l != NULL; l = l->next) {
slot = l->data;
@@ -1455,8 +1549,8 @@ nautilus_forget_history (void)
}
}
- nautilus_navigation_window_allow_back (window, FALSE);
- nautilus_navigation_window_allow_forward (window, FALSE);
+ nautilus_window_allow_back (window, FALSE);
+ nautilus_window_allow_forward (window, FALSE);
}
g_object_unref (app);
@@ -1535,6 +1629,49 @@ nautilus_window_get_extra_slot (NautilusWindow *window)
}
static void
+window_set_search_action_text (NautilusWindow *window,
+ gboolean setting)
+{
+ GtkAction *action;
+ NautilusWindowPane *pane;
+ GList *l;
+
+ for (l = window->details->panes; l != NULL; l = l->next) {
+ pane = l->data;
+ action = gtk_action_group_get_action (pane->action_group,
+ NAUTILUS_ACTION_SEARCH);
+
+ gtk_action_set_is_important (action, setting);
+ }
+}
+
+static NautilusWindowSlot *
+create_extra_pane (NautilusWindow *window)
+{
+ NautilusWindowPane *pane;
+ NautilusWindowSlot *slot;
+ GtkPaned *paned;
+
+ /* New pane */
+ pane = nautilus_window_pane_new (window);
+ window->details->panes = g_list_append (window->details->panes, pane);
+
+ paned = GTK_PANED (window->details->split_view_hpane);
+ if (gtk_paned_get_child1 (paned) == NULL) {
+ gtk_paned_pack1 (paned, pane->widget, TRUE, FALSE);
+ } else {
+ gtk_paned_pack2 (paned, pane->widget, TRUE, FALSE);
+ }
+
+ /* slot */
+ slot = nautilus_window_open_slot (NAUTILUS_WINDOW_PANE (pane),
+ NAUTILUS_WINDOW_OPEN_SLOT_APPEND);
+ pane->active_slot = slot;
+
+ return slot;
+}
+
+static void
nautilus_window_reload (NautilusWindow *window)
{
NautilusWindowSlot *active_slot;
@@ -1543,6 +1680,450 @@ nautilus_window_reload (NautilusWindow *window)
nautilus_window_slot_reload (active_slot);
}
+static gboolean
+nautilus_window_state_event (GtkWidget *widget,
+ GdkEventWindowState *event)
+{
+ if (event->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) {
+ g_settings_set_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_MAXIMIZED,
+ event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED);
+ }
+
+ if (GTK_WIDGET_CLASS (nautilus_window_parent_class)->window_state_event != NULL) {
+ return GTK_WIDGET_CLASS (nautilus_window_parent_class)->window_state_event (widget, event);
+ }
+
+ return FALSE;
+}
+
+static gboolean
+nautilus_window_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ NautilusWindow *window;
+ gboolean handled;
+
+ handled = FALSE;
+ window = NAUTILUS_WINDOW (widget);
+
+ if (mouse_extra_buttons && (event->button == mouse_back_button)) {
+ nautilus_window_go_back (window);
+ handled = TRUE;
+ } else if (mouse_extra_buttons && (event->button == mouse_forward_button)) {
+ nautilus_window_go_forward (window);
+ handled = TRUE;
+ } else if (GTK_WIDGET_CLASS (nautilus_window_parent_class)->button_press_event) {
+ handled = GTK_WIDGET_CLASS (nautilus_window_parent_class)->button_press_event (widget, event);
+ } else {
+ handled = FALSE;
+ }
+ return handled;
+}
+
+static void
+mouse_back_button_changed (gpointer callback_data)
+{
+ int new_back_button;
+
+ new_back_button = g_settings_get_int (nautilus_preferences, NAUTILUS_PREFERENCES_MOUSE_BACK_BUTTON);
+
+ /* Bounds checking */
+ if (new_back_button < 6 || new_back_button > UPPER_MOUSE_LIMIT)
+ return;
+
+ mouse_back_button = new_back_button;
+}
+
+static void
+mouse_forward_button_changed (gpointer callback_data)
+{
+ int new_forward_button;
+
+ new_forward_button = g_settings_get_int (nautilus_preferences, NAUTILUS_PREFERENCES_MOUSE_FORWARD_BUTTON);
+
+ /* Bounds checking */
+ if (new_forward_button < 6 || new_forward_button > UPPER_MOUSE_LIMIT)
+ return;
+
+ mouse_forward_button = new_forward_button;
+}
+
+static void
+use_extra_mouse_buttons_changed (gpointer callback_data)
+{
+ mouse_extra_buttons = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS);
+}
+
+void
+nautilus_window_restore_focus_widget (NautilusWindow *window)
+{
+ if (window->details->last_focus_widget != NULL) {
+ if (NAUTILUS_IS_VIEW (window->details->last_focus_widget)) {
+ nautilus_view_grab_focus (NAUTILUS_VIEW (window->details->last_focus_widget));
+ } else {
+ gtk_widget_grab_focus (window->details->last_focus_widget);
+ }
+
+ nautilus_window_unset_focus_widget (window);
+ }
+}
+
+/*
+ * Main API
+ */
+
+void
+nautilus_window_go_back (NautilusWindow *window)
+{
+ nautilus_window_back_or_forward (window, TRUE, 0, FALSE);
+}
+
+void
+nautilus_window_go_forward (NautilusWindow *window)
+{
+ nautilus_window_back_or_forward (window, FALSE, 0, FALSE);
+}
+
+void
+nautilus_window_allow_back (NautilusWindow *window, gboolean allow)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (nautilus_navigation_state_get_master (window->details->nav_state),
+ NAUTILUS_ACTION_BACK);
+
+ gtk_action_set_sensitive (action, allow);
+}
+
+void
+nautilus_window_allow_forward (NautilusWindow *window, gboolean allow)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (nautilus_navigation_state_get_master (window->details->nav_state),
+ NAUTILUS_ACTION_FORWARD);
+
+ gtk_action_set_sensitive (action, allow);
+}
+
+void
+nautilus_window_show_search (NautilusWindow *window)
+{
+ NautilusWindowPane *pane;
+
+ remember_focus_widget (window);
+
+ pane = window->details->active_pane;
+
+ nautilus_window_pane_ensure_search_bar (pane);
+}
+
+void
+nautilus_window_hide_search (NautilusWindow *window)
+{
+ NautilusWindowPane *pane = window->details->active_pane;
+
+ nautilus_window_pane_hide_search_bar (pane);
+ nautilus_window_restore_focus_widget (window);
+}
+
+/* This updates the UI state of the search button, but does not
+ in itself trigger a search action */
+void
+nautilus_window_set_search_button (NautilusWindow *window,
+ gboolean state)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (window->details->main_action_group,
+ "Search");
+
+ /* Block callback so we don't activate the action and thus focus the
+ search entry */
+ g_object_set_data (G_OBJECT (action), "blocked", GINT_TO_POINTER (1));
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), state);
+ g_object_set_data (G_OBJECT (action), "blocked", NULL);
+}
+
+/**
+ * nautilus_window_get_base_page_index:
+ * @window: Window to get index from
+ *
+ * Returns the index of the base page in the history list.
+ * Base page is not the currently displayed page, but the page
+ * that acts as the base from which the back and forward commands
+ * navigate from.
+ */
+gint
+nautilus_window_get_base_page_index (NautilusWindow *window)
+{
+ NautilusWindowSlot *slot;
+ gint forward_count;
+
+ slot = window->details->active_pane->active_slot;
+
+ forward_count = g_list_length (slot->forward_list);
+
+ /* If forward is empty, the base it at the top of the list */
+ if (forward_count == 0) {
+ return 0;
+ }
+
+ /* The forward count indicate the relative postion of the base page
+ * in the history list
+ */
+ return forward_count;
+}
+
+/* side pane helpers */
+static void
+side_pane_size_allocate_callback (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer user_data)
+{
+ NautilusWindow *window;
+
+ window = user_data;
+
+ if (allocation->width != window->details->side_pane_width) {
+ window->details->side_pane_width = allocation->width;
+
+ DEBUG ("Saving sidebar width: %d", allocation->width);
+
+ g_settings_set_int (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH,
+ allocation->width <= 1 ? 0 : allocation->width);
+ }
+}
+
+static void
+setup_side_pane_width (NautilusWindow *window)
+{
+ g_return_if_fail (window->details->sidebar != NULL);
+
+ window->details->side_pane_width =
+ g_settings_get_int (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_SIDEBAR_WIDTH);
+
+ gtk_paned_set_position (GTK_PANED (window->details->content_paned),
+ window->details->side_pane_width);
+}
+
+static gboolean
+sidebar_id_is_valid (const gchar *sidebar_id)
+{
+ return (g_strcmp0 (sidebar_id, NAUTILUS_WINDOW_SIDEBAR_PLACES) == 0 ||
+ g_strcmp0 (sidebar_id, NAUTILUS_WINDOW_SIDEBAR_TREE) == 0);
+}
+
+static void
+nautilus_window_set_up_sidebar (NautilusWindow *window)
+{
+ GtkWidget *sidebar;
+
+ DEBUG ("Setting up sidebar id %s", window->details->sidebar_id);
+
+ window->details->sidebar = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+
+ gtk_paned_pack1 (GTK_PANED (window->details->content_paned),
+ GTK_WIDGET (window->details->sidebar),
+ FALSE, FALSE);
+
+ setup_side_pane_width (window);
+ g_signal_connect (window->details->sidebar,
+ "size_allocate",
+ G_CALLBACK (side_pane_size_allocate_callback),
+ window);
+
+ if (g_strcmp0 (window->details->sidebar_id, NAUTILUS_WINDOW_SIDEBAR_PLACES) == 0) {
+ sidebar = nautilus_places_sidebar_new (window);
+ } else if (g_strcmp0 (window->details->sidebar_id, NAUTILUS_WINDOW_SIDEBAR_TREE) == 0) {
+ sidebar = nautilus_tree_sidebar_new (window);
+ } else {
+ g_assert_not_reached ();
+ }
+
+ gtk_box_pack_start (GTK_BOX (window->details->sidebar), sidebar, TRUE, TRUE, 0);
+ gtk_widget_show (sidebar);
+ gtk_widget_show (GTK_WIDGET (window->details->sidebar));
+}
+
+static void
+nautilus_window_tear_down_sidebar (NautilusWindow *window)
+{
+ DEBUG ("Destroying sidebar");
+
+ gtk_widget_destroy (GTK_WIDGET (window->details->sidebar));
+ window->details->sidebar = NULL;
+}
+
+void
+nautilus_window_hide_sidebar (NautilusWindow *window)
+{
+ DEBUG ("Called hide_sidebar()");
+
+ if (window->details->sidebar == NULL) {
+ return;
+ }
+
+ nautilus_window_tear_down_sidebar (window);
+ nautilus_window_update_show_hide_menu_items (window);
+
+ g_settings_set_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR, FALSE);
+}
+
+void
+nautilus_window_show_sidebar (NautilusWindow *window)
+{
+ DEBUG ("Called show_sidebar()");
+
+ if (window->details->sidebar != NULL) {
+ return;
+ }
+
+ nautilus_window_set_up_sidebar (window);
+ nautilus_window_update_show_hide_menu_items (window);
+ g_settings_set_boolean (nautilus_window_state, NAUTILUS_WINDOW_STATE_START_WITH_SIDEBAR, TRUE);
+}
+
+static void
+side_pane_id_changed (NautilusWindow *window)
+{
+ gchar *sidebar_id;
+
+ sidebar_id = g_settings_get_string (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_SIDE_PANE_VIEW);
+
+ DEBUG ("Sidebar id changed to %s", sidebar_id);
+
+ if (g_strcmp0 (sidebar_id, window->details->sidebar_id) == 0) {
+ g_free (sidebar_id);
+ return;
+ }
+
+ if (!sidebar_id_is_valid (sidebar_id)) {
+ g_free (sidebar_id);
+ return;
+ }
+
+ g_free (window->details->sidebar_id);
+ window->details->sidebar_id = sidebar_id;
+
+ if (window->details->sidebar != NULL) {
+ /* refresh the sidebar setting */
+ nautilus_window_tear_down_sidebar (window);
+ nautilus_window_set_up_sidebar (window);
+ }
+}
+
+static void
+nautilus_window_init (NautilusWindow *window)
+{
+ GtkWidget *table;
+ GtkWidget *menu;
+ GtkWidget *statusbar;
+ GtkWidget *hpaned;
+ GtkWidget *vbox;
+ NautilusWindowPane *pane;
+
+ window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_WINDOW, NautilusWindowDetails);
+
+ window->details->panes = NULL;
+ window->details->active_pane = NULL;
+
+ window->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
+
+ /* Set initial window title */
+ gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
+
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
+
+ table = gtk_table_new (1, 6, FALSE);
+ window->details->table = table;
+ gtk_widget_show (table);
+ gtk_container_add (GTK_CONTAINER (window), table);
+
+ statusbar = gtk_statusbar_new ();
+ gtk_widget_set_name (statusbar, "statusbar-noborder");
+ window->details->statusbar = statusbar;
+ window->details->help_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (statusbar), "help_message");
+ /* Statusbar is packed in the subclasses */
+
+ nautilus_window_initialize_menus (window);
+ nautilus_window_initialize_actions (window);
+
+ menu = gtk_ui_manager_get_widget (window->details->ui_manager, "/MenuBar");
+ window->details->menubar = menu;
+ gtk_widget_show (menu);
+ gtk_table_attach (GTK_TABLE (table),
+ menu,
+ /* X direction */ /* Y direction */
+ 0, 1, 0, 1,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0,
+ 0, 0);
+
+ /* Register to menu provider extension signal managing menu updates */
+ g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
+ G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
+
+ window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+ gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE);
+
+ window->details->content_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_table_attach (GTK_TABLE (window->details->table),
+ window->details->content_paned,
+ /* X direction */ /* Y direction */
+ 0, 1, 3, 4,
+ GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK,
+ 0, 0);
+ gtk_widget_show (window->details->content_paned);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_paned_pack2 (GTK_PANED (window->details->content_paned), vbox,
+ TRUE, FALSE);
+ gtk_widget_show (vbox);
+
+ hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
+ gtk_widget_show (hpaned);
+ window->details->split_view_hpane = hpaned;
+
+ gtk_box_pack_start (GTK_BOX (vbox), window->details->statusbar, FALSE, FALSE, 0);
+
+ g_settings_bind (nautilus_window_state,
+ NAUTILUS_WINDOW_STATE_START_WITH_STATUS_BAR,
+ window->details->statusbar,
+ "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pane = nautilus_window_pane_new (window);
+ window->details->panes = g_list_prepend (window->details->panes, pane);
+
+ gtk_paned_pack1 (GTK_PANED (hpaned), pane->widget, TRUE, FALSE);
+ gtk_widget_show (pane->widget);
+
+ /* this has to be done after the location bar has been set up,
+ * but before menu stuff is being called */
+ nautilus_window_set_active_pane (window, pane);
+
+ g_signal_connect_swapped (nautilus_window_state,
+ "changed::" NAUTILUS_WINDOW_STATE_SIDE_PANE_VIEW,
+ G_CALLBACK (side_pane_id_changed),
+ window);
+
+ side_pane_id_changed (window);
+}
+
+static NautilusIconInfo *
+real_get_icon (NautilusWindow *window,
+ NautilusWindowSlot *slot)
+{
+ return nautilus_file_get_icon (slot->viewed_file, 48,
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING |
+ NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON);
+}
+
static void
nautilus_window_class_init (NautilusWindowClass *class)
{
@@ -1562,9 +2143,12 @@ nautilus_window_class_init (NautilusWindowClass *class)
wclass->get_preferred_height = nautilus_window_get_preferred_height;
wclass->realize = nautilus_window_realize;
wclass->key_press_event = nautilus_window_key_press_event;
+ wclass->window_state_event = nautilus_window_state_event;
+ wclass->button_press_event = nautilus_window_button_press_event;
- class->set_allow_up = real_set_allow_up;
- class->close_slot = real_close_slot;
+ class->window_type = NAUTILUS_WINDOW_NAVIGATION;
+ class->bookmarks_placeholder = MENU_PATH_BOOKMARKS_PLACEHOLDER;
+ class->get_icon = real_get_icon;
g_object_class_install_property (oclass,
ARG_APP,
@@ -1649,5 +2233,84 @@ nautilus_window_class_init (NautilusWindowClass *class)
class->reload = nautilus_window_reload;
class->go_up = nautilus_window_go_up_signal;
+ g_signal_connect_swapped (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_MOUSE_BACK_BUTTON,
+ G_CALLBACK(mouse_back_button_changed),
+ NULL);
+
+ g_signal_connect_swapped (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_MOUSE_FORWARD_BUTTON,
+ G_CALLBACK(mouse_forward_button_changed),
+ NULL);
+
+ g_signal_connect_swapped (nautilus_preferences,
+ "changed::" NAUTILUS_PREFERENCES_MOUSE_USE_EXTRA_BUTTONS,
+ G_CALLBACK(use_extra_mouse_buttons_changed),
+ NULL);
+
g_type_class_add_private (oclass, sizeof (NautilusWindowDetails));
}
+
+void
+nautilus_window_split_view_on (NautilusWindow *window)
+{
+ NautilusWindowSlot *slot, *old_active_slot;
+ GFile *location;
+
+ old_active_slot = nautilus_window_get_active_slot (window);
+ slot = create_extra_pane (window);
+
+ location = NULL;
+ if (old_active_slot != NULL) {
+ location = nautilus_window_slot_get_location (old_active_slot);
+ if (location != NULL) {
+ if (g_file_has_uri_scheme (location, "x-nautilus-search")) {
+ g_object_unref (location);
+ location = NULL;
+ }
+ }
+ }
+ if (location == NULL) {
+ location = g_file_new_for_path (g_get_home_dir ());
+ }
+
+ nautilus_window_slot_go_to (slot, location, FALSE);
+ g_object_unref (location);
+
+ window_set_search_action_text (window, FALSE);
+}
+
+void
+nautilus_window_split_view_off (NautilusWindow *window)
+{
+ NautilusWindowPane *pane, *active_pane;
+ GList *l, *next;
+
+ g_return_if_fail (window);
+
+ active_pane = window->details->active_pane;
+
+ /* delete all panes except the first (main) pane */
+ for (l = window->details->panes; l != NULL; l = next) {
+ next = l->next;
+ pane = l->data;
+ if (pane != active_pane) {
+ nautilus_window_close_pane (pane);
+ }
+ }
+
+ nautilus_window_set_active_pane (window, active_pane);
+ nautilus_navigation_state_set_master (window->details->nav_state,
+ active_pane->action_group);
+
+ nautilus_window_update_show_hide_menu_items (window);
+ nautilus_window_update_split_view_actions_sensitivity (window);
+
+ window_set_search_action_text (window, TRUE);
+}
+
+gboolean
+nautilus_window_split_view_showing (NautilusWindow *window)
+{
+ return g_list_length (NAUTILUS_WINDOW (window)->details->panes) > 1;
+}
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index e15cda0..c07c5c7 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -56,7 +56,6 @@ typedef enum {
} NautilusWindowShowHiddenFilesMode;
typedef enum {
- NAUTILUS_WINDOW_SPATIAL,
NAUTILUS_WINDOW_NAVIGATION,
NAUTILUS_WINDOW_DESKTOP
} NautilusWindowType;
@@ -76,6 +75,9 @@ typedef enum {
NAUTILUS_WINDOW_OPEN_SLOT_APPEND = 1
} NautilusWindowOpenSlotFlags;
+#define NAUTILUS_WINDOW_SIDEBAR_PLACES "places"
+#define NAUTILUS_WINDOW_SIDEBAR_TREE "tree"
+
typedef struct NautilusWindowDetails NautilusWindowDetails;
typedef struct {
@@ -89,7 +91,7 @@ typedef struct {
void (* sync_title) (NautilusWindow *window,
NautilusWindowSlot *slot);
NautilusIconInfo * (* get_icon) (NautilusWindow *window,
- NautilusWindowSlot *slot);
+ NautilusWindowSlot *slot);
void (* sync_allow_stop) (NautilusWindow *window,
NautilusWindowSlot *slot);
@@ -161,4 +163,27 @@ NautilusWindowSlot * nautilus_window_get_active_slot (NautilusWindow *wind
void nautilus_window_push_status (NautilusWindow *window,
const char *text);
+void nautilus_window_allow_back (NautilusWindow *window,
+ gboolean allow);
+void nautilus_window_allow_forward (NautilusWindow *window,
+ gboolean allow);
+void nautilus_window_clear_back_list (NautilusWindow *window);
+void nautilus_window_clear_forward_list (NautilusWindow *window);
+void nautilus_forget_history (void);
+gint nautilus_window_get_base_page_index (NautilusWindow *window);
+void nautilus_window_hide_sidebar (NautilusWindow *window);
+void nautilus_window_show_sidebar (NautilusWindow *window);
+void nautilus_window_back_or_forward (NautilusWindow *window,
+ gboolean back,
+ guint distance,
+ gboolean new_tab);
+void nautilus_window_show_search (NautilusWindow *window);
+void nautilus_window_hide_search (NautilusWindow *window);
+void nautilus_window_set_search_button (NautilusWindow *window,
+ gboolean state);
+void nautilus_window_restore_focus_widget (NautilusWindow *window);
+void nautilus_window_split_view_on (NautilusWindow *window);
+void nautilus_window_split_view_off (NautilusWindow *window);
+gboolean nautilus_window_split_view_showing (NautilusWindow *window);
+
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]