From 171b1bcc7175aef5dbc2189f7e295d2899816a17 Mon Sep 17 00:00:00 2001 From: 4rkal <4rkal@horsefucker.org> Date: Sun, 27 Oct 2024 11:43:06 +0200 Subject: [PATCH 1/2] added show notification on startup option --- dev.deedles.Trayscale.gschema.xml | 5 +++++ internal/ui/app.go | 6 +++++- internal/ui/preferences.go | 7 ++++--- internal/ui/preferences.ui | 6 ++++++ internal/ui/settings.go | 1 + 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dev.deedles.Trayscale.gschema.xml b/dev.deedles.Trayscale.gschema.xml index 3333dc15..9a8b7813 100644 --- a/dev.deedles.Trayscale.gschema.xml +++ b/dev.deedles.Trayscale.gschema.xml @@ -10,6 +10,11 @@ example, display the current Tailscale connection status. + + true + Show Notification on Startup + If enabled, shows a notification when the application starts + 5 Interval at which to poll the Tailscale daemon diff --git a/internal/ui/app.go b/internal/ui/app.go index 8a85e622..cea04ab4 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -170,7 +170,11 @@ func (a *App) update(s tsutil.Status) { if online { body = "Tailscale is connected." } - a.notify("Tailscale Status", body) // TODO: Notify on startup if not connected? + showNotification := a.settings.Boolean("show-notification-on-startup") + if showNotification { + a.notify("Tailscale Status", body) // TODO: Notify on startup if not connected? + + } } if a.win == nil { return diff --git a/internal/ui/preferences.go b/internal/ui/preferences.go index e21280f5..56690e72 100644 --- a/internal/ui/preferences.go +++ b/internal/ui/preferences.go @@ -13,9 +13,10 @@ var preferencesXML string type PreferencesWindow struct { *adw.PreferencesWindow `gtk:"PreferencesWindow"` - UseTrayIconRow *adw.SwitchRow - PollingIntervalRow *adw.SpinRow - PollingIntervalAdjustment *gtk.Adjustment + UseTrayIconRow *adw.SwitchRow + PollingIntervalRow *adw.SpinRow + ShowNotificationOnStartupRow *adw.SwitchRow + PollingIntervalAdjustment *gtk.Adjustment } func NewPreferencesWindow() *PreferencesWindow { diff --git a/internal/ui/preferences.ui b/internal/ui/preferences.ui index c4f8b416..1ca217f3 100644 --- a/internal/ui/preferences.ui +++ b/internal/ui/preferences.ui @@ -15,6 +15,12 @@ Use Tray Icon + + + When enabled, shows a notification when the application starts + Show Notification on Startup + + diff --git a/internal/ui/settings.go b/internal/ui/settings.go index 39655795..db8d1309 100644 --- a/internal/ui/settings.go +++ b/internal/ui/settings.go @@ -81,6 +81,7 @@ func (a *App) showPreferences() { win := NewPreferencesWindow() a.settings.Bind("tray-icon", win.UseTrayIconRow.Object, "active", gio.SettingsBindDefault) + a.settings.Bind("show-notification-on-startup", win.ShowNotificationOnStartupRow.Object, "active", gio.SettingsBindDefault) a.settings.Bind("polling-interval", win.PollingIntervalAdjustment.Object, "value", gio.SettingsBindDefault) win.SetTransientFor(&a.win.Window) win.SetVisible(true) From ebe0d770997d167ce69e8f3242cfaa897cce9f29 Mon Sep 17 00:00:00 2001 From: 4rkal <4rkal@horsefucker.org> Date: Sun, 27 Oct 2024 11:43:58 +0200 Subject: [PATCH 2/2] changed if to when --- dev.deedles.Trayscale.gschema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.deedles.Trayscale.gschema.xml b/dev.deedles.Trayscale.gschema.xml index 9a8b7813..1b726e4a 100644 --- a/dev.deedles.Trayscale.gschema.xml +++ b/dev.deedles.Trayscale.gschema.xml @@ -13,7 +13,7 @@ true Show Notification on Startup - If enabled, shows a notification when the application starts + When enabled, shows a notification when the application starts 5