tootle-linux-client/src/Dialogs/Preferences.vala

57 lines
1.9 KiB
Vala
Raw Normal View History

2018-05-20 14:43:42 +02:00
using Gtk;
2020-05-31 20:55:40 +02:00
[GtkTemplate (ui = "/com/github/bleakgrey/tootle/ui/dialogs/preferences.ui")]
public class Tootle.Dialogs.Preferences : Hdy.PreferencesWindow {
2018-05-20 14:43:42 +02:00
2020-05-31 22:56:43 +02:00
[GtkChild]
Switch dark_theme;
[GtkChild]
Switch autostart;
[GtkChild]
Switch work_in_background;
2020-05-31 20:55:40 +02:00
[GtkChild]
Hdy.ComboRow default_post_visibility;
2020-05-31 22:56:43 +02:00
[GtkChild]
SpinButton timeline_page_size;
[GtkChild]
SpinButton post_text_size;
[GtkChild]
Switch live_updates;
[GtkChild]
Switch public_live_updates;
2018-05-20 14:43:42 +02:00
2020-05-31 20:55:40 +02:00
construct {
2018-10-23 12:05:24 +02:00
transient_for = window;
2019-03-11 15:14:37 +01:00
2020-05-31 20:55:40 +02:00
default_post_visibility.set_for_enum (typeof (API.Visibility), e => {
var i = e.get_value ();
var vis = API.Visibility.all ()[i];
default_post_visibility.subtitle = vis.get_desc ();
return vis.get_name ();
2018-05-20 14:43:42 +02:00
});
2019-03-11 15:14:37 +01:00
2020-05-31 22:56:43 +02:00
bind ();
2020-05-31 20:55:40 +02:00
show ();
2018-05-20 14:43:42 +02:00
}
public static void open () {
2020-05-31 20:55:40 +02:00
new Preferences ();
2018-05-20 14:43:42 +02:00
}
2020-05-31 22:56:43 +02:00
void bind () {
settings.bind ("dark-theme", dark_theme, "active", SettingsBindFlags.DEFAULT);
settings.bind ("autostart", autostart, "active", SettingsBindFlags.DEFAULT);
settings.bind ("work-in-background", work_in_background, "active", SettingsBindFlags.DEFAULT);
default_post_visibility.selected_index = (int) settings.default_post_visibility;
default_post_visibility.notify["selected-index"].connect (p => {
var i = default_post_visibility.selected_index;
settings.default_post_visibility = (API.Visibility) i;
});
settings.bind ("timeline-page-size", timeline_page_size.adjustment, "value", SettingsBindFlags.DEFAULT);
settings.bind ("post-text-size", post_text_size.adjustment, "value", SettingsBindFlags.DEFAULT);
settings.bind ("live-updates", live_updates, "active", SettingsBindFlags.DEFAULT);
settings.bind ("public-live-updates", public_live_updates, "active", SettingsBindFlags.DEFAULT);
}
2018-05-20 14:43:42 +02:00
}