[epiphany/wip/exalm/tabs: 10/10] fixup! Port to HdyTabView/HdyTabBar
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/tabs: 10/10] fixup! Port to HdyTabView/HdyTabBar
- Date: Tue, 2 Feb 2021 13:47:32 +0000 (UTC)
commit 035d4e4a162b3c83835342936f684c0a4bf5a335
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Feb 2 18:47:15 2021 +0500
fixup! Port to HdyTabView/HdyTabBar
embed/ephy-embed-container.c | 11 +++++++----
embed/ephy-embed-container.h | 6 ++++--
src/ephy-shell.c | 5 +++--
src/ephy-tab-view.c | 11 +++++++++--
src/ephy-tab-view.h | 3 ++-
src/ephy-window.c | 30 +++---------------------------
src/ephy-window.h | 3 ---
7 files changed, 28 insertions(+), 41 deletions(-)
---
diff --git a/embed/ephy-embed-container.c b/embed/ephy-embed-container.c
index cbd66e19e..edb86445f 100644
--- a/embed/ephy-embed-container.c
+++ b/embed/ephy-embed-container.c
@@ -43,18 +43,21 @@ ephy_embed_container_default_init (EphyEmbedContainerInterface *iface)
* ephy_embed_container_add_child:
* @container: an #EphyEmbedContainer
* @child: an #EphyEmbed
- * @position: the position in @container's
+ * @parent: (nullable): the parent #EphyEmbed, or %NULL
+ * @position: the position in @container if @parent is %NULL
* @set_active: whether to set @embed as the active child of @container
* after insertion
*
- * Inserts @child into @container.
+ * Inserts @child into @container. The new embed will be inserted after @parent,
+ * or at @position if it's %NULL.
*
* Return value: @child's new position inside @container.
**/
gint
ephy_embed_container_add_child (EphyEmbedContainer *container,
EphyEmbed *child,
- gint position,
+ EphyEmbed *parent,
+ int position,
gboolean set_active)
{
EphyEmbedContainerInterface *iface;
@@ -63,7 +66,7 @@ ephy_embed_container_add_child (EphyEmbedContainer *container,
g_assert (EPHY_IS_EMBED (child));
iface = EPHY_EMBED_CONTAINER_GET_IFACE (container);
- return iface->add_child (container, child, position, set_active);
+ return iface->add_child (container, child, parent, position, set_active);
}
/**
diff --git a/embed/ephy-embed-container.h b/embed/ephy-embed-container.h
index 18b8ee01a..86a573d3c 100644
--- a/embed/ephy-embed-container.h
+++ b/embed/ephy-embed-container.h
@@ -38,7 +38,8 @@ struct _EphyEmbedContainerInterface
gint (* add_child) (EphyEmbedContainer *container,
EphyEmbed *child,
- gint position,
+ EphyEmbed *parent,
+ int position,
gboolean set_active);
void (* set_active_child) (EphyEmbedContainer *container,
@@ -58,7 +59,8 @@ struct _EphyEmbedContainerInterface
gint ephy_embed_container_add_child (EphyEmbedContainer *container,
EphyEmbed *child,
- gint position,
+ EphyEmbed *parent,
+ int position,
gboolean set_active);
void ephy_embed_container_set_active_child (EphyEmbedContainer *container,
EphyEmbed *child);
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index ae19357d9..650531da8 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -1024,6 +1024,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
EphyEmbed *embed = NULL;
gboolean jump_to = FALSE;
int position = -1;
+ EphyEmbed *parent = NULL;
g_assert (EPHY_IS_SHELL (shell));
g_assert (EPHY_IS_WINDOW (window));
@@ -1039,7 +1040,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
if (flags & EPHY_NEW_TAB_APPEND_AFTER) {
if (previous_embed)
- position = ephy_window_get_position_for_new_embed (window, previous_embed);
+ parent = previous_embed;
else
g_warning ("Requested to append new tab after parent, but 'previous_embed' was NULL");
}
@@ -1060,7 +1061,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
"progress-bar-enabled", ephy_embed_shell_get_mode (embed_shell) ==
EPHY_EMBED_SHELL_MODE_APPLICATION,
NULL));
gtk_widget_show (GTK_WIDGET (embed));
- ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (window), embed, position, jump_to);
+ ephy_embed_container_add_child (EPHY_EMBED_CONTAINER (window), embed, parent, position, jump_to);
if ((flags & EPHY_NEW_TAB_DONT_SHOW_WINDOW) == 0 &&
ephy_embed_shell_get_mode (embed_shell) != EPHY_EMBED_SHELL_MODE_TEST) {
diff --git a/src/ephy-tab-view.c b/src/ephy-tab-view.c
index 75a728e1e..18de36110 100644
--- a/src/ephy-tab-view.c
+++ b/src/ephy-tab-view.c
@@ -420,16 +420,23 @@ update_indicator_cb (HdyTabPage *page)
int
ephy_tab_view_add_tab (EphyTabView *self,
EphyEmbed *embed,
+ EphyEmbed *parent,
int position,
gboolean jump_to)
{
HdyTabPage *page;
EphyWebView *view;
- if (position < 0)
+ if (parent) {
+ HdyTabPage *parent_page;
+
+ parent_page = hdy_tab_view_get_page (self->tab_view, GTK_WIDGET (parent));
+ page = hdy_tab_view_add_page (self->tab_view, GTK_WIDGET (embed), parent_page);
+ } else if (position < 0) {
page = hdy_tab_view_append (self->tab_view, GTK_WIDGET (embed));
- else
+ } 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);
diff --git a/src/ephy-tab-view.h b/src/ephy-tab-view.h
index 6e72a5e16..fb8e0dc57 100644
--- a/src/ephy-tab-view.h
+++ b/src/ephy-tab-view.h
@@ -72,7 +72,8 @@ gboolean ephy_tab_view_get_is_pinned (EphyTabView *self,
gint ephy_tab_view_add_tab (EphyTabView *self,
EphyEmbed *embed,
- gint position,
+ EphyEmbed *parent,
+ int position,
gboolean jump_to);
GtkWidget *ephy_tab_view_get_current_page (EphyTabView *self);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index da99cb5aa..6882bf143 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -217,7 +217,8 @@ enum {
static gint
impl_add_child (EphyEmbedContainer *container,
EphyEmbed *child,
- gint position,
+ EphyEmbed *parent,
+ int position,
gboolean jump_to)
{
EphyWindow *window = EPHY_WINDOW (container);
@@ -225,7 +226,7 @@ impl_add_child (EphyEmbedContainer *container,
g_assert (!window->is_popup || ephy_tab_view_get_n_pages (window->tab_view) < 1);
- ret = ephy_tab_view_add_tab (window->tab_view, child, position, jump_to);
+ ret = ephy_tab_view_add_tab (window->tab_view, child, parent, position, jump_to);
if (jump_to)
ephy_window_update_entry_focus (window, ephy_embed_get_web_view (child));
@@ -4367,31 +4368,6 @@ ephy_window_show_fullscreen_header_bar (EphyWindow *window)
window->show_fullscreen_header_bar = TRUE;
}
-int
-ephy_window_get_position_for_new_embed (EphyWindow *window,
- EphyEmbed *embed)
-{
- 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++;
-
- 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);
-
- g_object_add_weak_pointer (G_OBJECT (embed), (gpointer *)&window->last_opened_embed);
- window->last_opened_embed = embed;
- window->last_opened_pos = position + 1;
-
- return position;
-}
-
gboolean
ephy_window_is_maximized (EphyWindow *window)
{
diff --git a/src/ephy-window.h b/src/ephy-window.h
index caa8d9d78..cdd40fd6f 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -85,9 +85,6 @@ void ephy_window_set_default_position (EphyWindow *window,
gint y);
void ephy_window_show_fullscreen_header_bar (EphyWindow *window);
-int ephy_window_get_position_for_new_embed (EphyWindow *window,
- EphyEmbed *embed);
-
void ephy_window_update_entry_focus (EphyWindow *window,
EphyWebView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]