[epiphany/wip/exalm/tabs: 43/57] tmp
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/tabs: 43/57] tmp
- Date: Mon, 16 Nov 2020 12:56:41 +0000 (UTC)
commit ca93e1093377c3e4c6a93e3ecbe451406693eba0
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Nov 16 13:22:52 2020 +0500
tmp
org.gnome.Epiphany.json | 18 +
src/ephy-action-bar.c | 26 +-
src/ephy-action-bar.h | 3 -
src/ephy-desktop-utils.c | 4 +-
src/ephy-header-bar.c | 1 -
src/ephy-location-controller.c | 35 +-
src/ephy-notebook.c | 1185 -----------------------
src/ephy-notebook.h | 62 --
src/ephy-page-row.c | 192 ++--
src/ephy-page-row.h | 12 +-
src/ephy-pages-popover.c | 274 ------
src/ephy-pages-popover.h | 41 -
src/ephy-pages-view.c | 166 +---
src/ephy-pages-view.h | 8 +-
src/ephy-session.c | 173 ++--
src/ephy-shell.c | 11 +-
src/ephy-suggestion-model.c | 15 +-
src/ephy-tab-label.c | 470 ---------
src/ephy-tab-label.h | 41 -
src/ephy-tab-view.c | 453 +++++++++
src/ephy-tab-view.h | 77 ++
src/ephy-window.c | 497 ++++------
src/ephy-window.h | 3 +-
src/meson.build | 4 +-
src/resources/ephy-missing-favicon-symbolic.svg | 32 -
src/resources/epiphany.gresource.xml | 2 -
src/resources/gtk/page-row.ui | 7 +
src/resources/gtk/tab-label.ui | 90 --
src/resources/themes/_Adwaita-base.scss | 33 -
src/resources/themes/elementary.scss | 6 -
src/window-commands.c | 219 +----
src/window-commands.h | 12 -
32 files changed, 1056 insertions(+), 3116 deletions(-)
---
diff --git a/org.gnome.Epiphany.json b/org.gnome.Epiphany.json
index 35c4a03a0..3ee5d0f07 100644
--- a/org.gnome.Epiphany.json
+++ b/org.gnome.Epiphany.json
@@ -30,6 +30,24 @@
}
]
},
+ {
+ "name" : "libhandy",
+ "buildsystem" : "meson",
+ "config-opts" : [
+ "-Dexamples=false",
+ "-Dglade_catalog=disabled",
+ "-Dintrospection=disabled",
+ "-Dtests=false",
+ "-Dvapi=false"
+ ],
+ "sources" : [
+ {
+ "type" : "git",
+ "url" : "https://gitlab.gnome.org/exalm/libhandy.git",
+ "branch" : "tabs"
+ }
+ ]
+ },
{
"name" : "libportal",
"buildsystem" : "meson",
diff --git a/src/ephy-action-bar.c b/src/ephy-action-bar.c
index ecd9a2152..97715544b 100644
--- a/src/ephy-action-bar.c
+++ b/src/ephy-action-bar.c
@@ -21,9 +21,9 @@
#include "ephy-action-bar.h"
#include "ephy-pages-button.h"
-#include "ephy-pages-popover.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
+#include "ephy-tab-view.h"
enum {
PROP_0,
@@ -40,7 +40,6 @@ struct _EphyActionBar {
EphyActionBarStart *action_bar_start;
EphyActionBarEnd *action_bar_end;
EphyPagesButton *pages_button;
- GtkNotebook *notebook;
EphyAdaptiveMode adaptive_mode;
gboolean can_reveal;
@@ -61,15 +60,6 @@ sync_chromes_visibility (EphyActionBar *action_bar)
chrome & EPHY_WINDOW_CHROME_BOOKMARKS);
}
-static void
-update_pages_button (EphyActionBar *action_bar)
-{
- int n_pages;
-
- n_pages = gtk_notebook_get_n_pages (action_bar->notebook);
- ephy_pages_button_set_n_pages (action_bar->pages_button, n_pages);
-}
-
static void
update_revealer (EphyActionBar *action_bar)
{
@@ -140,24 +130,22 @@ static void
ephy_action_bar_constructed (GObject *object)
{
EphyActionBar *action_bar = EPHY_ACTION_BAR (object);
+ EphyTabView *view;
G_OBJECT_CLASS (ephy_action_bar_parent_class)->constructed (object);
- action_bar->notebook = GTK_NOTEBOOK (ephy_window_get_notebook (action_bar->window));
- update_pages_button (action_bar);
+ view = ephy_window_get_tab_view (action_bar->window);
g_signal_connect_object (action_bar->window, "notify::chrome",
G_CALLBACK (sync_chromes_visibility), action_bar,
G_CONNECT_SWAPPED);
- g_signal_connect_object (action_bar->notebook, "page-added",
- G_CALLBACK (update_pages_button), action_bar,
- G_CONNECT_SWAPPED);
- g_signal_connect_object (action_bar->notebook, "page-removed",
- G_CALLBACK (update_pages_button), action_bar,
- G_CONNECT_SWAPPED);
g_signal_connect_object (DZL_APPLICATION_WINDOW (action_bar->window), "notify::titlebar-animation",
G_CALLBACK (titlebar_animation_changed), action_bar,
G_CONNECT_SWAPPED);
+
+ g_object_bind_property (view, "n-pages",
+ action_bar->pages_button, "n-pages",
+ G_BINDING_SYNC_CREATE);
}
static void
diff --git a/src/ephy-action-bar.h b/src/ephy-action-bar.h
index da94137af..390e92007 100644
--- a/src/ephy-action-bar.h
+++ b/src/ephy-action-bar.h
@@ -26,7 +26,6 @@
#include "ephy-action-bar-end.h"
#include "ephy-action-bar-start.h"
#include "ephy-adaptive-mode.h"
-#include "ephy-notebook.h"
#include "ephy-window.h"
G_BEGIN_DECLS
@@ -38,8 +37,6 @@ G_DECLARE_FINAL_TYPE (EphyActionBar, ephy_action_bar, EPHY, ACTION_BAR, GtkRevea
EphyActionBar *ephy_action_bar_new (EphyWindow *window);
EphyActionBarStart *ephy_action_bar_get_action_bar_start (EphyActionBar *action_bar);
EphyActionBarEnd *ephy_action_bar_get_action_bar_end (EphyActionBar *action_bar);
-void ephy_action_bar_set_notebook (EphyActionBar *action_bar,
- EphyNotebook *notebook);
void ephy_action_bar_set_adaptive_mode (EphyActionBar *action_bar,
EphyAdaptiveMode adaptive_mode);
diff --git a/src/ephy-desktop-utils.c b/src/ephy-desktop-utils.c
index 008ed4d6c..6d5412aa5 100644
--- a/src/ephy-desktop-utils.c
+++ b/src/ephy-desktop-utils.c
@@ -61,10 +61,10 @@ ephy_get_fallback_favicon_name (const char *uri,
{
if (uri) {
if (g_str_has_prefix (uri, "ephy-about:overview") || g_str_has_prefix (uri, "about:overview"))
- return "view-grid-symbolic";
+ return (type == EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER) ? "view-grid-symbolic" : NULL;
else if (g_str_has_prefix (uri, "ephy-about:") || g_str_has_prefix (uri, "about:"))
return "web-browser-symbolic";
}
- return type == EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER ? "ephy-missing-favicon-symbolic" : NULL;
+ return NULL;
}
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index c0fd583c0..7e83823c1 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -29,7 +29,6 @@
#include "ephy-file-helpers.h"
#include "ephy-flatpak-utils.h"
#include "ephy-location-entry.h"
-#include "ephy-notebook.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-title-box.h"
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 01175c445..f9eaa6b1d 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -147,15 +147,14 @@ entry_activate_cb (GtkEntry *entry,
return;
if (g_str_has_prefix (content, "ephy-tab://")) {
- GtkWidget *notebook = ephy_window_get_notebook (controller->window);
+ EphyTabView *tab_view = ephy_window_get_tab_view (controller->window);
GtkWidget *tab;
EphyWebView *webview;
- gint current = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
g_auto (GStrv) split = g_strsplit (content + strlen ("ephy-tab://"), "@", -1);
g_assert (g_strv_length (split) == 2);
- tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), current);
+ tab = ephy_tab_view_get_selected_page (tab_view);
webview = ephy_embed_get_web_view (EPHY_EMBED (tab));
if (atoi (split[1]) != 0) {
@@ -169,15 +168,15 @@ entry_activate_cb (GtkEntry *entry,
windows = gtk_application_get_windows (GTK_APPLICATION (application));
window = g_list_nth_data (windows, atoi (split[1]));
- notebook = ephy_window_get_notebook (window);
+ tab_view = ephy_window_get_tab_view (window);
gtk_window_present (GTK_WINDOW (window));
}
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), atoi (split[0]));
+ ephy_tab_view_select_nth_page (tab_view, atoi (split[0]));
if (ephy_web_view_is_overview (webview))
- g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", tab);
+ ephy_tab_view_close (tab_view, tab);
return;
}
@@ -295,10 +294,7 @@ focus_out_event_cb (GtkWidget *entry,
}
static void
-switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphyLocationController *controller)
+notify_selected_index_cb (EphyLocationController *controller)
{
if (controller->sync_address_is_blocked == TRUE) {
controller->sync_address_is_blocked = FALSE;
@@ -343,15 +339,17 @@ ephy_location_controller_constructed (GObject *object)
EphyHistoryService *history_service;
EphyBookmarksManager *bookmarks_manager;
EphySuggestionModel *model;
- GtkWidget *notebook, *widget, *reader_mode, *entry;
+ EphyTabView *tab_view;
+ GtkWidget *widget, *reader_mode, *entry;
G_OBJECT_CLASS (ephy_location_controller_parent_class)->constructed (object);
- notebook = ephy_window_get_notebook (controller->window);
+ tab_view = ephy_window_get_tab_view (controller->window);
widget = GTK_WIDGET (controller->title_widget);
- g_signal_connect (notebook, "switch-page",
- G_CALLBACK (switch_page_cb), controller);
+ g_signal_connect_object (tab_view, "notify::selected-index",
+ G_CALLBACK (notify_selected_index_cb), controller,
+ G_CONNECT_SWAPPED);
sync_address (controller, NULL, widget);
g_signal_connect_object (controller, "notify::address",
@@ -446,14 +444,9 @@ static void
ephy_location_controller_dispose (GObject *object)
{
EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
- GtkWidget *notebook;
- notebook = ephy_window_get_notebook (controller->window);
-
- if (notebook == NULL ||
- controller->title_widget == NULL) {
+ if (controller->title_widget == NULL)
return;
- }
g_clear_object (&controller->longpress_gesture);
@@ -463,8 +456,6 @@ ephy_location_controller_dispose (GObject *object)
g_signal_handlers_disconnect_matched (controller->title_widget, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, controller);
}
- g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, controller);
controller->title_widget = NULL;
G_OBJECT_CLASS (ephy_location_controller_parent_class)->dispose (object);
diff --git a/src/ephy-page-row.c b/src/ephy-page-row.c
index adacca81a..ea4a000f5 100644
--- a/src/ephy-page-row.c
+++ b/src/ephy-page-row.c
@@ -22,67 +22,30 @@
#include "config.h"
#include "ephy-desktop-utils.h"
-#include "ephy-embed-utils.h"
+#include "ephy-embed.h"
#include "ephy-page-row.h"
#include "ephy-web-view.h"
-enum {
- CLOSED,
-
- LAST_SIGNAL
-};
-
struct _EphyPageRow {
GtkPopover parent_instance;
- GtkBox *box;
GtkImage *icon;
GtkStack *icon_stack;
GtkImage *speaker_icon;
GtkSpinner *spinner;
GtkLabel *title;
GtkButton *close_button;
-};
-static guint signals[LAST_SIGNAL];
+ HdyTabPage *page;
+ EphyTabView *tab_view;
+};
G_DEFINE_TYPE (EphyPageRow, ephy_page_row, GTK_TYPE_LIST_BOX_ROW)
-static void
-sync_load_status (EphyWebView *view,
- GParamSpec *pspec,
- EphyPageRow *self)
-{
- EphyEmbed *embed;
-
- g_assert (EPHY_IS_WEB_VIEW (view));
- g_assert (EPHY_IS_PAGE_ROW (self));
-
- embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (view);
-
- g_assert (EPHY_IS_EMBED (embed));
-
- if (ephy_web_view_is_loading (view) && !ephy_embed_has_load_pending (embed)) {
- gtk_stack_set_visible_child (self->icon_stack, GTK_WIDGET (self->spinner));
- gtk_spinner_start (GTK_SPINNER (self->spinner));
- } else {
- gtk_stack_set_visible_child (self->icon_stack, GTK_WIDGET (self->icon));
- gtk_spinner_stop (GTK_SPINNER (self->spinner));
- }
-}
-
-static void
-load_changed_cb (EphyWebView *view,
- WebKitLoadEvent load_event,
- EphyPageRow *self)
-{
- sync_load_status (view, NULL, self);
-}
-
static void
close_clicked_cb (EphyPageRow *self)
{
- g_signal_emit (self, signals[CLOSED], 0);
+ hdy_tab_view_close_page (ephy_tab_view_get_tab_view (self->tab_view), self->page);
}
static gboolean
@@ -93,7 +56,7 @@ button_release_event (GtkWidget *widget,
GdkEventButton *button_event = (GdkEventButton *)event;
if (button_event->button == GDK_BUTTON_MIDDLE) {
- g_signal_emit (self, signals[CLOSED], 0);
+ hdy_tab_view_close_page (ephy_tab_view_get_tab_view (self->tab_view), self->page);
return GDK_EVENT_STOP;
}
@@ -106,15 +69,7 @@ ephy_page_row_class_init (EphyPageRowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- signals[CLOSED] =
- g_signal_new ("closed",
- EPHY_TYPE_PAGE_ROW,
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-
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);
@@ -131,93 +86,100 @@ 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
-sync_favicon (EphyWebView *view,
- GParamSpec *pspec,
- EphyPageRow *self)
+update_icon_cb (EphyPageRow *self)
{
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (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;
+ HdyTabView *tab_view;
+
+ if (icon) {
+ gtk_image_set_from_gicon (self->icon, icon, GTK_ICON_SIZE_MENU);
- if (ephy_web_view_get_icon (view))
- pixbuf = gdk_pixbuf_copy (ephy_web_view_get_icon (view));
+ return;
+ }
- if (pixbuf) {
- cairo_surface_t *surface;
+ uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view));
+ favicon_name = ephy_get_fallback_favicon_name (uri, EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER);
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf,
- 0,
- gtk_widget_get_window (GTK_WIDGET (view)));
- gtk_image_set_from_surface (GTK_IMAGE (self->icon), surface);
- cairo_surface_destroy (surface);
- } else {
- const char *favicon_name = ephy_get_fallback_favicon_name (ephy_web_view_get_display_address (view),
EPHY_FAVICON_TYPE_SHOW_MISSING_PLACEHOLDER);
+ if (favicon_name) {
+ g_autoptr (GIcon) fallback_icon = g_themed_icon_new (favicon_name);
- gtk_image_set_from_icon_name (GTK_IMAGE (self->icon), favicon_name, GTK_ICON_SIZE_MENU);
+ gtk_image_set_from_gicon (self->icon, fallback_icon, GTK_ICON_SIZE_MENU);
+
+ return;
}
+
+ tab_view = ephy_tab_view_get_tab_view (self->tab_view);
+
+ gtk_image_set_from_gicon (self->icon, hdy_tab_view_get_default_icon (tab_view), GTK_ICON_SIZE_MENU);
}
EphyPageRow *
-ephy_page_row_new (EphyNotebook *notebook,
- gint position)
+ephy_page_row_new (EphyTabView *tab_view,
+ HdyTabPage *page)
{
EphyPageRow *self;
- GtkWidget *embed;
- GtkWidget *tab_label;
+ GtkWidget *embed = hdy_tab_page_get_content (page);
EphyWebView *view;
- g_assert (notebook != NULL);
- g_assert (position >= 0);
-
- self = g_object_new (EPHY_TYPE_PAGE_ROW, NULL);
-
- embed = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), position);
-
+ g_assert (HDY_IS_TAB_PAGE (page));
g_assert (EPHY_IS_EMBED (embed));
- tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), embed);
view = ephy_embed_get_web_view (EPHY_EMBED (embed));
- sync_favicon (view, NULL, self);
- g_signal_connect_object (view, "notify::icon", G_CALLBACK (sync_favicon), self, 0);
- g_object_bind_property (embed, "title", self->title, "label", G_BINDING_SYNC_CREATE);
- g_object_bind_property (embed, "title", self->title, "tooltip-text", G_BINDING_SYNC_CREATE);
- g_object_bind_property (view, "is-playing-audio", self->speaker_icon, "visible", G_BINDING_SYNC_CREATE);
- g_object_bind_property (tab_label, "pinned", self->close_button, "visible", G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
- sync_load_status (view, NULL, self);
- g_signal_connect_object (view, "load-changed",
- G_CALLBACK (load_changed_cb), self, 0);
+ 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, "secondary-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 (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)
+HdyTabPage *
+ephy_page_row_get_page (EphyPageRow *self)
{
- GtkStyleContext *context;
-
g_assert (EPHY_IS_PAGE_ROW (self));
- context = gtk_widget_get_style_context (GTK_WIDGET (self));
-
- switch (adaptive_mode) {
- case EPHY_ADAPTIVE_MODE_NORMAL:
- gtk_widget_set_size_request (GTK_WIDGET (self->box), -1, -1);
- gtk_widget_set_margin_end (GTK_WIDGET (self->box), 0);
- gtk_widget_set_margin_start (GTK_WIDGET (self->box), 4);
- gtk_box_set_spacing (self->box, 0);
-
- gtk_style_context_remove_class (context, "narrow");
-
- break;
- case EPHY_ADAPTIVE_MODE_NARROW:
- gtk_widget_set_size_request (GTK_WIDGET (self->box), -1, 50);
- gtk_widget_set_margin_end (GTK_WIDGET (self->box), 4);
- gtk_widget_set_margin_start (GTK_WIDGET (self->box), 8);
- gtk_box_set_spacing (self->box, 4);
-
- gtk_style_context_add_class (context, "narrow");
-
- break;
- }
+ return self->page;
}
diff --git a/src/ephy-page-row.h b/src/ephy-page-row.h
index 337a7ba92..6369359d7 100644
--- a/src/ephy-page-row.h
+++ b/src/ephy-page-row.h
@@ -21,9 +21,8 @@
#pragma once
-#include <gtk/gtk.h>
-#include "ephy-adaptive-mode.h"
-#include "ephy-notebook.h"
+#include <handy.h>
+#include "ephy-tab-view.h"
G_BEGIN_DECLS
@@ -31,10 +30,9 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyPageRow, ephy_page_row, EPHY, PAGE_ROW, GtkListBoxRow)
-EphyPageRow *ephy_page_row_new (EphyNotebook *notebook,
- int position);
+EphyPageRow *ephy_page_row_new (EphyTabView *view,
+ HdyTabPage *page);
-void ephy_page_row_set_adaptive_mode (EphyPageRow *self,
- EphyAdaptiveMode adaptive_mode);
+HdyTabPage *ephy_page_row_get_page (EphyPageRow *self);
G_END_DECLS
diff --git a/src/ephy-pages-view.c b/src/ephy-pages-view.c
index 13485f816..8ac9d424d 100644
--- a/src/ephy-pages-view.c
+++ b/src/ephy-pages-view.c
@@ -24,7 +24,6 @@
#include "ephy-pages-view.h"
-#include "ephy-notebook.h"
#include "ephy-page-row.h"
#include "ephy-window.h"
@@ -33,127 +32,68 @@ struct _EphyPagesView {
GtkListBox *list_box;
- GListStore *list_store;
- EphyNotebook *notebook;
- EphyAdaptiveMode adaptive_mode;
+ GListModel *model;
+ EphyTabView *tab_view;
};
G_DEFINE_TYPE (EphyPagesView, ephy_pages_view, GTK_TYPE_SCROLLED_WINDOW)
static void
-drop_notebook (EphyPagesView *self)
+drop_tab_view (EphyPagesView *self)
{
- self->notebook = NULL;
- g_list_store_remove_all (self->list_store);
+ self->tab_view = NULL;
}
static void
-release_notebook (EphyPagesView *self)
+release_tab_view (EphyPagesView *self)
{
- if (self->notebook) {
- g_object_weak_unref (G_OBJECT (self->notebook), (GWeakNotify)drop_notebook, self);
- drop_notebook (self);
+ if (self->tab_view) {
+ g_object_weak_unref (G_OBJECT (self->tab_view), (GWeakNotify)drop_tab_view, self);
+ drop_tab_view (self);
}
}
-static GtkWidget *
-create_row (gpointer item,
- gpointer user_data)
-{
- return GTK_WIDGET (g_object_ref (G_OBJECT (item)));
-}
-
static void
row_activated_cb (EphyPagesView *self,
- GtkListBoxRow *row)
+ EphyPageRow *row)
{
- gint new_page;
EphyWindow *window;
GApplication *application;
+ HdyTabPage *page;
g_assert (EPHY_IS_PAGES_VIEW (self));
- g_assert (!row || GTK_IS_LIST_BOX_ROW (row));
+ 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));
- if (!row)
- return;
-
- new_page = gtk_list_box_row_get_index (row);
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (self->notebook), new_page);
+ hdy_tab_view_set_selected_page (ephy_tab_view_get_tab_view (self->tab_view), page);
ephy_window_close_pages_view (window);
}
-static void
-row_closed_cb (EphyPagesView *self,
- EphyPageRow *row)
-{
- GtkWindow *window;
- GtkWidget *embed;
- EphyEmbedShell *shell;
-
- g_assert (EPHY_IS_PAGES_VIEW (self));
- g_assert (EPHY_IS_PAGE_ROW (row));
-
- shell = ephy_embed_shell_get_default ();
- window = gtk_application_get_active_window (GTK_APPLICATION (shell));
-
- embed = gtk_notebook_get_nth_page (GTK_NOTEBOOK (self->notebook),
- gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (row)));
- g_signal_emit_by_name (self->notebook,
- "tab-close-request",
- embed, window);
-}
-
-
-static void
-current_page_changed (EphyPagesView *self)
-{
- GtkListBoxRow *current_row, *new_row;
- gint current_page;
-
- g_assert (EPHY_IS_PAGES_VIEW (self));
-
- current_row = gtk_list_box_get_selected_row (self->list_box);
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (self->notebook));
- if (current_row && gtk_list_box_row_get_index (current_row) == current_page)
- return;
-
- new_row = gtk_list_box_get_row_at_index (self->list_box, current_page);
- gtk_list_box_select_row (self->list_box, new_row);
-}
-
-static void
-items_changed_cb (EphyPagesView *self,
- gint position,
- gint removed,
- gint added,
- GMenuModel *menu_model)
+static GtkWidget *
+create_row (HdyTabPage *page,
+ EphyPagesView *self)
{
- g_autofree EphyPageRow **items = g_new (EphyPageRow *, added);
+ EphyPageRow *row = ephy_page_row_new (self->tab_view, page);
- for (int i = 0; i < added; i++) {
- items[i] = ephy_page_row_new (self->notebook, position + i);
- ephy_page_row_set_adaptive_mode (EPHY_PAGE_ROW (items[i]),
- EPHY_ADAPTIVE_MODE_NARROW);
- g_signal_connect_swapped (items[i], "closed", G_CALLBACK (row_closed_cb), self);
- }
+ gtk_widget_show (GTK_WIDGET (row));
- g_list_store_splice (self->list_store, position, removed, (gpointer)items, added);
-
- current_page_changed (self);
+ return GTK_WIDGET (row);
}
static void
-ephy_pages_view_finalize (GObject *object)
+selected_page_changed_cb (HdyTabView *tab_view,
+ GParamSpec *pspec,
+ EphyPagesView *self)
{
- EphyPagesView *self = EPHY_PAGES_VIEW (object);
+ HdyTabPage *page = hdy_tab_view_get_selected_page (tab_view);
+ gint position = hdy_tab_view_get_page_position (tab_view, page);
+ GtkListBoxRow *row;
- g_object_unref (self->list_store);
-
- G_OBJECT_CLASS (ephy_pages_view_parent_class)->finalize (object);
+ row = gtk_list_box_get_row_at_index (self->list_box, position);
+ gtk_list_box_select_row (self->list_box, row);
}
static void
@@ -161,7 +101,7 @@ ephy_pages_view_dispose (GObject *object)
{
EphyPagesView *self = EPHY_PAGES_VIEW (object);
- release_notebook (self);
+ release_tab_view (self);
G_OBJECT_CLASS (ephy_pages_view_parent_class)->dispose (object);
}
@@ -173,7 +113,6 @@ ephy_pages_view_class_init (EphyPagesViewClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = ephy_pages_view_dispose;
- object_class->finalize = ephy_pages_view_finalize;
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);
@@ -207,14 +146,6 @@ ephy_pages_view_init (EphyPagesView *self)
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_header_func (self->list_box, separator_header, NULL, NULL);
-
- self->list_store = g_list_store_new (EPHY_TYPE_PAGE_ROW);
-
- gtk_list_box_bind_model (self->list_box,
- G_LIST_MODEL (self->list_store),
- create_row,
- NULL,
- NULL);
}
EphyPagesView *
@@ -223,39 +154,40 @@ ephy_pages_view_new (void)
return g_object_new (EPHY_TYPE_PAGES_VIEW, NULL);
}
-EphyNotebook *
-ephy_pages_view_get_notebook (EphyPagesView *self)
+EphyTabView *
+ephy_pages_view_get_tab_view (EphyPagesView *self)
{
g_assert (EPHY_IS_PAGES_VIEW (self));
- return self->notebook;
+ return self->tab_view;
}
void
-ephy_pages_view_set_notebook (EphyPagesView *self,
- EphyNotebook *notebook)
+ephy_pages_view_set_tab_view (EphyPagesView *self,
+ EphyTabView *tab_view)
{
- GMenu *pages_menu;
-
g_assert (EPHY_IS_PAGES_VIEW (self));
- if (self->notebook)
- release_notebook (self);
+ if (self->tab_view)
+ release_tab_view (self);
- if (!notebook)
+ if (!tab_view)
return;
- g_object_weak_ref (G_OBJECT (notebook), (GWeakNotify)drop_notebook, self);
- self->notebook = notebook;
- pages_menu = ephy_notebook_get_pages_menu (EPHY_NOTEBOOK (notebook));
+ g_object_weak_ref (G_OBJECT (tab_view), (GWeakNotify)drop_tab_view, self);
+ self->tab_view = tab_view;
+
+ self->model = hdy_tab_view_get_pages (ephy_tab_view_get_tab_view (tab_view));
- items_changed_cb (self, 0, 0,
- g_menu_model_get_n_items (G_MENU_MODEL (pages_menu)),
- G_MENU_MODEL (pages_menu));
+ gtk_list_box_bind_model (self->list_box,
+ self->model,
+ (GtkListBoxCreateWidgetFunc)create_row,
+ self,
+ NULL);
- g_signal_connect_object (pages_menu,
- "items-changed",
- G_CALLBACK (items_changed_cb),
+ g_signal_connect_object (ephy_tab_view_get_tab_view (tab_view),
+ "notify::selected-page",
+ G_CALLBACK (selected_page_changed_cb),
self,
- G_CONNECT_SWAPPED);
+ 0);
}
diff --git a/src/ephy-pages-view.h b/src/ephy-pages-view.h
index fe8cd91ce..47f137b44 100644
--- a/src/ephy-pages-view.h
+++ b/src/ephy-pages-view.h
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
#include "ephy-adaptive-mode.h"
-#include "ephy-notebook.h"
+#include "ephy-tab-view.h"
G_BEGIN_DECLS
@@ -33,8 +33,8 @@ G_DECLARE_FINAL_TYPE (EphyPagesView, ephy_pages_view, EPHY, PAGES_VIEW, GtkScrol
EphyPagesView *ephy_pages_view_new (void);
-EphyNotebook *ephy_pages_view_get_notebook (EphyPagesView *view);
-void ephy_pages_view_set_notebook (EphyPagesView *view,
- EphyNotebook *notebook);
+EphyTabView *ephy_pages_view_get_tab_view (EphyPagesView *view);
+void ephy_pages_view_set_tab_view (EphyPagesView *view,
+ EphyTabView *tab_view);
G_END_DECLS
diff --git a/src/ephy-session.c b/src/ephy-session.c
index cd7f71c8f..3abf54556 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -32,11 +32,12 @@
#include "ephy-file-helpers.h"
#include "ephy-gui.h"
#include "ephy-link.h"
-#include "ephy-notebook.h"
+#include "ephy-tab-view.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-string.h"
+#include "ephy-tab-view.h"
#include "ephy-window.h"
#include <glib/gi18n.h>
@@ -45,12 +46,12 @@
#include <libxml/xmlwriter.h>
typedef struct {
- EphyNotebook *notebook;
+ EphyTabView *tab_view;
gint ref_count;
-} NotebookTracker;
+} TabViewTracker;
typedef struct {
- NotebookTracker *notebook_tracker;
+ TabViewTracker *tab_view_tracker;
int position;
char *url;
WebKitWebViewSessionState *state;
@@ -132,35 +133,35 @@ load_changed_cb (WebKitWebView *view,
}
static void
-notebook_tracker_set_notebook (NotebookTracker *tracker,
- EphyNotebook *notebook)
+tab_view_tracker_set_tab_view (TabViewTracker *tracker,
+ EphyTabView *tab_view)
{
- if (tracker->notebook == notebook) {
+ if (tracker->tab_view == tab_view) {
return;
}
- if (tracker->notebook) {
- g_object_remove_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
+ if (tracker->tab_view) {
+ g_object_remove_weak_pointer (G_OBJECT (tracker->tab_view), (gpointer *)&tracker->tab_view);
}
- tracker->notebook = notebook;
- if (tracker->notebook) {
- g_object_add_weak_pointer (G_OBJECT (tracker->notebook), (gpointer *)&tracker->notebook);
+ tracker->tab_view = tab_view;
+ if (tracker->tab_view) {
+ g_object_add_weak_pointer (G_OBJECT (tracker->tab_view), (gpointer *)&tracker->tab_view);
}
}
-static NotebookTracker *
-notebook_tracker_new (EphyNotebook *notebook)
+static TabViewTracker *
+tab_view_tracker_new (EphyTabView *tab_view)
{
- NotebookTracker *tracker = g_new0 (NotebookTracker, 1);
+ TabViewTracker *tracker = g_new0 (TabViewTracker, 1);
tracker->ref_count = 1;
- notebook_tracker_set_notebook (tracker, notebook);
+ tab_view_tracker_set_tab_view (tracker, tab_view);
return tracker;
}
-static NotebookTracker *
-notebook_tracker_ref (NotebookTracker *tracker)
+static TabViewTracker *
+tab_view_tracker_ref (TabViewTracker *tracker)
{
g_atomic_int_inc (&tracker->ref_count);
@@ -168,57 +169,57 @@ notebook_tracker_ref (NotebookTracker *tracker)
}
static void
-notebook_tracker_unref (NotebookTracker *tracker)
+tab_view_tracker_unref (TabViewTracker *tracker)
{
if (!g_atomic_int_dec_and_test (&tracker->ref_count))
return;
- notebook_tracker_set_notebook (tracker, NULL);
+ tab_view_tracker_set_tab_view (tracker, NULL);
g_free (tracker);
}
-static EphyNotebook *
-closed_tab_get_notebook (ClosedTab *tab)
+static EphyTabView *
+closed_tab_get_tab_view (ClosedTab *tab)
{
- return tab->notebook_tracker->notebook;
+ return tab->tab_view_tracker->tab_view;
}
static int
-compare_func (ClosedTab *iter,
- EphyNotebook *notebook)
+compare_func (ClosedTab *iter,
+ EphyTabView *tab_view)
{
- return GTK_NOTEBOOK (closed_tab_get_notebook (iter)) - GTK_NOTEBOOK (notebook);
+ return (gpointer)closed_tab_get_tab_view (iter) - (gpointer)tab_view;
}
-static NotebookTracker *
-ephy_session_ref_or_create_notebook_tracker (EphySession *session,
- EphyNotebook *notebook)
+static TabViewTracker *
+ephy_session_ref_or_create_tab_view_tracker (EphySession *session,
+ EphyTabView *tab_view)
{
- GList *item = g_queue_find_custom (session->closed_tabs, notebook, (GCompareFunc)compare_func);
- return item ? notebook_tracker_ref (((ClosedTab *)item->data)->notebook_tracker) : notebook_tracker_new
(notebook);
+ GList *item = g_queue_find_custom (session->closed_tabs, tab_view, (GCompareFunc)compare_func);
+ return item ? tab_view_tracker_ref (((ClosedTab *)item->data)->tab_view_tracker) : tab_view_tracker_new
(tab_view);
}
static void
closed_tab_free (ClosedTab *tab)
{
g_free (tab->url);
- notebook_tracker_unref (tab->notebook_tracker);
+ tab_view_tracker_unref (tab->tab_view_tracker);
webkit_web_view_session_state_unref (tab->state);
g_free (tab);
}
static ClosedTab *
-closed_tab_new (EphyWebView *web_view,
- int position,
- NotebookTracker *notebook_tracker)
+closed_tab_new (EphyWebView *web_view,
+ int position,
+ TabViewTracker *tab_view_tracker)
{
ClosedTab *tab = g_new0 (ClosedTab, 1);
tab->url = g_strdup (ephy_web_view_get_address (web_view));
tab->position = position;
/* Takes the ownership of the tracker */
- tab->notebook_tracker = notebook_tracker;
+ tab->tab_view_tracker = tab_view_tracker;
tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
return tab;
@@ -233,7 +234,7 @@ ephy_session_undo_close_tab (EphySession *session)
WebKitBackForwardListItem *item;
ClosedTab *tab;
EphyWindow *window;
- EphyNotebook *notebook;
+ EphyTabView *tab_view;
EphyNewTabFlags flags = EPHY_NEW_TAB_JUMP;
g_assert (EPHY_IS_SESSION (session));
@@ -243,12 +244,12 @@ ephy_session_undo_close_tab (EphySession *session)
return;
LOG ("UNDO CLOSE TAB: %s", tab->url);
- notebook = closed_tab_get_notebook (tab);
- if (notebook) {
+ tab_view = closed_tab_get_tab_view (tab);
+ if (tab_view) {
if (tab->position > 0) {
/* Append in the n-th position. */
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
- tab->position - 1));
+ embed = EPHY_EMBED (ephy_tab_view_get_nth_page (tab_view,
+ tab->position - 1));
flags |= EPHY_NEW_TAB_APPEND_AFTER;
} else {
/* Just prepend in the first position. */
@@ -256,7 +257,7 @@ ephy_session_undo_close_tab (EphySession *session)
flags |= EPHY_NEW_TAB_FIRST;
}
- window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (notebook)));
+ window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab_view)));
new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
window, embed,
flags);
@@ -264,8 +265,8 @@ ephy_session_undo_close_tab (EphySession *session)
window = ephy_window_new ();
new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
window, NULL, flags);
- notebook_tracker_set_notebook (tab->notebook_tracker,
- EPHY_NOTEBOOK (ephy_window_get_notebook (window)));
+ tab_view_tracker_set_tab_view (tab->tab_view_tracker,
+ ephy_window_get_tab_view (window));
}
web_view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (new_tab));
@@ -288,10 +289,10 @@ ephy_session_undo_close_tab (EphySession *session)
}
static void
-ephy_session_tab_closed (EphySession *session,
- EphyNotebook *notebook,
- EphyEmbed *embed,
- gint position)
+ephy_session_tab_closed (EphySession *session,
+ EphyTabView *tab_view,
+ EphyEmbed *embed,
+ gint position)
{
EphyWebView *view;
WebKitWebView *wk_view;
@@ -306,7 +307,7 @@ ephy_session_tab_closed (EphySession *session,
}
tab = closed_tab_new (view, position,
- ephy_session_ref_or_create_notebook_tracker (session, notebook));
+ ephy_session_ref_or_create_tab_view_tracker (session, tab_view));
g_queue_push_head (session->closed_tabs, tab);
if (g_queue_get_length (session->closed_tabs) == 1)
@@ -325,33 +326,38 @@ ephy_session_get_can_undo_tab_closed (EphySession *session)
}
static void
-notebook_page_added_cb (GtkWidget *notebook,
- EphyEmbed *embed,
+tab_view_page_added_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
guint position,
EphySession *session)
{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+
g_signal_connect (ephy_embed_get_web_view (embed), "load-changed",
G_CALLBACK (load_changed_cb), session);
}
static void
-notebook_page_removed_cb (GtkWidget *notebook,
- EphyEmbed *embed,
- guint position,
+tab_view_page_removed_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
+ gint position,
EphySession *session)
{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+ EphyTabView *ephy_tab_view = EPHY_TAB_VIEW (g_object_get_data (G_OBJECT (tab_view), "ephy-tab-view"));
+
ephy_session_save (session);
g_signal_handlers_disconnect_by_func
(ephy_embed_get_web_view (embed), G_CALLBACK (load_changed_cb),
session);
- ephy_session_tab_closed (session, EPHY_NOTEBOOK (notebook), embed, position);
+ ephy_session_tab_closed (session, ephy_tab_view, embed, position);
}
static void
-notebook_page_reordered_cb (GtkWidget *notebook,
- GtkWidget *tab,
+tab_view_page_reordered_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
guint position,
EphySession *session)
{
@@ -359,10 +365,9 @@ notebook_page_reordered_cb (GtkWidget *notebook,
}
static void
-notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphySession *session)
+tab_view_notify_selected_page_cb (HdyTabView *tab_view,
+ GParamSpec *pspec,
+ EphySession *session)
{
ephy_session_save (session);
}
@@ -386,8 +391,8 @@ window_added_cb (GtkApplication *application,
GtkWindow *window,
EphySession *session)
{
- GtkWidget *notebook;
EphyWindow *ephy_window;
+ HdyTabView *tab_view;
ephy_session_save (session);
@@ -396,15 +401,15 @@ window_added_cb (GtkApplication *application,
ephy_window = EPHY_WINDOW (window);
- notebook = ephy_window_get_notebook (ephy_window);
- g_signal_connect (notebook, "page-added",
- G_CALLBACK (notebook_page_added_cb), session);
- g_signal_connect (notebook, "page-removed",
- G_CALLBACK (notebook_page_removed_cb), session);
- g_signal_connect (notebook, "page-reordered",
- G_CALLBACK (notebook_page_reordered_cb), session);
- g_signal_connect_after (notebook, "switch-page",
- G_CALLBACK (notebook_switch_page_cb), session);
+ tab_view = ephy_tab_view_get_tab_view (ephy_window_get_tab_view (ephy_window));
+ g_signal_connect (tab_view, "page-added",
+ G_CALLBACK (tab_view_page_added_cb), session);
+ g_signal_connect (tab_view, "page-removed",
+ G_CALLBACK (tab_view_page_removed_cb), session);
+ g_signal_connect (tab_view, "page-reordered",
+ G_CALLBACK (tab_view_page_reordered_cb), session);
+ g_signal_connect_after (tab_view, "notify::selected-page",
+ G_CALLBACK (tab_view_notify_selected_page_cb), session);
/* Set unique identifier as role, so that on restore, the WM can
* place the window on the right workspace
@@ -563,7 +568,7 @@ typedef struct {
static SessionTab *
session_tab_new (EphyEmbed *embed,
EphySession *session,
- GtkNotebook *notebook)
+ EphyTabView *tab_view)
{
SessionTab *session_tab;
const char *address;
@@ -592,7 +597,7 @@ session_tab_new (EphyEmbed *embed,
session_tab->crashed = (error_page == EPHY_WEB_VIEW_ERROR_PAGE_CRASH ||
error_page == EPHY_WEB_VIEW_ERROR_PROCESS_CRASH);
session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));
- session_tab->pinned = ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), embed);
+ session_tab->pinned = ephy_tab_view_get_is_pinned (tab_view, GTK_WIDGET (embed));
return session_tab;
}
@@ -613,7 +618,7 @@ session_window_new (EphyWindow *window,
{
SessionWindow *session_window;
GList *tabs, *l;
- GtkNotebook *notebook;
+ EphyTabView *tab_view;
tabs = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
/* Do not save an empty EphyWindow.
@@ -626,18 +631,18 @@ session_window_new (EphyWindow *window,
session_window = g_new0 (SessionWindow, 1);
get_window_geometry (window, session_window);
session_window->role = g_strdup (gtk_window_get_role (GTK_WINDOW (window)));
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (window));
+ tab_view = ephy_window_get_tab_view (window);
for (l = tabs; l != NULL; l = l->next) {
SessionTab *tab;
- tab = session_tab_new (EPHY_EMBED (l->data), session, notebook);
+ tab = session_tab_new (EPHY_EMBED (l->data), session, tab_view);
session_window->tabs = g_list_prepend (session_window->tabs, tab);
}
g_list_free (tabs);
session_window->tabs = g_list_reverse (session_window->tabs);
- session_window->active_tab = gtk_notebook_get_current_page (notebook);
+ session_window->active_tab = ephy_tab_view_get_selected_index (tab_view);
return session_window;
}
@@ -1184,7 +1189,7 @@ session_parse_embed (SessionParserContext *context,
const gchar **names,
const gchar **values)
{
- GtkWidget *notebook;
+ HdyTabView *tab_view;
const char *url = NULL;
const char *title = NULL;
const char *history = NULL;
@@ -1201,7 +1206,7 @@ session_parse_embed (SessionParserContext *context,
return;
}
- notebook = ephy_window_get_notebook (context->window);
+ tab_view = ephy_tab_view_get_tab_view (ephy_window_get_tab_view (context->window));
for (i = 0; names[i]; i++) {
if (strcmp (names[i], "url") == 0) {
@@ -1251,7 +1256,9 @@ session_parse_embed (SessionParserContext *context,
context->window, NULL, flags,
0);
- ephy_notebook_tab_set_pinned (EPHY_NOTEBOOK (notebook), GTK_WIDGET (embed), is_pin);
+ hdy_tab_view_set_page_pinned (tab_view,
+ hdy_tab_view_get_page (tab_view, GTK_WIDGET (embed)),
+ is_pin);
web_view = ephy_embed_get_web_view (embed);
if (history) {
@@ -1327,7 +1334,7 @@ session_end_element (GMarkupParseContext *ctx,
SessionParserContext *context = (SessionParserContext *)user_data;
if (strcmp (element_name, "window") == 0) {
- GtkWidget *notebook;
+ EphyTabView *tab_view;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
if (!context->window) {
@@ -1337,8 +1344,8 @@ session_end_element (GMarkupParseContext *ctx,
return;
}
- notebook = ephy_window_get_notebook (context->window);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), context->active_tab);
+ tab_view = ephy_window_get_tab_view (context->window);
+ ephy_tab_view_select_nth_page (tab_view, context->active_tab);
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_TEST) {
EphyEmbed *active_child;
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 2ee5684f4..66a0d0259 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -925,23 +925,22 @@ webkit_notification_clicked_cb (WebKitNotification *notification,
for (guint win_idx = 0; win_idx < g_list_length (windows); win_idx++) {
EphyWindow *window;
- GtkWidget *notebook;
+ EphyTabView *tab_view;
int n_pages;
window = EPHY_WINDOW (g_list_nth_data (windows, win_idx));
-
- notebook = ephy_window_get_notebook (window);
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+ tab_view = ephy_window_get_tab_view (window);
+ n_pages = ephy_tab_view_get_n_pages (tab_view);
for (int i = 0; i < n_pages; i++) {
EphyEmbed *embed;
WebKitWebView *webview;
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
+ embed = EPHY_EMBED (ephy_tab_view_get_nth_page (tab_view, i));
webview = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed));
if (webview == notification_webview) {
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), i);
+ ephy_tab_view_select_page (tab_view, GTK_WIDGET (embed));
gtk_window_present (GTK_WINDOW (window));
return;
}
diff --git a/src/ephy-suggestion-model.c b/src/ephy-suggestion-model.c
index 106b39c8b..c91e53823 100644
--- a/src/ephy-suggestion-model.c
+++ b/src/ephy-suggestion-model.c
@@ -433,10 +433,9 @@ add_tabs (EphySuggestionModel *self,
GApplication *application;
EphyEmbedShell *shell;
EphyWindow *window;
- GtkWidget *notebook;
+ EphyTabView *tab_view;
GList *windows;
- gint n_pages;
- gint current;
+ gint n_pages, selected;
guint added = 0;
shell = ephy_embed_shell_get_default ();
@@ -446,9 +445,9 @@ add_tabs (EphySuggestionModel *self,
for (guint win_idx = 0; win_idx < g_list_length (windows); win_idx++) {
window = EPHY_WINDOW (g_list_nth_data (windows, win_idx));
- notebook = ephy_window_get_notebook (window);
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
- current = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+ tab_view = ephy_window_get_tab_view (window);
+ n_pages = ephy_tab_view_get_n_pages (tab_view);
+ selected = ephy_tab_view_get_selected_index (tab_view);
for (int i = 0; i < n_pages; i++) {
EphyEmbed *embed;
@@ -464,10 +463,10 @@ add_tabs (EphySuggestionModel *self,
g_autofree gchar *display_address_casefold = NULL;
g_autofree gchar *query_casefold = NULL;
- if (win_idx == 0 && i == current)
+ if (win_idx == 0 && i == selected)
continue;
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
+ embed = EPHY_EMBED (ephy_tab_view_get_nth_page (tab_view, i));
webview = ephy_embed_get_web_view (embed);
display_address = ephy_web_view_get_display_address (webview);
url = ephy_web_view_get_address (webview);
diff --git a/src/ephy-tab-view.c b/src/ephy-tab-view.c
new file mode 100644
index 000000000..75e32b7d8
--- /dev/null
+++ b/src/ephy-tab-view.c
@@ -0,0 +1,453 @@
+/* -*- 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-tab-view.h"
+
+#include "ephy-desktop-utils.h"
+#include "ephy-embed-utils.h"
+
+struct _EphyTabView {
+ GtkBin parent_instance;
+
+ HdyTabView *tab_view;
+ HdyTabPage *current_page;
+};
+
+G_DEFINE_TYPE (EphyTabView, ephy_tab_view, GTK_TYPE_BIN)
+
+enum {
+ PROP_0,
+ PROP_N_PAGES,
+ PROP_SELECTED_INDEX,
+ N_PROPS
+};
+
+static GParamSpec *properties[N_PROPS];
+
+static void
+notify_n_pages_cb (EphyTabView *self)
+{
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_N_PAGES]);
+}
+
+static void
+notify_selected_page_cb (EphyTabView *self)
+{
+ HdyTabPage *page = hdy_tab_view_get_selected_page (self->tab_view);
+
+ hdy_tab_page_set_needs_attention (page, FALSE);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_INDEX]);
+}
+
+static void
+secondary_icon_activated_cb (EphyTabView *self,
+ HdyTabPage *page)
+{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+ EphyWebView *view = ephy_embed_get_web_view (embed);
+ gboolean muted = webkit_web_view_get_is_muted (WEBKIT_WEB_VIEW (view));
+
+ webkit_web_view_set_is_muted (WEBKIT_WEB_VIEW (view), !muted);
+}
+
+static void
+setup_menu_cb (EphyTabView *self,
+ HdyTabPage *page)
+{
+ self->current_page = page;
+}
+
+static HdyTabPage *
+get_current_page (EphyTabView *self)
+{
+ if (self->current_page)
+ return self->current_page;
+
+ return hdy_tab_view_get_selected_page (self->tab_view);
+}
+
+static void
+ephy_tab_view_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyTabView *self = EPHY_TAB_VIEW (object);
+
+ switch (prop_id) {
+ case PROP_N_PAGES:
+ g_value_set_int (value, ephy_tab_view_get_n_pages (self));
+ break;
+
+ case PROP_SELECTED_INDEX:
+ g_value_set_int (value, ephy_tab_view_get_selected_index (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ephy_tab_view_class_init (EphyTabViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = ephy_tab_view_get_property;
+
+ properties[PROP_N_PAGES] =
+ g_param_spec_int ("n-pages",
+ "Number of pages",
+ "The number of pages in the tab view",
+ 0,
+ G_MAXINT,
+ 0,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY));
+
+ properties[PROP_SELECTED_INDEX] =
+ g_param_spec_int ("selected-index",
+ "Selected index",
+ "The index of the currently selected page",
+ 0,
+ G_MAXINT,
+ 0,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
+}
+
+static void
+ephy_tab_view_init (EphyTabView *self)
+{
+ self->tab_view = HDY_TAB_VIEW (hdy_tab_view_new ());
+ gtk_widget_show (GTK_WIDGET (self->tab_view));
+
+ g_object_set_data (G_OBJECT (self->tab_view), "ephy-tab-view", self);
+
+ gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (self->tab_view));
+
+ g_signal_connect_object (self->tab_view,
+ "notify::n-pages",
+ G_CALLBACK (notify_n_pages_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->tab_view,
+ "notify::selected-page",
+ G_CALLBACK (notify_selected_page_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->tab_view,
+ "setup-menu",
+ G_CALLBACK (setup_menu_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->tab_view,
+ "secondary-icon-activated",
+ G_CALLBACK (secondary_icon_activated_cb),
+ self,
+ G_CONNECT_SWAPPED);
+}
+
+EphyTabView *
+ephy_tab_view_new (void)
+{
+ return g_object_new (EPHY_TYPE_TAB_VIEW, NULL);
+}
+
+void
+ephy_tab_view_next (EphyTabView *self)
+{
+ hdy_tab_view_select_next_page (self->tab_view);
+}
+
+void
+ephy_tab_view_pin (EphyTabView *self)
+{
+ hdy_tab_view_set_page_pinned (self->tab_view, get_current_page (self), TRUE);
+}
+
+void
+ephy_tab_view_unpin (EphyTabView *self)
+{
+ hdy_tab_view_set_page_pinned (self->tab_view, get_current_page (self), FALSE);
+}
+
+void
+ephy_tab_view_close (EphyTabView *self,
+ GtkWidget *widget)
+{
+ HdyTabPage *page = hdy_tab_view_get_page (self->tab_view, widget);
+
+ hdy_tab_view_close_page (self->tab_view, page);
+}
+
+void
+ephy_tab_view_close_selected (EphyTabView *self)
+{
+ hdy_tab_view_close_page (self->tab_view, get_current_page (self));
+}
+
+void
+ephy_tab_view_close_left (EphyTabView *self)
+{
+ hdy_tab_view_close_pages_before (self->tab_view, get_current_page (self));
+}
+
+void
+ephy_tab_view_close_right (EphyTabView *self)
+{
+ hdy_tab_view_close_pages_after (self->tab_view, get_current_page (self));
+}
+
+void
+ephy_tab_view_close_other (EphyTabView *self)
+{
+ hdy_tab_view_close_other_pages (self->tab_view, get_current_page (self));
+}
+
+void
+ephy_tab_view_foreach (EphyTabView *self,
+ GtkCallback callback,
+ gpointer user_data)
+{
+ gint i, n;
+
+ n = hdy_tab_view_get_n_pages (self->tab_view);
+
+ for (i = 0; i < n; i++) {
+ HdyTabPage *page = hdy_tab_view_get_nth_page (self->tab_view, i);
+
+ callback (hdy_tab_page_get_content (page), user_data);
+ }
+}
+
+gint
+ephy_tab_view_get_n_pages (EphyTabView *self)
+{
+ return hdy_tab_view_get_n_pages (self->tab_view);
+}
+
+gint
+ephy_tab_view_get_selected_index (EphyTabView *self)
+{
+ HdyTabPage *page = hdy_tab_view_get_selected_page (self->tab_view);
+
+ return hdy_tab_view_get_page_position (self->tab_view, page);
+}
+
+GtkWidget *
+ephy_tab_view_get_nth_page (EphyTabView *self,
+ gint index)
+{
+ HdyTabPage *page = hdy_tab_view_get_nth_page (self->tab_view, index);
+
+ return hdy_tab_page_get_content (page);
+}
+
+void
+ephy_tab_view_select_nth_page (EphyTabView *self,
+ gint index)
+{
+ HdyTabPage *page = hdy_tab_view_get_nth_page (self->tab_view, index);
+
+ hdy_tab_view_set_selected_page (self->tab_view, page);
+}
+
+gboolean
+ephy_tab_view_select_page (EphyTabView *self,
+ GtkWidget *widget)
+{
+ HdyTabPage *page = hdy_tab_view_get_page (self->tab_view, widget);
+
+ if (page)
+ hdy_tab_view_set_selected_page (self->tab_view, page);
+
+ return page != NULL;
+}
+
+GtkWidget *
+ephy_tab_view_get_selected_page (EphyTabView *self)
+{
+ HdyTabPage *page = hdy_tab_view_get_selected_page (self->tab_view);
+
+ return hdy_tab_page_get_content (page);
+}
+
+HdyTabView *
+ephy_tab_view_get_tab_view (EphyTabView *self)
+{
+ return self->tab_view;
+}
+
+GList *
+ephy_tab_view_get_pages (EphyTabView *self)
+{
+ GList *list = NULL;
+ gint i, n;
+
+ n = hdy_tab_view_get_n_pages (self->tab_view);
+
+ for (i = 0; i < n; i++) {
+ HdyTabPage *page = hdy_tab_view_get_nth_page (self->tab_view, i);
+ GtkWidget *content = hdy_tab_page_get_content (page);
+
+ list = g_list_prepend (list, content);
+ }
+
+ return g_list_reverse (list);
+}
+
+gboolean
+ephy_tab_view_get_is_pinned (EphyTabView *self,
+ GtkWidget *widget)
+{
+ HdyTabPage *page = hdy_tab_view_get_page (self->tab_view, widget);
+
+ return hdy_tab_page_get_pinned (page);
+}
+
+static void
+update_title_cb (HdyTabPage *page)
+{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+ EphyWebView *view = ephy_embed_get_web_view (embed);
+ const gchar *title = ephy_embed_get_title (embed);
+ const gchar *address;
+
+ if (!ephy_embed_has_load_pending (embed) &&
+ !hdy_tab_page_get_selected (page) &&
+ hdy_tab_page_get_pinned (page))
+ hdy_tab_page_set_needs_attention (page, TRUE);
+
+ if (title && strlen (title)) {
+ hdy_tab_page_set_title (page, title);
+
+ return;
+ }
+
+ address = ephy_web_view_get_display_address (view);
+
+ if (ephy_web_view_is_loading (view) &&
+ !ephy_embed_utils_is_no_show_address (address))
+ hdy_tab_page_set_title (page, address);
+}
+
+static void
+update_icon_cb (HdyTabPage *page)
+{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+ EphyWebView *view = ephy_embed_get_web_view (embed);
+ g_autoptr (GIcon) icon = G_ICON (ephy_web_view_get_icon (view));
+ const char *uri, *favicon_name;
+
+ if (icon) {
+ hdy_tab_page_set_icon (page, g_steal_pointer (&icon));
+
+ return;
+ }
+
+ uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view));
+ favicon_name = ephy_get_fallback_favicon_name (uri, EPHY_FAVICON_TYPE_NO_MISSING_PLACEHOLDER);
+
+ if (favicon_name)
+ icon = g_themed_icon_new (favicon_name);
+
+ hdy_tab_page_set_icon (page, icon);
+}
+
+static void
+update_secondary_icon_cb (HdyTabPage *page)
+{
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+ EphyWebView *view = ephy_embed_get_web_view (embed);
+ GIcon *icon = NULL;
+
+ if (webkit_web_view_is_playing_audio (WEBKIT_WEB_VIEW (view))) {
+ if (webkit_web_view_get_is_muted (WEBKIT_WEB_VIEW (view)))
+ icon = G_ICON (g_themed_icon_new ("ephy-audio-muted-symbolic"));
+ else
+ icon = G_ICON (g_themed_icon_new ("ephy-audio-playing-symbolic"));
+ }
+
+ hdy_tab_page_set_secondary_icon (page, icon);
+}
+
+gint
+ephy_tab_view_add_tab (EphyTabView *self,
+ EphyEmbed *embed,
+ gint position,
+ gboolean jump_to)
+{
+ HdyTabPage *page;
+ EphyWebView *view;
+
+ if (position < 0)
+ page = hdy_tab_view_append (self->tab_view, GTK_WIDGET (embed));
+ else
+ page = hdy_tab_view_insert (self->tab_view, GTK_WIDGET (embed), position);
+
+ if (jump_to)
+ hdy_tab_view_set_selected_page (self->tab_view, page);
+
+ view = ephy_embed_get_web_view (embed);
+
+ hdy_tab_page_set_secondary_icon_activatable (page, TRUE);
+
+ g_object_bind_property (view, "is-loading", page, "loading", G_BINDING_SYNC_CREATE);
+
+ g_signal_connect_object (embed, "notify::title",
+ G_CALLBACK (update_title_cb), page,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (view, "notify::display-address",
+ G_CALLBACK (update_title_cb), page,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (view, "notify::icon",
+ G_CALLBACK (update_icon_cb), page,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (view, "notify::uri",
+ G_CALLBACK (update_icon_cb), page,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (view, "notify::is-playing-audio",
+ G_CALLBACK (update_secondary_icon_cb), page,
+ G_CONNECT_SWAPPED);
+ g_signal_connect_object (view, "notify::is-muted",
+ G_CALLBACK (update_secondary_icon_cb), page,
+ G_CONNECT_SWAPPED);
+
+ update_title_cb (page);
+ update_icon_cb (page);
+ update_secondary_icon_cb (page);
+
+ return hdy_tab_view_get_page_position (self->tab_view, page);
+}
+
+GtkWidget *
+ephy_tab_view_get_current_page (EphyTabView *self)
+{
+ return hdy_tab_page_get_content (get_current_page (self));
+}
diff --git a/src/ephy-tab-view.h b/src/ephy-tab-view.h
new file mode 100644
index 000000000..13fa1e0be
--- /dev/null
+++ b/src/ephy-tab-view.h
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 2; indent-pages-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2020 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 <handy.h>
+#include "ephy-embed.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_TAB_VIEW (ephy_tab_view_get_type())
+
+G_DECLARE_FINAL_TYPE (EphyTabView, ephy_tab_view, EPHY, TAB_VIEW, GtkBin)
+
+EphyTabView *ephy_tab_view_new (void);
+
+void ephy_tab_view_next (EphyTabView *self);
+
+void ephy_tab_view_pin (EphyTabView *self);
+void ephy_tab_view_unpin (EphyTabView *self);
+
+void ephy_tab_view_close (EphyTabView *self,
+ GtkWidget *widget);
+void ephy_tab_view_close_selected (EphyTabView *self);
+void ephy_tab_view_close_left (EphyTabView *self);
+void ephy_tab_view_close_right (EphyTabView *self);
+void ephy_tab_view_close_other (EphyTabView *self);
+
+void ephy_tab_view_foreach (EphyTabView *self,
+ GtkCallback callback,
+ gpointer user_data);
+
+gint ephy_tab_view_get_n_pages (EphyTabView *self);
+gint ephy_tab_view_get_selected_index (EphyTabView *self);
+
+GtkWidget *ephy_tab_view_get_nth_page (EphyTabView *self,
+ gint index);
+void ephy_tab_view_select_nth_page (EphyTabView *self,
+ gint index);
+
+gboolean ephy_tab_view_select_page (EphyTabView *self,
+ GtkWidget *widget);
+
+GtkWidget *ephy_tab_view_get_selected_page (EphyTabView *self);
+
+HdyTabView *ephy_tab_view_get_tab_view (EphyTabView *self);
+
+GList *ephy_tab_view_get_pages (EphyTabView *self);
+
+gboolean ephy_tab_view_get_is_pinned (EphyTabView *self,
+ GtkWidget *widget);
+
+gint ephy_tab_view_add_tab (EphyTabView *self,
+ EphyEmbed *embed,
+ gint position,
+ gboolean jump_to);
+
+GtkWidget *ephy_tab_view_get_current_page (EphyTabView *self);
+
+G_END_DECLS
diff --git a/src/ephy-window.c b/src/ephy-window.c
index b661d99d1..721063443 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -44,7 +44,6 @@
#include "ephy-link.h"
#include "ephy-location-entry.h"
#include "ephy-mouse-gesture-controller.h"
-#include "ephy-notebook.h"
#include "ephy-pages-view.h"
#include "ephy-permissions-manager.h"
#include "ephy-prefs.h"
@@ -129,10 +128,6 @@ const struct {
{ "toolbar.combined-stop-reload", { NULL } },
/* Tabs */
- { "tab.previous", { "<Primary>Page_Up", "<Primary>KP_9", "<shift><Primary>Tab", NULL } },
- { "tab.next", { "<Primary>Page_Down", "<Primary>KP_3", "<Primary>Tab", NULL } },
- { "tab.move-left", { "<shift><Primary>Page_Up", NULL } },
- { "tab.move-right", { "<shift><Primary>Page_Down", NULL } },
{ "tab.duplicate", { "<shift><Primary>K", NULL } },
{ "tab.close", { "<Primary>W", NULL } },
{ "tab.mute", { "<Primary>M", NULL } },
@@ -155,7 +150,9 @@ struct _EphyWindow {
EphyPagesView *pages_view;
EphyBookmarksManager *bookmarks_manager;
GHashTable *action_labels;
- GtkNotebook *notebook;
+ EphyTabView *tab_view;
+ HdyTabBar *tab_bar;
+ GtkRevealer *tab_bar_revealer;
GtkWidget *action_bar;
EphyEmbed *active_embed;
EphyWindowChrome chrome;
@@ -216,24 +213,25 @@ impl_add_child (EphyEmbedContainer *container,
gboolean jump_to)
{
EphyWindow *window = EPHY_WINDOW (container);
+ int ret;
- g_assert (!window->is_popup || gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) < 1);
+ g_assert (!window->is_popup || ephy_tab_view_get_n_pages (window->tab_view) < 1);
- return ephy_notebook_add_tab (EPHY_NOTEBOOK (window->notebook),
- child, position, jump_to);
+ ret = ephy_tab_view_add_tab (window->tab_view, child, position, jump_to);
+
+ if (jump_to)
+ ephy_window_update_entry_focus (window, ephy_embed_get_web_view (child));
+
+ return ret;
}
static void
impl_set_active_child (EphyEmbedContainer *container,
EphyEmbed *child)
{
- int page;
- EphyWindow *window;
-
- window = EPHY_WINDOW (container);
+ EphyWindow *window = EPHY_WINDOW (container);
- page = gtk_notebook_page_num (window->notebook, GTK_WIDGET (child));
- gtk_notebook_set_current_page (window->notebook, page);
+ ephy_tab_view_select_page (window->tab_view, GTK_WIDGET (child));
}
static GtkWidget *
@@ -303,12 +301,9 @@ static void
impl_remove_child (EphyEmbedContainer *container,
EphyEmbed *child)
{
- EphyWindow *window;
+ EphyWindow *window = EPHY_WINDOW (container);
- window = EPHY_WINDOW (container);
- g_signal_emit_by_name (window->notebook,
- "tab-close-request",
- child, window);
+ ephy_tab_view_close (window->tab_view, GTK_WIDGET (child));
}
static EphyEmbed *
@@ -322,7 +317,7 @@ impl_get_children (EphyEmbedContainer *container)
{
EphyWindow *window = EPHY_WINDOW (container);
- return gtk_container_get_children (GTK_CONTAINER (window->notebook));
+ return ephy_tab_view_get_pages (window->tab_view);
}
static gboolean
@@ -336,7 +331,7 @@ impl_get_n_children (EphyEmbedContainer *container)
{
EphyWindow *window = EPHY_WINDOW (container);
- return gtk_notebook_get_n_pages (window->notebook);
+ return ephy_tab_view_get_n_pages (window->tab_view);
}
static void
@@ -440,8 +435,8 @@ sync_chromes_visibility (EphyWindow *window)
show_tabsbar = (window->chrome & EPHY_WINDOW_CHROME_TABSBAR);
- ephy_notebook_set_tabs_allowed (EPHY_NOTEBOOK (window->notebook),
- show_tabsbar && !(window->is_popup || window->is_fullscreen));
+ gtk_widget_set_visible (GTK_WIDGET (window->tab_bar),
+ show_tabsbar && !(window->is_popup || window->is_fullscreen));
}
static void
@@ -514,7 +509,6 @@ update_adaptive_mode (EphyWindow *window)
{
EphyHeaderBar *header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
EphyActionBar *action_bar = EPHY_ACTION_BAR (window->action_bar);
- EphyNotebook *notebook = EPHY_NOTEBOOK (window->notebook);
gboolean is_narrow, is_mobile_landscape;
EphyAdaptiveMode adaptive_mode;
gint width, height;
@@ -547,7 +541,9 @@ update_adaptive_mode (EphyWindow *window)
EPHY_ADAPTIVE_MODE_NORMAL;
ephy_header_bar_set_adaptive_mode (header_bar, adaptive_mode);
ephy_action_bar_set_adaptive_mode (action_bar, adaptive_mode);
- ephy_notebook_set_adaptive_mode (notebook, adaptive_mode);
+
+ 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.
@@ -869,22 +865,16 @@ static const GActionEntry window_entries [] = {
{ "content", window_cmd_go_content },
{ "tabs-view", window_cmd_go_tabs_view },
- { "show-tab", window_cmd_show_tab, "u", "uint32 0", window_cmd_change_show_tab_state },
-
/* Toggle actions */
{ "browse-with-caret", NULL, NULL, "false", window_cmd_change_browse_with_caret_state },
{ "fullscreen", NULL, NULL, "false", window_cmd_change_fullscreen_state },
};
static const GActionEntry tab_entries [] = {
- { "previous", window_cmd_tabs_previous },
- { "next", window_cmd_tabs_next },
{ "duplicate", window_cmd_tabs_duplicate },
{ "close", window_cmd_tabs_close },
{ "close-left", window_cmd_tabs_close_left },
{ "close-right", window_cmd_tabs_close_right },
- { "move-left", window_cmd_tabs_move_left },
- { "move-right", window_cmd_tabs_move_right },
{ "close-others", window_cmd_tabs_close_others },
{ "reload-all", window_cmd_tabs_reload_all_tabs },
{ "pin", window_cmd_tabs_pin },
@@ -2576,7 +2566,7 @@ tab_accels_item_activate (GSimpleAction *action,
tab_number = atoi (action_name + strlen ("accel-"));
- gtk_notebook_set_current_page (EPHY_WINDOW (user_data)->notebook, tab_number);
+ ephy_tab_view_select_nth_page (EPHY_WINDOW (user_data)->tab_view, tab_number);
}
static void
@@ -2590,7 +2580,7 @@ tab_accels_update (EphyWindow *window)
action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
actions = g_action_group_list_actions (action_group);
- n_pages = gtk_notebook_get_n_pages (window->notebook);
+ n_pages = ephy_tab_view_get_n_pages (window->tab_view);
for (i = 0; actions[i] != NULL; i++) {
if (strstr (actions[i], "accel-") != NULL) {
GAction *action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
@@ -2607,19 +2597,10 @@ tab_accels_update (EphyWindow *window)
static void
accel_cb_tabs_next (GtkWidget *widget,
gpointer user_data)
-{
- window_cmd_tabs_next (NULL, NULL, user_data);
-}
-
-static void
-last_tab_accel_activate (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
{
EphyWindow *window = EPHY_WINDOW (user_data);
- EphyNotebook *notebook = EPHY_NOTEBOOK (window->notebook);
- ephy_notebook_switch_to_last_tab (notebook);
+ ephy_tab_view_next (ephy_window_get_tab_view (window));
}
#define TAB_ACCELS_N 10
@@ -2631,12 +2612,11 @@ setup_tab_accels (EphyWindow *window)
GApplication *app;
guint i;
DzlShortcutController *controller = dzl_shortcut_controller_find (GTK_WIDGET (window));
- GSimpleAction *last_tab_action;
action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
app = g_application_get_default ();
- for (i = 0; i < TAB_ACCELS_N - 1; i++) {
+ for (i = 0; i < TAB_ACCELS_N; i++) {
GSimpleAction *simple_action;
char *action_name;
char *action_name_with_tab;
@@ -2662,16 +2642,6 @@ setup_tab_accels (EphyWindow *window)
g_free (action_name_with_tab);
}
- last_tab_action = g_simple_action_new ("switch-to-last-tab", NULL);
- g_action_map_add_action (G_ACTION_MAP (action_group), G_ACTION (last_tab_action));
- gtk_application_set_accels_for_action (GTK_APPLICATION (app),
- "tab.switch-to-last-tab",
- (const gchar *[]) {"<alt>0", NULL});
-
- g_signal_connect (G_ACTION (last_tab_action), "activate",
- G_CALLBACK (last_tab_accel_activate), window);
- g_object_unref (last_tab_action);
-
/* We have to setup the Ctrl + Tab shortcut in the window's ShortcutController
* because otherwise libdazzle would handle this shortcut by changing
* the focused widget instead of switching between the browser tabs
@@ -2693,118 +2663,69 @@ setup_tab_accels (EphyWindow *window)
NULL);
}
-static gboolean
-show_notebook_popup_menu (GtkNotebook *notebook,
- EphyWindow *window,
- GdkEventButton *event)
+static void
+tab_view_setup_menu_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
+ EphyWindow *window)
{
- GtkWidget *menu, *tab, *tab_label;
- GMenu *menu_model;
- GtkBuilder *builder;
+ EphyWebView *view;
GActionGroup *action_group;
GAction *action;
+ int n_pages;
+ int n_pinned_pages;
+ int position;
+ gboolean pinned;
+ gboolean audio_playing;
+ gboolean muted;
- builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/notebook-context-menu.ui");
-
- menu_model = G_MENU (gtk_builder_get_object (builder, "notebook-menu"));
- menu = gtk_menu_new_from_model (G_MENU_MODEL (menu_model));
- gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (window->active_embed), NULL);
-
- action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
-
- if (event != NULL) {
- EphyWebView *view;
- int n_pages;
- int page_num;
- gboolean pinned;
- gboolean audio_playing;
- gboolean muted;
-
- tab = GTK_WIDGET (window->active_embed);
- n_pages = gtk_notebook_get_n_pages (notebook);
- page_num = gtk_notebook_page_num (notebook, tab);
- pinned = ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), EPHY_EMBED (tab));
+ if (page) {
+ n_pages = hdy_tab_view_get_n_pages (tab_view);
+ n_pinned_pages = hdy_tab_view_get_n_pinned_pages (tab_view);
+ position = hdy_tab_view_get_page_position (tab_view, page);
+ pinned = hdy_tab_page_get_pinned (page);
- view = ephy_embed_get_web_view (EPHY_EMBED (tab));
+ view = ephy_embed_get_web_view (EPHY_EMBED (hdy_tab_page_get_content (page)));
audio_playing = webkit_web_view_is_playing_audio (WEBKIT_WEB_VIEW (view));
muted = webkit_web_view_get_is_muted (WEBKIT_WEB_VIEW (view));
+ }
- /* enable/disable close others/left/right */
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "close-left");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (page_num > 0) && !pinned);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "close-right");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (page_num < n_pages - 1) && !pinned);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "close-others");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), (n_pages > 1) && !pinned);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "reload-all");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), n_pages > 1);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "pin");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !pinned);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "unpin");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), pinned);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "mute");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), audio_playing);
- g_simple_action_set_state (G_SIMPLE_ACTION (action),
- g_variant_new_boolean (muted));
+ action_group = gtk_widget_get_action_group (GTK_WIDGET (window), "tab");
- action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
- "close");
- g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !pinned);
+ /* enable/disable close others/left/right */
+ /* If there's no page, enable all actions so that we don't interfere with hotkeys */
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "close-left");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || position > n_pinned_pages);
- gtk_menu_popup_at_pointer (GTK_MENU (menu), (GdkEvent *)event);
- } else {
- tab = GTK_WIDGET (window->active_embed);
- tab_label = gtk_notebook_get_tab_label (notebook, tab);
-
- /* Not tested, because I don't know how to trigger this code. */
- gtk_menu_popup_at_widget (GTK_MENU (menu),
- tab_label,
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- NULL);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- }
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "close-right");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || (position < n_pages - 1 && !pinned));
- g_object_unref (builder);
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "close-others");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || (n_pages > n_pinned_pages + 1 && !pinned));
- return TRUE;
-}
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "reload-all");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || n_pages > 1);
-static gboolean
-notebook_button_press_cb (GtkNotebook *notebook,
- GdkEventButton *event,
- EphyWindow *window)
-{
- if (GDK_BUTTON_PRESS == event->type && 3 == event->button) {
- return show_notebook_popup_menu (notebook, window, event);
- }
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "pin");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || !pinned);
- return FALSE;
-}
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "unpin");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || pinned);
-static gboolean
-notebook_popup_menu_cb (GtkNotebook *notebook,
- EphyWindow *window)
-{
- /* Only respond if the notebook is the actual focus */
- if (EPHY_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window)))) {
- return show_notebook_popup_menu (notebook, window, NULL);
- }
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "mute");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || audio_playing);
+ g_simple_action_set_state (G_SIMPLE_ACTION (action),
+ g_variant_new_boolean (muted));
- return FALSE;
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
+ "close-tab");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !page || !pinned);
}
static gboolean
@@ -2836,7 +2757,7 @@ download_only_load_cb (EphyWebView *view,
if (ephy_web_view_get_document_type (view) == EPHY_WEB_VIEW_DOCUMENT_PDF)
return;
- if (gtk_notebook_get_n_pages (window->notebook) == 1) {
+ if (ephy_tab_view_get_n_pages (window->tab_view) == 1) {
ephy_web_view_load_homepage (view);
return;
}
@@ -2876,14 +2797,19 @@ reader_mode_cb (EphyWebView *view,
}
static void
-notebook_page_added_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- guint position,
- EphyWindow *window)
+tab_view_page_added_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
+ gint position,
+ EphyWindow *window)
{
- LOG ("page-added notebook %p embed %p position %u\n", notebook, embed, position);
+ GtkWidget *content = hdy_tab_page_get_content (page);
+ EphyEmbed *embed;
- g_assert (EPHY_IS_EMBED (embed));
+ LOG ("page-added tab view %p embed %p position %d\n", tab_view, embed, position);
+
+ g_assert (EPHY_IS_EMBED (content));
+
+ embed = EPHY_EMBED (content);
g_signal_connect_object (ephy_embed_get_web_view (embed), "download-only-load",
G_CALLBACK (download_only_load_cb), window, G_CONNECT_AFTER);
@@ -2900,24 +2826,25 @@ notebook_page_added_cb (EphyNotebook *notebook,
}
static void
-notebook_page_removed_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- guint position,
- EphyWindow *window)
+tab_view_page_removed_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
+ gint position,
+ EphyWindow *window)
{
- LOG ("page-removed notebook %p embed %p position %u\n", notebook, embed, position);
+ GtkWidget *content = hdy_tab_page_get_content (page);
+ LOG ("page-removed tab view %p embed %p position %d\n", tab_view, content, position);
if (window->closing)
return;
- g_assert (EPHY_IS_EMBED (embed));
+ g_assert (EPHY_IS_EMBED (content));
g_signal_handlers_disconnect_by_func
- (ephy_embed_get_web_view (embed), G_CALLBACK (download_only_load_cb), window);
+ (ephy_embed_get_web_view (EPHY_EMBED (content)), G_CALLBACK (download_only_load_cb), window);
tab_accels_update (window);
- if (gtk_notebook_get_n_pages (window->notebook) == 0) {
+ if (ephy_tab_view_get_n_pages (window->tab_view) == 0) {
EphyShell *shell = ephy_shell_get_default ();
GList *windows = gtk_application_get_windows (GTK_APPLICATION (shell));
@@ -2958,7 +2885,7 @@ ephy_window_close_tab (EphyWindow *window,
if (mode != EPHY_EMBED_SHELL_MODE_AUTOMATION)
keep_window_open = g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_KEEP_WINDOW_OPEN);
- if (keep_window_open && gtk_notebook_get_n_pages (window->notebook) == 1) {
+ if (keep_window_open && ephy_tab_view_get_n_pages (window->tab_view) == 1) {
EphyWebView *view = ephy_embed_get_web_view (tab);
if (ephy_web_view_get_is_blank (view) || ephy_web_view_is_overview (view))
@@ -2968,7 +2895,6 @@ ephy_window_close_tab (EphyWindow *window,
}
g_object_set_data (G_OBJECT (tab), "ephy-window-close-tab-closed", GINT_TO_POINTER (TRUE));
- gtk_widget_destroy (GTK_WIDGET (tab));
if (window->last_opened_embed)
g_clear_weak_pointer ((gpointer *)&window->last_opened_embed);
@@ -2979,26 +2905,30 @@ 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 && gtk_notebook_get_n_pages (window->notebook) == 0)
+ if (!window->closing && ephy_tab_view_get_n_pages (window->tab_view) == 0)
gtk_widget_destroy (GTK_WIDGET (window));
}
typedef struct {
EphyWindow *window;
EphyEmbed *embed;
+ HdyTabPage *page;
guint id;
} TabHasModifiedFormsData;
static TabHasModifiedFormsData *
tab_has_modified_forms_data_new (EphyWindow *window,
- EphyEmbed *embed)
+ EphyEmbed *embed,
+ HdyTabPage *page)
{
TabHasModifiedFormsData *data = g_new (TabHasModifiedFormsData, 1);
data->window = window;
data->embed = embed;
+ data->page = page;
data->id = 0;
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&data->window);
g_object_add_weak_pointer (G_OBJECT (embed), (gpointer *)&data->embed);
+ g_object_add_weak_pointer (G_OBJECT (page), (gpointer *)&data->page);
return data;
}
@@ -3007,6 +2937,7 @@ tab_has_modified_forms_data_free (TabHasModifiedFormsData *data)
{
g_clear_weak_pointer (&data->window);
g_clear_weak_pointer (&data->embed);
+ g_clear_weak_pointer (&data->page);
g_clear_handle_id (&data->id, g_source_remove);
g_clear_pointer (&data, g_free);
}
@@ -3028,8 +2959,14 @@ tab_has_modified_forms_cb (EphyWebView *view,
if (data->id != 0 &&
data->window != NULL &&
data->embed != NULL &&
- (!has_modified_forms || confirm_close_with_modified_forms (data->window))) {
- ephy_window_close_tab (data->window, data->embed);
+ data->page != NULL) {
+ HdyTabView *tab_view = ephy_tab_view_get_tab_view (data->window->tab_view);
+
+ if (!has_modified_forms || confirm_close_with_modified_forms (data->window)) {
+ ephy_window_close_tab (data->window, data->embed);
+ hdy_tab_view_close_page_finish (tab_view, data->page, TRUE);
+ } else
+ hdy_tab_view_close_page_finish (tab_view, data->page, FALSE);
}
data->id = 0;
@@ -3046,9 +2983,17 @@ tab_has_modified_forms_timeout_cb (TabHasModifiedFormsData *data)
* ephy_window_close_tab().
*/
data->id = 0;
- if (data->window != NULL && data->embed != NULL)
+ if (data->window != NULL &&
+ data->embed != NULL &&
+ data->page != NULL) {
+ HdyTabView *tab_view = ephy_tab_view_get_tab_view (data->window->tab_view);
+ HdyTabPage *page = data->page;
+
ephy_window_close_tab (data->window, data->embed);
+ hdy_tab_view_close_page_finish (tab_view, page, TRUE);
+ }
+
return G_SOURCE_REMOVE;
}
@@ -3073,15 +3018,18 @@ run_downloads_in_background (EphyWindow *window,
gtk_widget_hide (GTK_WIDGET (window));
}
-static void
-notebook_page_close_request_cb (EphyNotebook *notebook,
- EphyEmbed *embed,
- EphyWindow *window)
+static gboolean
+tab_view_close_page_cb (HdyTabView *tab_view,
+ HdyTabPage *page,
+ EphyWindow *window)
{
- if (gtk_notebook_get_n_pages (window->notebook) == 1) {
+ EphyEmbed *embed = EPHY_EMBED (hdy_tab_page_get_content (page));
+
+ if (ephy_tab_view_get_n_pages (window->tab_view) == 1) {
if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_QUIT)) {
- return;
+ hdy_tab_view_close_page_finish (tab_view, page, FALSE);
+ return GDK_EVENT_STOP;
}
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_AUTOMATION) {
@@ -3096,7 +3044,8 @@ notebook_page_close_request_cb (EphyNotebook *notebook,
if (ephy_downloads_manager_has_active_downloads (manager)) {
GList *list = ephy_downloads_manager_get_downloads (manager);
run_downloads_in_background (window, g_list_length (list));
- return;
+ hdy_tab_view_close_page_finish (tab_view, page, FALSE);
+ return GDK_EVENT_STOP;
}
}
}
@@ -3111,23 +3060,23 @@ notebook_page_close_request_cb (EphyNotebook *notebook,
* also be caused by a network process hang!) We'll assume the process has
* been hung if there's no response after one second.
*/
- data = tab_has_modified_forms_data_new (window, embed);
+ data = tab_has_modified_forms_data_new (window, embed, page);
data->id = g_timeout_add_seconds (1, (GSourceFunc)tab_has_modified_forms_timeout_cb, data);
ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
NULL,
(GAsyncReadyCallback)tab_has_modified_forms_cb,
data);
+ return GDK_EVENT_STOP;
} else {
ephy_window_close_tab (window, embed);
}
+
+ return GDK_EVENT_PROPAGATE;
}
-static GtkWidget *
-notebook_create_window_cb (GtkNotebook *notebook,
- GtkWidget *page,
- int x,
- int y,
- EphyWindow *window)
+static HdyTabView *
+tab_view_create_window_cb (HdyTabView *tab_view,
+ EphyWindow *window)
{
EphyWindow *new_window;
@@ -3136,24 +3085,7 @@ notebook_create_window_cb (GtkNotebook *notebook,
new_window->present_on_insert = TRUE;
new_window->present_on_insert_user_time = gtk_get_current_event_time ();
- return ephy_window_get_notebook (new_window);
-}
-
-static EphyEmbed *
-real_get_active_tab (EphyWindow *window,
- int page_num)
-{
- GtkWidget *embed;
-
- if (page_num == -1) {
- page_num = gtk_notebook_get_current_page (window->notebook);
- }
-
- embed = gtk_notebook_get_nth_page (window->notebook, page_num);
-
- g_assert (EPHY_IS_EMBED (embed));
-
- return EPHY_EMBED (embed);
+ return ephy_tab_view_get_tab_view (new_window->tab_view);
}
void
@@ -3176,81 +3108,79 @@ ephy_window_update_entry_focus (EphyWindow *window,
}
static void
-notebook_switch_page_cb (GtkNotebook *notebook,
- GtkWidget *page,
- guint page_num,
- EphyWindow *window)
+tab_view_notify_selected_page_cb (EphyWindow *window)
{
EphyEmbed *embed;
- GActionGroup *group;
- GAction *action;
EphyWebView *view;
-
- LOG ("switch-page notebook %p position %u\n", notebook, page_num);
+ int page_num;
if (window->closing)
return;
+ page_num = ephy_tab_view_get_selected_index (window->tab_view);
+
+ LOG ("switch-page tab view %p position %d\n", window->tab_view, page_num);
+
/* get the new tab */
- embed = real_get_active_tab (window, page_num);
+
+ embed = EPHY_EMBED (ephy_tab_view_get_nth_page (window->tab_view, page_num));
view = ephy_embed_get_web_view (embed);
/* update new tab */
ephy_window_set_active_tab (window, embed);
- /* update notebook menu */
- group = gtk_widget_get_action_group (GTK_WIDGET (window), "win");
- action = g_action_map_lookup_action (G_ACTION_MAP (group), "show-tab");
- g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_uint32 (page_num));
-
update_reader_mode (window, view);
-
- ephy_window_update_entry_focus (window, view);
}
static void
-notebook_page_reordered_cb (GtkNotebook *notebook,
- GtkWidget *child,
- guint page_num,
- gpointer user_data)
+tab_view_page_reordered_cb (EphyWindow *window)
{
- EphyWindow *window = EPHY_WINDOW (user_data);
-
window->last_opened_embed = NULL;
}
-static GtkNotebook *
-setup_notebook (EphyWindow *window)
+static EphyTabView *
+setup_tab_view (EphyWindow *window)
{
- GtkNotebook *notebook;
-
- notebook = GTK_NOTEBOOK (g_object_new (EPHY_TYPE_NOTEBOOK, NULL));
+ EphyTabView *tab_view = ephy_tab_view_new ();
+ HdyTabView *view = ephy_tab_view_get_tab_view (tab_view);
+ g_autoptr (GtkBuilder) builder = NULL;
- g_signal_connect_after (notebook, "switch-page",
- G_CALLBACK (notebook_switch_page_cb),
- window);
- g_signal_connect (notebook, "create-window",
- G_CALLBACK (notebook_create_window_cb),
- window);
-
- g_signal_connect (notebook, "popup-menu",
- G_CALLBACK (notebook_popup_menu_cb), window);
- g_signal_connect (notebook, "button-press-event",
- G_CALLBACK (notebook_button_press_cb), window);
-
- g_signal_connect (notebook, "page-added",
- G_CALLBACK (notebook_page_added_cb), window);
- g_signal_connect (notebook, "page-removed",
- G_CALLBACK (notebook_page_removed_cb), window);
- g_signal_connect (notebook, "tab-close-request",
- G_CALLBACK (notebook_page_close_request_cb), window);
- g_signal_connect (notebook, "page-reordered",
- G_CALLBACK (notebook_page_reordered_cb), window);
-
- g_signal_connect_swapped (notebook, "open-link",
- G_CALLBACK (ephy_link_open), window);
+ builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/notebook-context-menu.ui");
- return notebook;
+ hdy_tab_view_set_menu_model (view, G_MENU_MODEL (gtk_builder_get_object (builder, "notebook-menu")));
+
+ g_signal_connect_object (view, "notify::selected-page",
+ G_CALLBACK (tab_view_notify_selected_page_cb),
+ window,
+ G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (view, "create-window",
+ G_CALLBACK (tab_view_create_window_cb),
+ window,
+ 0);
+ g_signal_connect_object (view, "setup-menu",
+ G_CALLBACK (tab_view_setup_menu_cb),
+ window,
+ 0);
+ g_signal_connect_object (view, "close-page",
+ G_CALLBACK (tab_view_close_page_cb),
+ window,
+ 0);
+
+ g_signal_connect_object (view, "page-added",
+ G_CALLBACK (tab_view_page_added_cb),
+ window,
+ 0);
+ g_signal_connect_object (view, "page-removed",
+ G_CALLBACK (tab_view_page_removed_cb),
+ window,
+ 0);
+ g_signal_connect_object (view, "page-reordered",
+ G_CALLBACK (tab_view_page_reordered_cb),
+ window,
+ G_CONNECT_SWAPPED);
+
+ return tab_view;
}
static void
@@ -3842,11 +3772,15 @@ ephy_window_constructed (GObject *object)
/* Setup tab accels */
setup_tab_accels (window);
- window->notebook = setup_notebook (window);
+ window->tab_view = setup_tab_view (window);
+ window->tab_bar = hdy_tab_bar_new ();
+ window->tab_bar_revealer = GTK_REVEALER (gtk_revealer_new ());
window->main_deck = hdy_deck_new ();
window->pages_view = ephy_pages_view_new ();
- ephy_pages_view_set_notebook (window->pages_view, EPHY_NOTEBOOK (window->notebook));
+ gtk_revealer_set_transition_type (window->tab_bar_revealer, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
+ hdy_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);
shell = ephy_shell_get_default ();
mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell));
@@ -3868,7 +3802,9 @@ ephy_window_constructed (GObject *object)
!ephy_profile_dir_is_web_application ())
add_default_browser_question (box);
- gtk_box_pack_start (box, GTK_WIDGET (window->notebook), TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (window->tab_bar_revealer), GTK_WIDGET (window->tab_bar));
+ gtk_box_pack_start (box, GTK_WIDGET (window->tab_bar_revealer), FALSE, TRUE, 0);
+ gtk_box_pack_start (box, GTK_WIDGET (window->tab_view), TRUE, TRUE, 0);
gtk_box_pack_start (box, GTK_WIDGET (window->action_bar), FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (window->main_deck), GTK_WIDGET (box));
gtk_container_add (GTK_CONTAINER (window->main_deck), GTK_WIDGET (window->pages_view));
@@ -3876,7 +3812,9 @@ ephy_window_constructed (GObject *object)
gtk_widget_show_all (GTK_WIDGET (window->pages_view));
gtk_widget_show (GTK_WIDGET (window->main_deck));
gtk_widget_show (GTK_WIDGET (box));
- gtk_widget_show (GTK_WIDGET (window->notebook));
+ gtk_widget_show (GTK_WIDGET (window->tab_view));
+ gtk_widget_show (GTK_WIDGET (window->tab_bar));
+ gtk_widget_show (GTK_WIDGET (window->tab_bar_revealer));
hdy_deck_set_visible_child (HDY_DECK (window->main_deck), GTK_WIDGET (box));
hdy_deck_set_can_swipe_back (HDY_DECK (window->main_deck), TRUE);
@@ -4013,19 +3951,19 @@ ephy_window_new (void)
}
/**
- * ephy_window_get_notebook:
+ * ephy_window_get_tab_view:
* @window: an #EphyWindow
*
- * Returns the #GtkNotebook used by this window.
+ * Returns the #EphyTabView used by this window.
*
- * Return value: (transfer none): the @window's #GtkNotebook
+ * Return value: (transfer none): the @window's #EphyTabView
**/
-GtkWidget *
-ephy_window_get_notebook (EphyWindow *window)
+EphyTabView *
+ephy_window_get_tab_view (EphyWindow *window)
{
g_assert (EPHY_IS_WINDOW (window));
- return GTK_WIDGET (window->notebook);
+ return window->tab_view;
}
/**
@@ -4344,7 +4282,7 @@ ephy_window_check_modified_forms (EphyWindow *window)
data = g_new0 (ModifiedFormsData, 1);
data->window = window;
data->cancellable = g_cancellable_new ();
- data->embeds_to_check = gtk_notebook_get_n_pages (window->notebook);
+ data->embeds_to_check = ephy_tab_view_get_n_pages (window->tab_view);
tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
for (l = tabs; l != NULL; l = l->next) {
@@ -4394,7 +4332,7 @@ ephy_window_close (EphyWindow *window)
if (!window->force_close &&
g_settings_get_boolean (EPHY_SETTINGS_MAIN,
EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA) &&
- gtk_notebook_get_n_pages (window->notebook) > 0) {
+ ephy_tab_view_get_n_pages (window->tab_view) > 0) {
ephy_window_check_modified_forms (window);
/* stop window close */
return FALSE;
@@ -4402,7 +4340,7 @@ ephy_window_close (EphyWindow *window)
session = ephy_shell_get_session (ephy_shell_get_default ());
if (ephy_shell_get_n_windows (ephy_shell_get_default ()) > 1 &&
- gtk_notebook_get_n_pages (window->notebook) > 1 &&
+ ephy_tab_view_get_n_pages (window->tab_view) > 1 &&
!ephy_session_is_closing (session) &&
!confirm_close_with_multiple_tabs (window)) {
/* stop window close */
@@ -4451,25 +4389,16 @@ int
ephy_window_get_position_for_new_embed (EphyWindow *window,
EphyEmbed *embed)
{
- GtkWidget *notebook = ephy_window_get_notebook (window);
+ HdyTabView *view = ephy_tab_view_get_tab_view (window->tab_view);
+ HdyTabPage *page;
int position;
if (embed == window->last_opened_embed)
return window->last_opened_pos++;
- position = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), GTK_WIDGET (embed)) + 1;
-
- /* Loop through all pages and skip all pinned tabs */
- do {
- GtkWidget *page;
-
- page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), position);
- if (!page)
- break;
-
- if (!ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), EPHY_EMBED (page)))
- break;
- } while (++position < gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)));
+ page = hdy_tab_view_get_page (view, GTK_WIDGET (embed));
+ position = hdy_tab_view_get_page_position (view, page) + 1;
+ position = MAX (position, hdy_tab_view_get_n_pinned_pages (view));
if (window->last_opened_embed)
g_object_remove_weak_pointer (G_OBJECT (window->last_opened_embed), (gpointer
*)&window->last_opened_embed);
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 01c272846..893dfed69 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -24,6 +24,7 @@
#include "ephy-embed.h"
#include "ephy-embed-event.h"
#include "ephy-location-controller.h"
+#include "ephy-tab-view.h"
#include "ephy-web-view.h"
#include <gtk/gtk.h>
@@ -46,7 +47,7 @@ typedef enum
EphyWindow *ephy_window_new (void);
-GtkWidget *ephy_window_get_notebook (EphyWindow *window);
+EphyTabView *ephy_window_get_tab_view (EphyWindow *window);
void ephy_window_open_pages_view (EphyWindow *window);
void ephy_window_close_pages_view (EphyWindow *window);
diff --git a/src/meson.build b/src/meson.build
index 667cd4fdc..efdaf16b8 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -33,16 +33,14 @@ libephymain_sources = [
'ephy-location-controller.c',
'ephy-lockdown.c',
'ephy-mouse-gesture-controller.c',
- 'ephy-notebook.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',
+ 'ephy-tab-view.c',
'ephy-tab-header-bar.c',
- 'ephy-tab-label.c',
'ephy-window.c',
'popup-commands.c',
'preferences/clear-data-view.c',
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 138894596..c66e77e08 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -39,14 +39,12 @@
<file preprocess="xml-stripblanks" compressed="true">gtk/prefs-privacy-page.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-label.ui</file>
<file preprocess="xml-stripblanks" compressed="true">gtk/webapp-additional-urls-dialog.ui</file>
</gresource>
<gresource prefix="/org/gnome/Epiphany/icons">
<file compressed="true" alias="scalable/actions/ephy-download-symbolic.svg"
preprocess="xml-stripblanks">ephy-download-symbolic.svg</file>
<file compressed="true"
alias="scalable/actions/ephy-bookmarks-symbolic.svg">ephy-bookmarks-symbolic.svg</file>
<file compressed="true"
alias="scalable/actions/ephy-bookmark-tag-symbolic.svg">ephy-bookmark-tag-symbolic.svg</file>
- <file compressed="true"
alias="scalable/actions/ephy-missing-favicon-symbolic.svg">ephy-missing-favicon-symbolic.svg</file>
<file compressed="true"
alias="scalable/actions/ephy-reader-mode-symbolic.svg">ephy-reader-mode-symbolic.svg</file>
<file compressed="true"
alias="scalable/status/ephy-audio-muted-symbolic.svg">ephy-audio-muted-symbolic.svg</file>
<file compressed="true"
alias="scalable/status/ephy-audio-playing-symbolic.svg">ephy-audio-playing-symbolic.svg</file>
diff --git a/src/resources/gtk/page-row.ui b/src/resources/gtk/page-row.ui
index 17bcb9278..8e95a71a7 100644
--- a/src/resources/gtk/page-row.ui
+++ b/src/resources/gtk/page-row.ui
@@ -4,6 +4,9 @@
<requires lib="gtk+" version="3.16"/>
<template class="EphyPageRow" parent="GtkListBoxRow">
<property name="can_focus">True</property>
+ <style>
+ <class name="narrow"/>
+ </style>
<child>
<object class="GtkEventBox">
<property name="visible">True</property>
@@ -13,6 +16,9 @@
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="height-request">50</property>
+ <property name="margin-start">8</property>
+ <property name="margin-end">4</property>
<child>
<object class="GtkStack" id="icon_stack">
<property name="visible">True</property>
@@ -32,6 +38,7 @@
<object class="GtkSpinner" id="spinner">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="active">True</property>
</object>
<packing>
<property name="position">1</property>
diff --git a/src/resources/themes/_Adwaita-base.scss b/src/resources/themes/_Adwaita-base.scss
index 01a51b9e8..66c62989e 100644
--- a/src/resources/themes/_Adwaita-base.scss
+++ b/src/resources/themes/_Adwaita-base.scss
@@ -85,39 +85,6 @@ $close_button_fg_color: if($variant == 'light', lighten($fg_color, 10%), darken(
animation-iteration-count: 3;
}
-// Pinned tabs
-.main-notebook {
- tab {
- min-width: 16px;
- }
-
- header {
- &.top,
- &.bottom {
- tab {
- border-style: none solid;
- }
- }
-
- &.left,
- &.right {
- tab {
- border-style: solid none;
- }
- }
- }
-}
-
-.tab-attention {
- $_dot_color: if($variant=='light', $selected_bg_color,
- lighten($selected_bg_color,15%));
- background-image: -gtk-gradient(radial,
- center center, 0,
- center center, 0.5,
- to($_dot_color),
- to(transparent));
-}
-
#title-box-container {
color: gtkalpha(themecolor(theme_fg_color), 0.2);
diff --git a/src/resources/themes/elementary.scss b/src/resources/themes/elementary.scss
index 26459a87c..04ca05682 100644
--- a/src/resources/themes/elementary.scss
+++ b/src/resources/themes/elementary.scss
@@ -56,12 +56,6 @@ $variant: 'light';
}
}
-.main-notebook {
- tab {
- min-width: 30px;
- }
-}
-
// FIXME: this should be in libdazzle
dzlsuggestionpopover > revealer > box {
// Fix background and shadow
diff --git a/src/window-commands.c b/src/window-commands.c
index c4ed583d5..ee71b5059 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -46,13 +46,13 @@
#include "ephy-history-dialog.h"
#include "ephy-link.h"
#include "ephy-location-entry.h"
-#include "ephy-notebook.h"
#include "ephy-password-import.h"
#include "ephy-prefs.h"
#include "ephy-session.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-string.h"
+#include "ephy-tab-view.h"
#include "ephy-view-source-handler.h"
#include "ephy-web-app-utils.h"
#include "ephy-zoom.h"
@@ -1229,7 +1229,7 @@ window_cmd_reload (GSimpleAction *action,
EphyWindow *window = EPHY_WINDOW (user_data);
EphyEmbed *embed;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ embed = EPHY_EMBED (ephy_tab_view_get_current_page (ephy_window_get_tab_view (window)));
g_assert (embed != NULL);
ephy_web_view_has_modified_forms (ephy_embed_get_web_view (embed),
@@ -2655,80 +2655,21 @@ window_cmd_change_fullscreen_state (GSimpleAction *action,
g_simple_action_set_state (action, g_variant_new_boolean (active));
}
-void
-window_cmd_tabs_previous (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- GtkWidget *nb;
-
- nb = ephy_window_get_notebook (EPHY_WINDOW (user_data));
- g_assert (nb != NULL);
-
- ephy_notebook_prev_page (EPHY_NOTEBOOK (nb));
-}
-
-void
-window_cmd_tabs_next (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- GtkWidget *nb;
-
- nb = ephy_window_get_notebook (EPHY_WINDOW (user_data));
- g_assert (nb != NULL);
-
- ephy_notebook_next_page (EPHY_NOTEBOOK (nb));
-}
-
-void
-window_cmd_tabs_move_left (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- GtkWidget *child;
- GtkNotebook *notebook;
- int page;
-
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (EPHY_WINDOW (user_data)));
- page = gtk_notebook_get_current_page (notebook);
- if (page < 1)
- return;
-
- child = gtk_notebook_get_nth_page (notebook, page);
- gtk_notebook_reorder_child (notebook, child, page - 1);
-}
-
-void window_cmd_tabs_move_right (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- GtkWidget *child;
- GtkNotebook *notebook;
- int page, n_pages;
-
- notebook = GTK_NOTEBOOK (ephy_window_get_notebook (EPHY_WINDOW (user_data)));
- page = gtk_notebook_get_current_page (notebook);
- n_pages = gtk_notebook_get_n_pages (notebook) - 1;
- if (page > n_pages - 1)
- return;
-
- child = gtk_notebook_get_nth_page (notebook, page);
- gtk_notebook_reorder_child (notebook, child, page + 1);
-}
-
void
window_cmd_tabs_duplicate (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
{
+ EphyTabView *tab_view;
EphyEmbed *embed, *new_embed;
WebKitWebView *view, *new_view;
WebKitWebViewSessionState *session_state;
WebKitBackForwardList *bf_list;
WebKitBackForwardListItem *item;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (user_data));
+ tab_view = ephy_window_get_tab_view (EPHY_WINDOW (user_data));
+ embed = EPHY_EMBED (ephy_tab_view_get_current_page (tab_view));
+
view = WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed));
session_state = webkit_web_view_get_session_state (view);
@@ -2756,25 +2697,17 @@ window_cmd_tabs_close (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = user_data;
- GtkWidget *notebook;
- EphyEmbed *embed;
- gboolean pinned;
+ EphyTabView *tab_view;
- notebook = ephy_window_get_notebook (window);
+ tab_view = ephy_window_get_tab_view (window);
if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_QUIT) &&
- gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) == 1) {
+ ephy_tab_view_get_n_pages (tab_view) <= 1) {
return;
}
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_assert (embed != NULL);
-
- pinned = ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), embed);
-
- if (!pinned)
- g_signal_emit_by_name (notebook, "tab-close-request", embed);
+ ephy_tab_view_close_selected (tab_view);
}
void
@@ -2783,27 +2716,8 @@ window_cmd_tabs_close_left (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = user_data;
- GtkWidget *notebook;
- EphyEmbed *embed;
- int current_page_no;
- GSList *pages_to_close = NULL;
-
- notebook = ephy_window_get_notebook (window);
- current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- for (int i = 0; i < current_page_no; i++) {
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
- if (!ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), embed))
- pages_to_close = g_slist_prepend (pages_to_close, embed);
- }
-
- for (GSList *l = pages_to_close; l != NULL; l = l->next) {
- g_assert (l->data != NULL);
- g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data);
- }
-
- g_slist_free (pages_to_close);
+ ephy_tab_view_close_left (ephy_window_get_tab_view (window));
}
void
@@ -2812,28 +2726,8 @@ window_cmd_tabs_close_right (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = user_data;
- GtkWidget *notebook;
- EphyEmbed *embed;
- int n_pages, current_page_no;
- GSList *pages_to_close = NULL;
- notebook = ephy_window_get_notebook (window);
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
- current_page_no = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- for (int i = current_page_no + 1; i < n_pages; i++) {
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
-
- if (!ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), embed))
- pages_to_close = g_slist_prepend (pages_to_close, embed);
- }
-
- for (GSList *l = pages_to_close; l != NULL; l = l->next) {
- g_assert (l->data != NULL);
- g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data);
- }
-
- g_slist_free (pages_to_close);
+ ephy_tab_view_close_right (ephy_window_get_tab_view (window));
}
void
@@ -2842,30 +2736,18 @@ window_cmd_tabs_close_others (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = user_data;
- GtkWidget *notebook;
- EphyEmbed *embed;
- int n_pages, current_page;
- GSList *pages_to_close = NULL;
-
- notebook = ephy_window_get_notebook (window);
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
- current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
-
- for (int i = 0; i < n_pages; i++) {
- if (i != current_page) {
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
- if (!ephy_notebook_tab_is_pinned (EPHY_NOTEBOOK (notebook), embed))
- pages_to_close = g_slist_prepend (pages_to_close, embed);
- }
- }
+ ephy_tab_view_close_other (ephy_window_get_tab_view (window));
+}
- for (GSList *l = pages_to_close; l != NULL; l = l->next) {
- g_assert (l->data != NULL);
- g_signal_emit_by_name (GTK_NOTEBOOK (notebook), "tab-close-request", l->data);
- }
+static void
+reload_cb (GtkWidget *widget,
+ gpointer user_data)
+{
+ EphyEmbed *embed = EPHY_EMBED (widget);
+ WebKitWebView *view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- g_slist_free (pages_to_close);
+ webkit_web_view_reload (view);
}
void
@@ -2874,45 +2756,10 @@ window_cmd_tabs_reload_all_tabs (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = user_data;
- EphyEmbed *embed;
- WebKitWebView *view;
- GtkWidget *notebook;
- int n_pages;
-
- notebook = ephy_window_get_notebook (window);
- n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
-
- for (int i = 0; i < n_pages; i++) {
- embed = EPHY_EMBED (gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), i));
-
- view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- webkit_web_view_reload (view);
- }
-}
-void
-window_cmd_show_tab (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- EphyWindow *window = EPHY_WINDOW (user_data);
- GtkWidget *notebook;
- guint32 tab_num;
-
- g_assert (g_variant_is_of_type (parameter, G_VARIANT_TYPE_UINT32));
- tab_num = g_variant_get_uint32 (parameter);
-
- notebook = ephy_window_get_notebook (window);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), tab_num);
- g_simple_action_set_state (action, parameter);
-}
-
-void
-window_cmd_change_show_tab_state (GSimpleAction *action,
- GVariant *parameter,
- gpointer user_data)
-{
- /* This page intentionally left blank. */
+ ephy_tab_view_foreach (ephy_window_get_tab_view (window),
+ reload_cb,
+ NULL);
}
void
@@ -3027,15 +2874,8 @@ window_cmd_tabs_pin (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = EPHY_WINDOW (user_data);
- EphyEmbed *embed;
- EphyNotebook *notebook;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_assert (embed != NULL);
-
- notebook = EPHY_NOTEBOOK (ephy_window_get_notebook (window));
- ephy_notebook_tab_set_pinned (notebook, GTK_WIDGET (embed), TRUE);
+ ephy_tab_view_pin (ephy_window_get_tab_view (window));
}
void
@@ -3044,15 +2884,8 @@ window_cmd_tabs_unpin (GSimpleAction *action,
gpointer user_data)
{
EphyWindow *window = EPHY_WINDOW (user_data);
- EphyEmbed *embed;
- EphyNotebook *notebook;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_assert (embed != NULL);
-
- notebook = EPHY_NOTEBOOK (ephy_window_get_notebook (window));
- ephy_notebook_tab_set_pinned (notebook, GTK_WIDGET (embed), FALSE);
+ ephy_tab_view_unpin (ephy_window_get_tab_view (window));
}
void
diff --git a/src/window-commands.h b/src/window-commands.h
index 353251e7f..3e4ece250 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -179,18 +179,6 @@ void window_cmd_change_browse_with_caret_state (GSimpleAction *action,
void window_cmd_change_fullscreen_state (GSimpleAction *action,
GVariant *state,
gpointer user_data);
-void window_cmd_tabs_previous (GSimpleAction *action,
- GVariant *state,
- gpointer user_data);
-void window_cmd_tabs_next (GSimpleAction *action,
- GVariant *state,
- gpointer user_data);
-void window_cmd_tabs_move_left (GSimpleAction *action,
- GVariant *state,
- gpointer user_data);
-void window_cmd_tabs_move_right (GSimpleAction *action,
- GVariant *state,
- gpointer user_data);
void window_cmd_tabs_duplicate (GSimpleAction *action,
GVariant *state,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]