add configure options to gui

This commit is contained in:
2020-08-07 20:21:05 -04:00
parent ec601c8aba
commit c69fee81b4
6 changed files with 167 additions and 21 deletions

View File

@@ -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;
}
}
}
}

View File

@@ -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)

View File

@@ -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);
}
}
}