From dcbbb16e1ca7deb7608f224f01b34e8b38a17f5d Mon Sep 17 00:00:00 2001 From: Alexander Mikhaylenko Date: Wed, 9 Sep 2020 02:46:32 +0500 Subject: Port to HdyTabView and HdyTabBar --- src/meson.build | 2 - src/nautilus-application.c | 3 - src/nautilus-notebook.c | 572 ------------------------------------ src/nautilus-notebook.h | 61 ---- src/nautilus-window-slot-dnd.c | 38 +-- src/nautilus-window-slot.c | 44 ++- src/nautilus-window.c | 474 ++++++++++++------------------ src/nautilus-window.h | 2 +- src/resources/css/Adwaita.css | 4 +- src/resources/ui/nautilus-window.ui | 41 ++- 10 files changed, 265 insertions(+), 976 deletions(-) delete mode 100644 src/nautilus-notebook.c delete mode 100644 src/nautilus-notebook.h diff --git a/src/meson.build b/src/meson.build index cbc9ab15e..913ea6101 100644 --- a/src/meson.build +++ b/src/meson.build @@ -100,8 +100,6 @@ libnautilus_sources = [ 'nautilus-location-entry.h', 'nautilus-mime-actions.c', 'nautilus-mime-actions.h', - 'nautilus-notebook.c', - 'nautilus-notebook.h', 'nautilus-other-locations-window-slot.c', 'nautilus-other-locations-window-slot.h', 'nautilus-pathbar.c', diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 9f7445407..10478da9c 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -1327,8 +1326,6 @@ nautilus_application_startup_common (NautilusApplication *self) */ G_APPLICATION_CLASS (nautilus_application_parent_class)->startup (G_APPLICATION (self)); - hdy_init (); - gtk_window_set_default_icon_name (APPLICATION_ID); setup_theme_extensions (); diff --git a/src/nautilus-notebook.c b/src/nautilus-notebook.c deleted file mode 100644 index 9d2fb1dcf..000000000 --- a/src/nautilus-notebook.c +++ /dev/null @@ -1,572 +0,0 @@ -/* - * 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, see . - * - */ - -#include "config.h" - -#include "nautilus-notebook.h" - -#include "nautilus-window.h" -#include "nautilus-window-slot.h" -#include "nautilus-window-slot-dnd.h" - -#include -#include -#include -#include - -#define AFTER_ALL_TABS -1 - -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); - -enum -{ - TAB_CLOSE_REQUEST, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -struct _NautilusNotebook -{ - GtkNotebook parent_instance; - - GtkGesture *multi_press_gesture; -}; - -G_DEFINE_TYPE (NautilusNotebook, nautilus_notebook, GTK_TYPE_NOTEBOOK); - -static void -nautilus_notebook_dispose (GObject *object) -{ - NautilusNotebook *notebook; - - notebook = NAUTILUS_NOTEBOOK (object); - - g_clear_object (¬ebook->multi_press_gesture); - - G_OBJECT_CLASS (nautilus_notebook_parent_class)->dispose (object); -} - -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->dispose = nautilus_notebook_dispose; - - container_class->remove = nautilus_notebook_remove; - - notebook_class->insert_page = nautilus_notebook_insert_page; - - signals[TAB_CLOSE_REQUEST] = - g_signal_new ("tab-close-request", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, - 1, - NAUTILUS_TYPE_WINDOW_SLOT); -} - -static gint -find_tab_num_at_pos (NautilusNotebook *notebook, - gint abs_x, - gint abs_y) -{ - int page_num = 0; - GtkNotebook *nb = GTK_NOTEBOOK (notebook); - GtkWidget *page; - GtkAllocation allocation; - - while ((page = gtk_notebook_get_nth_page (nb, page_num))) - { - GtkWidget *tab; - gint max_x, max_y; - - tab = gtk_notebook_get_tab_label (nb, page); - g_return_val_if_fail (tab != NULL, -1); - - if (!gtk_widget_get_mapped (GTK_WIDGET (tab))) - { - page_num++; - continue; - } - - gtk_widget_get_allocation (tab, &allocation); - - max_x = allocation.x + allocation.width; - max_y = allocation.y + allocation.height; - - if (abs_x <= max_x && abs_y <= max_y) - { - return page_num; - } - - page_num++; - } - return AFTER_ALL_TABS; -} - -static void -button_press_cb (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) -{ - guint button; - GdkEventSequence *sequence; - const GdkEvent *event; - GtkWidget *widget; - NautilusNotebook *notebook; - int tab_clicked; - GdkModifierType state; - - button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)); - sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); - event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); - widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); - notebook = NAUTILUS_NOTEBOOK (widget); - tab_clicked = find_tab_num_at_pos (notebook, x, y); - - gdk_event_get_state (event, &state); - - if (n_press != 1) - { - return; - } - - if (tab_clicked == -1) - { - return; - } - - if (button == GDK_BUTTON_SECONDARY && - (state & gtk_accelerator_get_default_mod_mask ()) == 0) - { - /* switch to the page the mouse is over, but don't consume the event */ - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_clicked); - } - else if (button == GDK_BUTTON_MIDDLE) - { - GtkWidget *slot; - - slot = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), tab_clicked); - g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot); - } -} - -static void -nautilus_notebook_init (NautilusNotebook *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); - - notebook->multi_press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (notebook)); - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (notebook->multi_press_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (notebook->multi_press_gesture), 0); - - g_signal_connect (notebook->multi_press_gesture, "pressed", G_CALLBACK (button_press_cb), NULL); -} - -gboolean -nautilus_notebook_contains_slot (NautilusNotebook *notebook, - NautilusWindowSlot *slot) -{ - GList *children; - GList *l; - gboolean found = FALSE; - - children = gtk_container_get_children (GTK_CONTAINER (notebook)); - for (l = children; l != NULL && !found; l = l->next) - { - found = l->data == slot; - } - - g_list_free (children); - - return found; -} - -gboolean -nautilus_notebook_content_area_hit (NautilusNotebook *notebook, - gint x, - gint y) -{ - return find_tab_num_at_pos (notebook, x, y) == -1; -} - -void -nautilus_notebook_sync_loading (NautilusNotebook *notebook, - NautilusWindowSlot *slot) -{ - GtkWidget *tab_label, *spinner, *icon; - gboolean active, allow_stop; - - 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), - GTK_WIDGET (slot)); - 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); - - active = FALSE; - g_object_get (spinner, "active", &active, NULL); - allow_stop = nautilus_window_slot_get_allow_stop (slot); - - if (active == allow_stop) - { - return; - } - - if (allow_stop) - { - gtk_widget_hide (icon); - gtk_widget_show (spinner); - gtk_spinner_start (GTK_SPINNER (spinner)); - } - else - { - gtk_spinner_stop (GTK_SPINNER (spinner)); - gtk_widget_hide (spinner); - gtk_widget_show (icon); - } -} - -void -nautilus_notebook_sync_tab_label (NautilusNotebook *notebook, - NautilusWindowSlot *slot) -{ - GtkWidget *hbox, *label; - char *location_name; - GFile *location; - const gchar *title_name; - - g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); - g_return_if_fail (NAUTILUS_IS_WINDOW_SLOT (slot)); - - hbox = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), GTK_WIDGET (slot)); - 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), nautilus_window_slot_get_title (slot)); - location = nautilus_window_slot_get_location (slot); - - if (location != NULL) - { - /* Set the tooltip on the label's parent (the tab label hbox), - * so it covers all of the tab label. - */ - location_name = g_file_get_parse_name (location); - title_name = nautilus_window_slot_get_title (slot); - if (eel_uri_is_search (location_name)) - { - gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), title_name); - } - else - { - gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), location_name); - } - g_free (location_name); - } - else - { - gtk_widget_set_tooltip_text (gtk_widget_get_parent (label), NULL); - } -} - -static void -close_button_clicked_cb (GtkWidget *widget, - NautilusWindowSlot *slot) -{ - GtkWidget *notebook; - - notebook = gtk_widget_get_ancestor (GTK_WIDGET (slot), NAUTILUS_TYPE_NOTEBOOK); - if (notebook != NULL) - { - g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, slot); - } -} - -static GtkWidget * -build_tab_label (NautilusNotebook *notebook, - NautilusWindowSlot *slot) -{ - GtkWidget *box; - GtkWidget *label; - GtkWidget *close_button; - GtkWidget *image; - GtkWidget *spinner; - GtkWidget *icon; - - /* When porting to Gtk+4, use GtkCenterBox instead */ - box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); - gtk_widget_show (box); - - /* Spinner to be shown as load feedback */ - spinner = gtk_spinner_new (); - gtk_box_pack_start (GTK_BOX (box), spinner, FALSE, FALSE, 0); - - /* Dummy icon to allocate space for spinner */ - icon = gtk_image_new (); - gtk_box_pack_start (GTK_BOX (box), icon, FALSE, FALSE, 0); - /* don't show the icon */ - - /* Tab title */ - 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_label_set_width_chars (GTK_LABEL (label), 6); - gtk_box_set_center_widget (GTK_BOX (box), label); - gtk_widget_show (label); - - /* Tab 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_widget_set_focus_on_click (close_button, FALSE); - - gtk_widget_set_name (close_button, "nautilus-tab-close-button"); - - image = gtk_image_new_from_icon_name ("window-close-symbolic", 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_end (GTK_BOX (box), close_button, FALSE, FALSE, 0); - gtk_widget_show (close_button); - - g_object_set_data (G_OBJECT (box), "nautilus-notebook-tab", GINT_TO_POINTER (1)); - nautilus_drag_slot_proxy_init (box, NULL, slot); - - g_object_set_data (G_OBJECT (box), "label", label); - g_object_set_data (G_OBJECT (box), "spinner", spinner); - g_object_set_data (G_OBJECT (box), "icon", icon); - g_object_set_data (G_OBJECT (box), "close-button", close_button); - - return box; -} - -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); - gtk_notebook_set_tab_detachable (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), - GTK_WIDGET (slot), - tab_label, - position); - - gtk_container_child_set (GTK_CONTAINER (notebook), - GTK_WIDGET (slot), - "tab-expand", TRUE, - "detachable", FALSE, - NULL); - - nautilus_notebook_sync_tab_label (notebook, slot); - nautilus_notebook_sync_loading (notebook, slot); - - 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); -} - -void -nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook, - int offset) -{ - GtkNotebook *gnotebook; - GtkWidget *child; - int page; - - g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); - - if (!nautilus_notebook_can_reorder_current_child_relative (notebook, offset)) - { - return; - } - - gnotebook = GTK_NOTEBOOK (notebook); - - page = gtk_notebook_get_current_page (gnotebook); - child = gtk_notebook_get_nth_page (gnotebook, page); - gtk_notebook_reorder_child (gnotebook, child, page + offset); -} - -static gboolean -nautilus_notebook_is_valid_relative_position (NautilusNotebook *notebook, - int offset) -{ - GtkNotebook *gnotebook; - int page; - int n_pages; - - gnotebook = GTK_NOTEBOOK (notebook); - - page = gtk_notebook_get_current_page (gnotebook); - n_pages = gtk_notebook_get_n_pages (gnotebook) - 1; - if (page < 0 || - (offset < 0 && page < -offset) || - (offset > 0 && page > n_pages - offset)) - { - return FALSE; - } - - return TRUE; -} - -gboolean -nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook, - int offset) -{ - g_return_val_if_fail (NAUTILUS_IS_NOTEBOOK (notebook), FALSE); - - return nautilus_notebook_is_valid_relative_position (notebook, offset); -} - -void -nautilus_notebook_next_page (NautilusNotebook *notebook) -{ - gint current_page, n_pages; - - g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); - - current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); - n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); - - if (current_page < n_pages - 1) - { - gtk_notebook_next_page (GTK_NOTEBOOK (notebook)); - } - else - { - gboolean wrap_around; - - g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)), - "gtk-keynav-wrap-around", &wrap_around, - NULL); - - if (wrap_around) - { - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0); - } - } -} - -void -nautilus_notebook_prev_page (NautilusNotebook *notebook) -{ - gint current_page; - - g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook)); - - current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); - - if (current_page > 0) - { - gtk_notebook_prev_page (GTK_NOTEBOOK (notebook)); - } - else - { - gboolean wrap_around; - - g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)), - "gtk-keynav-wrap-around", &wrap_around, - NULL); - - if (wrap_around) - { - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1); - } - } -} diff --git a/src/nautilus-notebook.h b/src/nautilus-notebook.h deleted file mode 100644 index 1590e111b..000000000 --- a/src/nautilus-notebook.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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, see . - * - */ - -#pragma once - -#include -#include - -#include "nautilus-window-slot.h" - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_NOTEBOOK (nautilus_notebook_get_type ()) -G_DECLARE_FINAL_TYPE (NautilusNotebook, nautilus_notebook, NAUTILUS, NOTEBOOK, GtkNotebook) - -int nautilus_notebook_add_tab (NautilusNotebook *nb, - NautilusWindowSlot *slot, - int position, - gboolean jump_to); - -void nautilus_notebook_sync_tab_label (NautilusNotebook *nb, - NautilusWindowSlot *slot); -void nautilus_notebook_sync_loading (NautilusNotebook *nb, - NautilusWindowSlot *slot); - -void nautilus_notebook_reorder_current_child_relative (NautilusNotebook *notebook, - int offset); -gboolean nautilus_notebook_can_reorder_current_child_relative (NautilusNotebook *notebook, - int offset); -void nautilus_notebook_prev_page (NautilusNotebook *notebook); -void nautilus_notebook_next_page (NautilusNotebook *notebook); - -gboolean nautilus_notebook_contains_slot (NautilusNotebook *notebook, - NautilusWindowSlot *slot); - -gboolean nautilus_notebook_content_area_hit (NautilusNotebook *notebook, - gint x, - gint y); - -G_END_DECLS diff --git a/src/nautilus-window-slot-dnd.c b/src/nautilus-window-slot-dnd.c index 96c5d9cc8..f0acc70cc 100644 --- a/src/nautilus-window-slot-dnd.c +++ b/src/nautilus-window-slot-dnd.c @@ -25,7 +25,6 @@ #include -#include "nautilus-notebook.h" #include "nautilus-application.h" #include "nautilus-files-view-dnd.h" #include "nautilus-window-slot-dnd.h" @@ -49,35 +48,9 @@ typedef struct NautilusWindowSlot *target_slot; GtkWidget *widget; - gboolean is_notebook; guint switch_location_timer; } NautilusDragSlotProxyInfo; -static void -switch_tab (NautilusDragSlotProxyInfo *drag_info) -{ - GtkWidget *notebook, *slot; - gint idx, n_pages; - - if (drag_info->target_slot == NULL) - { - return; - } - - notebook = gtk_widget_get_ancestor (GTK_WIDGET (drag_info->target_slot), NAUTILUS_TYPE_NOTEBOOK); - n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)); - - for (idx = 0; idx < n_pages; idx++) - { - slot = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), idx); - if (NAUTILUS_WINDOW_SLOT (slot) == drag_info->target_slot) - { - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), idx); - break; - } - } -} - static void switch_location (NautilusDragSlotProxyInfo *drag_info) { @@ -106,14 +79,7 @@ slot_proxy_switch_location_timer (gpointer user_data) drag_info->switch_location_timer = 0; - if (drag_info->is_notebook) - { - switch_tab (drag_info); - } - else - { - switch_location (drag_info); - } + switch_location (drag_info); return FALSE; } @@ -526,8 +492,6 @@ nautilus_drag_slot_proxy_init (GtkWidget *widget, g_object_set_data_full (G_OBJECT (widget), "drag-slot-proxy-data", drag_info, drag_info_free); - drag_info->is_notebook = (g_object_get_data (G_OBJECT (widget), "nautilus-notebook-tab") != NULL); - if (target_file != NULL) { drag_info->target_file = nautilus_file_ref (target_file); diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index b5ff00008..5be145bac 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -61,6 +61,8 @@ enum PROP_SELECTION, PROP_LOCATION, PROP_TOOLTIP, + PROP_ALLOW_STOP, + PROP_TITLE, NUM_PROPERTIES }; @@ -957,6 +959,18 @@ nautilus_window_slot_get_property (GObject *object, } break; + case PROP_ALLOW_STOP: + { + g_value_set_boolean (value, nautilus_window_slot_get_allow_stop (self)); + } + break; + + case PROP_TITLE: + { + g_value_set_string (value, nautilus_window_slot_get_title (self)); + } + break; + default: { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1030,6 +1044,7 @@ nautilus_window_slot_constructed (GObject *object) G_BINDING_DEFAULT); priv->title = g_strdup (_("Loading…")); + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]); } static void @@ -3285,6 +3300,20 @@ nautilus_window_slot_class_init (NautilusWindowSlotClass *klass) NULL, G_PARAM_READWRITE); + properties[PROP_ALLOW_STOP] = + g_param_spec_boolean ("allow-stop", + "Allow stop", + "Whether the slot allows stopping the loading", + FALSE, + G_PARAM_READABLE); + + properties[PROP_TITLE] = + g_param_spec_string ("title", + "Title", + "The title of the slot", + NULL, + G_PARAM_READABLE); + g_object_class_install_properties (oclass, NUM_PROPERTIES, properties); } @@ -3402,6 +3431,8 @@ nautilus_window_slot_update_title (NautilusWindowSlot *self) if (do_sync) { nautilus_window_sync_title (window, self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]); } if (title != NULL) @@ -3435,6 +3466,8 @@ nautilus_window_slot_set_allow_stop (NautilusWindowSlot *self, window = nautilus_window_slot_get_window (self); nautilus_window_sync_allow_stop (window, self); + + g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ALLOW_STOP]); } void @@ -3665,15 +3698,16 @@ nautilus_window_slot_set_active (NautilusWindowSlot *self, if (active) { - int page_num; + HdyTabView *tab_view; + HdyTabPage *page; priv = nautilus_window_slot_get_instance_private (self); window = priv->window; - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nautilus_window_get_notebook (window)), - GTK_WIDGET (self)); - g_assert (page_num >= 0); - gtk_notebook_set_current_page (GTK_NOTEBOOK (nautilus_window_get_notebook (window)), page_num); + tab_view = nautilus_window_get_tab_view (window); + page = hdy_tab_view_get_page (tab_view, GTK_WIDGET (self)); + + hdy_tab_view_set_selected_page (tab_view, page); /* sync window to new slot */ nautilus_window_sync_allow_stop (window, self); diff --git a/src/nautilus-window.c b/src/nautilus-window.c index df724f4e7..52b76b28e 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -60,7 +60,6 @@ #include "nautilus-location-entry.h" #include "nautilus-metadata.h" #include "nautilus-mime-actions.h" -#include "nautilus-notebook.h" #include "nautilus-other-locations-window-slot.h" #include "nautilus-pathbar.h" #include "nautilus-profile.h" @@ -83,7 +82,7 @@ static void nautilus_window_initialize_actions (NautilusWindow *window); static GtkWidget *nautilus_window_ensure_location_entry (NautilusWindow *window); static void close_slot (NautilusWindow *window, NautilusWindowSlot *slot, - gboolean remove_from_notebook); + gboolean remove_tab); /* 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 @@ -100,7 +99,8 @@ struct _NautilusWindow { HdyApplicationWindow parent_instance; - GtkWidget *notebook; + HdyTabView *tab_view; + HdyTabPage *menu_page; /* available slots, and active slot. * Both of them may never be NULL. @@ -151,7 +151,6 @@ struct _NautilusWindow GtkPadController *pad_controller; GtkGesture *multi_press_gesture; - GtkGesture *notebook_multi_press_gesture; }; enum @@ -202,13 +201,15 @@ action_close_current_view (GSimpleAction *action, GVariant *state, gpointer user_data) { - NautilusWindow *window; - NautilusWindowSlot *slot; + NautilusWindow *window = user_data; + HdyTabPage *page = window->menu_page; - window = NAUTILUS_WINDOW (user_data); - slot = nautilus_window_get_active_slot (window); + if (!page) + { + page = hdy_tab_view_get_selected_page (window->tab_view); + } - nautilus_window_slot_close (window, slot); + hdy_tab_view_close_page (window->tab_view, page); } static void @@ -328,34 +329,20 @@ action_enter_location (GSimpleAction *action, nautilus_window_ensure_location_entry (window); } -static void -action_tab_previous (GSimpleAction *action, - GVariant *state, - gpointer user_data) -{ - NautilusWindow *window = user_data; - - nautilus_notebook_prev_page (NAUTILUS_NOTEBOOK (window->notebook)); -} - -static void -action_tab_next (GSimpleAction *action, - GVariant *state, - gpointer user_data) -{ - NautilusWindow *window = user_data; - - nautilus_notebook_next_page (NAUTILUS_NOTEBOOK (window->notebook)); -} - static void action_tab_move_left (GSimpleAction *action, GVariant *state, gpointer user_data) { NautilusWindow *window = user_data; + HdyTabPage *page = window->menu_page; + + if (!page) + { + page = hdy_tab_view_get_selected_page (window->tab_view); + } - nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1); + hdy_tab_view_reorder_backward (window->tab_view, page); } static void @@ -364,8 +351,14 @@ action_tab_move_right (GSimpleAction *action, gpointer user_data) { NautilusWindow *window = user_data; + HdyTabPage *page = window->menu_page; - nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1); + if (!page) + { + page = hdy_tab_view_get_selected_page (window->tab_view); + } + + hdy_tab_view_reorder_forward (window->tab_view, page); } static void @@ -374,15 +367,14 @@ action_go_to_tab (GSimpleAction *action, gpointer user_data) { NautilusWindow *window = NAUTILUS_WINDOW (user_data); - GtkNotebook *notebook; gint16 num; - notebook = GTK_NOTEBOOK (window->notebook); - num = g_variant_get_int32 (value); - if (num < gtk_notebook_get_n_pages (notebook)) + if (num < hdy_tab_view_get_n_pages (window->tab_view)) { - gtk_notebook_set_current_page (notebook, num); + HdyTabPage *page = hdy_tab_view_get_nth_page (window->tab_view, num); + + hdy_tab_view_set_selected_page (window->tab_view, page); } } @@ -479,15 +471,45 @@ on_slot_selection_changed (NautilusWindowSlot *slot, } static void -notebook_switch_page_cb (GtkNotebook *notebook, - GtkWidget *page, - unsigned int page_num, - NautilusWindow *window) +tab_view_setup_menu_cb (HdyTabView *tab_view, + HdyTabPage *page, + NautilusWindow *window) { + GAction *move_tab_left_action; + GAction *move_tab_right_action; + int position, n_pages; + + if (page) + { + position = hdy_tab_view_get_page_position (tab_view, page); + n_pages = hdy_tab_view_get_n_pages (tab_view); + } + + move_tab_left_action = g_action_map_lookup_action (G_ACTION_MAP (window), + "tab-move-left"); + move_tab_right_action = g_action_map_lookup_action (G_ACTION_MAP (window), + "tab-move-right"); + + g_simple_action_set_enabled (G_SIMPLE_ACTION (move_tab_left_action), + !page || position > 0); + g_simple_action_set_enabled (G_SIMPLE_ACTION (move_tab_right_action), + !page || position < n_pages - 1); + + window->menu_page = page; +} + +static void +tab_view_notify_selected_page_cb (HdyTabView *tab_view, + GParamSpec *pspec, + NautilusWindow *window) +{ + HdyTabPage *page; NautilusWindowSlot *slot; GtkWidget *widget; - widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), page_num); + page = hdy_tab_view_get_selected_page (tab_view); + widget = hdy_tab_page_get_child (page); + g_assert (widget != NULL); /* find slot corresponding to the target page */ @@ -574,28 +596,80 @@ replace_active_slot (NautilusWindow *window, return new_slot; } +static gboolean +location_to_tooltip (GBinding *binding, + const GValue *input, + GValue *output, + NautilusWindowSlot *slot) +{ + GFile *location = g_value_get_object (input); + g_autofree gchar *location_name = NULL; + + if (!location) + { + return TRUE; + } + + /* Set the tooltip on the label's parent (the tab label hbox), + * so it covers all of the tab label. + */ + location_name = g_file_get_parse_name (location); + + if (eel_uri_is_search (location_name)) + { + g_value_set_string (output, nautilus_window_slot_get_title (slot)); + } + else + { + g_value_set_string (output, location_name); + } + + return TRUE; +} + void nautilus_window_initialize_slot (NautilusWindow *window, NautilusWindowSlot *slot, NautilusWindowOpenFlags flags) { + HdyTabPage *page; + g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); connect_slot (window, slot); - g_signal_handlers_block_by_func (window->notebook, - G_CALLBACK (notebook_switch_page_cb), - window); - nautilus_notebook_add_tab (NAUTILUS_NOTEBOOK (window->notebook), - slot, - (flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0 ? - -1 : - gtk_notebook_get_current_page (GTK_NOTEBOOK (window->notebook)) + 1, - FALSE); - g_signal_handlers_unblock_by_func (window->notebook, - G_CALLBACK (notebook_switch_page_cb), - window); + if ((flags & NAUTILUS_WINDOW_OPEN_SLOT_APPEND) != 0) + { + page = hdy_tab_view_append (window->tab_view, GTK_WIDGET (slot)); + } + else + { + HdyTabPage *current = hdy_tab_view_get_selected_page (window->tab_view); + + if (current) + { + int position = hdy_tab_view_get_page_position (window->tab_view, current) + 1; + + page = hdy_tab_view_insert (window->tab_view, GTK_WIDGET (slot), position); + } + else + { + page = hdy_tab_view_prepend (window->tab_view, GTK_WIDGET (slot)); + } + } + + g_object_bind_property (slot, "allow-stop", + page, "loading", + G_BINDING_SYNC_CREATE); + g_object_bind_property (slot, "title", + page, "title", + G_BINDING_SYNC_CREATE); + g_object_bind_property_full (slot, "location", + page, "tooltip", + G_BINDING_SYNC_CREATE, + (GBindingTransformFunc) location_to_tooltip, + NULL, window, NULL); window->slots = g_list_append (window->slots, slot); g_signal_emit (window, signals[SLOT_ADDED], 0, slot); @@ -748,14 +822,10 @@ location_entry_location_changed_callback (GtkWidget *widget, static void close_slot (NautilusWindow *window, NautilusWindowSlot *slot, - gboolean remove_from_notebook) + gboolean remove_tab) { - int page_num; - GtkNotebook *notebook; - g_assert (NAUTILUS_IS_WINDOW_SLOT (slot)); - DEBUG ("Closing slot %p", slot); disconnect_slot (window, slot); @@ -764,15 +834,12 @@ close_slot (NautilusWindow *window, g_signal_emit (window, signals[SLOT_REMOVED], 0, slot); - notebook = GTK_NOTEBOOK (window->notebook); - - if (remove_from_notebook) + if (remove_tab) { - page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (slot)); - g_assert (page_num >= 0); + HdyTabPage *page = hdy_tab_view_get_page (window->tab_view, + GTK_WIDGET (slot)); - /* this will call gtk_widget_destroy on the slot */ - gtk_notebook_remove_page (notebook, page_num); + hdy_tab_view_close_page (window->tab_view, page); } } @@ -864,22 +931,15 @@ nautilus_window_sync_allow_stop (NautilusWindow *window, { update_cursor (window); } - - /* Avoid updating the notebook if we are calling on dispose or - * on removal of a notebook tab */ - if (nautilus_notebook_contains_slot (NAUTILUS_NOTEBOOK (window->notebook), slot)) - { - nautilus_notebook_sync_loading (NAUTILUS_NOTEBOOK (window->notebook), slot); - } } } -GtkWidget * -nautilus_window_get_notebook (NautilusWindow *window) +HdyTabView * +nautilus_window_get_tab_view (NautilusWindow *window) { g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL); - return window->notebook; + return window->tab_view; } static gboolean @@ -1831,143 +1891,6 @@ path_bar_location_changed_callback (GtkWidget *widget, nautilus_window_open_location_full (window, location, 0, NULL, NULL); } -static void -notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem, - gpointer user_data) -{ - NautilusWindow *window = user_data; - - nautilus_window_new_tab (window); -} - -static void -notebook_popup_menu_move_left_cb (GtkMenuItem *menuitem, - gpointer user_data) -{ - NautilusWindow *window = user_data; - - nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), -1); -} - -static void -notebook_popup_menu_move_right_cb (GtkMenuItem *menuitem, - gpointer user_data) -{ - NautilusWindow *window = user_data; - - - nautilus_notebook_reorder_current_child_relative (NAUTILUS_NOTEBOOK (window->notebook), 1); -} - -static void -notebook_popup_menu_close_cb (GtkMenuItem *menuitem, - gpointer user_data) -{ - NautilusWindow *window = user_data; - NautilusWindowSlot *slot; - - slot = window->active_slot; - nautilus_window_slot_close (window, slot); -} - -static void -notebook_popup_menu_show (NautilusWindow *window, - const GdkEvent *event) -{ - GtkWidget *popup; - GtkWidget *item; - gboolean can_move_left, can_move_right; - NautilusNotebook *notebook; - - notebook = NAUTILUS_NOTEBOOK (window->notebook); - - can_move_left = nautilus_notebook_can_reorder_current_child_relative (notebook, -1); - can_move_right = nautilus_notebook_can_reorder_current_child_relative (notebook, 1); - - popup = gtk_menu_new (); - - item = gtk_menu_item_new_with_mnemonic (_("_New Tab")); - g_signal_connect (item, "activate", - G_CALLBACK (notebook_popup_menu_new_tab_cb), - window); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - item); - - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - gtk_separator_menu_item_new ()); - - item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left")); - g_signal_connect (item, "activate", - G_CALLBACK (notebook_popup_menu_move_left_cb), - window); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - item); - gtk_widget_set_sensitive (item, can_move_left); - - item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Right")); - g_signal_connect (item, "activate", - G_CALLBACK (notebook_popup_menu_move_right_cb), - window); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - item); - gtk_widget_set_sensitive (item, can_move_right); - - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - gtk_separator_menu_item_new ()); - - item = gtk_menu_item_new_with_mnemonic (_("_Close Tab")); - g_signal_connect (item, "activate", - G_CALLBACK (notebook_popup_menu_close_cb), window); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), - item); - - gtk_widget_show_all (popup); - - gtk_menu_popup_at_pointer (GTK_MENU (popup), event); -} - -/* emitted when the user clicks the "close" button of tabs */ -static void -notebook_tab_close_requested (NautilusNotebook *notebook, - NautilusWindowSlot *slot, - NautilusWindow *window) -{ - nautilus_window_slot_close (window, slot); -} - -static void -notebook_button_press_cb (GtkGestureMultiPress *gesture, - gint n_press, - gdouble x, - gdouble y, - gpointer user_data) -{ - NautilusWindow *window; - GdkEventSequence *sequence; - const GdkEvent *event; - - window = NAUTILUS_WINDOW (user_data); - - if (nautilus_notebook_content_area_hit (NAUTILUS_NOTEBOOK (window->notebook), x, y)) - { - return; - } - - sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); - event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence); - - notebook_popup_menu_show (window, event); -} - -static gboolean -notebook_popup_menu_cb (GtkWidget *widget, - gpointer user_data) -{ - NautilusWindow *window = user_data; - notebook_popup_menu_show (window, NULL); - return TRUE; -} - GtkWidget * nautilus_window_get_toolbar (NautilusWindow *window) { @@ -2002,16 +1925,31 @@ setup_toolbar (NautilusWindow *window) G_CALLBACK (location_entry_cancel_callback), window, 0); } +static gboolean +tab_view_close_page_cb (HdyTabView *view, + HdyTabPage *page, + NautilusWindow *window) +{ + NautilusWindowSlot *slot; + + slot = NAUTILUS_WINDOW_SLOT (hdy_tab_page_get_child (page)); + + nautilus_window_slot_close (window, slot); + + return GDK_EVENT_PROPAGATE; +} + static void -notebook_page_removed_cb (GtkNotebook *notebook, - GtkWidget *page, - guint page_num, - gpointer user_data) +tab_view_page_detached_cb (HdyTabView *tab_view, + HdyTabPage *page, + gint position, + NautilusWindow *window) { - NautilusWindow *window = user_data; - NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (page), *next_slot; + NautilusWindowSlot *slot, *next_slot; gboolean dnd_slot; + slot = NAUTILUS_WINDOW_SLOT (hdy_tab_page_get_child (page)); + dnd_slot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (slot), "dnd-window-slot")); if (!dnd_slot) { @@ -2028,16 +1966,16 @@ notebook_page_removed_cb (GtkNotebook *notebook, } static void -notebook_page_added_cb (GtkNotebook *notebook, - GtkWidget *page, - guint page_num, - gpointer user_data) +tab_view_page_attached_cb (HdyTabView *tab_view, + HdyTabPage *page, + gint position, + NautilusWindow *window) { - NautilusWindow *window = user_data; - NautilusWindowSlot *slot = NAUTILUS_WINDOW_SLOT (page); - NautilusWindowSlot *dummy_slot; + NautilusWindowSlot *slot, *dummy_slot; gboolean dnd_slot; + slot = NAUTILUS_WINDOW_SLOT (hdy_tab_page_get_child (page)); + dnd_slot = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (slot), "dnd-window-slot")); if (!dnd_slot) { @@ -2062,59 +2000,44 @@ notebook_page_added_cb (GtkNotebook *notebook, gtk_widget_show (GTK_WIDGET (window)); } -static GtkNotebook * -notebook_create_window_cb (GtkNotebook *notebook, - GtkWidget *page, - gint x, - gint y, - gpointer user_data) +static HdyTabView * +tab_view_create_window_cb (HdyTabView *tab_view, + NautilusWindow *window) { NautilusApplication *app; NautilusWindow *new_window; - NautilusWindowSlot *slot; - - if (!NAUTILUS_IS_WINDOW_SLOT (page)) - { - return NULL; - } app = NAUTILUS_APPLICATION (g_application_get_default ()); new_window = nautilus_application_create_window - (app, gtk_widget_get_screen (GTK_WIDGET (notebook))); - - slot = NAUTILUS_WINDOW_SLOT (page); - g_object_set_data (G_OBJECT (slot), "dnd-window-slot", - GINT_TO_POINTER (TRUE)); + (app, gtk_widget_get_screen (GTK_WIDGET (tab_view))); gtk_window_set_position (GTK_WINDOW (new_window), GTK_WIN_POS_MOUSE); - return GTK_NOTEBOOK (new_window->notebook); + gtk_window_present (GTK_WINDOW (new_window)); + + return new_window->tab_view; } static void -setup_notebook (NautilusWindow *window) +setup_tab_view (NautilusWindow *window) { - g_signal_connect (window->notebook, "tab-close-request", - G_CALLBACK (notebook_tab_close_requested), - window); - g_signal_connect (window->notebook, "popup-menu", - G_CALLBACK (notebook_popup_menu_cb), + g_signal_connect (window->tab_view, "close-page", + G_CALLBACK (tab_view_close_page_cb), window); - g_signal_connect (window->notebook, "switch-page", - G_CALLBACK (notebook_switch_page_cb), + g_signal_connect (window->tab_view, "setup-menu", + G_CALLBACK (tab_view_setup_menu_cb), window); - g_signal_connect (window->notebook, "create-window", - G_CALLBACK (notebook_create_window_cb), + g_signal_connect (window->tab_view, "notify::selected-page", + G_CALLBACK (tab_view_notify_selected_page_cb), window); - g_signal_connect (window->notebook, "page-added", - G_CALLBACK (notebook_page_added_cb), + g_signal_connect (window->tab_view, "create-window", + G_CALLBACK (tab_view_create_window_cb), window); - g_signal_connect (window->notebook, "page-removed", - G_CALLBACK (notebook_page_removed_cb), + g_signal_connect (window->tab_view, "page-attached", + G_CALLBACK (tab_view_page_attached_cb), window); - - g_signal_connect (window->notebook_multi_press_gesture, "pressed", - G_CALLBACK (notebook_button_press_cb), + g_signal_connect (window->tab_view, "page-detached", + G_CALLBACK (tab_view_page_detached_cb), window); } @@ -2134,8 +2057,6 @@ const GActionEntry win_entries[] = /* Only accesible by shorcuts */ { "close-current-view", action_close_current_view }, { "go-home", action_go_home }, - { "tab-previous", action_tab_previous }, - { "tab-next", action_tab_next }, { "tab-move-left", action_tab_move_left }, { "tab-move-right", action_tab_move_right }, { "prompt-root-location", action_prompt_for_location_root }, @@ -2195,8 +2116,6 @@ nautilus_window_initialize_actions (NautilusWindow *window) nautilus_application_set_accelerator (app, "win.bookmark-current-location", "d"); nautilus_application_set_accelerator (app, "win.up", "Up"); nautilus_application_set_accelerator (app, "win.go-home", "Home"); - nautilus_application_set_accelerator (app, "win.tab-previous", "Page_Up"); - nautilus_application_set_accelerator (app, "win.tab-next", "Page_Down"); nautilus_application_set_accelerator (app, "win.tab-move-left", "Page_Up"); nautilus_application_set_accelerator (app, "win.tab-move-right", "Page_Down"); nautilus_application_set_accelerators (app, "win.prompt-root-location", prompt_root_location_accels); @@ -2246,7 +2165,7 @@ nautilus_window_constructed (GObject *self) NAUTILUS_WINDOW_DEFAULT_WIDTH, NAUTILUS_WINDOW_DEFAULT_HEIGHT); - setup_notebook (window); + setup_tab_view (window); nautilus_window_set_up_sidebar (window); @@ -2333,18 +2252,6 @@ nautilus_window_destroy (GtkWidget *object) GTK_WIDGET_CLASS (nautilus_window_parent_class)->destroy (object); } -static void -nautilus_window_dispose (GObject *object) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (object); - - g_clear_object (&window->notebook_multi_press_gesture); - - G_OBJECT_CLASS (nautilus_window_parent_class)->dispose (object); -} - static void nautilus_window_finalize (GObject *object) { @@ -2552,8 +2459,6 @@ nautilus_window_sync_title (NautilusWindow *window, { gtk_window_set_title (GTK_WINDOW (window), nautilus_window_slot_get_title (slot)); } - - nautilus_notebook_sync_tab_label (NAUTILUS_NOTEBOOK (window->notebook), slot); } #ifdef GDK_WINDOWING_WAYLAND @@ -2770,7 +2675,6 @@ nautilus_window_init (NautilusWindow *window) GtkWindowGroup *window_group; g_type_ensure (NAUTILUS_TYPE_TOOLBAR); - g_type_ensure (NAUTILUS_TYPE_NOTEBOOK); gtk_widget_init_template (GTK_WIDGET (window)); g_signal_connect (window, "notify::is-maximized", @@ -2807,13 +2711,6 @@ nautilus_window_init (NautilusWindow *window) g_signal_connect (window->multi_press_gesture, "pressed", G_CALLBACK (on_multi_press_gesture_pressed), NULL); - - window->notebook_multi_press_gesture = gtk_gesture_multi_press_new (window->notebook); - - gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (window->notebook_multi_press_gesture), - GTK_PHASE_CAPTURE); - gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (window->notebook_multi_press_gesture), - GDK_BUTTON_SECONDARY); } static void @@ -2822,7 +2719,6 @@ nautilus_window_class_init (NautilusWindowClass *class) GObjectClass *oclass = G_OBJECT_CLASS (class); GtkWidgetClass *wclass = GTK_WIDGET_CLASS (class); - oclass->dispose = nautilus_window_dispose; oclass->finalize = nautilus_window_finalize; oclass->constructed = nautilus_window_constructed; @@ -2840,7 +2736,7 @@ nautilus_window_class_init (NautilusWindowClass *class) gtk_widget_class_bind_template_child (wclass, NautilusWindow, sidebar); gtk_widget_class_bind_template_child (wclass, NautilusWindow, places_sidebar); gtk_widget_class_bind_template_child (wclass, NautilusWindow, main_view); - gtk_widget_class_bind_template_child (wclass, NautilusWindow, notebook); + gtk_widget_class_bind_template_child (wclass, NautilusWindow, tab_view); gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo); gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo_label); gtk_widget_class_bind_template_child (wclass, NautilusWindow, in_app_notification_undo_undo_button); diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 83cc99a27..b65592a4f 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -83,7 +83,7 @@ void nautilus_window_back_or_forward (NautilusWindow *window, NautilusWindowOpenFlags flags); void nautilus_window_reset_menus (NautilusWindow *window); -GtkWidget * nautilus_window_get_notebook (NautilusWindow *window); +HdyTabView * nautilus_window_get_tab_view (NautilusWindow *window); NautilusWindowOpenFlags nautilus_event_get_window_open_flags (void); void nautilus_window_show_about_dialog (NautilusWindow *window); diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css index 546d3e98a..4097944d1 100644 --- a/src/resources/css/Adwaita.css +++ b/src/resources/css/Adwaita.css @@ -1,6 +1,4 @@ -.nautilus-window, -.nautilus-window notebook, -.nautilus-window notebook > stack { +.nautilus-window { background: @theme_base_color; } diff --git a/src/resources/ui/nautilus-window.ui b/src/resources/ui/nautilus-window.ui index 97fce2573..53f9f6951 100644 --- a/src/resources/ui/nautilus-window.ui +++ b/src/resources/ui/nautilus-window.ui @@ -47,10 +47,21 @@ True - + True - False - False + vertical + + + True + tab_view + + + + + True + tab_menu + + @@ -200,4 +211,28 @@ + +
+ + _New Tab + win.new-tab + +
+
+ + Move Tab _Left + win.tab-move-left + + + Move Tab _Right + win.tab-move-right + +
+
+ + _Close Tab + win.close-current-view + +
+
-- cgit v1.2.1