Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Show Notification on Startup in settings menu #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dev.deedles.Trayscale.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
example, display the current Tailscale connection status.
</description>
</key>
<key name="show-notification-on-startup" type="b">
<default>true</default>
<summary>Show Notification on Startup</summary>
<description>When enabled, shows a notification when the application starts</description>
</key>
<key name="polling-interval" type="d">
<default>5</default>
<summary>Interval at which to poll the Tailscale daemon</summary>
Expand Down
6 changes: 5 additions & 1 deletion internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions internal/ui/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions internal/ui/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<property name="title">Use Tray Icon</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="ShowNotificationOnStartupRow">
<property name="subtitle">When enabled, shows a notification when the application starts</property>
<property name="title">Show Notification on Startup</property>
</object>
</child>
<child>
<object class="AdwSpinRow" id="PollingIntervalRow">
<property name="adjustment">
Expand Down
1 change: 1 addition & 0 deletions internal/ui/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down