From f354694fedee67faabbfadecdb427c85c4f4c8d2 Mon Sep 17 00:00:00 2001 From: Cassidy James Blaede Date: Mon, 22 Apr 2024 17:29:43 -0600 Subject: [PATCH] GNOME 46 (#44) * Bump to GNOME 46 * MainWindow: Update About dialog to use latest GNOME style * MainWindow: Update Domain dialog to new GNOME style * MainWindow: Update Log Out dialog to new GNOME style * WebView: Fix cookies, fix add-site page * Lint: excess newlines * MetaInfo: Added brand colors, update release info * Remove 'Plausible' from .desktop name * Workflows: update to latest GitHub actions * Workflows: Update lint action --- .github/workflows/flatpak.yml | 37 ++++++-------------- .github/workflows/lint.yml | 17 +++++---- com.cassidyjames.plausible.json | 2 +- data/launcher.desktop | 2 +- data/metainfo.xml | 34 ++++++++++-------- meson.build | 5 ++- src/App.vala | 2 +- src/MainWindow.vala | 61 ++++++++++++--------------------- src/WebContext.vala | 34 ------------------ src/Widgets/WebView.vala | 48 ++++++++++++++++---------- 10 files changed, 97 insertions(+), 145 deletions(-) delete mode 100644 src/WebContext.vala diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index b9ea753..58987c7 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -1,6 +1,9 @@ name: Flatpak - -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -8,35 +11,15 @@ concurrency: jobs: flatpak: + name: Flathub runs-on: ubuntu-latest - container: - image: bilelmoussaoui/flatpak-github-actions:gnome-42 + image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-46 options: --privileged - - strategy: - matrix: - arch: [x86_64, aarch64] - # Don't fail the whole workflow if one architecture fails - fail-fast: false steps: - - uses: actions/checkout@v2 - - - name: Install deps - run: | - dnf -y install docker - if: ${{ matrix.arch == 'aarch64' }} - - - name: Set up QEMU - id: qemu - uses: docker/setup-qemu-action@v1 - with: - platforms: arm64 - if: ${{ matrix.arch == 'aarch64' }} - - - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4 + - uses: actions/checkout@v4 + - uses: flathub-infra/flatpak-github-actions/flatpak-builder@master with: - bundle: plausible-${{ matrix.arch }}.flatpak + bundle: tally.flatpak manifest-path: com.cassidyjames.plausible.json cache-key: "flatpak-builder-${{ github.sha }}" - arch: ${{ matrix.arch }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e9f0537..b659604 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,13 +1,18 @@ -name: CI - -on: [push, pull_request] +name: Lint +on: + pull_request: jobs: lint: + name: Vala Lint runs-on: ubuntu-latest + container: image: valalang/lint + steps: - - uses: actions/checkout@v1 - - name: Lint - run: io.elementary.vala-lint -d . + - name: Checkout + uses: actions/checkout@v4 + + - name: Lint + run: io.elementary.vala-lint -d . diff --git a/com.cassidyjames.plausible.json b/com.cassidyjames.plausible.json index b13a03c..9c691a8 100644 --- a/com.cassidyjames.plausible.json +++ b/com.cassidyjames.plausible.json @@ -1,7 +1,7 @@ { "app-id" : "com.cassidyjames.plausible", "runtime" : "org.gnome.Platform", - "runtime-version" : "43", + "runtime-version" : "46", "sdk" : "org.gnome.Sdk", "command" : "com.cassidyjames.plausible", "finish-args" : [ diff --git a/data/launcher.desktop b/data/launcher.desktop index b39cc21..c836a06 100644 --- a/data/launcher.desktop +++ b/data/launcher.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Name=Tally for Plausible +Name=Tally GenericName=Web Analytics Comment=See the stats on your Plausible dashboard Categories=Network;GTK; diff --git a/data/metainfo.xml b/data/metainfo.xml index 221a4b4..79be609 100644 --- a/data/metainfo.xml +++ b/data/metainfo.xml @@ -1,9 +1,9 @@ - + com.cassidyjames.plausible - Tally for Plausible - Simple and privacy-friendly alternative to Google Analytics + Tally + Dashboard for Plausible Analytics CC-BY-SA-4.0 GPL-3.0-or-later @@ -40,6 +40,15 @@ touch + + +

Updated for GNOME 46

+
    +
  • Fixed “Add Website” page
  • +
  • Dialogs follow the new GNOME style
  • +
+
+

New icon thanks to Micah Ilbery! Rather than use the Plausible icon, Tally now has its own identity.

@@ -115,22 +124,22 @@
- https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/dashboard-dark.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/dashboard-dark.png - https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/dashboard-light.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/dashboard-light.png - https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/sites-dark.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/sites-dark.png - https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/sites-light.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/sites-light.png - https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/login-dark.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/login-dark.png - https://raw.githubusercontent.com/cassidyjames/tally/main/data/screenshots/login-light.png + https://raw.githubusercontent.com/cassidyjames/tally/3.0.1/data/screenshots/login-light.png @@ -143,10 +152,7 @@ https://cassidyjames.com/support - #5850EC + #b5b3fe + #393499 - - #5850EC - #fff -
diff --git a/meson.build b/meson.build index 82c7da0..f671483 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'com.cassidyjames.plausible', 'vala', 'c', - version: '3.0.1' + version: '3.1.0' ) gnome = import('gnome') @@ -29,7 +29,6 @@ executable( meson.project_name(), 'src' / 'App.vala', 'src' / 'MainWindow.vala', - 'src' / 'WebContext.vala', 'src' / 'Widgets' / 'WebView.vala', asresources, config_file, @@ -37,7 +36,7 @@ executable( dependency('glib-2.0'), dependency('gtk4'), dependency('libadwaita-1'), - dependency('webkit2gtk-5.0'), + dependency('webkitgtk-6.0'), meson.get_compiler('vala').find_library('posix'), ], install: true diff --git a/src/App.vala b/src/App.vala index 92d549d..031012f 100644 --- a/src/App.vala +++ b/src/App.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2020–2023 Cassidy James Blaede + * SPDX-FileCopyrightText: 2020–2024 Cassidy James Blaede */ public class Plausible.App : Adw.Application { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index d89f976..44d3935 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2020–2023 Cassidy James Blaede + * SPDX-FileCopyrightText: 2020–2024 Cassidy James Blaede */ public class Plausible.MainWindow : Adw.ApplicationWindow { @@ -17,6 +17,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { public MainWindow (Gtk.Application application) { Object ( application: application, + height_request: 180, icon_name: APP_ID, resizable: true, title: App.NAME, @@ -29,7 +30,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { var sites_button = new Gtk.Button.with_label ("Sites") { valign = Gtk.Align.CENTER }; - sites_button.get_style_context ().add_class ("back-button"); + sites_button.add_css_class ("back-button"); sites_revealer = new Gtk.Revealer () { transition_duration = 200, @@ -38,12 +39,12 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { sites_revealer.child = sites_button; var site_menu = new Menu (); - site_menu.append (_("Account Settings"), "win.account_settings"); - site_menu.append (_("Log Out…"), "win.log_out"); + site_menu.append (_("Account _Settings"), "win.account_settings"); + site_menu.append (_("_Log Out…"), "win.log_out"); var app_menu = new Menu (); - app_menu.append (_("Custom Domain…"), "win.custom_domain"); - app_menu.append (_("About %s").printf (App.NAME), "win.about"); + app_menu.append (_("_Custom Domain…"), "win.custom_domain"); + app_menu.append (_("_About %s").printf (App.NAME), "win.about"); var menu = new Menu (); menu.append_section (null, site_menu); @@ -52,13 +53,12 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { var menu_button = new Gtk.MenuButton () { icon_name = "open-menu-symbolic", menu_model = menu, - tooltip_text = _("Menu"), + tooltip_text = _("Main Menu"), }; var header = new Adw.HeaderBar (); header.pack_start (sites_revealer); header.pack_end (menu_button); - // header.pack_end (account_revealer); web_view = new Plausible.WebView (); @@ -82,7 +82,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { transition_duration = 400, transition_type = Gtk.StackTransitionType.UNDER_UP }; - stack.get_style_context ().add_class ("loading"); + stack.add_css_class ("loading"); stack.add_named (status_page, "loading"); stack.add_named (web_view, "web"); @@ -153,21 +153,6 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { web_view.uri != "https://" + domain + "/sites" ); - // TODO: Figure out how to disable the relevant actions when on - // these URIs. - // - // account_revealer.reveal_child = ( - // web_view.uri != "https://" + domain + "/login" && - // web_view.uri != "https://" + domain + "/register" && - // web_view.uri != "https://" + domain + "/password/request-reset" - // ); - // - // if (web_view.uri == "https://" + domain + "/settings") { - // account_stack.visible_child_name = "logout"; - // } else { - // account_stack.visible_child_name = "account"; - // } - App.settings.set_string ("current-url", web_view.uri); } } @@ -226,20 +211,19 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { domain_grid.attach (domain_label, 0, 0); domain_grid.attach (domain_entry, 1, 0); - var domain_dialog = new Adw.MessageDialog ( - this, + var domain_dialog = new Adw.AlertDialog ( "Set a Custom Domain", - "If you’re self-hosting Plausible or using an instance other than %s, set the domain name here.".printf (domain) + "If you’re self-hosting Plausible or using an instance other than %s, set the domain name.".printf (domain) ) { body_use_markup = true, default_response = "save", extra_child = domain_grid, }; - domain_dialog.add_response ("close", "Cancel"); - domain_dialog.add_response ("save", _("Set Domain")); + domain_dialog.add_response ("close", "_Cancel"); + domain_dialog.add_response ("save", _("_Set Domain")); domain_dialog.set_response_appearance ("save", Adw.ResponseAppearance.SUGGESTED); - domain_dialog.present (); + domain_dialog.present (this); domain_dialog.response.connect ((response_id) => { if (response_id == "save") { @@ -262,19 +246,18 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { private void on_log_out_activate () { string domain = App.settings.get_string ("domain"); - var log_out_dialog = new Adw.MessageDialog ( - this, + var log_out_dialog = new Adw.AlertDialog ( "Log out of Plausible?", "You will need to re-enter your email and password for %s to log back in.".printf (domain) ) { body_use_markup = true, default_response = "log_out" }; - log_out_dialog.add_response ("close", "Stay Logged In"); - log_out_dialog.add_response ("log_out", _("Log Out")); + log_out_dialog.add_response ("close", "_Stay Logged In"); + log_out_dialog.add_response ("log_out", _("_Log Out")); log_out_dialog.set_response_appearance ("log_out", Adw.ResponseAppearance.DESTRUCTIVE); - log_out_dialog.present (); + log_out_dialog.present (this); log_out_dialog.response.connect ((response_id) => { if (response_id == "log_out") { @@ -284,7 +267,7 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { // Instead, we clear cookies then load /sites, which will prompt for // login before showing the dashboard once again. - web_view.get_website_data_manager ().clear.begin ( + web_view.network_session.get_website_data_manager ().clear.begin ( WebKit.WebsiteDataTypes.COOKIES, 0, null, () => { debug ("Cleared cookies; going home."); web_view.load_uri ("https://" + domain + "/sites"); @@ -295,8 +278,8 @@ public class Plausible.MainWindow : Adw.ApplicationWindow { } private void on_about_activate () { - var about_window = new Adw.AboutWindow () { - transient_for = this, + var about_window = new Adw.AboutDialog () { + // transient_for = this, application_icon = APP_ID, application_name = _("%s for Plausible").printf (App.NAME), @@ -333,6 +316,6 @@ Email: hello@plausible.io """ ); - about_window.present (); + about_window.present (this); } } diff --git a/src/WebContext.vala b/src/WebContext.vala deleted file mode 100644 index 56cefb7..0000000 --- a/src/WebContext.vala +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2019–2023 Cassidy James Blaede - */ - -public class Plausible.WebContext : WebKit.WebContext { - public WebContext () { - Object ( - // This causes a known visual regression with navigation gestures. - // See: https://bugs.webkit.org/show_bug.cgi?id=205651 - process_swap_on_cross_site_navigation_enabled: true - ); - - var cookie_manager = get_cookie_manager (); - cookie_manager.set_accept_policy (WebKit.CookieAcceptPolicy.ALWAYS); - - string config_dir = Path.build_path ( - Path.DIR_SEPARATOR_S, - Environment.get_user_config_dir (), - Environment.get_prgname () - ); - - DirUtils.create_with_parents (config_dir, 0700); - - string cookies = Path.build_filename (config_dir, "cookies"); - cookie_manager.set_persistent_storage ( - cookies, - WebKit.CookiePersistentStorage.SQLITE - ); - - set_process_model (WebKit.ProcessModel.MULTIPLE_SECONDARY_PROCESSES); - set_sandbox_enabled (true); - } -} diff --git a/src/Widgets/WebView.vala b/src/Widgets/WebView.vala index 07076bf..c4ab510 100644 --- a/src/Widgets/WebView.vala +++ b/src/Widgets/WebView.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2020–2022 Cassidy James Blaede + * SPDX-FileCopyrightText: 2020–2024 Cassidy James Blaede */ public class Plausible.WebView : WebKit.WebView { @@ -10,6 +10,7 @@ public class Plausible.WebView : WebKit.WebView { Object ( hexpand: true, vexpand: true, + network_session: new WebKit.NetworkSession (null, null), user_content_manager: new WebKit.UserContentManager () ); } @@ -19,7 +20,6 @@ public class Plausible.WebView : WebKit.WebView { var webkit_settings = new WebKit.Settings () { default_font_family = Gtk.Settings.get_default ().gtk_font_name, - enable_accelerated_2d_canvas = true, enable_back_forward_navigation_gestures = true, enable_developer_extras = is_terminal, enable_dns_prefetching = true, @@ -39,15 +39,19 @@ public class Plausible.WebView : WebKit.WebView { cursor: default; } - nav, - main + * { + body > nav { display: none; } - main { + body > main { margin-top: -1.5em; } + /* Footer */ + body > main + div { + display: none; + } + button, [role=button], .button, @@ -66,9 +70,27 @@ public class Plausible.WebView : WebKit.WebView { user_content_manager.add_style_sheet (custom_css); settings = webkit_settings; - web_context = new Plausible.WebContext (); - context_menu.connect (on_context_menu); + var cookie_manager = network_session.get_cookie_manager (); + cookie_manager.set_accept_policy (WebKit.CookieAcceptPolicy.ALWAYS); + + string config_dir = Path.build_path ( + Path.DIR_SEPARATOR_S, + Environment.get_user_config_dir (), + Environment.get_prgname () + ); + + DirUtils.create_with_parents (config_dir, 0700); + + string cookies = Path.build_filename (config_dir, "cookies"); + cookie_manager.set_persistent_storage ( + cookies, + WebKit.CookiePersistentStorage.SQLITE + ); + + context_menu.connect (() => { + return !is_terminal; + }); var back_click_gesture = new Gtk.GestureClick () { button = 8 @@ -82,16 +104,4 @@ public class Plausible.WebView : WebKit.WebView { forward_click_gesture.pressed.connect (go_forward); add_controller (forward_click_gesture); } - - private bool on_context_menu ( - WebKit.ContextMenu context_menu, - Gdk.Event event, - WebKit.HitTestResult hit_test_result - ) { - if (is_terminal) { - return Gdk.EVENT_PROPAGATE; - } - - return !Gdk.EVENT_PROPAGATE; - } }