diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2022-08-16 23:21:21 +0400 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2022-10-09 19:53:34 +0400 |
commit | fd1c893f18adbb752e035acb81676ba77b053a24 (patch) | |
tree | ecd5f741d659ff9847e7854480ff8b951128b1e7 | |
parent | 2ad67a2ff28f2e13916bdb4fe8f8f761d91543bd (diff) | |
download | epiphany-wip/exalm/gtk4-overview.tar.gz |
Port to AdwTabOverviewwip/exalm/gtk4-overview
27 files changed, 141 insertions, 1218 deletions
diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c index bc5d1200a..46f42ef2a 100644 --- a/src/ephy-action-bar-end.c +++ b/src/ephy-action-bar-end.c @@ -39,6 +39,7 @@ struct _EphyActionBarEnd { GtkWidget *downloads_popover; GtkWidget *downloads_icon; GtkWidget *browser_action_box; + GtkWidget *overview_button; GdkPaintable *downloads_paintable; @@ -142,6 +143,9 @@ ephy_action_bar_end_class_init (EphyActionBarEndClass *klass) gtk_widget_class_bind_template_child (widget_class, EphyActionBarEnd, browser_action_box); + gtk_widget_class_bind_template_child (widget_class, + EphyActionBarEnd, + overview_button); } static void @@ -273,3 +277,11 @@ ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd *action_bar_e g_assert_not_reached (); } } + +void +ephy_action_bar_end_set_adaptive_mode (EphyActionBarEnd *action_bar_end, + EphyAdaptiveMode adaptive_mode) +{ + gtk_widget_set_visible (action_bar_end->overview_button, + adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL); +} diff --git a/src/ephy-action-bar-end.h b/src/ephy-action-bar-end.h index ffecf9596..b9cf0219e 100644 --- a/src/ephy-action-bar-end.h +++ b/src/ephy-action-bar-end.h @@ -21,10 +21,11 @@ #pragma once -#include "ephy-bookmark-states.h" - #include <gtk/gtk.h> +#include "ephy-adaptive-mode.h" +#include "ephy-bookmark-states.h" + G_BEGIN_DECLS #define EPHY_TYPE_ACTION_BAR_END (ephy_action_bar_end_get_type ()) @@ -47,4 +48,7 @@ void ephy_action_bar_end_set_show_bookmark_button (EphyActionBarEnd void ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd *action_bar_end, EphyBookmarkIconState state); +void ephy_action_bar_end_set_adaptive_mode (EphyActionBarEnd *action_bar_end, + EphyAdaptiveMode adaptive_mode); + G_END_DECLS diff --git a/src/ephy-action-bar.c b/src/ephy-action-bar.c index a381a8756..1f919ac38 100644 --- a/src/ephy-action-bar.c +++ b/src/ephy-action-bar.c @@ -21,7 +21,6 @@ #include "ephy-action-bar.h" #include "ephy-add-bookmark-popover.h" -#include "ephy-pages-button.h" #include "ephy-settings.h" #include "ephy-shell.h" #include "ephy-tab-view.h" @@ -42,7 +41,7 @@ struct _EphyActionBar { GtkRevealer *revealer; EphyActionBarStart *action_bar_start; EphyActionBarEnd *action_bar_end; - EphyPagesButton *pages_button; + AdwTabButton *pages_button; EphyAdaptiveMode adaptive_mode; gboolean can_reveal; @@ -131,9 +130,8 @@ ephy_action_bar_constructed (GObject *object) G_CALLBACK (sync_chromes_visibility), action_bar, G_CONNECT_SWAPPED); - g_object_bind_property (view, "n-pages", - action_bar->pages_button, "n-pages", - G_BINDING_SYNC_CREATE); + adw_tab_button_set_view (ADW_TAB_BUTTON (action_bar->pages_button), + ephy_tab_view_get_tab_view (view)); } static void @@ -184,21 +182,16 @@ ephy_action_bar_class_init (EphyActionBarClass *klass) static void ephy_action_bar_init (EphyActionBar *action_bar) { - EphyEmbedShellMode mode; - /* Ensure the types used by the template have been initialized. */ EPHY_TYPE_ACTION_BAR_END; EPHY_TYPE_ACTION_BAR_START; - EPHY_TYPE_PAGES_BUTTON; gtk_widget_init_template (GTK_WIDGET (action_bar)); - mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (ephy_shell_get_default ())); - gtk_widget_set_visible (GTK_WIDGET (action_bar->pages_button), - mode != EPHY_EMBED_SHELL_MODE_APPLICATION); - ephy_action_bar_start_set_adaptive_mode (action_bar->action_bar_start, EPHY_ADAPTIVE_MODE_NARROW); + ephy_action_bar_end_set_adaptive_mode (action_bar->action_bar_end, + EPHY_ADAPTIVE_MODE_NARROW); g_object_bind_property (action_bar->revealer, "child-revealed", action_bar, "visible", diff --git a/src/ephy-page-row.c b/src/ephy-page-row.c deleted file mode 100644 index eb99c05b0..000000000 --- a/src/ephy-page-row.c +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Purism SPC - * Copyright © 2019 Adrien Plazas <kekun.plazas@laposte.net> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "ephy-desktop-utils.h" -#include "ephy-embed.h" -#include "ephy-page-row.h" -#include "ephy-web-view.h" - -struct _EphyPageRow { - GtkPopover parent_instance; - - GtkBox *box; - GtkImage *icon; - GtkStack *icon_stack; - GtkImage *speaker_icon; - GtkSpinner *spinner; - GtkLabel *title; - GtkButton *close_button; - - AdwTabPage *page; - EphyTabView *tab_view; -}; - -G_DEFINE_TYPE (EphyPageRow, ephy_page_row, GTK_TYPE_LIST_BOX_ROW) - -static void -update_spinner (EphyPageRow *self) -{ - if (gtk_widget_get_mapped (GTK_WIDGET (self)) && - adw_tab_page_get_loading (self->page)) - gtk_spinner_start (self->spinner); - else - gtk_spinner_stop (self->spinner); -} - -static void -close_clicked_cb (EphyPageRow *self) -{ - adw_tab_view_close_page (ephy_tab_view_get_tab_view (self->tab_view), self->page); -} - -static void -released_cb (GtkGesture *gesture, - int n_press, - double x, - double y, - EphyPageRow *self) -{ - gtk_gesture_set_state (gesture, GTK_EVENT_SEQUENCE_CLAIMED); - - adw_tab_view_close_page (ephy_tab_view_get_tab_view (self->tab_view), self->page); -} - -static void -ephy_page_row_class_init (EphyPageRowClass *klass) -{ - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/page-row.ui"); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, box); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, icon); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, icon_stack); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, speaker_icon); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, spinner); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, title); - gtk_widget_class_bind_template_child (widget_class, EphyPageRow, close_button); - gtk_widget_class_bind_template_callback (widget_class, update_spinner); - gtk_widget_class_bind_template_callback (widget_class, close_clicked_cb); - gtk_widget_class_bind_template_callback (widget_class, released_cb); -} - -static void -ephy_page_row_init (EphyPageRow *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); -} - -static gboolean -loading_to_visible_child (GBinding *binding, - const GValue *input, - GValue *output, - EphyPageRow *self) -{ - if (g_value_get_boolean (input)) - g_value_set_object (output, self->spinner); - else - g_value_set_object (output, self->icon); - - return TRUE; -} - -static void -update_icon_cb (EphyPageRow *self) -{ - EphyEmbed *embed = EPHY_EMBED (adw_tab_page_get_child (self->page)); - EphyWebView *view = ephy_embed_get_web_view (embed); - GIcon *icon = G_ICON (ephy_web_view_get_icon (view)); - const char *uri, *favicon_name; - AdwTabView *tab_view; - - if (icon) { - gtk_image_set_from_gicon (self->icon, icon); - - return; - } - - uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view)); - favicon_name = ephy_get_fallback_favicon_name (uri, EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER); - - if (favicon_name) { - g_autoptr (GIcon) fallback_icon = g_themed_icon_new (favicon_name); - - gtk_image_set_from_gicon (self->icon, fallback_icon); - - return; - } - - tab_view = ephy_tab_view_get_tab_view (self->tab_view); - - gtk_image_set_from_gicon (self->icon, adw_tab_view_get_default_icon (tab_view)); -} - -EphyPageRow * -ephy_page_row_new (EphyTabView *tab_view, - AdwTabPage *page) -{ - EphyPageRow *self; - GtkWidget *embed = adw_tab_page_get_child (page); - EphyWebView *view; - - g_assert (ADW_IS_TAB_PAGE (page)); - g_assert (EPHY_IS_EMBED (embed)); - - view = ephy_embed_get_web_view (EPHY_EMBED (embed)); - - self = g_object_new (EPHY_TYPE_PAGE_ROW, NULL); - self->tab_view = tab_view; - self->page = page; - - g_object_bind_property (page, "title", - self->title, "label", - G_BINDING_SYNC_CREATE); - g_object_bind_property (page, "indicator-icon", - self->speaker_icon, "gicon", - G_BINDING_SYNC_CREATE); - g_object_bind_property (page, "pinned", - self->close_button, "visible", - G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); - g_object_bind_property_full (page, "loading", - self->icon_stack, "visible-child", - G_BINDING_SYNC_CREATE, - (GBindingTransformFunc)loading_to_visible_child, - NULL, - self, NULL); - g_signal_connect_object (page, "notify::loading", - G_CALLBACK (update_spinner), self, - G_CONNECT_SWAPPED); - - g_signal_connect_object (view, "notify::icon", - G_CALLBACK (update_icon_cb), self, - G_CONNECT_SWAPPED); - g_signal_connect_object (view, "notify::uri", - G_CALLBACK (update_icon_cb), self, - G_CONNECT_SWAPPED); - - update_icon_cb (self); - - return self; -} - -void -ephy_page_row_set_adaptive_mode (EphyPageRow *self, - EphyAdaptiveMode adaptive_mode) -{ - g_assert (EPHY_IS_PAGE_ROW (self)); - - switch (adaptive_mode) { - case EPHY_ADAPTIVE_MODE_NORMAL: - gtk_widget_set_margin_start (GTK_WIDGET (self->box), 3); - gtk_widget_set_margin_end (GTK_WIDGET (self->box), 1); - gtk_box_set_spacing (self->box, 0); - - break; - case EPHY_ADAPTIVE_MODE_NARROW: - gtk_widget_set_margin_start (GTK_WIDGET (self->box), 8); - gtk_widget_set_margin_end (GTK_WIDGET (self->box), 0); - gtk_box_set_spacing (self->box, 4); - - break; - } -} - -AdwTabPage * -ephy_page_row_get_page (EphyPageRow *self) -{ - g_assert (EPHY_IS_PAGE_ROW (self)); - - return self->page; -} diff --git a/src/ephy-page-row.h b/src/ephy-page-row.h deleted file mode 100644 index e74957220..000000000 --- a/src/ephy-page-row.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Purism SPC - * Copyright © 2019 Adrien Plazas <kekun.plazas@laposte.net> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <adwaita.h> -#include "ephy-adaptive-mode.h" -#include "ephy-tab-view.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_PAGE_ROW (ephy_page_row_get_type()) - -G_DECLARE_FINAL_TYPE (EphyPageRow, ephy_page_row, EPHY, PAGE_ROW, GtkListBoxRow) - -EphyPageRow *ephy_page_row_new (EphyTabView *view, - AdwTabPage *page); - -void ephy_page_row_set_adaptive_mode (EphyPageRow *self, - EphyAdaptiveMode adaptive_mode); - -AdwTabPage *ephy_page_row_get_page (EphyPageRow *self); - -G_END_DECLS diff --git a/src/ephy-pages-button.c b/src/ephy-pages-button.c deleted file mode 100644 index 4a4b683c6..000000000 --- a/src/ephy-pages-button.c +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Alexander Mikhaylenko <exalm7659@gmail.com> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "ephy-pages-button.h" - -/* Copied from GtkInspector code */ -#define XFT_DPI_MULTIPLIER (96.0 * PANGO_SCALE) -#define FONT_SIZE_LARGE 8 -#define FONT_SIZE_SMALL 6 - -struct _EphyPagesButton { - GtkButton parent_instance; - - GtkLabel *pages_label; - GtkImage *pages_icon; - - int n_pages; -}; - -G_DEFINE_TYPE (EphyPagesButton, ephy_pages_button, GTK_TYPE_BUTTON) - -enum { - PROP_0, - PROP_N_PAGES, - N_PROPS -}; - -static GParamSpec *properties[N_PROPS]; - -/* FIXME: I hope there is a better way to prevent the label from changing scale */ -static void -update_label_scale (EphyPagesButton *self, - GtkSettings *settings) -{ - int xft_dpi; - PangoAttrList *attrs; - PangoAttribute *scale_attribute; - - g_object_get (settings, "gtk-xft-dpi", &xft_dpi, NULL); - - attrs = gtk_label_get_attributes (self->pages_label); - scale_attribute = pango_attr_scale_new (XFT_DPI_MULTIPLIER / xft_dpi); - - pango_attr_list_change (attrs, scale_attribute); -} - -static void -xft_dpi_changed (GtkSettings *settings, - GParamSpec *spec, - EphyPagesButton *self) -{ - update_label_scale (self, settings); -} - -static void -update_icon (EphyPagesButton *self) -{ - gboolean is_overflow; - double font_size; - const char *icon_name; - g_autofree char *label_text = NULL; - PangoAttrList *attrs; - PangoAttribute *size_attribute; - - g_assert (self->n_pages >= 0); - - is_overflow = self->n_pages >= 100; - font_size = self->n_pages >= 10 ? FONT_SIZE_SMALL : FONT_SIZE_LARGE; - icon_name = is_overflow ? "ephy-tab-overflow-symbolic" : "ephy-tab-counter-symbolic"; - label_text = g_strdup_printf ("%u", (guint)self->n_pages); - - attrs = gtk_label_get_attributes (self->pages_label); - size_attribute = pango_attr_size_new (font_size * PANGO_SCALE); - pango_attr_list_change (attrs, size_attribute); - - gtk_widget_set_visible (GTK_WIDGET (self->pages_label), !is_overflow); - gtk_label_set_text (self->pages_label, label_text); - gtk_image_set_from_icon_name (self->pages_icon, icon_name); -} - -EphyPagesButton * -ephy_pages_button_new (void) -{ - return g_object_new (EPHY_TYPE_PAGES_BUTTON, NULL); -} - -int -ephy_pages_button_get_n_pages (EphyPagesButton *self) -{ - return self->n_pages; -} - -void -ephy_pages_button_set_n_pages (EphyPagesButton *self, - int n_pages) -{ - self->n_pages = n_pages; - - update_icon (self); -} - -static void -ephy_pages_button_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EphyPagesButton *self = EPHY_PAGES_BUTTON (object); - - switch (prop_id) { - case PROP_N_PAGES: - g_value_set_int (value, ephy_pages_button_get_n_pages (self)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -ephy_pages_button_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EphyPagesButton *self = EPHY_PAGES_BUTTON (object); - - switch (prop_id) { - case PROP_N_PAGES: - ephy_pages_button_set_n_pages (self, g_value_get_int (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -ephy_pages_button_constructed (GObject *object) -{ - EphyPagesButton *self = EPHY_PAGES_BUTTON (object); - GtkSettings *settings; - - G_OBJECT_CLASS (ephy_pages_button_parent_class)->constructed (object); - - update_icon (self); - - settings = gtk_settings_get_default (); - update_label_scale (self, settings); - g_signal_connect_object (settings, "notify::gtk-xft-dpi", - G_CALLBACK (xft_dpi_changed), self, 0); -} - -static void -ephy_pages_button_class_init (EphyPagesButtonClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->get_property = ephy_pages_button_get_property; - object_class->set_property = ephy_pages_button_set_property; - object_class->constructed = ephy_pages_button_constructed; - - properties [PROP_N_PAGES] = - g_param_spec_int ("n-pages", - "Number of pages", - "The number of pages displayed on the button", - 0, - G_MAXINT, - 1, - (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - - g_object_class_install_properties (object_class, N_PROPS, properties); - - gtk_widget_class_set_template_from_resource (widget_class, - "/org/gnome/epiphany/gtk/pages-button.ui"); - - gtk_widget_class_bind_template_child (widget_class, EphyPagesButton, pages_label); - gtk_widget_class_bind_template_child (widget_class, EphyPagesButton, pages_icon); -} - -static void -ephy_pages_button_init (EphyPagesButton *self) -{ - self->n_pages = 1; - - gtk_widget_init_template (GTK_WIDGET (self)); -} diff --git a/src/ephy-pages-button.h b/src/ephy-pages-button.h deleted file mode 100644 index f7addb5c3..000000000 --- a/src/ephy-pages-button.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-pages-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Alexander Mikhaylenko <exalm7659@gmail.com> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_PAGES_BUTTON (ephy_pages_button_get_type()) - -G_DECLARE_FINAL_TYPE (EphyPagesButton, ephy_pages_button, EPHY, PAGES_BUTTON, GtkButton) - -EphyPagesButton *ephy_pages_button_new (void); - -int ephy_pages_button_get_n_pages (EphyPagesButton *self); - -void ephy_pages_button_set_n_pages (EphyPagesButton *self, - int n_pages); - -G_END_DECLS diff --git a/src/ephy-pages-popover.c b/src/ephy-pages-popover.c deleted file mode 100644 index f6c028e11..000000000 --- a/src/ephy-pages-popover.c +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Purism SPC - * Copyright © 2019 Adrien Plazas <kekun.plazas@laposte.net> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "ephy-pages-popover.h" - -#include "ephy-page-row.h" -#include "ephy-window.h" - -struct _EphyPagesPopover { - GtkPopover parent_instance; - - GtkListBox *list_box; - GtkScrolledWindow *scrolled_window; - - GListModel *model; - EphyTabView *tab_view; -}; - -G_DEFINE_TYPE (EphyPagesPopover, ephy_pages_popover, GTK_TYPE_POPOVER) - -static void -drop_tab_view (EphyPagesPopover *self) -{ - self->tab_view = NULL; -} - -static void -release_tab_view (EphyPagesPopover *self) -{ - if (self->tab_view) { - g_object_weak_unref (G_OBJECT (self->tab_view), (GWeakNotify)drop_tab_view, self); - drop_tab_view (self); - } -} - -static void -row_activated_cb (EphyPagesPopover *self, - EphyPageRow *row) -{ - EphyWindow *window; - GApplication *application; - AdwTabPage *page; - - g_assert (EPHY_IS_PAGES_POPOVER (self)); - g_assert (EPHY_IS_PAGE_ROW (row)); - - application = g_application_get_default (); - window = EPHY_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (application))); - page = ephy_page_row_get_page (EPHY_PAGE_ROW (row)); - - adw_tab_view_set_selected_page (ephy_tab_view_get_tab_view (self->tab_view), page); - ephy_window_close_pages_view (window); - - gtk_popover_popdown (GTK_POPOVER (self)); -} - -static GtkWidget * -create_row (AdwTabPage *page, - EphyPagesPopover *self) -{ - EphyPageRow *row = ephy_page_row_new (self->tab_view, page); - - ephy_page_row_set_adaptive_mode (row, EPHY_ADAPTIVE_MODE_NORMAL); - - return GTK_WIDGET (row); -} - -static void -selected_page_changed_cb (AdwTabView *tab_view, - GParamSpec *pspec, - EphyPagesPopover *self) -{ - AdwTabPage *page = adw_tab_view_get_selected_page (tab_view); - gint position; - GtkListBoxRow *row; - - if (!page) { - gtk_list_box_unselect_all (self->list_box); - - return; - } - - position = adw_tab_view_get_page_position (tab_view, page); - row = gtk_list_box_get_row_at_index (self->list_box, position); - gtk_list_box_select_row (self->list_box, row); -} - -static void -ephy_pages_popover_dispose (GObject *object) -{ - EphyPagesPopover *self = EPHY_PAGES_POPOVER (object); - - release_tab_view (self); - - G_OBJECT_CLASS (ephy_pages_popover_parent_class)->dispose (object); -} - -static void -ephy_pages_popover_class_init (EphyPagesPopoverClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->dispose = ephy_pages_popover_dispose; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/pages-popover.ui"); - gtk_widget_class_bind_template_child (widget_class, EphyPagesPopover, list_box); - gtk_widget_class_bind_template_child (widget_class, EphyPagesPopover, scrolled_window); - gtk_widget_class_bind_template_callback (widget_class, row_activated_cb); -} - -static void -ephy_pages_popover_init (EphyPagesPopover *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); -} - -EphyPagesPopover * -ephy_pages_popover_new (void) -{ - return g_object_new (EPHY_TYPE_PAGES_POPOVER, NULL); -} - -EphyTabView * -ephy_pages_popover_get_tab_view (EphyPagesPopover *self) -{ - g_assert (EPHY_IS_PAGES_POPOVER (self)); - - return self->tab_view; -} - -void -ephy_pages_popover_set_tab_view (EphyPagesPopover *self, - EphyTabView *tab_view) -{ - g_assert (EPHY_IS_PAGES_POPOVER (self)); - - if (self->tab_view) - release_tab_view (self); - - if (!tab_view) - return; - - g_object_weak_ref (G_OBJECT (tab_view), (GWeakNotify)drop_tab_view, self); - self->tab_view = tab_view; - - self->model = G_LIST_MODEL (adw_tab_view_get_pages (ephy_tab_view_get_tab_view (tab_view))); - - gtk_list_box_bind_model (self->list_box, - self->model, - (GtkListBoxCreateWidgetFunc)create_row, - self, - NULL); - - g_signal_connect_object (ephy_tab_view_get_tab_view (tab_view), - "notify::selected-page", - G_CALLBACK (selected_page_changed_cb), - self, - 0); -} diff --git a/src/ephy-pages-popover.h b/src/ephy-pages-popover.h deleted file mode 100644 index d0a9c5eba..000000000 --- a/src/ephy-pages-popover.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Purism SPC - * Copyright © 2019 Adrien Plazas <kekun.plazas@laposte.net> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <gtk/gtk.h> - -#include "ephy-tab-view.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_PAGES_POPOVER (ephy_pages_popover_get_type()) - -G_DECLARE_FINAL_TYPE (EphyPagesPopover, ephy_pages_popover, EPHY, PAGES_POPOVER, GtkPopover) - -EphyPagesPopover *ephy_pages_popover_new (void); - -EphyTabView *ephy_pages_popover_get_tab_view (EphyPagesPopover *self); -void ephy_pages_popover_set_tab_view (EphyPagesPopover *self, - EphyTabView *tab_view); - -G_END_DECLS diff --git a/src/ephy-pages-view.c b/src/ephy-pages-view.c deleted file mode 100644 index 4eb11ab56..000000000 --- a/src/ephy-pages-view.c +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Purism SPC - * Copyright © 2019 Adrien Plazas <kekun.plazas@laposte.net> - * Copyright © 2019 Christopher Davis <christopherdavis@gnome.org> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" - -#include "ephy-pages-view.h" - -#include "ephy-page-row.h" -#include "ephy-window.h" - -struct _EphyPagesView { - GtkBox parent_instance; - - GtkListBox *list_box; - - GListModel *model; - EphyTabView *tab_view; -}; - -G_DEFINE_TYPE (EphyPagesView, ephy_pages_view, GTK_TYPE_BOX) - -static void -row_activated_cb (EphyPagesView *self, - EphyPageRow *row) -{ - EphyWindow *window; - GApplication *application; - AdwTabPage *page; - - g_assert (EPHY_IS_PAGES_VIEW (self)); - g_assert (EPHY_IS_PAGE_ROW (row)); - - application = g_application_get_default (); - window = EPHY_WINDOW (gtk_application_get_active_window (GTK_APPLICATION (application))); - page = ephy_page_row_get_page (EPHY_PAGE_ROW (row)); - - adw_tab_view_set_selected_page (ephy_tab_view_get_tab_view (self->tab_view), page); - ephy_window_close_pages_view (window); -} - -static GtkWidget * -create_row (AdwTabPage *page, - EphyPagesView *self) -{ - EphyPageRow *row = ephy_page_row_new (self->tab_view, page); - - ephy_page_row_set_adaptive_mode (row, EPHY_ADAPTIVE_MODE_NARROW); - - return GTK_WIDGET (row); -} - -static void -selected_page_changed_cb (AdwTabView *tab_view, - GParamSpec *pspec, - EphyPagesView *self) -{ - AdwTabPage *page = adw_tab_view_get_selected_page (tab_view); - gint position; - GtkListBoxRow *row; - - if (!page) { - gtk_list_box_unselect_all (self->list_box); - - return; - } - - position = adw_tab_view_get_page_position (tab_view, page); - row = gtk_list_box_get_row_at_index (self->list_box, position); - gtk_list_box_select_row (self->list_box, row); -} - -static void -ephy_pages_view_dispose (GObject *object) -{ - EphyPagesView *self = EPHY_PAGES_VIEW (object); - - g_clear_weak_pointer (&self->tab_view); - - G_OBJECT_CLASS (ephy_pages_view_parent_class)->dispose (object); -} - -static void -ephy_pages_view_class_init (EphyPagesViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - object_class->dispose = ephy_pages_view_dispose; - - gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/epiphany/gtk/pages-view.ui"); - gtk_widget_class_bind_template_child (widget_class, EphyPagesView, list_box); - gtk_widget_class_bind_template_callback (widget_class, row_activated_cb); -} - -static void -ephy_pages_view_init (EphyPagesView *self) -{ - gtk_widget_init_template (GTK_WIDGET (self)); -} - -EphyPagesView * -ephy_pages_view_new (void) -{ - return g_object_new (EPHY_TYPE_PAGES_VIEW, NULL); -} - -EphyTabView * -ephy_pages_view_get_tab_view (EphyPagesView *self) -{ - g_assert (EPHY_IS_PAGES_VIEW (self)); - - return self->tab_view; -} - -void -ephy_pages_view_set_tab_view (EphyPagesView *self, - EphyTabView *tab_view) -{ - g_assert (EPHY_IS_PAGES_VIEW (self)); - - g_clear_weak_pointer (&self->tab_view); - - if (!tab_view) - return; - - g_object_add_weak_pointer (G_OBJECT (tab_view), (gpointer *)&self->tab_view); - self->tab_view = tab_view; - - self->model = G_LIST_MODEL (adw_tab_view_get_pages (ephy_tab_view_get_tab_view (tab_view))); - - gtk_list_box_bind_model (self->list_box, - self->model, - (GtkListBoxCreateWidgetFunc)create_row, - self, - NULL); - - g_signal_connect_object (ephy_tab_view_get_tab_view (tab_view), - "notify::selected-page", - G_CALLBACK (selected_page_changed_cb), - self, - 0); -} diff --git a/src/ephy-pages-view.h b/src/ephy-pages-view.h deleted file mode 100644 index 0ad828b35..000000000 --- a/src/ephy-pages-view.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Christopher Davis <christopherdavis@gnome.org> - * - * This file is part of Epiphany. - * - * Epiphany 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 3 of the License, or - * (at your option) any later version. - * - * Epiphany 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 Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <gtk/gtk.h> - -#include "ephy-tab-view.h" - -G_BEGIN_DECLS - -#define EPHY_TYPE_PAGES_VIEW (ephy_pages_view_get_type ()) - -G_DECLARE_FINAL_TYPE (EphyPagesView, ephy_pages_view, EPHY, PAGES_VIEW, GtkBox) - -EphyPagesView *ephy_pages_view_new (void); - -EphyTabView *ephy_pages_view_get_tab_view (EphyPagesView *self); -void ephy_pages_view_set_tab_view (EphyPagesView *self, - EphyTabView *tab_view); - -G_END_DECLS diff --git a/src/ephy-tab-view.c b/src/ephy-tab-view.c index b80c4e6e5..075018582 100644 --- a/src/ephy-tab-view.c +++ b/src/ephy-tab-view.c @@ -34,6 +34,7 @@ struct _EphyTabView { AdwTabView *tab_view; AdwTabBar *tab_bar; + AdwTabOverview *tab_overview; AdwTabPage *current_page; }; @@ -403,6 +404,20 @@ update_icon_cb (AdwTabPage *page) } static void +update_uri_cb (AdwTabPage *page) +{ + EphyEmbed *embed = EPHY_EMBED (adw_tab_page_get_child (page)); + EphyWebView *view = ephy_embed_get_web_view (embed); + const char *uri; + + update_icon_cb (page); + + uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view)); + + adw_tab_page_set_keyword (page, uri); +} + +static void update_indicator_cb (AdwTabPage *page) { EphyEmbed *embed = EPHY_EMBED (adw_tab_page_get_child (page)); @@ -459,7 +474,7 @@ ephy_tab_view_add_tab (EphyTabView *self, G_CALLBACK (update_icon_cb), page, G_CONNECT_SWAPPED); g_signal_connect_object (view, "notify::uri", - G_CALLBACK (update_icon_cb), page, + G_CALLBACK (update_uri_cb), page, G_CONNECT_SWAPPED); g_signal_connect_object (view, "notify::is-playing-audio", G_CALLBACK (update_indicator_cb), page, @@ -469,7 +484,7 @@ ephy_tab_view_add_tab (EphyTabView *self, G_CONNECT_SWAPPED); update_title_cb (page); - update_icon_cb (page); + update_uri_cb (page); update_indicator_cb (page); return adw_tab_view_get_page_position (self->tab_view, page); @@ -588,7 +603,13 @@ is_layout_reversed (void) static void notify_decoration_layout_cb (EphyTabView *self) { - adw_tab_bar_set_inverted (self->tab_bar, is_layout_reversed ()); + gboolean inverted = is_layout_reversed (); + + if (self->tab_bar) + adw_tab_bar_set_inverted (self->tab_bar, inverted); + + if (self->tab_overview) + adw_tab_overview_set_inverted (self->tab_overview, inverted); } void @@ -645,3 +666,22 @@ ephy_tab_view_set_tab_bar (EphyTabView *self, visibility_policy_changed_cb (self); notify_decoration_layout_cb (self); } + +void +ephy_tab_view_set_tab_overview (EphyTabView *self, + AdwTabOverview *tab_overview) +{ + self->tab_overview = tab_overview; + + adw_tab_overview_setup_extra_drop_target (tab_overview, GDK_ACTION_COPY, (GType[3]) { + G_TYPE_STRING, + G_TYPE_FILE, + GDK_TYPE_FILE_LIST, + }, 3); + + g_signal_connect_object (tab_overview, "extra-drag-drop", + G_CALLBACK (drag_drop_cb), self, + G_CONNECT_SWAPPED); + + notify_decoration_layout_cb (self); +} diff --git a/src/ephy-tab-view.h b/src/ephy-tab-view.h index fd6c04484..c74f675cf 100644 --- a/src/ephy-tab-view.h +++ b/src/ephy-tab-view.h @@ -81,7 +81,8 @@ gint ephy_tab_view_add_tab (EphyTabView *self, GtkWidget *ephy_tab_view_get_current_page (EphyTabView *self); -void ephy_tab_view_set_tab_bar (EphyTabView *self, - AdwTabBar *tab_bar); - +void ephy_tab_view_set_tab_bar (EphyTabView *self, + AdwTabBar *tab_bar); +void ephy_tab_view_set_tab_overview (EphyTabView *self, + AdwTabOverview *tab_overview); G_END_DECLS diff --git a/src/ephy-window.c b/src/ephy-window.c index 365f73867..fb4105d88 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -47,8 +47,6 @@ #include "ephy-link.h" #include "ephy-location-entry.h" #include "ephy-mouse-gesture-controller.h" -#include "ephy-pages-popover.h" -#include "ephy-pages-view.h" #include "ephy-permissions-manager.h" #include "ephy-prefs.h" #include "ephy-security-popover.h" @@ -151,18 +149,15 @@ static guint64 window_uid = 1; struct _EphyWindow { AdwApplicationWindow parent_instance; - GtkWidget *main_leaflet; + GtkWidget *overview; EphyFullscreenBox *fullscreen_box; GtkBox *titlebar_box; GtkWidget *header_bar; - EphyPagesView *pages_view; EphyBookmarksManager *bookmarks_manager; GHashTable *action_labels; EphyTabView *tab_view; AdwTabBar *tab_bar; GtkRevealer *tab_bar_revealer; - GtkRevealer *pages_menu_revealer; - EphyPagesPopover *pages_popover; GtkWidget *action_bar; EphyEmbed *active_embed; EphyWindowChrome chrome; @@ -351,7 +346,12 @@ ephy_window_open_link (EphyLink *link, EPHY_LINK_NEW_TAB | EPHY_LINK_NEW_WINDOW)) { EphyNewTabFlags ntflags = 0; - EphyWindow *target_window = EPHY_WINDOW (gtk_widget_get_root (GTK_WIDGET (embed))); + EphyWindow *target_window; + + if (embed == NULL) + target_window = window; + else + target_window = EPHY_WINDOW (gtk_widget_get_root (GTK_WIDGET (embed))); if (flags & EPHY_LINK_JUMP_TO) { ntflags |= EPHY_NEW_TAB_JUMP; @@ -533,12 +533,6 @@ update_adaptive_mode (EphyWindow *window) gtk_revealer_set_reveal_child (window->tab_bar_revealer, adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL); - - /* When switching to desktop sizes, drop the tabs view and go back - * to the main view. - */ - if (adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL) - ephy_window_close_pages_view (window); } static void @@ -2726,6 +2720,9 @@ tab_view_page_detached_cb (AdwTabView *tab_view, g_signal_handlers_disconnect_by_func (ephy_embed_get_web_view (EPHY_EMBED (content)), G_CALLBACK (download_only_load_cb), window); + + if (ephy_tab_view_get_n_pages (window->tab_view) == 0) + window->active_embed = NULL; } static void @@ -2765,7 +2762,8 @@ ephy_window_close_tab (EphyWindow *window, * Beware: window->closing could be true now, after destroying the * tab, even if it wasn't at the start of this function. */ - if (!window->closing && ephy_tab_view_get_n_pages (window->tab_view) == 0) + if (!window->closing && ephy_tab_view_get_n_pages (window->tab_view) == 0 && + !adw_tab_overview_get_open (ADW_TAB_OVERVIEW (window->overview))) gtk_window_destroy (GTK_WINDOW (window)); } @@ -3323,48 +3321,6 @@ setup_header_bar (EphyWindow *window) return header_bar; } -static void -update_pages_menu_revealer (EphyWindow *window) -{ - gtk_revealer_set_reveal_child (window->pages_menu_revealer, - adw_tab_bar_get_is_overflowing (window->tab_bar) || - gtk_widget_get_visible (GTK_WIDGET (window->pages_popover))); -} - -static void -setup_tabs_menu (EphyWindow *window) -{ - GtkRevealer *revealer; - GtkWidget *menu_button; - EphyPagesPopover *popover; - - revealer = GTK_REVEALER (gtk_revealer_new ()); - gtk_revealer_set_transition_type (revealer, - GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT); - adw_tab_bar_set_end_action_widget (window->tab_bar, GTK_WIDGET (revealer)); - window->pages_menu_revealer = revealer; - - menu_button = gtk_menu_button_new (); - gtk_widget_add_css_class (menu_button, "flat"); - /* Translators: tooltip for the tab switcher menu button */ - gtk_widget_set_tooltip_text (menu_button, _("View open tabs")); - gtk_widget_set_margin_start (menu_button, 1); - gtk_revealer_set_child (revealer, menu_button); - - popover = ephy_pages_popover_new (); - ephy_pages_popover_set_tab_view (popover, window->tab_view); - gtk_menu_button_set_popover (GTK_MENU_BUTTON (menu_button), - GTK_WIDGET (popover)); - window->pages_popover = popover; - - g_signal_connect_object (window->tab_bar, "notify::is-overflowing", - G_CALLBACK (update_pages_menu_revealer), window, - G_CONNECT_SWAPPED); - g_signal_connect_object (window->pages_popover, "notify::visible", - G_CALLBACK (update_pages_menu_revealer), window, - G_CONNECT_SWAPPED); -} - static EphyLocationController * setup_location_controller (EphyWindow *window, EphyHeaderBar *header_bar) @@ -3534,13 +3490,13 @@ download_completed_cb (EphyDownload *download, } static void -notify_leaflet_child_cb (EphyWindow *window) +notify_overview_open_cb (EphyWindow *window) { GActionGroup *action_group; GAction *action; gboolean pages_open; - pages_open = adw_leaflet_get_visible_child (ADW_LEAFLET (window->main_leaflet)) == GTK_WIDGET (window->pages_view); + pages_open = adw_tab_overview_get_open (ADW_TAB_OVERVIEW (window->overview)); action_group = ephy_window_get_action_group (window, "win"); action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "content"); @@ -3550,6 +3506,16 @@ notify_leaflet_child_cb (EphyWindow *window) g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !pages_open); } +static AdwTabPage * +create_tab_cb (EphyWindow *window) +{ + AdwTabView *view = ephy_tab_view_get_tab_view (window->tab_view); + + window_cmd_new_tab (NULL, NULL, window); + + return adw_tab_view_get_selected_page (view); +} + static void insert_action_group (const char *prefix, GActionGroup *group, @@ -3572,6 +3538,7 @@ ephy_window_constructed (GObject *object) EphyWindowChrome chrome = EPHY_WINDOW_CHROME_DEFAULT; GApplication *app; GtkEventController *controller; + g_autoptr (GtkBuilder) builder = NULL; G_OBJECT_CLASS (ephy_window_parent_class)->constructed (object); @@ -3649,19 +3616,22 @@ ephy_window_constructed (GObject *object) window->tab_view = setup_tab_view (window); window->tab_bar = adw_tab_bar_new (); window->tab_bar_revealer = GTK_REVEALER (gtk_revealer_new ()); - window->main_leaflet = adw_leaflet_new (); + window->overview = adw_tab_overview_new (); window->fullscreen_box = ephy_fullscreen_box_new (); - window->pages_view = ephy_pages_view_new (); - adw_leaflet_set_can_unfold (ADW_LEAFLET (window->main_leaflet), FALSE); - g_signal_connect_swapped (window->main_leaflet, "notify::visible-child", - G_CALLBACK (notify_leaflet_child_cb), window); + builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/tab-overview-menu.ui"); + + adw_tab_overview_set_enable_new_tab (ADW_TAB_OVERVIEW (window->overview), TRUE); + adw_tab_overview_set_secondary_menu (ADW_TAB_OVERVIEW (window->overview), + G_MENU_MODEL (gtk_builder_get_object (builder, "overview-menu"))); + g_signal_connect_swapped (window->overview, "notify::open", + G_CALLBACK (notify_overview_open_cb), window); + g_signal_connect_swapped (window->overview, "create-tab", + G_CALLBACK (create_tab_cb), window); gtk_revealer_set_transition_type (window->tab_bar_revealer, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN); adw_tab_bar_set_view (window->tab_bar, ephy_tab_view_get_tab_view (window->tab_view)); - ephy_pages_view_set_tab_view (window->pages_view, window->tab_view); - - setup_tabs_menu (window); + adw_tab_overview_set_view (ADW_TAB_OVERVIEW (window->overview), ephy_tab_view_get_tab_view (window->tab_view)); shell = ephy_shell_get_default (); mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell)); @@ -3692,14 +3662,12 @@ ephy_window_constructed (GObject *object) ephy_fullscreen_box_set_content (window->fullscreen_box, GTK_WIDGET (box)); ephy_fullscreen_box_set_titlebar (window->fullscreen_box, GTK_WIDGET (window->titlebar_box)); - adw_leaflet_append (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->fullscreen_box)); - adw_leaflet_append (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->pages_view)); - adw_application_window_set_content (ADW_APPLICATION_WINDOW (window), GTK_WIDGET (window->main_leaflet)); + adw_tab_overview_set_child (ADW_TAB_OVERVIEW (window->overview), + GTK_WIDGET (window->fullscreen_box)); + adw_application_window_set_content (ADW_APPLICATION_WINDOW (window), GTK_WIDGET (window->overview)); ephy_tab_view_set_tab_bar (window->tab_view, window->tab_bar); - - adw_leaflet_set_visible_child (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->fullscreen_box)); - adw_leaflet_set_can_navigate_back (ADW_LEAFLET (window->main_leaflet), TRUE); + ephy_tab_view_set_tab_overview (window->tab_view, ADW_TAB_OVERVIEW (window->overview)); /* other notifiers */ action_group = ephy_window_get_action_group (window, "win"); @@ -3875,7 +3843,7 @@ ephy_window_open_pages_view (EphyWindow *window) { g_assert (EPHY_IS_WINDOW (window)); - adw_leaflet_navigate (ADW_LEAFLET (window->main_leaflet), ADW_NAVIGATION_DIRECTION_FORWARD); + adw_tab_overview_set_open (ADW_TAB_OVERVIEW (window->overview), TRUE); } /** @@ -3889,7 +3857,7 @@ ephy_window_close_pages_view (EphyWindow *window) { g_assert (EPHY_IS_WINDOW (window)); - adw_leaflet_navigate (ADW_LEAFLET (window->main_leaflet), ADW_NAVIGATION_DIRECTION_BACK); + adw_tab_overview_set_open (ADW_TAB_OVERVIEW (window->overview), FALSE); } /** diff --git a/src/meson.build b/src/meson.build index 7e0b52438..1aa1f6b8a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -36,10 +36,6 @@ libephymain_sources = [ 'ephy-location-controller.c', 'ephy-lockdown.c', 'ephy-mouse-gesture-controller.c', - 'ephy-page-row.c', - 'ephy-pages-button.c', - 'ephy-pages-popover.c', - 'ephy-pages-view.c', 'ephy-session.c', 'ephy-shell.c', 'ephy-suggestion-model.c', diff --git a/src/resources/ephy-tab-counter-symbolic.svg b/src/resources/ephy-tab-counter-symbolic.svg deleted file mode 100644 index 02742970e..000000000 --- a/src/resources/ephy-tab-counter-symbolic.svg +++ /dev/null @@ -1,3 +0,0 @@ -<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"> - <path style="color:#bebebe;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#2e3436;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="M2.2 0C.943 0 0 1.1 0 2.318v11.364C0 14.9.944 16 2.2 16h11.6c1.256 0 2.2-1.1 2.2-2.318V2.318C16 1.1 15.056 0 13.8 0Zm0 2h11.6c.074 0 .2.075.2.318v11.364c0 .243-.126.318-.2.318H2.2c-.074 0-.2-.075-.2-.318V2.318C2 2.075 2.126 2 2.2 2Z"/> -</svg> diff --git a/src/resources/ephy-tab-overflow-symbolic.svg b/src/resources/ephy-tab-overflow-symbolic.svg deleted file mode 100644 index ca8a3780e..000000000 --- a/src/resources/ephy-tab-overflow-symbolic.svg +++ /dev/null @@ -1,4 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16"> - <path d="M2.2 0C.943 0 0 1.1 0 2.318v11.364C0 14.9.944 16 2.2 16h11.6c1.256 0 2.2-1.1 2.2-2.318V2.318C16 1.1 15.056 0 13.8 0Zm0 2h11.6c.074 0 .2.075.2.318v11.364c0 .243-.126.318-.2.318H2.2c-.074 0-.2-.075-.2-.318V2.318C2 2.075 2.126 2 2.2 2Z" style="color:#bebebe;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#241f31;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"/> - <path d="M-14.52 10.488c1.14 0 1.836-.66 2.388-1.44.504.78 1.176 1.44 2.388 1.44 1.572 0 2.628-1.068 2.628-2.64 0-1.488-.972-2.472-2.376-2.472-1.104 0-1.8.624-2.352 1.356-.48-.732-1.14-1.356-2.352-1.356-1.596 0-2.688 1.056-2.688 2.64 0 1.476.972 2.472 2.364 2.472zm-.804-2.58c0-.744.396-1.236 1.056-1.236.744 0 1.152.624 1.56 1.38-.42.636-.864 1.14-1.524 1.14-.672 0-1.092-.516-1.092-1.284zm5.544-1.236c.648 0 1.104.492 1.104 1.32 0 .72-.36 1.2-1.02 1.2-.78 0-1.176-.672-1.572-1.452.408-.6.852-1.068 1.488-1.068z" transform="translate(20)" style="font-style:normal;font-variant:normal;font-weight:700;font-stretch:normal;font-size:12px;line-height:1.25;font-family:Cantarell;-inkscape-font-specification:'Cantarell Bold';text-align:center;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#241f31;fill-opacity:1;stroke:none" aria-label="∞"/> -</svg> diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml index 120497952..27b389897 100644 --- a/src/resources/epiphany.gresource.xml +++ b/src/resources/epiphany.gresource.xml @@ -18,10 +18,6 @@ <file preprocess="xml-stripblanks" compressed="true">gtk/location-entry.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/notebook-context-menu.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/page-menu-popover.ui</file> - <file preprocess="xml-stripblanks" compressed="true">gtk/page-row.ui</file> - <file preprocess="xml-stripblanks" compressed="true">gtk/pages-button.ui</file> - <file preprocess="xml-stripblanks" compressed="true">gtk/pages-popover.ui</file> - <file preprocess="xml-stripblanks" compressed="true">gtk/pages-view.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/passwords-view.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/prefs-appearance-page.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/prefs-dialog.ui</file> @@ -32,6 +28,7 @@ <file preprocess="xml-stripblanks" compressed="true">gtk/search-engine-row.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/synced-tabs-dialog.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/shortcuts-dialog.ui</file> + <file preprocess="xml-stripblanks" compressed="true">gtk/tab-overview-menu.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/webapp-additional-urls-dialog.ui</file> <file preprocess="xml-stripblanks" compressed="true">gtk/web-extensions-dialog.ui</file> </gresource> @@ -59,8 +56,6 @@ <file compressed="true" alias="scalable/status/ephy-non-starred-symbolic.svg">ephy-non-starred-symbolic.svg</file> <file compressed="true" alias="scalable/status/ephy-open-link-symbolic.svg">ephy-open-link-symbolic.svg</file> <file compressed="true" alias="scalable/status/ephy-starred-symbolic.svg">ephy-starred-symbolic.svg</file> - <file compressed="true" alias="scalable/status/ephy-tab-counter-symbolic.svg">ephy-tab-counter-symbolic.svg</file> - <file compressed="true" alias="scalable/status/ephy-tab-overflow-symbolic.svg">ephy-tab-overflow-symbolic.svg</file> <file compressed="true" alias="scalable/status/ephy-library-symbolic.svg">ephy-library-symbolic.svg</file> <file compressed="true" alias="scalable/status/ephy-webpage-symbolic.svg">ephy-webpage-symbolic.svg</file> </gresource> diff --git a/src/resources/gtk/action-bar-end.ui b/src/resources/gtk/action-bar-end.ui index 08ac80396..05676cbf8 100644 --- a/src/resources/gtk/action-bar-end.ui +++ b/src/resources/gtk/action-bar-end.ui @@ -28,6 +28,12 @@ </object> </child> <child> + <object class="GtkButton" id="overview_button"> + <property name="icon-name">view-grid-symbolic</property> + <property name="action-name">win.tabs-view</property> + </object> + </child> + <child> <object class="GtkMenuButton" id="bookmark_button"> <!-- Translators: tooltip for the bookmark button --> <property name="tooltip_text" translatable="yes">Bookmark page</property> diff --git a/src/resources/gtk/action-bar.ui b/src/resources/gtk/action-bar.ui index dc1851c20..162035fb8 100644 --- a/src/resources/gtk/action-bar.ui +++ b/src/resources/gtk/action-bar.ui @@ -10,9 +10,7 @@ <object class="EphyActionBarStart" id="action_bar_start"/> </child> <child type="end"> - <object class="EphyPagesButton" id="pages_button"> - <!-- Translators: tooltip for the page switcher button --> - <property name="tooltip_text" translatable="yes">View open pages</property> + <object class="AdwTabButton" id="pages_button"> <property name="action_name">win.tabs-view</property> </object> </child> diff --git a/src/resources/gtk/page-row.ui b/src/resources/gtk/page-row.ui deleted file mode 100644 index e3a301fe8..000000000 --- a/src/resources/gtk/page-row.ui +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> -<interface> - <requires lib="gtk+" version="3.16"/> - <template class="EphyPageRow" parent="GtkListBoxRow"> - <signal name="map" handler="update_spinner" swapped="true"/> - <signal name="unmap" handler="update_spinner" swapped="true"/> - <child> - <object class="GtkGestureClick"> - <property name="button">2</property> - <signal name="released" handler="released_cb"/> - </object> - </child> - <child> - <object class="GtkBox" id="box"> - <property name="margin-start">3</property> - <property name="margin-end">1</property> - <child> - <object class="GtkStack" id="icon_stack"> - <property name="margin_start">4</property> - <property name="margin_end">4</property> - <child> - <object class="GtkImage" id="icon"> - <property name="pixel_size">16</property> - <property name="margin_top">6</property> - <property name="margin_bottom">6</property> - </object> - </child> - <child> - <object class="GtkSpinner" id="spinner"/> - </child> - </object> - </child> - <child> - <object class="GtkLabel" id="title"> - <property name="margin_start">4</property> - <property name="hexpand">True</property> - <property name="ellipsize">end</property> - <property name="single_line_mode">True</property> - <property name="xalign">0</property> - </object> - </child> - <child> - <object class="GtkImage" id="speaker_icon"> - <property name="margin_start">8</property> - <property name="icon_name">audio-volume-high-symbolic</property> - </object> - </child> - <child> - <object class="GtkButton" id="close_button"> - <property name="focus_on_click">False</property> - <property name="tooltip_text" translatable="yes">Close page</property> - <property name="valign">center</property> - <property name="icon_name">window-close-symbolic</property> - <signal name="clicked" handler="close_clicked_cb" swapped="yes"/> - <style> - <class name="flat"/> - <class name="close-button"/> - </style> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/src/resources/gtk/pages-button.ui b/src/resources/gtk/pages-button.ui deleted file mode 100644 index c42512a02..000000000 --- a/src/resources/gtk/pages-button.ui +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <!-- interface-requires gtk+ 3.16 --> - <template class="EphyPagesButton" parent="GtkButton"> - <style> - <class name="image-button"/> - </style> - <child> - <object class="GtkOverlay"> - <property name="can-focus">False</property> - <child> - <object class="GtkImage" id="pages_icon"/> - </child> - <child type="overlay"> - <object class="GtkLabel" id="pages_label"> - <property name="width-chars">2</property> - <attributes> - <attribute name="font-features" value="tnum=1"/> - <attribute name="size" value="7000"/> - <attribute name="weight" value="ultrabold"/> - </attributes> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/src/resources/gtk/pages-popover.ui b/src/resources/gtk/pages-popover.ui deleted file mode 100644 index e17212aa9..000000000 --- a/src/resources/gtk/pages-popover.ui +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <!-- interface-requires gtk+ 3.16 --> - <template class="EphyPagesPopover" parent="GtkPopover"> - <style> - <class name="menu"/> - </style> - <child> - <object class="GtkScrolledWindow" id="scrolled_window"> - <property name="hscrollbar_policy">never</property> - <property name="propagate_natural_height">True</property> - <property name="max-content-height">700</property> - <child> - <object class="GtkListBox" id="list_box"> - <property name="selection_mode">single</property> - <property name="width_request">300</property> - <signal name="row-activated" handler="row_activated_cb" swapped="true"/> - <style> - <class name="pages-list"/> - </style> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/src/resources/gtk/pages-view.ui b/src/resources/gtk/pages-view.ui deleted file mode 100644 index 1077a53db..000000000 --- a/src/resources/gtk/pages-view.ui +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <!-- interface-requires gtk+ 3.16 --> - <template class="EphyPagesView" parent="GtkBox"> - <property name="name">pages-view</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkHeaderBar"> - <property name="title-widget"> - <object class="AdwWindowTitle"> - <property name="title" translatable="yes">Tabs</property> - </object> - </property> - <child type="start"> - <object class="GtkButton"> - <property name="action-name">win.content</property> - <property name="icon-name">go-previous-symbolic</property> - </object> - </child> - <child type="end"> - <object class="GtkButton"> - <property name="action-name">win.new-tab</property> - <property name="icon-name">tab-new-symbolic</property> - </object> - </child> - </object> - </child> - <child> - <object class="GtkScrolledWindow"> - <property name="hscrollbar_policy">never</property> - <property name="vexpand">True</property> - <child> - <object class="GtkListBox" id="list_box"> - <property name="selection_mode">single</property> - <property name="width_request">300</property> - <signal name="row-activated" handler="row_activated_cb" swapped="true"/> - <style> - <class name="pages-list"/> - <class name="navigation-sidebar"/> - </style> - </object> - </child> - </object> - </child> - </template> -</interface> diff --git a/src/resources/gtk/tab-overview-menu.ui b/src/resources/gtk/tab-overview-menu.ui new file mode 100644 index 000000000..13e87290c --- /dev/null +++ b/src/resources/gtk/tab-overview-menu.ui @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <menu id="overview-menu"> + <section> + <item> + <attribute name="label" translatable="yes">_New Window</attribute> + <attribute name="action">app.new-window</attribute> + </item> + <item> + <attribute name="label" translatable="yes">New _Incognito Window</attribute> + <attribute name="action">app.new-incognito</attribute> + </item> + </section> + <section> + <item> + <attribute name="label" translatable="yes">Reopen Closed _Tab</attribute> + <attribute name="action">app.reopen-closed-tab</attribute> + </item> + </section> + </menu> +</interface> diff --git a/src/resources/style.css b/src/resources/style.css index 6889ae971..5289351a7 100644 --- a/src/resources/style.css +++ b/src/resources/style.css @@ -193,23 +193,6 @@ fullscreenbox > flap > shadow { background: linear-gradient(to bottom, alpha(black, .1), alpha(black, .0)); } -.pages-list row { - min-height: 30px; - padding: 3px; -} - -.pages-list .close-button { - border-radius: 100%; - padding: 0; - min-width: 28px; - min-height: 28px; -} - -#pages-view .close-button { - min-width: 36px; - min-height: 36px; -} - dnd > .boxed-list { margin: 6px; background-color: @window_bg_color; diff --git a/src/window-commands.c b/src/window-commands.c index 215fa2187..265e76fc7 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -1338,7 +1338,6 @@ window_cmd_new_tab (GSimpleAction *action, ephy_link_open (EPHY_LINK (window), url, NULL, EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO); - ephy_window_close_pages_view (window); g_free (url); } |