diff --git a/README.md b/README.md index eacfbd1..7516620 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,12 @@ To build TUF Manager the following is needed: - polkit - polkit-gobject - gmodule-export +- libnotify +- libappindicator3 ## Other requirements -This software will only work if using the [faustus](https://github.com/hackbnw/faustus) driver module. +This software will only work if using the [hackbnw/faustus](https://github.com/hackbnw/faustus) driver module. To get notifications on fan mode changes the fork of faustus at [rublag/faustus](https://github.com/rublag/faustus) should be used instead since it supports polling. ## Build options @@ -87,11 +89,9 @@ This is the daemon that runs in the background and handles all requests from bot - tuf-tray -This is the tray icon to control the TUF Manager program +This is the tray icon to control the TUF Manager program. It should automatically start in any desktop environment that supports xdg. ## Future plans - Manpage - Config options for both tuf-gui and tuf-cli -- Notifications of fan mode change via status bar -- Restore last known settings on login via status bar icon diff --git a/data/gschema/org.tuf.manager.gschema.xml b/data/gschema/org.tuf.manager.gschema.xml index 39f7be4..ade338e 100644 --- a/data/gschema/org.tuf.manager.gschema.xml +++ b/data/gschema/org.tuf.manager.gschema.xml @@ -1,12 +1,19 @@ - false + true Should TUF Manager restore previous settings when run? Should TUF Manager restore previous settings when run? + + true + Should TUF Manager show notifications? + + Should TUF Manager show notifications? + + 0 Fan mode diff --git a/data/ui/tuf.manager.window.ui b/data/ui/tuf.manager.window.ui index 6d5736d..08a20be 100644 --- a/data/ui/tuf.manager.window.ui +++ b/data/ui/tuf.manager.window.ui @@ -30,7 +30,7 @@ Author: Chris Cromer --> - + @@ -57,6 +57,9 @@ Author: Chris Cromer True False center + start + 5 + 5 5 5 True @@ -196,6 +199,8 @@ Author: Chris Cromer False center start + 5 + 5 5 5 True @@ -255,10 +260,94 @@ Author: Chris Cromer - + + True + False + center + start + 5 + 5 + 5 + 5 + + + True + False + end + 5 + 5 + 5 + 5 + Restore on start + + + 0 + 0 + + + + + Restore + True + True + 5 + 5 + 5 + 5 + + + + 1 + 0 + + + + + True + False + end + 5 + 5 + 5 + 5 + Notifications + + + 0 + 1 + + + + + Notifications + True + True + 5 + 5 + 5 + 5 + + + + 1 + 1 + + + + + 2 + - + + True + False + Settings + + + 2 + False + diff --git a/src/gui-window.vala b/src/gui-window.vala index 1fddba9..b8d19a3 100644 --- a/src/gui-window.vala +++ b/src/gui-window.vala @@ -59,6 +59,18 @@ namespace TUFManager { [GtkChild] private Gtk.ColorChooserWidget keyboard_color; + /** + * The restore switch + */ + [GtkChild] + private Gtk.Switch restore_settings; + + /** + * The notifications switch + */ + [GtkChild] + private Gtk.Switch notifications; + /** * Create the main window * @param application The application used to make the GLib object @@ -95,7 +107,12 @@ namespace TUFManager { print (_ ("Client version: ") + VERSION + "\n"); print (_ ("Server version: ") + get_server_version () + "\n"); + if (settings.get_boolean ("notifications")) { + notifications.set_active (true); + } + if (settings.get_boolean ("restore")) { + restore_settings.set_active (true); restore (); } else { @@ -264,6 +281,40 @@ namespace TUFManager { settings.set_string ("keyboard-color", rgba.to_string ()); } } + + /** + * Called when the user clicks the restore settings switch + * + * @param gtk_switch The switch that was clicked + * @param switched The new state of the switch + */ + [GtkCallback] + public bool on_restore_settings_state_set (Gtk.Switch gtk_switch, bool switched) { + if (switched) { + settings.set_boolean ("restore", true); + } + else { + settings.set_boolean ("restore", false); + } + return false; + } + + /** + * Called when the user clicks the notifications switch + * + * @param gtk_switch The switch that was clicked + * @param switched The new state of the switch + */ + [GtkCallback] + public bool on_notifications_state_set (Gtk.Switch gtk_switch, bool switched) { + if (switched) { + settings.set_boolean ("notifications", true); + } + else { + settings.set_boolean ("notifications", false); + } + return false; + } } } } diff --git a/src/meson.build b/src/meson.build index cb80a7a..aaab63a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,5 @@ glib_dep = dependency('glib-2.0') -gtk_dep = dependency('gtk+-3.0', version: '>=3.10.0') +gtk_dep = dependency('gtk+-3.0', version: '>=3.14.0') posix_dep = meson.get_compiler('vala').find_library('posix', required: true) m_dep = meson.get_compiler('c').find_library('m', required: true) diff --git a/src/tray-icon.vala b/src/tray-icon.vala index 3f8ea99..33ccd77 100644 --- a/src/tray-icon.vala +++ b/src/tray-icon.vala @@ -154,19 +154,16 @@ namespace TUFManager { private void set_fan_balanced () { set_fan_mode (0); - //show_notification (_ ("Fan set to balanced")); settings.set_int ("fan-mode", 0); } private void set_fan_turbo () { set_fan_mode (1); - //show_notification (_ ("Fan set to turbo")); settings.set_int ("fan-mode", 1); } private void set_fan_silent () { set_fan_mode (2); - //show_notification (_ ("Fan set to silenced")); settings.set_int ("fan-mode", 2); } @@ -210,15 +207,17 @@ namespace TUFManager { } private void show_notification (string message) { - try { - close_notification (); - notification = new Notify.Notification (_ ("TUF Manager"), message, "tuf-manager"); - notification.set_timeout (Notify.EXPIRES_DEFAULT); - notification.add_action ("default", _ ("Details"), close_notification); - notification.show (); - } - catch (Error e) { - warning (e.message); + if (settings.get_boolean ("notifications")) { + try { + close_notification (); + notification = new Notify.Notification (_ ("TUF Manager"), message, "tuf-manager"); + notification.set_timeout (Notify.EXPIRES_DEFAULT); + notification.add_action ("default", _ ("Details"), close_notification); + notification.show (); + } + catch (Error e) { + warning (e.message); + } } }