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

97 lines
3.5 KiB
Vala
Raw Normal View History

2018-05-20 14:43:42 +02:00
using Gtk;
using Tootle;
public class Tootle.SettingsDialog : Gtk.Dialog {
private static SettingsDialog dialog;
2018-05-30 14:58:27 +02:00
private SettingsSwitch switch_notifications;
private SettingsSwitch switch_watcher;
2018-06-13 15:13:41 +02:00
private SettingsSwitch switch_stream;
private SettingsSwitch switch_stream_public;
2018-05-20 14:43:42 +02:00
private Gtk.Grid grid;
public SettingsDialog () {
2018-06-13 15:13:41 +02:00
border_width = 6;
deletable = false;
resizable = false;
title = _("Settings");
2018-10-23 12:05:24 +02:00
transient_for = window;
2018-05-20 14:43:42 +02:00
int i = 0;
grid = new Gtk.Grid ();
2018-06-13 15:13:41 +02:00
switch_watcher = new SettingsSwitch ("always-online");
switch_notifications = new SettingsSwitch ("notifications");
switch_notifications.state_set.connect (state => {
switch_watcher.sensitive = state;
return false;
});
switch_stream = new SettingsSwitch ("live-updates");
switch_stream_public = new SettingsSwitch ("live-updates-public");
switch_stream.state_set.connect (state => {
switch_stream_public.sensitive = state;
return false;
});
2018-05-20 23:37:33 +02:00
grid.attach (new Granite.HeaderLabel (_("Appearance")), 0, i++, 2, 1);
grid.attach (new SettingsLabel (_("Dark theme:")), 0, i);
grid.attach (new SettingsSwitch ("dark-theme"), 1, i++);
2018-05-20 14:43:42 +02:00
grid.attach (new Granite.HeaderLabel (_("Timelines")), 0, i++, 2, 1);
grid.attach (new SettingsLabel (_("Real-time updates:")), 0, i);
2018-06-13 15:13:41 +02:00
grid.attach (switch_stream, 1, i++);
grid.attach (new SettingsLabel (_("Update public timelines:")), 0, i);
grid.attach (switch_stream_public, 1, i++);
2018-05-20 14:43:42 +02:00
2018-05-25 12:00:11 +02:00
// grid.attach (new Granite.HeaderLabel (_("Caching")), 0, i++, 2, 1);
// grid.attach (new SettingsLabel (_("Use cache:")), 0, i);
// grid.attach (new SettingsSwitch ("cache"), 1, i++);
// grid.attach (new SettingsLabel (_("Max cache size (MB):")), 0, i);
// var cache_size = new Gtk.SpinButton.with_range (16, 256, 1);
// settings.schema.bind ("cache-size", cache_size, "value", SettingsBindFlags.DEFAULT);
// grid.attach (cache_size, 1, i++);
2018-05-20 14:43:42 +02:00
grid.attach (new Granite.HeaderLabel (_("Notifications")), 0, i++, 2, 1);
2018-05-30 14:58:27 +02:00
grid.attach (new SettingsLabel (_("Display notifications:")), 0, i);
grid.attach (switch_notifications, 1, i++);
2018-05-20 14:43:42 +02:00
grid.attach (new SettingsLabel (_("Always receive notifications:")), 0, i);
2018-05-30 14:58:27 +02:00
grid.attach (switch_watcher, 1, i++);
2018-05-20 14:43:42 +02:00
var content = get_content_area () as Gtk.Box;
content.pack_start (grid, false, false, 0);
var close = add_button (_("_Close"), Gtk.ResponseType.CLOSE) as Gtk.Button;
close.clicked.connect (() => {
destroy ();
dialog = null;
});
show_all ();
}
public static void open () {
if (dialog == null)
dialog = new SettingsDialog ();
}
protected class SettingsLabel : Gtk.Label {
public SettingsLabel (string text) {
label = text;
halign = Gtk.Align.END;
margin_start = 12;
margin_end = 12;
}
}
protected class SettingsSwitch : Gtk.Switch {
public SettingsSwitch (string setting) {
halign = Gtk.Align.START;
valign = Gtk.Align.CENTER;
margin_bottom = 6;
2018-07-14 10:37:41 +02:00
settings.schema.bind (setting, this, "active", SettingsBindFlags.DEFAULT);
2018-05-20 14:43:42 +02:00
}
}
}