diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2020-09-08 20:19:05 +0500 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2021-01-28 15:43:49 +0000 |
commit | 31760bca39deabee324269feb9395bffdb097bbd (patch) | |
tree | d0bb0b31e81659bc78c99bea5d2276eb861260fa | |
parent | 7f943af4f01631a40013cbb500602ac797c9db37 (diff) | |
download | epiphany-31760bca39deabee324269feb9395bffdb097bbd.tar.gz |
Merge TabHeaderBar into PagesView
This change does regress the UI a little by introducing a duplicate header
bar in the pages view. This will be fixed in the next commit, otherwise the
change would be very massive.
-rw-r--r-- | src/ephy-pages-view.c | 5 | ||||
-rw-r--r-- | src/ephy-pages-view.h | 2 | ||||
-rw-r--r-- | src/ephy-tab-header-bar.c | 86 | ||||
-rw-r--r-- | src/ephy-tab-header-bar.h | 35 | ||||
-rw-r--r-- | src/ephy-window.c | 23 | ||||
-rw-r--r-- | src/meson.build | 1 | ||||
-rw-r--r-- | src/resources/gtk/pages-view.ui | 62 |
7 files changed, 55 insertions, 159 deletions
diff --git a/src/ephy-pages-view.c b/src/ephy-pages-view.c index bad9335cb..3fe63c216 100644 --- a/src/ephy-pages-view.c +++ b/src/ephy-pages-view.c @@ -29,16 +29,15 @@ #include "ephy-window.h" struct _EphyPagesView { - GtkScrolledWindow parent_instance; + GtkBox parent_instance; GtkListBox *list_box; GListStore *list_store; EphyNotebook *notebook; - EphyAdaptiveMode adaptive_mode; }; -G_DEFINE_TYPE (EphyPagesView, ephy_pages_view, GTK_TYPE_SCROLLED_WINDOW) +G_DEFINE_TYPE (EphyPagesView, ephy_pages_view, GTK_TYPE_BOX) static void drop_notebook (EphyPagesView *self) diff --git a/src/ephy-pages-view.h b/src/ephy-pages-view.h index fe8cd91ce..db910d1b8 100644 --- a/src/ephy-pages-view.h +++ b/src/ephy-pages-view.h @@ -29,7 +29,7 @@ G_BEGIN_DECLS #define EPHY_TYPE_PAGES_VIEW (ephy_pages_view_get_type ()) -G_DECLARE_FINAL_TYPE (EphyPagesView, ephy_pages_view, EPHY, PAGES_VIEW, GtkScrolledWindow) +G_DECLARE_FINAL_TYPE (EphyPagesView, ephy_pages_view, EPHY, PAGES_VIEW, GtkBox) EphyPagesView *ephy_pages_view_new (void); diff --git a/src/ephy-tab-header-bar.c b/src/ephy-tab-header-bar.c deleted file mode 100644 index ea21eda6f..000000000 --- a/src/ephy-tab-header-bar.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Christopher Davis <christopherdavis@gnome.org> - * - * This file is part of Epiphany. - * - * Epiphany is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Epiphany is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "ephy-tab-header-bar.h" - -#include <gtk/gtk.h> -#include <glib/gi18n.h> - -struct _EphyTabHeaderBar { - GtkHeaderBar parent_instance; - - GtkWidget *back_button; - GtkWidget *new_tab_button; -}; - -G_DEFINE_TYPE (EphyTabHeaderBar, ephy_tab_header_bar, GTK_TYPE_HEADER_BAR) - -/** - * ephy_tab_header_bar_new: - * - * Create a new #EphyTabHeaderBar. - * - * Returns: (transfer full): a newly created #EphyTabHeaderBar - */ -GtkWidget * -ephy_tab_header_bar_new (void) -{ - return GTK_WIDGET (g_object_new (EPHY_TYPE_TAB_HEADER_BAR, NULL)); -} - -static void -ephy_tab_header_bar_constructed (GObject *object) -{ - GtkWidget *back_button; - GtkWidget *new_tab_button; - EphyTabHeaderBar *self = EPHY_TAB_HEADER_BAR (object); - - G_OBJECT_CLASS (ephy_tab_header_bar_parent_class)->constructed (object); - - back_button = GTK_WIDGET (gtk_button_new_from_icon_name ("go-previous-symbolic", GTK_ICON_SIZE_BUTTON)); - new_tab_button = GTK_WIDGET (gtk_button_new_from_icon_name ("tab-new-symbolic", GTK_ICON_SIZE_BUTTON)); - - self->back_button = back_button; - self->new_tab_button = new_tab_button; - gtk_actionable_set_action_name (GTK_ACTIONABLE (back_button), "win.content"); - gtk_actionable_set_action_name (GTK_ACTIONABLE (new_tab_button), "win.new-tab"); - - gtk_header_bar_pack_start (GTK_HEADER_BAR (self), back_button); - gtk_header_bar_pack_end (GTK_HEADER_BAR (self), new_tab_button); - - gtk_header_bar_set_title (GTK_HEADER_BAR (self), _("Tabs")); - gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (self), FALSE); - gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self), TRUE); - - gtk_widget_show_all (GTK_WIDGET (self)); -} - -static void -ephy_tab_header_bar_class_init (EphyTabHeaderBarClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = ephy_tab_header_bar_constructed; -} - -static void -ephy_tab_header_bar_init (EphyTabHeaderBar *self) -{ -} diff --git a/src/ephy-tab-header-bar.h b/src/ephy-tab-header-bar.h deleted file mode 100644 index a562a774d..000000000 --- a/src/ephy-tab-header-bar.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * Copyright © 2019 Christopher Davis <christopherdavis@gnome.org> - * - * This file is part of Epiphany. - * - * Epiphany is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Epiphany is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Epiphany. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define EPHY_TYPE_TAB_HEADER_BAR (ephy_tab_header_bar_get_type ()) - -G_DECLARE_FINAL_TYPE (EphyTabHeaderBar, ephy_tab_header_bar, EPHY, TAB_HEADER_BAR, GtkHeaderBar) - -GtkWidget *ephy_tab_header_bar_new (); - -G_END_DECLS - - diff --git a/src/ephy-window.c b/src/ephy-window.c index 57af66537..3adb2275d 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -52,7 +52,6 @@ #include "ephy-session.h" #include "ephy-settings.h" #include "ephy-shell.h" -#include "ephy-tab-header-bar.h" #include "ephy-title-box.h" #include "ephy-title-widget.h" #include "ephy-type-builtins.h" @@ -3560,33 +3559,13 @@ title_widget_lock_clicked_cb (EphyTitleWidget *title_widget, static GtkWidget * setup_header_bar (EphyWindow *window) { - GtkWidget *title_bar; GtkWidget *header_bar; - GtkWidget *tab_header_bar; - GtkWidget *header_deck; EphyTitleWidget *title_widget; - HdySwipeGroup *swipe_group; - title_bar = hdy_title_bar_new (); header_bar = ephy_header_bar_new (window); - tab_header_bar = ephy_tab_header_bar_new (); - header_deck = hdy_deck_new (); - hdy_deck_set_can_swipe_back (HDY_DECK (header_deck), TRUE); - gtk_container_add (GTK_CONTAINER (title_bar), header_deck); - gtk_container_add (GTK_CONTAINER (header_deck), header_bar); - gtk_container_add (GTK_CONTAINER (header_deck), tab_header_bar); - - hdy_deck_set_visible_child (HDY_DECK (header_deck), header_bar); - - swipe_group = hdy_swipe_group_new (); - hdy_swipe_group_add_swipeable (swipe_group, HDY_SWIPEABLE (header_deck)); - hdy_swipe_group_add_swipeable (swipe_group, HDY_SWIPEABLE (window->main_deck)); - - dzl_application_window_set_titlebar (DZL_APPLICATION_WINDOW (window), title_bar); - gtk_widget_show (title_bar); + dzl_application_window_set_titlebar (DZL_APPLICATION_WINDOW (window), header_bar); gtk_widget_show (header_bar); - gtk_widget_show (header_deck); title_widget = ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (header_bar)); g_signal_connect (title_widget, "lock-clicked", diff --git a/src/meson.build b/src/meson.build index 4a78dd75e..7886d6f14 100644 --- a/src/meson.build +++ b/src/meson.build @@ -44,7 +44,6 @@ libephymain_sources = [ 'ephy-session.c', 'ephy-shell.c', 'ephy-suggestion-model.c', - 'ephy-tab-header-bar.c', 'ephy-tab-label.c', 'ephy-web-extension-dialog.c', 'ephy-window.c', diff --git a/src/resources/gtk/pages-view.ui b/src/resources/gtk/pages-view.ui index d9e576bcd..9ee40daa3 100644 --- a/src/resources/gtk/pages-view.ui +++ b/src/resources/gtk/pages-view.ui @@ -1,20 +1,60 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.16 --> - <template class="EphyPagesView" parent="GtkScrolledWindow"> + <template class="EphyPagesView" parent="GtkBox"> <property name="name">pages-view</property> - <property name="hscrollbar_policy">never</property> - <property name="propagate_natural_height">True</property> - <property name="visible">True</property> + <property name="orientation">vertical</property> <child> - <object class="GtkListBox" id="list_box"> - <property name="selection_mode">single</property> + <object class="HdyHeaderBar"> <property name="visible">True</property> - <property name="width_request">300</property> - <signal name="row-activated" handler="row_activated_cb" swapped="true"/> - <style> - <class name="pages-list"/> - </style> + <property name="show-close-button">True</property> + <property name="title" translatable="yes">Tabs</property> + <property name="has-subtitle">False</property> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="action-name">win.content</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">go-previous-symbolic</property> + </object> + </child> + </object> + </child> + <child> + <object class="GtkButton"> + <property name="visible">True</property> + <property name="action-name">win.new-tab</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="icon-name">tab-new-symbolic</property> + </object> + </child> + </object> + <packing> + <property name="pack-type">end</property> + </packing> + </child> + </object> + </child> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vexpand">True</property> + <child> + <object class="GtkListBox" id="list_box"> + <property name="selection_mode">single</property> + <property name="visible">True</property> + <property name="width_request">300</property> + <signal name="row-activated" handler="row_activated_cb" swapped="true"/> + <style> + <class name="pages-list"/> + </style> + </object> + </child> </object> </child> </template> |