[evince/wip/cdavis/hdywindow] shell: Use HdyApplicationWindow




commit a7d13f6f438afa78d2bc02e68d902e5998a6b2ac
Author: Christopher Davis <brainblasted disroot org>
Date:   Wed Feb 3 08:46:37 2021 -0800

    shell: Use HdyApplicationWindow
    
    For GNOME 40 core apps have started using HdyApplicationWindow for
    rounded window corners. We should use rounded window corners
    for consistency.

 meson.build             |  2 ++
 shell/ev-application.c  |  3 +++
 shell/ev-toolbar.c      | 14 +++++++-------
 shell/ev-toolbar.h      |  4 ++--
 shell/ev-window-title.c | 12 ++++++------
 shell/ev-window.c       | 13 +++++++------
 shell/ev-window.h       |  5 +++--
 shell/meson.build       |  1 +
 8 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/meson.build b/meson.build
index 9cd6d789..5ab77956 100644
--- a/meson.build
+++ b/meson.build
@@ -144,6 +144,7 @@ top_inc = include_directories('.')
 
 glib_req_version = '>= 2.44.0'
 gtk_req_version = '>= 3.22.0'
+hdy_req_version = '>= 1.0.0'
 
 gdk_pixbuf_dep = dependency('gdk-pixbuf-2.0', version: '>= 2.40.0')
 config_h.set_quoted('EXTRA_GDK_PIXBUF_LOADERS_DIR',
@@ -155,6 +156,7 @@ gmodule_dep = dependency('gmodule-2.0')
 gmodule_no_export_dep = dependency('gmodule-no-export-2.0', version: glib_req_version)
 gtk_dep = dependency('gtk+-3.0', version: gtk_req_version)
 gthread_dep = dependency('gthread-2.0', version: glib_req_version)
+hdy_dep = dependency('libhandy-1', version: hdy_req_version)
 
 m_dep = cc.find_library('m')
 
diff --git a/shell/ev-application.c b/shell/ev-application.c
index ed6ea70f..3a902869 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -30,6 +30,7 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
+#include <libhandy-1/handy.h>
 #ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
 #endif
@@ -995,6 +996,8 @@ ev_application_startup (GApplication *gapplication)
 
         G_APPLICATION_CLASS (ev_application_parent_class)->startup (gapplication);
 
+        hdy_init ();
+
         for (it = action_accels; it[0]; it += g_strv_length ((gchar **)it) + 1)
                 gtk_application_set_accels_for_action (GTK_APPLICATION (application), it[0], &it[1]);
 }
diff --git a/shell/ev-toolbar.c b/shell/ev-toolbar.c
index 4e384342..75306a76 100644
--- a/shell/ev-toolbar.c
+++ b/shell/ev-toolbar.c
@@ -54,7 +54,7 @@ typedef struct {
         EvToolbarMode toolbar_mode;
 } EvToolbarPrivate;
 
-G_DEFINE_TYPE_WITH_PRIVATE (EvToolbar, ev_toolbar, GTK_TYPE_HEADER_BAR)
+G_DEFINE_TYPE_WITH_PRIVATE (EvToolbar, ev_toolbar, HDY_TYPE_HEADER_BAR)
 
 # define GET_PRIVATE(o) ev_toolbar_get_instance_private (o)
 
@@ -210,7 +210,7 @@ ev_toolbar_constructed (GObject *object)
                                                   EV_STOCK_VIEW_SIDEBAR,
                                                   _("Side pane"));
         priv->sidebar_button = button;
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), button);
+        hdy_header_bar_pack_start (HDY_HEADER_BAR (ev_toolbar), button);
 
         /* Page selector */
         /* Use EvPageActionWidget for now, since the page selector action is also used by the previewer */
@@ -220,14 +220,14 @@ ev_toolbar_constructed (GObject *object)
         priv->page_selector = tool_item;
         ev_page_action_widget_set_model (EV_PAGE_ACTION_WIDGET (tool_item),
                                          ev_window_get_document_model (priv->window));
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), tool_item);
+        hdy_header_bar_pack_start (HDY_HEADER_BAR (ev_toolbar), tool_item);
 
         /* Edit Annots */
         button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-edit-annots", 
"document-edit-symbolic",
                                                   _("Annotate the document"));
         atk_object_set_name (gtk_widget_get_accessible (button), _("Annotate document"));
         priv->annots_button = button;
-        gtk_header_bar_pack_start (GTK_HEADER_BAR (ev_toolbar), button);
+        hdy_header_bar_pack_start (HDY_HEADER_BAR (ev_toolbar), button);
 
         /* Action Menu */
         menu = G_MENU_MODEL (gtk_builder_get_object (builder, "action-menu"));
@@ -237,13 +237,13 @@ ev_toolbar_constructed (GObject *object)
         atk_object_set_name (gtk_widget_get_accessible (button), _("File options"));
 
         priv->action_menu_button = button;
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), button);
+        hdy_header_bar_pack_end (HDY_HEADER_BAR (ev_toolbar), button);
 
         /* Find */
         button = ev_toolbar_create_toggle_button (ev_toolbar, "win.toggle-find", "edit-find-symbolic",
                                                   NULL);
         priv->find_button = button;
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), button);
+        hdy_header_bar_pack_end (HDY_HEADER_BAR (ev_toolbar), button);
         g_signal_connect (button,
                           "notify::sensitive",
                           G_CALLBACK (ev_toolbar_find_button_sensitive_changed),
@@ -258,7 +258,7 @@ ev_toolbar_constructed (GObject *object)
         g_signal_connect (vbox, "activated",
                           G_CALLBACK (zoom_selector_activated),
                           ev_toolbar);
-        gtk_header_bar_pack_end (GTK_HEADER_BAR (ev_toolbar), vbox);
+        hdy_header_bar_pack_end (HDY_HEADER_BAR (ev_toolbar), vbox);
 
         g_object_unref (builder);
 }
diff --git a/shell/ev-toolbar.h b/shell/ev-toolbar.h
index 97cd5c66..9ad76fc5 100644
--- a/shell/ev-toolbar.h
+++ b/shell/ev-toolbar.h
@@ -43,11 +43,11 @@ typedef struct _EvToolbar        EvToolbar;
 typedef struct _EvToolbarClass   EvToolbarClass;
 
 struct _EvToolbar {
-        GtkHeaderBar base_instance;
+        HdyHeaderBar base_instance;
 };
 
 struct _EvToolbarClass {
-        GtkHeaderBarClass base_class;
+        HdyHeaderBarClass base_class;
 };
 
 GType         ev_toolbar_get_type           (void);
diff --git a/shell/ev-window-title.c b/shell/ev-window-title.c
index e25fb40f..87fbd1f7 100644
--- a/shell/ev-window-title.c
+++ b/shell/ev-window-title.c
@@ -97,13 +97,13 @@ static void
 ev_window_title_update (EvWindowTitle *window_title)
 {
        GtkWindow *window = GTK_WINDOW (window_title->window);
-       GtkHeaderBar *toolbar = GTK_HEADER_BAR (ev_window_get_toolbar (EV_WINDOW (window)));
+       HdyHeaderBar *toolbar = HDY_HEADER_BAR (ev_window_get_toolbar (EV_WINDOW (window)));
        char *title = NULL, *p;
        char *subtitle = NULL, *title_header = NULL;
        gboolean ltr;
 
         if (window_title->type == EV_WINDOW_TITLE_RECENT) {
-                gtk_header_bar_set_subtitle (toolbar, NULL);
+                hdy_header_bar_set_subtitle (toolbar, NULL);
                 gtk_window_set_title (window, _("Recent Documents"));
                 return;
         }
@@ -137,8 +137,8 @@ ev_window_title_update (EvWindowTitle *window_title)
        case EV_WINDOW_TITLE_DOCUMENT:
                gtk_window_set_title (window, title);
                if (title_header && subtitle) {
-                       gtk_header_bar_set_title (toolbar, title_header);
-                       gtk_header_bar_set_subtitle (toolbar, subtitle);
+                       hdy_header_bar_set_title (toolbar, title_header);
+                       hdy_header_bar_set_subtitle (toolbar, subtitle);
                }
                if (window_title->dirname)
                        gtk_widget_set_tooltip_text (GTK_WIDGET (toolbar),
@@ -155,8 +155,8 @@ ev_window_title_update (EvWindowTitle *window_title)
                gtk_window_set_title (window, password_title);
                g_free (password_title);
 
-                gtk_header_bar_set_title (toolbar, _("Password Required"));
-                gtk_header_bar_set_subtitle (toolbar, title);
+                hdy_header_bar_set_title (toolbar, _("Password Required"));
+                hdy_header_bar_set_subtitle (toolbar, title);
         }
                break;
         case EV_WINDOW_TITLE_RECENT:
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 14efd85b..95516b41 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -40,6 +40,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 #include <gtk/gtk.h>
+#include <libhandy-1/handy.h>
 
 #include "dzl-file-manager.h"
 #include "ev-find-sidebar.h"
@@ -415,7 +416,7 @@ static void ev_window_cancel_add_annot              (EvWindow *window);
 
 static gchar *nautilus_sendto = NULL;
 
-G_DEFINE_TYPE_WITH_PRIVATE (EvWindow, ev_window, GTK_TYPE_APPLICATION_WINDOW)
+G_DEFINE_TYPE_WITH_PRIVATE (EvWindow, ev_window, HDY_TYPE_APPLICATION_WINDOW)
 
 static gboolean
 ev_window_is_recent_view (EvWindow *ev_window)
@@ -5387,8 +5388,8 @@ ev_window_document_modified_cb (EvDocument *document,
                                 EvWindow   *ev_window)
 {
        EvWindowPrivate *priv = GET_PRIVATE (ev_window);
-       GtkHeaderBar *toolbar = GTK_HEADER_BAR (ev_window_get_toolbar (ev_window));
-       const gchar *title = gtk_header_bar_get_title (toolbar);
+       HdyHeaderBar *toolbar = HDY_HEADER_BAR (ev_window_get_toolbar (ev_window));
+       const gchar *title = hdy_header_bar_get_title (toolbar);
        gchar *new_title;
 
        if (priv->is_modified)
@@ -5401,7 +5402,7 @@ ev_window_document_modified_cb (EvDocument *document,
                new_title = g_strconcat (title, " •", NULL);
 
        if (new_title) {
-               gtk_header_bar_set_title (toolbar, new_title);
+               hdy_header_bar_set_title (toolbar, new_title);
                g_free (new_title);
        }
 }
@@ -7616,8 +7617,8 @@ ev_window_init (EvWindow *ev_window)
 
        priv->toolbar = ev_toolbar_new (ev_window);
        gtk_widget_set_no_show_all (priv->toolbar, TRUE);
-       gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (priv->toolbar), TRUE);
-       gtk_window_set_titlebar (GTK_WINDOW (ev_window), priv->toolbar);
+       hdy_header_bar_set_show_close_button (HDY_HEADER_BAR (priv->toolbar), TRUE);
+       gtk_box_pack_start (GTK_BOX (priv->main_box), priv->toolbar, FALSE, TRUE, 0);
        gtk_widget_show (priv->toolbar);
 
        /* Window title */
diff --git a/shell/ev-window.h b/shell/ev-window.h
index cd20baaa..09a82b6f 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -25,6 +25,7 @@
 
 #include <glib.h>
 #include <gtk/gtk.h>
+#include <libhandy-1/handy.h>
 
 #include "ev-link.h"
 #include "ev-history.h"
@@ -62,11 +63,11 @@ typedef struct _EvWindowClass EvWindowClass;
 
 
 struct _EvWindow {
-       GtkApplicationWindow base_instance;
+       HdyApplicationWindow base_instance;
 };
 
 struct _EvWindowClass {
-       GtkApplicationWindowClass base_class;
+       HdyApplicationWindowClass base_class;
 };
 
 GType          ev_window_get_type                       (void) G_GNUC_CONST;
diff --git a/shell/meson.build b/shell/meson.build
index eefaf045..7cbc48f2 100644
--- a/shell/meson.build
+++ b/shell/meson.build
@@ -52,6 +52,7 @@ sources += gnome.compile_resources(
 deps = [
   gdk_pixbuf_dep,
   gnome_desktop_dep,
+  hdy_dep,
   libevmisc_dep,
   libevproperties_dep,
   libdazzle_dep,


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