[epiphany/wip/exalm/gtk4-overview: 3/3] Port to AdwTabOverview




commit a3d0cd94deb3ba000d141472e2aa3471aaba3d0d
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Tue Aug 16 23:21:21 2022 +0400

    Port to AdwTabOverview

 org.gnome.Epiphany.json                      |  10 ++
 src/ephy-action-bar-end.c                    |  12 ++
 src/ephy-action-bar-end.h                    |   8 +-
 src/ephy-action-bar.c                        |  13 +-
 src/ephy-page-row.c                          | 219 ---------------------------
 src/ephy-page-row.h                          |  42 -----
 src/ephy-pages-button.c                      | 203 -------------------------
 src/ephy-pages-button.h                      |  38 -----
 src/ephy-pages-popover.c                     | 180 ----------------------
 src/ephy-pages-popover.h                     |  40 -----
 src/ephy-pages-view.c                        | 161 --------------------
 src/ephy-pages-view.h                        |  39 -----
 src/ephy-window.c                            |  90 +++--------
 src/meson.build                              |   4 -
 src/resources/ephy-tab-counter-symbolic.svg  |   3 -
 src/resources/ephy-tab-overflow-symbolic.svg |   4 -
 src/resources/epiphany.gresource.xml         |   6 -
 src/resources/gtk/action-bar-end.ui          |   6 +
 src/resources/gtk/action-bar.ui              |   4 +-
 src/resources/gtk/page-row.ui                |  65 --------
 src/resources/gtk/pages-button.ui            |  27 ----
 src/resources/gtk/pages-popover.ui           |  26 ----
 src/resources/gtk/pages-view.ui              |  46 ------
 src/resources/style.css                      |  17 ---
 24 files changed, 59 insertions(+), 1204 deletions(-)
---
diff --git a/org.gnome.Epiphany.json b/org.gnome.Epiphany.json
index 8ac8d797b..ed02b398c 100644
--- a/org.gnome.Epiphany.json
+++ b/org.gnome.Epiphany.json
@@ -123,6 +123,16 @@
                 }
             ]
         },
+    {
+      "name": "libadwaita",
+      "buildsystem": "meson",
+      "sources": [
+        {
+          "type": "dir",
+          "path": "../libadwaita"
+        }
+      ]
+    },
         {
             "name" : "epiphany",
             "buildsystem" : "meson",
diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c
index bc5d1200a..46f42ef2a 100644
--- a/src/ephy-action-bar-end.c
+++ b/src/ephy-action-bar-end.c
@@ -39,6 +39,7 @@ struct _EphyActionBarEnd {
   GtkWidget *downloads_popover;
   GtkWidget *downloads_icon;
   GtkWidget *browser_action_box;
+  GtkWidget *overview_button;
 
   GdkPaintable *downloads_paintable;
 
@@ -142,6 +143,9 @@ ephy_action_bar_end_class_init (EphyActionBarEndClass *klass)
   gtk_widget_class_bind_template_child (widget_class,
                                         EphyActionBarEnd,
                                         browser_action_box);
+  gtk_widget_class_bind_template_child (widget_class,
+                                        EphyActionBarEnd,
+                                        overview_button);
 }
 
 static void
@@ -273,3 +277,11 @@ ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd      *action_bar_e
       g_assert_not_reached ();
   }
 }
+
+void
+ephy_action_bar_end_set_adaptive_mode (EphyActionBarEnd *action_bar_end,
+                                       EphyAdaptiveMode  adaptive_mode)
+{
+  gtk_widget_set_visible (action_bar_end->overview_button,
+                          adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL);
+}
diff --git a/src/ephy-action-bar-end.h b/src/ephy-action-bar-end.h
index ffecf9596..b9cf0219e 100644
--- a/src/ephy-action-bar-end.h
+++ b/src/ephy-action-bar-end.h
@@ -21,10 +21,11 @@
 
 #pragma once
 
-#include "ephy-bookmark-states.h"
-
 #include <gtk/gtk.h>
 
+#include "ephy-adaptive-mode.h"
+#include "ephy-bookmark-states.h"
+
 G_BEGIN_DECLS
 
 #define EPHY_TYPE_ACTION_BAR_END (ephy_action_bar_end_get_type ())
@@ -47,4 +48,7 @@ void              ephy_action_bar_end_set_show_bookmark_button (EphyActionBarEnd
 void              ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd       *action_bar_end,
                                                                EphyBookmarkIconState  state);
 
+void              ephy_action_bar_end_set_adaptive_mode       (EphyActionBarEnd *action_bar_end,
+                                                               EphyAdaptiveMode  adaptive_mode);
+
 G_END_DECLS
diff --git a/src/ephy-action-bar.c b/src/ephy-action-bar.c
index a381a8756..982398937 100644
--- a/src/ephy-action-bar.c
+++ b/src/ephy-action-bar.c
@@ -21,7 +21,6 @@
 
 #include "ephy-action-bar.h"
 #include "ephy-add-bookmark-popover.h"
-#include "ephy-pages-button.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-tab-view.h"
@@ -42,7 +41,7 @@ struct _EphyActionBar {
   GtkRevealer *revealer;
   EphyActionBarStart *action_bar_start;
   EphyActionBarEnd *action_bar_end;
-  EphyPagesButton *pages_button;
+  AdwTabButton *pages_button;
 
   EphyAdaptiveMode adaptive_mode;
   gboolean can_reveal;
@@ -131,9 +130,8 @@ ephy_action_bar_constructed (GObject *object)
                            G_CALLBACK (sync_chromes_visibility), action_bar,
                            G_CONNECT_SWAPPED);
 
-  g_object_bind_property (view, "n-pages",
-                          action_bar->pages_button, "n-pages",
-                          G_BINDING_SYNC_CREATE);
+  adw_tab_button_set_view (ADW_TAB_BUTTON (action_bar->pages_button),
+                           ephy_tab_view_get_tab_view (view));
 }
 
 static void
@@ -189,16 +187,15 @@ ephy_action_bar_init (EphyActionBar *action_bar)
   /* Ensure the types used by the template have been initialized. */
   EPHY_TYPE_ACTION_BAR_END;
   EPHY_TYPE_ACTION_BAR_START;
-  EPHY_TYPE_PAGES_BUTTON;
 
   gtk_widget_init_template (GTK_WIDGET (action_bar));
 
   mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (ephy_shell_get_default ()));
-  gtk_widget_set_visible (GTK_WIDGET (action_bar->pages_button),
-                          mode != EPHY_EMBED_SHELL_MODE_APPLICATION);
 
   ephy_action_bar_start_set_adaptive_mode (action_bar->action_bar_start,
                                            EPHY_ADAPTIVE_MODE_NARROW);
+  ephy_action_bar_end_set_adaptive_mode (action_bar->action_bar_end,
+                                         EPHY_ADAPTIVE_MODE_NARROW);
 
   g_object_bind_property (action_bar->revealer, "child-revealed",
                           action_bar, "visible",
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 4e727791b..7d01956a2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -47,8 +47,6 @@
 #include "ephy-link.h"
 #include "ephy-location-entry.h"
 #include "ephy-mouse-gesture-controller.h"
-#include "ephy-pages-popover.h"
-#include "ephy-pages-view.h"
 #include "ephy-permissions-manager.h"
 #include "ephy-prefs.h"
 #include "ephy-security-popover.h"
@@ -151,18 +149,15 @@ static guint64 window_uid = 1;
 struct _EphyWindow {
   AdwApplicationWindow parent_instance;
 
-  GtkWidget *main_leaflet;
+  GtkWidget *overview;
   EphyFullscreenBox *fullscreen_box;
   GtkBox *titlebar_box;
   GtkWidget *header_bar;
-  EphyPagesView *pages_view;
   EphyBookmarksManager *bookmarks_manager;
   GHashTable *action_labels;
   EphyTabView *tab_view;
   AdwTabBar *tab_bar;
   GtkRevealer *tab_bar_revealer;
-  GtkRevealer *pages_menu_revealer;
-  EphyPagesPopover *pages_popover;
   GtkWidget *action_bar;
   EphyEmbed *active_embed;
   EphyWindowChrome chrome;
@@ -534,12 +529,6 @@ update_adaptive_mode (EphyWindow *window)
 
   gtk_revealer_set_reveal_child (window->tab_bar_revealer,
                                  adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL);
-
-  /* When switching to desktop sizes, drop the tabs view and go back
-   * to the main view.
-   */
-  if (adaptive_mode == EPHY_ADAPTIVE_MODE_NORMAL)
-    ephy_window_close_pages_view (window);
 }
 
 static void
@@ -3351,48 +3340,6 @@ setup_header_bar (EphyWindow *window)
   return header_bar;
 }
 
-static void
-update_pages_menu_revealer (EphyWindow *window)
-{
-  gtk_revealer_set_reveal_child (window->pages_menu_revealer,
-                                 adw_tab_bar_get_is_overflowing (window->tab_bar) ||
-                                 gtk_widget_get_visible (GTK_WIDGET (window->pages_popover)));
-}
-
-static void
-setup_tabs_menu (EphyWindow *window)
-{
-  GtkRevealer *revealer;
-  GtkWidget *menu_button;
-  EphyPagesPopover *popover;
-
-  revealer = GTK_REVEALER (gtk_revealer_new ());
-  gtk_revealer_set_transition_type (revealer,
-                                    GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
-  adw_tab_bar_set_end_action_widget (window->tab_bar, GTK_WIDGET (revealer));
-  window->pages_menu_revealer = revealer;
-
-  menu_button = gtk_menu_button_new ();
-  gtk_widget_add_css_class (menu_button, "flat");
-  /* Translators: tooltip for the tab switcher menu button */
-  gtk_widget_set_tooltip_text (menu_button, _("View open tabs"));
-  gtk_widget_set_margin_start (menu_button, 1);
-  gtk_revealer_set_child (revealer, menu_button);
-
-  popover = ephy_pages_popover_new ();
-  ephy_pages_popover_set_tab_view (popover, window->tab_view);
-  gtk_menu_button_set_popover (GTK_MENU_BUTTON (menu_button),
-                               GTK_WIDGET (popover));
-  window->pages_popover = popover;
-
-  g_signal_connect_object (window->tab_bar, "notify::is-overflowing",
-                           G_CALLBACK (update_pages_menu_revealer), window,
-                           G_CONNECT_SWAPPED);
-  g_signal_connect_object (window->pages_popover, "notify::visible",
-                           G_CALLBACK (update_pages_menu_revealer), window,
-                           G_CONNECT_SWAPPED);
-}
-
 static EphyLocationController *
 setup_location_controller (EphyWindow    *window,
                            EphyHeaderBar *header_bar)
@@ -3568,7 +3515,8 @@ notify_leaflet_child_cb (EphyWindow *window)
   GAction *action;
   gboolean pages_open;
 
-  pages_open = adw_leaflet_get_visible_child (ADW_LEAFLET (window->main_leaflet)) == GTK_WIDGET 
(window->pages_view);
+  pages_open = FALSE; // FIXME
+//  pages_open = adw_leaflet_get_visible_child (ADW_LEAFLET (window->main_leaflet)) == GTK_WIDGET 
(window->pages_view);
   action_group = ephy_window_get_action_group (window, "win");
 
   action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "content");
@@ -3677,19 +3625,22 @@ ephy_window_constructed (GObject *object)
   window->tab_view = setup_tab_view (window);
   window->tab_bar = adw_tab_bar_new ();
   window->tab_bar_revealer = GTK_REVEALER (gtk_revealer_new ());
-  window->main_leaflet = adw_leaflet_new ();
+  window->overview = adw_tab_overview_new ();
   window->fullscreen_box = ephy_fullscreen_box_new ();
-  window->pages_view = ephy_pages_view_new ();
 
-  adw_leaflet_set_can_unfold (ADW_LEAFLET (window->main_leaflet), FALSE);
-  g_signal_connect_swapped (window->main_leaflet, "notify::visible-child",
-                            G_CALLBACK (notify_leaflet_child_cb), window);
+  g_object_bind_property (window->tab_bar, "inverted",
+                          window->overview, "inverted",
+                          G_BINDING_DEFAULT);
+  adw_tab_overview_set_thumbnail_xalign (ADW_TAB_OVERVIEW (window->overview), 0);
+  adw_tab_overview_set_thumbnail_yalign (ADW_TAB_OVERVIEW (window->overview), 0);
+
+// FIXME
+//  g_signal_connect_swapped (window->main_leaflet, "notify::visible-child",
+//                            G_CALLBACK (notify_leaflet_child_cb), window);
 
   gtk_revealer_set_transition_type (window->tab_bar_revealer, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
   adw_tab_bar_set_view (window->tab_bar, ephy_tab_view_get_tab_view (window->tab_view));
-  ephy_pages_view_set_tab_view (window->pages_view, window->tab_view);
-
-  setup_tabs_menu (window);
+  adw_tab_overview_set_view (ADW_TAB_OVERVIEW (window->overview), ephy_tab_view_get_tab_view 
(window->tab_view));
 
   shell = ephy_shell_get_default ();
   mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell));
@@ -3720,15 +3671,12 @@ ephy_window_constructed (GObject *object)
   ephy_fullscreen_box_set_content (window->fullscreen_box, GTK_WIDGET (box));
   ephy_fullscreen_box_set_titlebar (window->fullscreen_box, GTK_WIDGET (window->titlebar_box));
 
-  adw_leaflet_append (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->fullscreen_box));
-  adw_leaflet_append (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->pages_view));
-  adw_application_window_set_content (ADW_APPLICATION_WINDOW (window), GTK_WIDGET (window->main_leaflet));
+  adw_tab_overview_set_child (ADW_TAB_OVERVIEW (window->overview),
+                              GTK_WIDGET (window->fullscreen_box));
+  adw_application_window_set_content (ADW_APPLICATION_WINDOW (window), GTK_WIDGET (window->overview));
 
   ephy_tab_view_set_tab_bar (window->tab_view, window->tab_bar);
 
-  adw_leaflet_set_visible_child (ADW_LEAFLET (window->main_leaflet), GTK_WIDGET (window->fullscreen_box));
-  adw_leaflet_set_can_navigate_back (ADW_LEAFLET (window->main_leaflet), TRUE);
-
   /* other notifiers */
   action_group = ephy_window_get_action_group (window, "win");
   action = g_action_map_lookup_action (G_ACTION_MAP (action_group),
@@ -3903,7 +3851,7 @@ ephy_window_open_pages_view (EphyWindow *window)
 {
   g_assert (EPHY_IS_WINDOW (window));
 
-  adw_leaflet_navigate (ADW_LEAFLET (window->main_leaflet), ADW_NAVIGATION_DIRECTION_FORWARD);
+  adw_tab_overview_open (ADW_TAB_OVERVIEW (window->overview));
 }
 
 /**
@@ -3917,7 +3865,7 @@ ephy_window_close_pages_view (EphyWindow *window)
 {
   g_assert (EPHY_IS_WINDOW (window));
 
-  adw_leaflet_navigate (ADW_LEAFLET (window->main_leaflet), ADW_NAVIGATION_DIRECTION_BACK);
+  adw_tab_overview_close (ADW_TAB_OVERVIEW (window->overview));
 }
 
 /**
diff --git a/src/meson.build b/src/meson.build
index 7e0b52438..1aa1f6b8a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -36,10 +36,6 @@ libephymain_sources = [
   'ephy-location-controller.c',
   'ephy-lockdown.c',
   'ephy-mouse-gesture-controller.c',
-  'ephy-page-row.c',
-  'ephy-pages-button.c',
-  'ephy-pages-popover.c',
-  'ephy-pages-view.c',
   'ephy-session.c',
   'ephy-shell.c',
   'ephy-suggestion-model.c',
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 120497952..615d8cde4 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -18,10 +18,6 @@
     <file preprocess="xml-stripblanks" compressed="true">gtk/location-entry.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/notebook-context-menu.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/page-menu-popover.ui</file>
-    <file preprocess="xml-stripblanks" compressed="true">gtk/page-row.ui</file>
-    <file preprocess="xml-stripblanks" compressed="true">gtk/pages-button.ui</file>
-    <file preprocess="xml-stripblanks" compressed="true">gtk/pages-popover.ui</file>
-    <file preprocess="xml-stripblanks" compressed="true">gtk/pages-view.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/passwords-view.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/prefs-appearance-page.ui</file>
     <file preprocess="xml-stripblanks" compressed="true">gtk/prefs-dialog.ui</file>
@@ -59,8 +55,6 @@
     <file compressed="true" 
alias="scalable/status/ephy-non-starred-symbolic.svg">ephy-non-starred-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-open-link-symbolic.svg">ephy-open-link-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-starred-symbolic.svg">ephy-starred-symbolic.svg</file>
-    <file compressed="true" 
alias="scalable/status/ephy-tab-counter-symbolic.svg">ephy-tab-counter-symbolic.svg</file>
-    <file compressed="true" 
alias="scalable/status/ephy-tab-overflow-symbolic.svg">ephy-tab-overflow-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-library-symbolic.svg">ephy-library-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-webpage-symbolic.svg">ephy-webpage-symbolic.svg</file>
   </gresource>
diff --git a/src/resources/gtk/action-bar-end.ui b/src/resources/gtk/action-bar-end.ui
index 08ac80396..05676cbf8 100644
--- a/src/resources/gtk/action-bar-end.ui
+++ b/src/resources/gtk/action-bar-end.ui
@@ -27,6 +27,12 @@
         </child>
       </object>
     </child>
+    <child>
+      <object class="GtkButton" id="overview_button">
+        <property name="icon-name">view-grid-symbolic</property>
+        <property name="action-name">win.tabs-view</property>
+      </object>
+    </child>
     <child>
       <object class="GtkMenuButton" id="bookmark_button">
         <!-- Translators: tooltip for the bookmark button -->
diff --git a/src/resources/gtk/action-bar.ui b/src/resources/gtk/action-bar.ui
index dc1851c20..162035fb8 100644
--- a/src/resources/gtk/action-bar.ui
+++ b/src/resources/gtk/action-bar.ui
@@ -10,9 +10,7 @@
               <object class="EphyActionBarStart" id="action_bar_start"/>
             </child>
             <child type="end">
-              <object class="EphyPagesButton" id="pages_button">
-                <!-- Translators: tooltip for the page switcher button -->
-                <property name="tooltip_text" translatable="yes">View open pages</property>
+              <object class="AdwTabButton" id="pages_button">
                 <property name="action_name">win.tabs-view</property>
               </object>
             </child>
diff --git a/src/resources/style.css b/src/resources/style.css
index e86eb4c84..120d7b4a8 100644
--- a/src/resources/style.css
+++ b/src/resources/style.css
@@ -187,23 +187,6 @@ fullscreenbox > flap > shadow {
   background: linear-gradient(to bottom, alpha(black, .1), alpha(black, .0));
 }
 
-.pages-list row {
-  min-height: 30px;
-  padding: 3px;
-}
-
-.pages-list .close-button {
-  border-radius: 100%;
-  padding: 0;
-  min-width: 28px;
-  min-height: 28px;
-}
-
-#pages-view .close-button {
-  min-width: 36px;
-  min-height: 36px;
-}
-
 dnd > .boxed-list {
   margin: 6px;
   background-color: @window_bg_color;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]