From 73458cbe2569c382fc8b17bd91c674d86a51dea0 Mon Sep 17 00:00:00 2001 From: Bruce Cowan <bruce@bcowan.me.uk> Date: Thu, 3 Aug 2023 12:43:44 +0100 Subject: [PATCH] Use new Adwaita widgets --- data/gtk/window.blp | 104 +++++++++++++++++---------------- meson.build | 10 ++-- src/rugby-possibility-widget.c | 7 ++- uk.me.bcowan.Rugby.yml | 2 +- 4 files changed, 66 insertions(+), 57 deletions(-) diff --git a/data/gtk/window.blp b/data/gtk/window.blp index 548466c..73f1871 100644 --- a/data/gtk/window.blp +++ b/data/gtk/window.blp @@ -8,9 +8,9 @@ using Adw 1; template $RugbyAppWindow : Adw.ApplicationWindow { title: "Rugby"; - Box { - orientation: vertical; + Adw.ToolbarView { + [top] Adw.HeaderBar { SpinButton scorespin { adjustment: Adjustment { @@ -36,66 +36,70 @@ template $RugbyAppWindow : Adw.ApplicationWindow { } } - Revealer { - halign: center; - margin-top: 6; - reveal-child: bind filter_toggle.active; - transition-type: slide_down; - - SpinButton tryspin { - adjustment: Adjustment { - step-increment: 1; - lower: 0; - upper: 40; - }; - focusable: true; - tooltip-text: "Tries"; - - value-changed => $try_spin_value_changed_cb(); + content: Box { + orientation: vertical; + + Revealer { + halign: center; + margin-top: 6; + reveal-child: bind filter_toggle.active; + transition-type: slide_down; + + SpinButton tryspin { + adjustment: Adjustment { + step-increment: 1; + lower: 0; + upper: 40; + }; + focusable: true; + tooltip-text: "Tries"; + + value-changed => $try_spin_value_changed_cb(); + } } - } - Stack stack { - StackPage { - name: "empty_page"; + Stack stack { + StackPage { + name: "empty_page"; - child: Adw.StatusPage { - icon-name: "list"; - title: "No possibilities"; - }; - } + child: Adw.StatusPage { + icon-name: "list"; + title: "No possibilities"; + }; + } - StackPage { - name: "list_page"; + StackPage { + name: "list_page"; - child: ScrolledWindow { - vexpand: true; + child: ScrolledWindow { + vexpand: true; - Adw.Clamp { - maximum-size: 600; - tightening-threshold: 400; + Adw.Clamp { + maximum-size: 600; + tightening-threshold: 400; - ListView listview { - styles ["rich-list", "card"] + ListView listview { + styles ["rich-list", "card"] - factory: BuilderListItemFactory { - resource: "/uk/me/bcowan/Rugby/gtk/score-item.ui"; - }; - model: NoSelection { - model: FilterListModel { - filter: CustomFilter try_filter {}; - model: $RugbyListStore list_store { - score: bind scorespin.value; + factory: BuilderListItemFactory { + resource: "/uk/me/bcowan/Rugby/gtk/score-item.ui"; + }; + model: NoSelection { + model: FilterListModel { + filter: CustomFilter try_filter {}; + model: $RugbyListStore list_store { + score: bind scorespin.value; + }; + + items-changed => $list_store_items_changed_cb(); }; - - items-changed => $list_store_items_changed_cb(); }; - }; + } } - } - }; + }; + } } - } + }; } ShortcutController { diff --git a/meson.build b/meson.build index 25d3166..d063c59 100644 --- a/meson.build +++ b/meson.build @@ -18,9 +18,9 @@ desktopdir = datadir / 'applications' gnome = import('gnome') -gio_dep = dependency('gio-2.0', version: '>= 2.66') -gtk_dep = dependency('gtk4', version: '>= 4.8') -libadwaita_dep = dependency('libadwaita-1') +gio_dep = dependency('gio-2.0', version: '>= 2.76') +gtk_dep = dependency('gtk4', version: '>= 4.11.3') +libadwaita_dep = dependency('libadwaita-1', version: '>=1.4.beta') conf = configuration_data() @@ -35,8 +35,8 @@ endif cflags = ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_66', '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_66', - '-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_8', - '-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_8', + '-DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_12', + '-DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_12', '-Wno-overlength-strings', ] diff --git a/src/rugby-possibility-widget.c b/src/rugby-possibility-widget.c index bd1f821..a08148c 100644 --- a/src/rugby-possibility-widget.c +++ b/src/rugby-possibility-widget.c @@ -97,9 +97,12 @@ render_bar (GtkWidget *widget, &area); gtk_snapshot_pop (snapshot); - GtkStyleContext *ctx = gtk_widget_get_style_context (widget); + G_GNUC_BEGIN_IGNORE_DEPRECATIONS GdkRGBA border_colour; + + GtkStyleContext *ctx = gtk_widget_get_style_context (widget); gtk_style_context_lookup_color (ctx, "card_fg_color", &border_colour); + G_GNUC_END_IGNORE_DEPRECATIONS gtk_snapshot_append_border (snapshot, &rounded, @@ -132,6 +135,7 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, NULL); int score = tries * try_points + utries * utry_points + kicks * kick_points; + G_GNUC_BEGIN_IGNORE_DEPRECATIONS GtkStyleContext *ctx = gtk_widget_get_style_context (widget); GdkRGBA rgba; @@ -161,6 +165,7 @@ rugby_possibility_widget_snapshot (GtkWidget *widget, render_bar (widget, snapshot, x, w, height, rgba); x += w; } + G_GNUC_END_IGNORE_DEPRECATIONS } static void diff --git a/uk.me.bcowan.Rugby.yml b/uk.me.bcowan.Rugby.yml index 9ec8eea..a41a3c1 100644 --- a/uk.me.bcowan.Rugby.yml +++ b/uk.me.bcowan.Rugby.yml @@ -4,7 +4,7 @@ app-id: uk.me.bcowan.Rugby runtime: org.gnome.Platform -runtime-version: "44" +runtime-version: "master" sdk: org.gnome.Sdk command: rugby -- GitLab