summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neumair <cneumair@gnome.org>2008-05-01 15:33:44 +0000
committerChristian Neumair <cneumair@src.gnome.org>2008-05-01 15:33:44 +0000
commit20bd85df674bb4c86c51aa7e18426db030e73892 (patch)
treebd3c3ba9e3937d901e5819febe0c551c2568d43a
parent977e31e63dac2e09e6c2c92cd40591abdc0c86ef (diff)
downloadnautilus-20bd85df674bb4c86c51aa7e18426db030e73892.tar.gz
Import Epiphany's EphyNotebook with some changes. Support a flag to
2008-05-01 Christian Neumair <cneumair@gnome.org> * src/Makefile.am: * src/ephy-spinner.c (ephy_spinner_get_spinning): * src/ephy-spinner.h: * src/nautilus-navigation-window-menus.c (action_new_tab_callback): * src/nautilus-navigation-window-slot.c (nautilus_navigation_window_slot_class_init): * src/nautilus-navigation-window.c (notebook_tab_close_requested), (nautilus_navigation_window_init), (real_sync_title), (real_sync_allow_stop), (real_open_slot), (nautilus_navigation_window_class_init): * src/nautilus-notebook.c (nautilus_notebook_set_dnd_enabled), (nautilus_notebook_get_property), (nautilus_notebook_set_property), (nautilus_notebook_class_init), (find_notebook_at_pointer), (is_in_notebook_window), (find_tab_num_at_pos), (button_press_cb), (notebook_drag_data_received_cb), (nautilus_notebook_init), (nautilus_notebook_sync_loading), (nautilus_notebook_sync_tab_label), (close_button_clicked_cb), (tab_label_style_set_cb), (build_tab_label), (nautilus_notebook_insert_page), (nautilus_notebook_add_tab), (nautilus_notebook_remove): * src/nautilus-notebook.h: * src/nautilus-spatial-window.c (real_sync_title), (real_sync_allow_stop), (real_open_slot), (nautilus_spatial_window_class_init): * src/nautilus-window-manage-views.c (nautilus_window_slot_open_location_full), (mount_not_mounted_callback): * src/nautilus-window-private.h: * src/nautilus-window-slot.c (real_active), (nautilus_window_slot_class_init), (nautilus_window_slot_set_title), (nautilus_window_slot_dispose): * src/nautilus-window-slot.h: * src/nautilus-window.c (nautilus_window_sync_allow_stop), (nautilus_window_slot_set_allow_stop), (nautilus_window_constructor), (nautilus_window_open_slot), (nautilus_window_set_active_slot), (get_last_active_slot), (nautilus_window_slot_close), (real_sync_title), (nautilus_window_sync_title), (nautilus_window_class_init): * src/nautilus-window.h: * src/nautilus-notebook.[ch]: Import Epiphany's EphyNotebook with some changes. Support a flag to control whether tabs are opened at the end, or after the currently active tab. Rename NautilusWindow's set_throbber_active() method to sync_allow_stop(), and set_title() to sync_title(). Adapt GUI synchronization so that notebook tab labels are updated as the state of the slot changes. svn path=/branches/multiview/; revision=14121
-rw-r--r--ChangeLog50
-rw-r--r--src/Makefile.am2
-rw-r--r--src/ephy-spinner.c7
-rw-r--r--src/ephy-spinner.h2
-rw-r--r--src/nautilus-navigation-window-menus.c2
-rw-r--r--src/nautilus-navigation-window-slot.c39
-rw-r--r--src/nautilus-navigation-window.c81
-rw-r--r--src/nautilus-notebook.c652
-rw-r--r--src/nautilus-notebook.h83
-rw-r--r--src/nautilus-spatial-window.c20
-rw-r--r--src/nautilus-window-manage-views.c4
-rw-r--r--src/nautilus-window-private.h10
-rw-r--r--src/nautilus-window-slot.c28
-rw-r--r--src/nautilus-window-slot.h5
-rw-r--r--src/nautilus-window.c86
-rw-r--r--src/nautilus-window.h17
16 files changed, 941 insertions, 147 deletions
diff --git a/ChangeLog b/ChangeLog
index 168d92a0d..926ecc207 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,55 @@
2008-05-01 Christian Neumair <cneumair@gnome.org>
+ * src/Makefile.am:
+ * src/ephy-spinner.c (ephy_spinner_get_spinning):
+ * src/ephy-spinner.h:
+ * src/nautilus-navigation-window-menus.c (action_new_tab_callback):
+ * src/nautilus-navigation-window-slot.c
+ (nautilus_navigation_window_slot_class_init):
+ * src/nautilus-navigation-window.c (notebook_tab_close_requested),
+ (nautilus_navigation_window_init), (real_sync_title),
+ (real_sync_allow_stop), (real_open_slot),
+ (nautilus_navigation_window_class_init):
+ * src/nautilus-notebook.c (nautilus_notebook_set_dnd_enabled),
+ (nautilus_notebook_get_property), (nautilus_notebook_set_property),
+ (nautilus_notebook_class_init), (find_notebook_at_pointer),
+ (is_in_notebook_window), (find_tab_num_at_pos), (button_press_cb),
+ (notebook_drag_data_received_cb), (nautilus_notebook_init),
+ (nautilus_notebook_sync_loading),
+ (nautilus_notebook_sync_tab_label), (close_button_clicked_cb),
+ (tab_label_style_set_cb), (build_tab_label),
+ (nautilus_notebook_insert_page), (nautilus_notebook_add_tab),
+ (nautilus_notebook_remove):
+ * src/nautilus-notebook.h:
+ * src/nautilus-spatial-window.c (real_sync_title),
+ (real_sync_allow_stop), (real_open_slot),
+ (nautilus_spatial_window_class_init):
+ * src/nautilus-window-manage-views.c
+ (nautilus_window_slot_open_location_full),
+ (mount_not_mounted_callback):
+ * src/nautilus-window-private.h:
+ * src/nautilus-window-slot.c (real_active),
+ (nautilus_window_slot_class_init),
+ (nautilus_window_slot_set_title), (nautilus_window_slot_dispose):
+ * src/nautilus-window-slot.h:
+ * src/nautilus-window.c (nautilus_window_sync_allow_stop),
+ (nautilus_window_slot_set_allow_stop),
+ (nautilus_window_constructor), (nautilus_window_open_slot),
+ (nautilus_window_set_active_slot), (get_last_active_slot),
+ (nautilus_window_slot_close), (real_sync_title),
+ (nautilus_window_sync_title), (nautilus_window_class_init):
+ * src/nautilus-window.h:
+ * src/nautilus-notebook.[ch]:
+ Import Epiphany's EphyNotebook with some changes.
+ Support a flag to control whether tabs are opened at the end, or after
+ the currently active tab.
+ Rename NautilusWindow's set_throbber_active() method to
+ sync_allow_stop(), and set_title() to sync_title().
+ Adapt GUI synchronization so that notebook tab labels are updated as
+ the state of the slot changes.
+
+2008-05-01 Christian Neumair <cneumair@gnome.org>
+
* src/nautilus-navigation-window-slot.c
(nautilus_navigation_window_slot_active),
(nautilus_navigation_window_slot_dispose),
diff --git a/src/Makefile.am b/src/Makefile.am
index 48107d424..47012a2f0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -100,6 +100,8 @@ nautilus_SOURCES = \
nautilus-navigation-window.h \
nautilus-navigation-window-slot.c \
nautilus-navigation-window-slot.h \
+ nautilus-notebook.c \
+ nautilus-notebook.h \
nautilus-notes-viewer.c \
nautilus-notes-viewer.h \
nautilus-pathbar.c \
diff --git a/src/ephy-spinner.c b/src/ephy-spinner.c
index 47aee8da4..e54a989b4 100644
--- a/src/ephy-spinner.c
+++ b/src/ephy-spinner.c
@@ -824,6 +824,13 @@ ephy_spinner_set_timeout (EphySpinner *spinner,
}
#endif
+gboolean
+ephy_spinner_get_spinning (EphySpinner *spinner)
+{
+ EphySpinnerDetails *details = spinner->details;
+ return details->spinning;
+}
+
static void
ephy_spinner_size_request (GtkWidget *widget,
GtkRequisition *requisition)
diff --git a/src/ephy-spinner.h b/src/ephy-spinner.h
index 5b3fad717..ac27be04e 100644
--- a/src/ephy-spinner.h
+++ b/src/ephy-spinner.h
@@ -62,6 +62,8 @@ void ephy_spinner_start (EphySpinner *throbber);
void ephy_spinner_stop (EphySpinner *throbber);
+gboolean ephy_spinner_get_spinning (EphySpinner *spinner);
+
void ephy_spinner_set_size (EphySpinner *spinner,
GtkIconSize size);
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 4b8907423..886431683 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -443,7 +443,7 @@ action_new_tab_callback (GtkAction *action,
window = NAUTILUS_WINDOW (current_slot->window);
if (current_location != NULL) {
- new_slot = nautilus_window_open_slot (window);
+ new_slot = nautilus_window_open_slot (window, 0);
nautilus_window_set_active_slot (window, new_slot);
nautilus_window_slot_go_to (new_slot, current_location);
g_object_unref (current_location);
diff --git a/src/nautilus-navigation-window-slot.c b/src/nautilus-navigation-window-slot.c
index 17b298893..6010c1d94 100644
--- a/src/nautilus-navigation-window-slot.c
+++ b/src/nautilus-navigation-window-slot.c
@@ -75,44 +75,6 @@ nautilus_navigation_window_slot_active (NautilusWindowSlot *slot)
}
}
-static NautilusWindowSlot *
-nautilus_navigation_window_slot_get_close_successor (NautilusWindowSlot *slot)
-{
- NautilusWindowSlot *successor;
- NautilusNavigationWindow *window;
- GtkNotebook *notebook;
- GtkWidget *widget;
- int page_num, n_pages;
-
- window = NAUTILUS_NAVIGATION_WINDOW (slot->window);
- notebook = GTK_NOTEBOOK (window->notebook);
-
- n_pages = gtk_notebook_get_n_pages (notebook);
-
- page_num = gtk_notebook_page_num (notebook, slot->content_box);
- g_assert (page_num >= 0);
-
- if (page_num == n_pages - 1) {
- /* use previous page */
- page_num--;
- } else {
- /* use next page */
- page_num++;
- }
-
- successor = NULL;
-
- widget = gtk_notebook_get_nth_page (notebook, page_num);
- if (widget != NULL) {
- successor = nautilus_window_get_slot_for_content_box (slot->window, widget);
- if (successor == slot) {
- successor = NULL;
- }
- }
-
- return successor;
-}
-
static void
nautilus_navigation_window_slot_dispose (GObject *object)
{
@@ -135,7 +97,6 @@ static void
nautilus_navigation_window_slot_class_init (NautilusNavigationWindowSlotClass *class)
{
NAUTILUS_WINDOW_SLOT_CLASS (class)->active = nautilus_navigation_window_slot_active;
- NAUTILUS_WINDOW_SLOT_CLASS (class)->get_close_successor = nautilus_navigation_window_slot_get_close_successor;
G_OBJECT_CLASS (class)->dispose = nautilus_navigation_window_slot_dispose;
}
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index bb0d5b4d8..8d5e8da0d 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -40,6 +40,7 @@
#include "nautilus-query-editor.h"
#include "nautilus-search-bar.h"
#include "nautilus-navigation-window-slot.h"
+#include "nautilus-notebook.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
#include <eel/eel-gtk-extensions.h>
@@ -208,6 +209,16 @@ notebook_switch_page_cb (GtkNotebook *notebook,
return FALSE;
}
+/* emitted when the user clicks the "close" button of tabs */
+static void
+notebook_tab_close_requested (NautilusNotebook *notebook,
+ NautilusWindowSlot *slot,
+ NautilusWindow *window)
+{
+ g_assert (slot->window == window);
+ nautilus_window_slot_close (slot);
+}
+
static void
nautilus_navigation_window_init (NautilusNavigationWindow *window)
{
@@ -229,7 +240,11 @@ nautilus_navigation_window_init (NautilusNavigationWindow *window)
0, 0);
gtk_widget_show (window->details->content_paned);
- window->notebook = gtk_notebook_new ();
+ window->notebook = g_object_new (NAUTILUS_TYPE_NOTEBOOK, NULL);
+ g_signal_connect (window->notebook,
+ "tab-close-request",
+ G_CALLBACK (notebook_tab_close_requested),
+ window);
nautilus_horizontal_splitter_pack2 (
NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned),
window->notebook);
@@ -954,21 +969,30 @@ real_load_view_as_menu (NautilusWindow *window)
}
static void
-real_set_title (NautilusWindow *window,
- const char *title)
+real_sync_title (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
+ NautilusNavigationWindow *navigation_window;
+ NautilusNotebook *notebook;
char *full_title;
char *window_title;
+ navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
+
EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS,
- set_title, (window, title));
+ sync_title, (window, slot));
+
+ if (slot == window->details->active_slot) {
+ full_title = g_strdup_printf (_("%s - File Browser"), slot->title);
- full_title = g_strdup_printf (_("%s - File Browser"), title);
+ window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH);
+ gtk_window_set_title (GTK_WINDOW (window), window_title);
+ g_free (window_title);
+ g_free (full_title);
+ }
- window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH);
- gtk_window_set_title (GTK_WINDOW (window), window_title);
- g_free (window_title);
- g_free (full_title);
+ notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
+ nautilus_notebook_sync_tab_label (notebook, slot);
}
static NautilusIconInfo *
@@ -1051,10 +1075,17 @@ real_disconnect_content_view (NautilusWindow *nautilus_window,
}
static void
-real_set_throbber_active (NautilusWindow *window, gboolean active)
+real_sync_allow_stop (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
- nautilus_navigation_window_set_throbber_active
- (NAUTILUS_NAVIGATION_WINDOW (window), active);
+ NautilusNavigationWindow *navigation_window;
+ NautilusNotebook *notebook;
+
+ navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
+ nautilus_navigation_window_set_throbber_active (navigation_window, slot->allow_stop);
+
+ notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
+ nautilus_notebook_sync_loading (notebook, slot);
}
static void
@@ -1597,19 +1628,20 @@ real_get_default_size (NautilusWindow *window,
}
static NautilusWindowSlot *
-real_open_slot (NautilusWindow *window)
+real_open_slot (NautilusWindow *window,
+ NautilusWindowOpenSlotFlags flags)
{
NautilusNavigationWindow *navigation_window;
NautilusWindowSlot *slot;
- GtkNotebook *notebook;
+ NautilusNotebook *notebook;
navigation_window = NAUTILUS_NAVIGATION_WINDOW (window);
- notebook = GTK_NOTEBOOK (navigation_window->notebook);
+ notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
slot = (NautilusWindowSlot *) g_object_new (NAUTILUS_TYPE_NAVIGATION_WINDOW_SLOT, NULL);
slot->window = window;
- g_signal_handlers_block_by_func (navigation_window->notebook,
+ g_signal_handlers_block_by_func (notebook,
G_CALLBACK (notebook_switch_page_cb),
window);
/* multiview-TODO add some way to influence the position.
@@ -1617,16 +1649,15 @@ real_open_slot (NautilusWindow *window)
* + "behind active tab" [for views]
* + "at the end" [for loading sessions]
*/
- gtk_notebook_append_page (notebook,
- slot->content_box,
- NULL);
+ nautilus_notebook_add_tab (notebook,
+ slot,
+ (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ?
+ -1 :
+ gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) + 1,
+ TRUE); // FIXME jump_to
g_signal_handlers_unblock_by_func (notebook,
G_CALLBACK (notebook_switch_page_cb),
window);
-
- gtk_notebook_set_show_tabs (notebook,
- gtk_notebook_get_n_pages (notebook) > 1);
-
gtk_widget_show (slot->content_box);
return slot;
@@ -1676,10 +1707,10 @@ nautilus_navigation_window_class_init (NautilusNavigationWindowClass *class)
NAUTILUS_WINDOW_CLASS (class)->load_view_as_menu = real_load_view_as_menu;
NAUTILUS_WINDOW_CLASS (class)->connect_content_view = real_connect_content_view;
NAUTILUS_WINDOW_CLASS (class)->disconnect_content_view = real_disconnect_content_view;
- NAUTILUS_WINDOW_CLASS (class)->set_throbber_active = real_set_throbber_active;
+ NAUTILUS_WINDOW_CLASS (class)->sync_allow_stop = real_sync_allow_stop;
NAUTILUS_WINDOW_CLASS (class)->prompt_for_location = real_prompt_for_location;
NAUTILUS_WINDOW_CLASS (class)->set_search_mode = real_set_search_mode;
- NAUTILUS_WINDOW_CLASS (class)->set_title = real_set_title;
+ NAUTILUS_WINDOW_CLASS (class)->sync_title = real_sync_title;
NAUTILUS_WINDOW_CLASS (class)->get_icon = real_get_icon;
NAUTILUS_WINDOW_CLASS (class)->get_default_size = real_get_default_size;
NAUTILUS_WINDOW_CLASS (class)->close = real_window_close;
diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c
new file mode 100644
index 000000000..3bd34b559
--- /dev/null
+++ b/src/nautilus-notebook.c
@@ -0,0 +1,652 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright © 2002 Christophe Fergeau
+ * Copyright © 2003, 2004 Marco Pesenti Gritti
+ * Copyright © 2003, 2004, 2005 Christian Persch
+ * (ephy-notebook.c)
+ *
+ * Copyright © 2008 Free Software Foundation, Inc.
+ * (nautilus-notebook.c)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "nautilus-notebook.h"
+#include "nautilus-navigation-window.h"
+#include "ephy-spinner.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtkeventbox.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkwidget.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkaccelgroup.h>
+#include <gtk/gtkiconfactory.h>
+
+#define TAB_WIDTH_N_CHARS 15
+
+#define AFTER_ALL_TABS -1
+#define NOT_IN_APP_WINDOWS -2
+
+#define INSANE_NUMBER_OF_URLS 20
+
+#define NAUTILUS_NOTEBOOK_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), NAUTILUS_TYPE_NOTEBOOK, NautilusNotebookPrivate))
+
+struct _NautilusNotebookPrivate
+{
+ guint dnd_enabled : 1;
+};
+
+static void nautilus_notebook_init (NautilusNotebook *notebook);
+static void nautilus_notebook_class_init (NautilusNotebookClass *klass);
+static int nautilus_notebook_insert_page (GtkNotebook *notebook,
+ GtkWidget *child,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position);
+static void nautilus_notebook_remove (GtkContainer *container,
+ GtkWidget *tab_widget);
+
+#if NOTEBOOK_DND_SUPPORT
+static const GtkTargetEntry url_drag_types [] =
+{
+ { NAUTILUS_DND_URI_LIST_TYPE, 0, 0 },
+ { NAUTILUS_DND_URL_TYPE, 0, 1 }
+};
+#endif
+
+enum
+{
+ PROP_0,
+ PROP_DND_ENABLED,
+ PROP_SHOW_TABS
+};
+
+enum
+{
+ TAB_CLOSE_REQUEST,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_TYPE (NautilusNotebook, nautilus_notebook, GTK_TYPE_NOTEBOOK);
+
+void
+nautilus_notebook_set_dnd_enabled (NautilusNotebook *notebook,
+ gboolean enabled)
+{
+ NautilusNotebookPrivate *priv = notebook->priv;
+
+ priv->dnd_enabled = enabled;
+ /* FIXME abort any DNDs in progress */
+
+ g_object_notify (G_OBJECT (notebook), "dnd-enabled");
+}
+
+static void
+nautilus_notebook_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusNotebook *notebook = NAUTILUS_NOTEBOOK (object);
+ NautilusNotebookPrivate *priv = notebook->priv;
+
+ switch (prop_id)
+ {
+ case PROP_DND_ENABLED:
+ g_value_set_boolean (value, priv->dnd_enabled);
+ break;
+ }
+}
+
+static void
+nautilus_notebook_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusNotebook *notebook = NAUTILUS_NOTEBOOK (object);
+
+ switch (prop_id)
+ {
+ case PROP_DND_ENABLED:
+ nautilus_notebook_set_dnd_enabled (notebook, g_value_get_boolean (value));
+ break;
+ }
+}
+
+static void
+nautilus_notebook_class_init (NautilusNotebookClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
+
+ object_class->get_property = nautilus_notebook_get_property;
+ object_class->set_property = nautilus_notebook_set_property;
+
+ container_class->remove = nautilus_notebook_remove;
+
+ notebook_class->insert_page = nautilus_notebook_insert_page;
+
+ gtk_rc_parse_string ("style \"nautilus-tab-close-button-style\"\n"
+ "{\n"
+ "GtkWidget::focus-padding = 0\n"
+ "GtkWidget::focus-line-width = 0\n"
+ "xthickness = 0\n"
+ "ythickness = 0\n"
+ "}\n"
+ "widget \"*.nautilus-tab-close-button\" style \"nautilus-tab-close-button-style\"");
+
+ signals[TAB_CLOSE_REQUEST] =
+ g_signal_new ("tab-close-request",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusNotebookClass, tab_close_request),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ NAUTILUS_TYPE_WINDOW_SLOT);
+
+ g_object_class_install_property (object_class,
+ PROP_DND_ENABLED,
+ g_param_spec_boolean ("dnd-enabled", NULL, NULL,
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private (object_class, sizeof (NautilusNotebookPrivate));
+}
+
+
+/* FIXME remove when gtknotebook's func for this becomes public, bug #.... */
+static NautilusNotebook *
+find_notebook_at_pointer (gint abs_x, gint abs_y)
+{
+ GdkWindow *win_at_pointer, *toplevel_win;
+ gpointer toplevel = NULL;
+ gint x, y;
+
+ /* FIXME multi-head */
+ win_at_pointer = gdk_window_at_pointer (&x, &y);
+ if (win_at_pointer == NULL)
+ {
+ /* We are outside all windows containing a notebook */
+ return NULL;
+ }
+
+ toplevel_win = gdk_window_get_toplevel (win_at_pointer);
+
+ /* get the GtkWidget which owns the toplevel GdkWindow */
+ gdk_window_get_user_data (toplevel_win, &toplevel);
+
+ /* toplevel should be an NautilusWindow */
+ if (toplevel != NULL && NAUTILUS_IS_NAVIGATION_WINDOW (toplevel))
+ {
+ return NAUTILUS_NOTEBOOK (NAUTILUS_NAVIGATION_WINDOW (toplevel)->notebook);
+ }
+
+ return NULL;
+}
+
+static gboolean
+is_in_notebook_window (NautilusNotebook *notebook,
+ gint abs_x, gint abs_y)
+{
+ NautilusNotebook *nb_at_pointer;
+
+ nb_at_pointer = find_notebook_at_pointer (abs_x, abs_y);
+
+ return nb_at_pointer == notebook;
+}
+
+static gint
+find_tab_num_at_pos (NautilusNotebook *notebook, gint abs_x, gint abs_y)
+{
+ GtkPositionType tab_pos;
+ int page_num = 0;
+ GtkNotebook *nb = GTK_NOTEBOOK (notebook);
+ GtkWidget *page;
+
+ tab_pos = gtk_notebook_get_tab_pos (GTK_NOTEBOOK (notebook));
+
+ if (GTK_NOTEBOOK (notebook)->first_tab == NULL)
+ {
+ return AFTER_ALL_TABS;
+ }
+
+ /* For some reason unfullscreen + quick click can
+ cause a wrong click event to be reported to the tab */
+ if (!is_in_notebook_window(notebook, abs_x, abs_y))
+ {
+ return NOT_IN_APP_WINDOWS;
+ }
+
+ while ((page = gtk_notebook_get_nth_page (nb, page_num)))
+ {
+ GtkWidget *tab;
+ gint max_x, max_y;
+ gint x_root, y_root;
+
+ tab = gtk_notebook_get_tab_label (nb, page);
+ g_return_val_if_fail (tab != NULL, -1);
+
+ if (!GTK_WIDGET_MAPPED (GTK_WIDGET (tab)))
+ {
+ page_num++;
+ continue;
+ }
+
+ gdk_window_get_origin (GDK_WINDOW (tab->window),
+ &x_root, &y_root);
+
+ max_x = x_root + tab->allocation.x + tab->allocation.width;
+ max_y = y_root + tab->allocation.y + tab->allocation.height;
+
+ if (((tab_pos == GTK_POS_TOP)
+ || (tab_pos == GTK_POS_BOTTOM))
+ &&(abs_x<=max_x))
+ {
+ return page_num;
+ }
+ else if (((tab_pos == GTK_POS_LEFT)
+ || (tab_pos == GTK_POS_RIGHT))
+ && (abs_y<=max_y))
+ {
+ return page_num;
+ }
+
+ page_num++;
+ }
+ return AFTER_ALL_TABS;
+}
+
+static gboolean
+button_press_cb (NautilusNotebook *notebook,
+ GdkEventButton *event,
+ gpointer data)
+{
+ int tab_clicked;
+
+ tab_clicked = find_tab_num_at_pos (notebook, event->x_root, event->y_root);
+
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == 3 &&
+ (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
+ {
+ if (tab_clicked == -1)
+ {
+ /* consume event, so that we don't pop up the context menu when
+ * the mouse if not over a tab label
+ */
+ return TRUE;
+ }
+
+ /* switch to the page the mouse is over, but don't consume the event */
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked);
+ }
+
+ return FALSE;
+}
+
+#if NOTEBOOK_DND_SUPPORT
+static void
+notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context,
+ gint x, gint y, GtkSelectionData *selection_data,
+ guint info, guint time, NautilusWindowSlot *slot)
+{
+ NautilusWindow *window;
+ GtkWidget *notebook;
+
+ g_signal_stop_emission_by_name (widget, "drag_data_received");
+
+ if (selection_data->length <= 0 ||
+ selection_data->data == NULL) {
+ return;
+ }
+
+ window = slot->window;
+ if (window == NULL) {
+ return;
+ }
+
+ notebook = window->notebook;
+
+ if (selection_data->target == gdk_atom_intern (NAUTILUS_DND_URL_TYPE, FALSE))
+ {
+ char **split;
+
+ /* URL_TYPE has format: url \n title */
+ split = g_strsplit ((const gchar *)selection_data->data, "\n", 2);
+ if (split != NULL && split[0] != NULL && split[0][0] != '\0')
+ {
+#if 0
+ ephy_link_open (EPHY_LINK (notebook), split[0], embed,
+ embed ? 0 : EPHY_LINK_NEW_TAB);
+#endif
+ }
+ g_strfreev (split);
+ }
+ else if (selection_data->target == gdk_atom_intern (NAUTILUS_DND_URI_LIST_TYPE, FALSE))
+ {
+ char **uris;
+ int i;
+
+ uris = gtk_selection_data_get_uris (selection_data);
+ if (uris == NULL) return;
+
+ for (i = 0; uris[i] != NULL && i < INSANE_NUMBER_OF_URLS; i++)
+ {
+#if 0
+ embed = ephy_link_open (EPHY_LINK (notebook), uris[i], embed,
+ (embed && i == 0) ? 0 : EPHY_LINK_NEW_TAB);
+#endif
+ }
+
+ g_strfreev (uris);
+ }
+ else
+ {
+ char *text;
+
+ text = (char *) gtk_selection_data_get_text (selection_data);
+ if (text != NULL) {
+#if 0
+ ephy_link_open (EPHY_LINK (notebook), text, embed,
+ embed ? 0 : EPHY_LINK_NEW_TAB);
+#endif
+ g_free (text);
+ }
+ }
+}
+#endif
+
+static void
+nautilus_notebook_init (NautilusNotebook *notebook)
+{
+ NautilusNotebookPrivate *priv;
+
+ priv = notebook->priv = NAUTILUS_NOTEBOOK_GET_PRIVATE (notebook);
+
+ gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+
+ priv->dnd_enabled = FALSE;
+
+ g_signal_connect (notebook, "button-press-event",
+ (GCallback)button_press_cb, NULL);
+
+#if NOTEBOOK_DND_SUPPORT
+ /* Set up drag-and-drop target */
+ g_signal_connect (notebook, "drag-data-received",
+ G_CALLBACK (notebook_drag_data_received_cb),
+ NULL);
+ gtk_drag_dest_set (GTK_WIDGET (notebook),
+ GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_DROP,
+ url_drag_types, G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_drag_dest_add_text_targets (GTK_WIDGET(notebook));
+#endif
+}
+
+void
+nautilus_notebook_sync_loading (NautilusNotebook *notebook,
+ NautilusWindowSlot *slot)
+{
+ GtkWidget *tab_label, *spinner, *icon;
+
+ g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
+ g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
+
+ tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), slot->content_box);
+ g_return_if_fail (GTK_IS_WIDGET (tab_label));
+
+ spinner = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "spinner"));
+ icon = GTK_WIDGET (g_object_get_data (G_OBJECT (tab_label), "icon"));
+ g_return_if_fail (spinner != NULL && icon != NULL);
+
+ if (ephy_spinner_get_spinning (EPHY_SPINNER (spinner)) == slot->allow_stop) {
+ return;
+ }
+
+ if (slot->allow_stop)
+ {
+ gtk_widget_hide (icon);
+ gtk_widget_show (spinner);
+ ephy_spinner_start (EPHY_SPINNER (spinner));
+ }
+ else
+ {
+ ephy_spinner_stop (EPHY_SPINNER (spinner));
+ gtk_widget_hide (spinner);
+ gtk_widget_show (icon);
+ }
+}
+
+void
+nautilus_notebook_sync_tab_label (NautilusNotebook *notebook,
+ NautilusWindowSlot *slot)
+{
+ GtkWidget *hbox, *label;
+
+ g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));
+ g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot));
+ g_return_if_fail (GTK_IS_WIDGET (slot->content_box));
+
+ hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), slot->content_box);
+ g_return_if_fail (GTK_IS_WIDGET (hbox));
+
+ label = GTK_WIDGET (g_object_get_data (G_OBJECT (hbox), "label"));
+ g_return_if_fail (GTK_IS_WIDGET (label));
+
+ gtk_label_set_text (GTK_LABEL (label), slot->title);
+
+ /* Set the tooltip on the label's parent (the tab label hbox),
+ * so it covers all of the tab label.
+ */
+ gtk_widget_set_tooltip_text (label->parent, slot->title);
+}
+
+static void
+close_button_clicked_cb (GtkWidget *widget,
+ NautilusWindowSlot *slot)
+{
+ GtkWidget *notebook;
+
+ notebook = gtk_widget_get_ancestor (slot->content_box, NAUTILUS_TYPE_NOTEBOOK);
+ if (notebook != NULL) {
+ g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot);
+ }
+}
+
+static void
+tab_label_style_set_cb (GtkWidget *hbox,
+ GtkStyle *previous_style,
+ gpointer user_data)
+{
+ PangoFontMetrics *metrics;
+ PangoContext *context;
+ GtkWidget *button;
+ int char_width, h, w;
+
+ context = gtk_widget_get_pango_context (hbox);
+ metrics = pango_context_get_metrics (context,
+ hbox->style->font_desc,
+ pango_context_get_language (context));
+
+ char_width = pango_font_metrics_get_approximate_digit_width (metrics);
+ pango_font_metrics_unref (metrics);
+
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (hbox),
+ GTK_ICON_SIZE_MENU, &w, &h);
+
+ gtk_widget_set_size_request
+ (hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS(char_width) + 2 * w, -1);
+
+ button = g_object_get_data (G_OBJECT (hbox), "close-button");
+ gtk_widget_set_size_request (button, w + 2, h + 2);
+}
+
+static GtkWidget *
+build_tab_label (NautilusNotebook *nb, NautilusWindowSlot *slot)
+{
+ GtkWidget *hbox, *label, *close_button, *image, *spinner, *icon;
+
+ /* set hbox spacing and label padding (see below) so that there's an
+ * equal amount of space around the label */
+ hbox = gtk_hbox_new (FALSE, 4);
+ gtk_widget_show (hbox);
+
+ /* setup load feedback */
+ spinner = ephy_spinner_new ();
+ ephy_spinner_set_size (EPHY_SPINNER (spinner), GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
+
+ /* setup site icon, empty by default */
+ icon = gtk_image_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+ /* don't show the icon */
+
+ /* setup label */
+ label = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 0, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ gtk_widget_show (label);
+
+ /* setup close button */
+ close_button = gtk_button_new ();
+ gtk_button_set_relief (GTK_BUTTON (close_button),
+ GTK_RELIEF_NONE);
+ /* don't allow focus on the close button */
+ gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
+
+ gtk_widget_set_name (close_button, "nautilus-tab-close-button");
+
+ image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text (close_button, _("Close tab"));
+ g_signal_connect_object (close_button, "clicked",
+ G_CALLBACK (close_button_clicked_cb), slot, 0);
+
+ gtk_container_add (GTK_CONTAINER (close_button), image);
+ gtk_widget_show (image);
+
+ gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);
+ gtk_widget_show (close_button);
+
+ /* Set minimal size */
+ g_signal_connect (hbox, "style-set",
+ G_CALLBACK (tab_label_style_set_cb), NULL);
+
+#if NOTEBOOK_DND_SUPPORT
+ /* Set up drag-and-drop target */
+ g_signal_connect_object (hbox, "drag-data-received",
+ G_CALLBACK (notebook_drag_data_received_cb), slot, 0);
+ gtk_drag_dest_set (hbox, GTK_DEST_DEFAULT_ALL,
+ url_drag_types, G_N_ELEMENTS (url_drag_types),
+ GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_drag_dest_add_text_targets (hbox);
+#endif
+
+ g_object_set_data (G_OBJECT (hbox), "label", label);
+ g_object_set_data (G_OBJECT (hbox), "spinner", spinner);
+ g_object_set_data (G_OBJECT (hbox), "icon", icon);
+ g_object_set_data (G_OBJECT (hbox), "close-button", close_button);
+
+ return hbox;
+}
+
+static int
+nautilus_notebook_insert_page (GtkNotebook *gnotebook,
+ GtkWidget *tab_widget,
+ GtkWidget *tab_label,
+ GtkWidget *menu_label,
+ int position)
+{
+ g_assert (GTK_IS_WIDGET (tab_widget));
+
+ position = GTK_NOTEBOOK_CLASS (nautilus_notebook_parent_class)->insert_page (gnotebook,
+ tab_widget,
+ tab_label,
+ menu_label,
+ position);
+
+ gtk_notebook_set_show_tabs (gnotebook,
+ gtk_notebook_get_n_pages (gnotebook) > 1);
+ gtk_notebook_set_tab_reorderable (gnotebook, tab_widget, TRUE);
+
+ return position;
+}
+
+int
+nautilus_notebook_add_tab (NautilusNotebook *notebook,
+ NautilusWindowSlot *slot,
+ int position,
+ gboolean jump_to)
+{
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (notebook);
+ GtkWidget *tab_label;
+
+ g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), -1);
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot), -1);
+
+ tab_label = build_tab_label (notebook, slot);
+
+ position = gtk_notebook_insert_page (GTK_NOTEBOOK (notebook),
+ slot->content_box,
+ tab_label,
+ position);
+
+ nautilus_notebook_sync_tab_label (notebook, slot);
+ nautilus_notebook_sync_loading (notebook, slot);
+
+
+ /* FIXME gtk bug! */
+ /* FIXME: this should be fixed in gtk 2.12; check & remove this! */
+ /* The signal handler may have reordered the tabs */
+ position = gtk_notebook_page_num (gnotebook, slot->content_box);
+
+ if (jump_to)
+ {
+ gtk_notebook_set_current_page (gnotebook, position);
+
+ }
+
+ return position;
+}
+
+static void
+nautilus_notebook_remove (GtkContainer *container,
+ GtkWidget *tab_widget)
+{
+ GtkNotebook *gnotebook = GTK_NOTEBOOK (container);
+ GTK_CONTAINER_CLASS (nautilus_notebook_parent_class)->remove (container, tab_widget);
+
+ gtk_notebook_set_show_tabs (gnotebook,
+ gtk_notebook_get_n_pages (gnotebook) > 1);
+
+}
diff --git a/src/nautilus-notebook.h b/src/nautilus-notebook.h
new file mode 100644
index 000000000..36af91736
--- /dev/null
+++ b/src/nautilus-notebook.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2002 Christophe Fergeau
+ * Copyright © 2003 Marco Pesenti Gritti
+ * Copyright © 2003, 2004 Christian Persch
+ * (ephy-notebook.c)
+ *
+ * Copyright © 2008 Free Software Foundation, Inc.
+ * (nautilus-notebook.c)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $Id: nautilus-notebook.h 8210 2008-04-11 20:05:25Z chpe $
+ */
+
+#ifndef NAUTILUS_NOTEBOOK_H
+#define NAUTILUS_NOTEBOOK_H
+
+#include <glib.h>
+#include <gtk/gtknotebook.h>
+#include "nautilus-window-slot.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_NOTEBOOK (nautilus_notebook_get_type ())
+#define NAUTILUS_NOTEBOOK(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_NOTEBOOK, NautilusNotebook))
+#define NAUTILUS_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_NOTEBOOK, NautilusNotebookClass))
+#define NAUTILUS_IS_NOTEBOOK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_NOTEBOOK))
+#define NAUTILUS_IS_NOTEBOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_NOTEBOOK))
+#define NAUTILUS_NOTEBOOK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_NOTEBOOK, NautilusNotebookClass))
+
+typedef struct _NautilusNotebookClass NautilusNotebookClass;
+typedef struct _NautilusNotebook NautilusNotebook;
+typedef struct _NautilusNotebookPrivate NautilusNotebookPrivate;
+
+struct _NautilusNotebook
+{
+ GtkNotebook parent;
+
+ /*< private >*/
+ NautilusNotebookPrivate *priv;
+};
+
+struct _NautilusNotebookClass
+{
+ GtkNotebookClass parent_class;
+
+ /* Signals */
+ void (* tab_close_request) (NautilusNotebook *notebook,
+ NautilusWindowSlot *slot);
+};
+
+GType nautilus_notebook_get_type (void);
+
+int nautilus_notebook_add_tab (NautilusNotebook *nb,
+ NautilusWindowSlot *slot,
+ int position,
+ gboolean jump_to);
+
+void nautilus_notebook_set_show_tabs (NautilusNotebook *nb,
+ gboolean show_tabs);
+
+void nautilus_notebook_set_dnd_enabled (NautilusNotebook *nb,
+ gboolean enabled);
+void nautilus_notebook_sync_tab_label (NautilusNotebook *nb,
+ NautilusWindowSlot *slot);
+void nautilus_notebook_sync_loading (NautilusNotebook *nb,
+ NautilusWindowSlot *slot);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_NOTEBOOK_H */
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index d8e049029..1f7f371c1 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -456,9 +456,11 @@ sync_window_title (NautilusWindow *window)
}
static void
-real_set_title (NautilusWindow *window,
- const char *title)
+real_sync_title (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
+ g_assert (slot == window->details->active_slot);
+
sync_window_title (window);
}
@@ -483,7 +485,8 @@ real_get_default_size (NautilusWindow *window,
}
static void
-real_set_throbber_active (NautilusWindow *window, gboolean active)
+real_sync_allow_stop (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
}
@@ -503,7 +506,8 @@ real_set_allow_up (NautilusWindow *window, gboolean allow)
}
static NautilusWindowSlot *
-real_open_slot (NautilusWindow *window)
+real_open_slot (NautilusWindow *window,
+ NautilusWindowOpenSlotFlags flags)
{
NautilusWindowSlot *slot;
@@ -1086,14 +1090,14 @@ nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class)
real_set_search_mode;
NAUTILUS_WINDOW_CLASS (class)->get_icon =
real_get_icon;
- NAUTILUS_WINDOW_CLASS (class)->set_title =
- real_set_title;
+ NAUTILUS_WINDOW_CLASS (class)->sync_title =
+ real_sync_title;
NAUTILUS_WINDOW_CLASS (class)->close =
real_window_close;
NAUTILUS_WINDOW_CLASS(class)->get_default_size = real_get_default_size;
- NAUTILUS_WINDOW_CLASS(class)->set_throbber_active =
- real_set_throbber_active;
+ NAUTILUS_WINDOW_CLASS(class)->sync_allow_stop =
+ real_sync_allow_stop;
NAUTILUS_WINDOW_CLASS(class)->set_allow_up =
real_set_allow_up;
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 8f5ece134..a60f0f993 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -593,7 +593,7 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB) != 0 &&
NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
g_assert (target_window == window);
- target_slot = nautilus_window_open_slot (window);
+ target_slot = nautilus_window_open_slot (window, 0);
}
if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) {
@@ -973,7 +973,7 @@ mount_not_mounted_callback (GObject *source_object,
error = NULL;
if (!g_file_mount_enclosing_volume_finish (G_FILE (source_object), res, &error)) {
slot->mount_error = error;
- got_file_info_for_view_selection_callback (slot->determine_view_file, window);
+ got_file_info_for_view_selection_callback (slot->determine_view_file, slot);
slot->mount_error = NULL;
g_error_free (error);
} else {
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index dc7607f4d..4e96a904e 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -61,6 +61,7 @@ struct NautilusWindowDetails
* Both of them may never be NULL.
*/
GList *slots;
+ GList *active_slots;
NautilusWindowSlot *active_slot;
NautilusWindowShowHiddenFilesMode show_hidden_files_mode;
@@ -175,7 +176,8 @@ void nautilus_window_zoom_to_level (Nautil
NautilusZoomLevel level);
void nautilus_window_zoom_to_default (NautilusWindow *window);
-NautilusWindowSlot *nautilus_window_open_slot (NautilusWindow *window);
+NautilusWindowSlot *nautilus_window_open_slot (NautilusWindow *window,
+ NautilusWindowOpenSlotFlags flags);
void nautilus_window_close_slot (NautilusWindow *window,
NautilusWindowSlot *slot);
@@ -204,8 +206,10 @@ void nautilus_window_constructed (Nautil
* and when updating the slot state.
*/
void nautilus_window_sync_status (NautilusWindow *window);
-void nautilus_window_sync_allow_stop (NautilusWindow *window);
-void nautilus_window_sync_title (NautilusWindow *window);
+void nautilus_window_sync_allow_stop (NautilusWindow *window,
+ NautilusWindowSlot *slot);
+void nautilus_window_sync_title (NautilusWindow *window,
+ NautilusWindowSlot *slot);
void nautilus_window_sync_location_widgets (NautilusWindow *window);
/* Navigation window menus */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 1dd197f54..6226acef5 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -54,8 +54,8 @@ real_active (NautilusWindowSlot *slot)
/* sync window to new slot */
nautilus_window_sync_status (window);
- nautilus_window_sync_allow_stop (window);
- nautilus_window_sync_title (window);
+ nautilus_window_sync_allow_stop (window, slot);
+ nautilus_window_sync_title (window, slot);
nautilus_window_sync_location_widgets (window);
if (slot->viewed_file != NULL) {
@@ -132,18 +132,11 @@ nautilus_window_slot_init (NautilusWindowSlot *slot)
slot->title = g_strdup (_("Loading..."));
}
-static NautilusWindowSlot *
-real_get_close_successor (NautilusWindowSlot *slot)
-{
- return NULL;
-}
-
static void
nautilus_window_slot_class_init (NautilusWindowSlotClass *class)
{
class->active = real_active;
class->inactive = real_inactive;
- class->get_close_successor = real_get_close_successor;
G_OBJECT_CLASS (class)->dispose = nautilus_window_slot_dispose;
}
@@ -245,8 +238,8 @@ nautilus_window_slot_set_title (NautilusWindowSlot *slot,
nautilus_send_history_list_changed ();
}
- if (changed && window->details->active_slot == slot) {
- nautilus_window_sync_title (window);
+ if (changed) {
+ nautilus_window_sync_title (window, slot);
}
}
@@ -336,17 +329,6 @@ nautilus_window_slot_add_extra_location_widget (NautilusWindowSlot *slot,
gtk_widget_show (slot->extra_location_widgets);
}
-/* gets the slot that is supposed to be displayed after closing
- * the active slot.
- */
-NautilusWindowSlot *
-nautilus_window_slot_get_close_successor (NautilusWindowSlot *slot)
-{
- return EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_SLOT_CLASS, slot,
- get_close_successor, (slot));
-}
-
-
static void
nautilus_window_slot_dispose (GObject *object)
{
@@ -397,6 +379,8 @@ nautilus_window_slot_dispose (GObject *object)
slot->new_content_view = NULL;
}
+ slot->window = NULL;
+
g_free (slot->title);
slot->title = NULL;
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index a4cb80292..18640ac3e 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -49,9 +49,6 @@ struct NautilusWindowSlotClass {
/* wrapped NautilusWindowInfo signals, for overloading */
void (* active) (NautilusWindowSlot *slot);
void (* inactive) (NautilusWindowSlot *slot);
-
- /* gets the slot to make active after this slot has been closed. */
- NautilusWindowSlot * (* get_close_successor) (NautilusWindowSlot *slot);
};
/* Each NautilusWindowSlot corresponds to
@@ -117,8 +114,6 @@ void nautilus_window_slot_update_icon (NautilusWindowSlot *slot);
GFile * nautilus_window_slot_get_location (NautilusWindowSlot *slot);
char * nautilus_window_slot_get_location_uri (NautilusWindowSlot *slot);
-NautilusWindowSlot *
- nautilus_window_slot_get_close_successor (NautilusWindowSlot *slot);
void nautilus_window_slot_close (NautilusWindowSlot *slot);
void nautilus_window_slot_reload (NautilusWindowSlot *slot);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 2ce218069..219913716 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -334,32 +334,30 @@ update_cursor (NautilusWindow *window)
}
void
-nautilus_window_sync_allow_stop (NautilusWindow *window)
+nautilus_window_sync_allow_stop (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
- NautilusWindowSlot *slot;
GtkAction *action;
gboolean allow_stop;
g_assert (NAUTILUS_IS_WINDOW (window));
- slot = window->details->active_slot;
- if (slot == NULL) {
- return;
- }
-
action = gtk_action_group_get_action (window->details->main_action_group,
NAUTILUS_ACTION_STOP);
allow_stop = gtk_action_get_sensitive (action);
- if (allow_stop != slot->allow_stop) {
- gtk_action_set_sensitive (action, slot->allow_stop);
+ if (slot != window->details->active_slot ||
+ allow_stop != slot->allow_stop) {
+ if (slot == window->details->active_slot) {
+ gtk_action_set_sensitive (action, slot->allow_stop);
+ }
if (GTK_WIDGET_REALIZED (GTK_WIDGET (window))) {
update_cursor (window);
}
EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- set_throbber_active, (window, slot->allow_stop));
+ sync_allow_stop, (window, slot));
}
}
@@ -374,9 +372,7 @@ nautilus_window_slot_set_allow_stop (NautilusWindowSlot *slot,
slot->allow_stop = allow;
window = NAUTILUS_WINDOW (slot->window);
- if (slot == window->details->active_slot) {
- nautilus_window_sync_allow_stop (window);
- }
+ nautilus_window_sync_allow_stop (window, slot);
}
void
@@ -700,7 +696,7 @@ nautilus_window_constructor (GType type,
window = NAUTILUS_WINDOW (object);
- slot = nautilus_window_open_slot (window);
+ slot = nautilus_window_open_slot (window, 0);
nautilus_window_set_active_slot (window, slot);
nautilus_window_initialize_menus_constructed (window);
@@ -749,14 +745,15 @@ nautilus_window_close (NautilusWindow *window)
}
NautilusWindowSlot *
-nautilus_window_open_slot (NautilusWindow *window)
+nautilus_window_open_slot (NautilusWindow *window,
+ NautilusWindowOpenSlotFlags flags)
{
NautilusWindowSlot *slot;
g_assert (NAUTILUS_IS_WINDOW (window));
slot = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
- open_slot, (window));
+ open_slot, (window, flags));
g_assert (NAUTILUS_IS_WINDOW_SLOT (slot));
g_assert (window == slot->window);
@@ -824,6 +821,9 @@ nautilus_window_set_active_slot (NautilusWindow *window,
if (new_slot != NULL) {
+ window->details->active_slots = g_list_remove (window->details->active_slots, new_slot);
+ window->details->active_slots = g_list_prepend (window->details->active_slots, new_slot);
+
/* inform sidebar panels */
nautilus_window_report_location_change (window);
/* TODO decide whether "selection-changed" should be emitted */
@@ -838,19 +838,35 @@ nautilus_window_set_active_slot (NautilusWindow *window,
}
}
+static inline NautilusWindowSlot *
+get_last_active_slot (NautilusWindow *window)
+{
+ if (window->details->active_slots != NULL) {
+ return NAUTILUS_WINDOW_SLOT (window->details->active_slots->data);
+ }
+
+ return NULL;
+}
+
void
nautilus_window_slot_close (NautilusWindowSlot *slot)
{
NautilusWindow *window;
window = slot->window;
+ if (window != NULL) {
+ window->details->active_slots = g_list_remove (window->details->active_slots, slot);
- nautilus_window_set_active_slot (window,
- nautilus_window_slot_get_close_successor (slot));
- nautilus_window_close_slot (window, slot);
+ if (window->details->active_slot == slot) {
+ nautilus_window_set_active_slot (window,
+ get_last_active_slot (window));
+ }
+
+ nautilus_window_close_slot (window, slot);
- if (g_list_length (window->details->slots) == 0) {
- nautilus_window_close (window);
+ if (g_list_length (window->details->slots) == 0) {
+ nautilus_window_close (window);
+ }
}
}
@@ -1302,29 +1318,25 @@ real_get_title (NautilusWindow *window)
}
static void
-real_set_title (NautilusWindow *window,
- const char *title)
+real_sync_title (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
- NautilusWindowSlot *slot;
char *copy;
- slot = window->details->active_slot;
-
- copy = g_strdup (slot->title);
- g_signal_emit_by_name (window, "title_changed",
- slot->title);
- g_free (copy);
+ if (slot == window->details->active_slot) {
+ copy = g_strdup (slot->title);
+ g_signal_emit_by_name (window, "title_changed",
+ slot->title);
+ g_free (copy);
+ }
}
void
-nautilus_window_sync_title (NautilusWindow *window)
+nautilus_window_sync_title (NautilusWindow *window,
+ NautilusWindowSlot *slot)
{
- NautilusWindowSlot *slot;
-
- slot = window->details->active_slot;
-
EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window,
- set_title, (window, slot->title));
+ sync_title, (window, slot));
}
static void
@@ -1846,7 +1858,7 @@ nautilus_window_class_init (NautilusWindowClass *class)
GTK_WIDGET_CLASS (class)->key_press_event = nautilus_window_key_press_event;
class->add_current_location_to_history_list = real_add_current_location_to_history_list;
class->get_title = real_get_title;
- class->set_title = real_set_title;
+ class->sync_title = real_sync_title;
class->connect_content_view = real_connect_content_view;
class->disconnect_content_view = real_disconnect_content_view;
class->load_view_as_menu = real_load_view_as_menu;
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 8762aa27b..8c4971322 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -57,6 +57,7 @@ typedef struct NautilusWindowSlot NautilusWindowSlot;
#endif
typedef struct NautilusWindowSlotClass NautilusWindowSlotClass;
+typedef enum NautilusWindowOpenSlotFlags NautilusWindowOpenSlotFlags;
GType nautilus_window_slot_get_type (void);
@@ -76,8 +77,8 @@ typedef struct {
void (* add_current_location_to_history_list) (NautilusWindow *window);
char * (* get_title) (NautilusWindow *window);
- void (* set_title) (NautilusWindow *window,
- const char *title);
+ void (* sync_title) (NautilusWindow *window,
+ NautilusWindowSlot *slot);
NautilusIconInfo * (* get_icon) (NautilusWindow *window,
NautilusWindowSlot *slot);
@@ -92,8 +93,8 @@ typedef struct {
void (* disconnect_content_view) (NautilusWindow *window,
NautilusView *new_view);
- void (* set_throbber_active) (NautilusWindow *window,
- gboolean active);
+ void (* sync_allow_stop) (NautilusWindow *window,
+ NautilusWindowSlot *slot);
void (* set_allow_up) (NautilusWindow *window, gboolean allow);
void (* reload) (NautilusWindow *window);
void (* prompt_for_location) (NautilusWindow *window, const char *initial);
@@ -102,7 +103,8 @@ typedef struct {
void (* show_window) (NautilusWindow *window);
void (* close) (NautilusWindow *window);
- NautilusWindowSlot * (* open_slot) (NautilusWindow *window);
+ NautilusWindowSlot * (* open_slot) (NautilusWindow *window,
+ NautilusWindowOpenSlotFlags flags);
void (* close_slot) (NautilusWindow *window,
NautilusWindowSlot *slot);
void (* set_active_slot) (NautilusWindow *window,
@@ -118,6 +120,11 @@ typedef enum {
NAUTILUS_WINDOW_SHOULD_SHOW
} NautilusWindowShowState;
+enum NautilusWindowOpenSlotFlags {
+ NAUTILUS_WINDOW_OPEN_SLOT_NONE = 0,
+ NAUTILUS_WINDOW_OPEN_SLOT_APPEND = 1
+};
+
typedef struct NautilusWindowDetails NautilusWindowDetails;
struct NautilusWindow {