From a835727fa9acbf21d036694de9a24d70eec43cd4 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Sun, 25 Sep 2022 19:12:28 +0100 Subject: [PATCH] Use Adwaita classes where possible --- data/window.blp | 65 +++++++++++++++++++++--------------------- src/rugby-app-window.c | 6 ++-- src/rugby-app-window.h | 7 +++-- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/data/window.blp b/data/window.blp index 67542cc..bba80b1 100644 --- a/data/window.blp +++ b/data/window.blp @@ -5,51 +5,49 @@ using Gtk 4.0; using Adw 1; -template RugbyAppWindow : ApplicationWindow { +template RugbyAppWindow : Adw.ApplicationWindow { title: "Rugby"; default-height: 600; default-width: 400; - [titlebar] - HeaderBar { - SpinButton scorespin { - adjustment: Adjustment { - step-increment: 1; - upper: 200; - }; - focusable: true; - tooltip-text: "Score"; - } + Box { + orientation: vertical; - [title] - Label { - styles ["title"] + Adw.HeaderBar { + SpinButton scorespin { + adjustment: Adjustment { + step-increment: 1; + upper: 200; + }; + focusable: true; + tooltip-text: "Score"; + } - label: "Rugby"; + [end] + MenuButton menu_button { + direction: none; + menu-model: app_menu; + } } - [end] - MenuButton menu_button { - direction: none; - menu-model: app_menu; - } - } + ScrolledWindow { + vexpand: true; - ScrolledWindow { - Adw.ClampScrollable { - maximum-size: 600; + Adw.ClampScrollable { + maximum-size: 600; - ListView listview { - styles ["rich-list"] + ListView listview { + styles ["rich-list"] - model: NoSelection { - model: .RugbyListStore { - score: bind scorespin.value; + model: NoSelection { + model: .RugbyListStore { + score: bind scorespin.value; + }; }; - }; - factory: BuilderListItemFactory { - resource: "/uk/me/bcowan/rugby/score-item.ui"; - }; + factory: BuilderListItemFactory { + resource: "/uk/me/bcowan/rugby/score-item.ui"; + }; + } } } } @@ -63,3 +61,4 @@ menu app_menu { item ("_About Rugby", "app.about") } } + diff --git a/src/rugby-app-window.c b/src/rugby-app-window.c index 3ed4d1f..1db5220 100644 --- a/src/rugby-app-window.c +++ b/src/rugby-app-window.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Bruce Cowan <bruce@bcowan.me.uk> + * SPDX-FileCopyrightText: 2017-2022 Bruce Cowan <bruce@bcowan.me.uk> * * SPDX-License-Identifier: GPL-3.0-or-later */ @@ -14,10 +14,10 @@ struct _RugbyAppWindow { - GtkApplicationWindow parent; + AdwApplicationWindow parent; }; -G_DEFINE_TYPE (RugbyAppWindow, rugby_app_window, GTK_TYPE_APPLICATION_WINDOW) +G_DEFINE_TYPE (RugbyAppWindow, rugby_app_window, ADW_TYPE_APPLICATION_WINDOW) static char * item_tooltip_cb (GtkListItem *item) diff --git a/src/rugby-app-window.h b/src/rugby-app-window.h index abf70c8..1f3fb8d 100644 --- a/src/rugby-app-window.h +++ b/src/rugby-app-window.h @@ -1,17 +1,18 @@ /* - * SPDX-FileCopyrightText: 2017 Bruce Cowan <bruce@bcowan.me.uk> + * SPDX-FileCopyrightText: 2017-2022 Bruce Cowan <bruce@bcowan.me.uk> + * * SPDX-License-Identifier: GPL-3.0-or-later */ #pragma once -#include <gtk/gtk.h> +#include <adwaita.h> G_BEGIN_DECLS #define RUGBY_TYPE_APP_WINDOW (rugby_app_window_get_type()) -G_DECLARE_FINAL_TYPE (RugbyAppWindow, rugby_app_window, RUGBY, APP_WINDOW, GtkApplicationWindow) +G_DECLARE_FINAL_TYPE (RugbyAppWindow, rugby_app_window, RUGBY, APP_WINDOW, AdwApplicationWindow) RugbyAppWindow * rugby_app_window_new (GtkApplication *app); -- GitLab