2018-05-20 12:43:42 +00:00
|
|
|
using Gtk;
|
|
|
|
|
2019-03-11 14:14:37 +00:00
|
|
|
public class Tootle.Dialogs.Preferences : Dialog {
|
2018-05-20 12:43:42 +00:00
|
|
|
|
2019-03-11 14:14:37 +00:00
|
|
|
private static Preferences dialog;
|
2018-05-20 12:43:42 +00:00
|
|
|
|
2018-05-30 12:58:27 +00:00
|
|
|
private SettingsSwitch switch_notifications;
|
|
|
|
private SettingsSwitch switch_watcher;
|
2018-06-13 13:13:41 +00:00
|
|
|
private SettingsSwitch switch_stream;
|
|
|
|
private SettingsSwitch switch_stream_public;
|
2019-03-11 14:14:37 +00:00
|
|
|
private Grid grid;
|
2018-05-20 12:43:42 +00:00
|
|
|
|
2019-03-11 14:14:37 +00:00
|
|
|
public Preferences () {
|
2018-06-13 13:13:41 +00:00
|
|
|
border_width = 6;
|
|
|
|
deletable = false;
|
|
|
|
resizable = false;
|
|
|
|
title = _("Settings");
|
2018-10-23 10:05:24 +00:00
|
|
|
transient_for = window;
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-20 12:43:42 +00:00
|
|
|
int i = 0;
|
2019-03-11 14:14:37 +00:00
|
|
|
grid = new Grid ();
|
|
|
|
|
2018-06-13 13:13:41 +00: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;
|
|
|
|
});
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-20 21:37:33 +00: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++);
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-20 12:43:42 +00:00
|
|
|
grid.attach (new Granite.HeaderLabel (_("Timelines")), 0, i++, 2, 1);
|
|
|
|
grid.attach (new SettingsLabel (_("Real-time updates:")), 0, i);
|
2018-06-13 13:13:41 +00:00
|
|
|
grid.attach (switch_stream, 1, i++);
|
|
|
|
grid.attach (new SettingsLabel (_("Update public timelines:")), 0, i);
|
|
|
|
grid.attach (switch_stream_public, 1, i++);
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-25 10:00:11 +00: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);
|
2019-03-11 14:14:37 +00:00
|
|
|
// var cache_size = new SpinButton.with_range (16, 256, 1);
|
2018-05-25 10:00:11 +00:00
|
|
|
// settings.schema.bind ("cache-size", cache_size, "value", SettingsBindFlags.DEFAULT);
|
|
|
|
// grid.attach (cache_size, 1, i++);
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-20 12:43:42 +00:00
|
|
|
grid.attach (new Granite.HeaderLabel (_("Notifications")), 0, i++, 2, 1);
|
2018-05-30 12:58:27 +00:00
|
|
|
grid.attach (new SettingsLabel (_("Display notifications:")), 0, i);
|
|
|
|
grid.attach (switch_notifications, 1, i++);
|
2018-05-20 12:43:42 +00:00
|
|
|
grid.attach (new SettingsLabel (_("Always receive notifications:")), 0, i);
|
2018-05-30 12:58:27 +00:00
|
|
|
grid.attach (switch_watcher, 1, i++);
|
2019-03-11 14:14:37 +00:00
|
|
|
|
|
|
|
var content = get_content_area () as Box;
|
2018-05-20 12:43:42 +00:00
|
|
|
content.pack_start (grid, false, false, 0);
|
2019-03-11 14:14:37 +00:00
|
|
|
|
|
|
|
var close = add_button (_("_Close"), ResponseType.CLOSE) as Button;
|
2018-05-20 12:43:42 +00:00
|
|
|
close.clicked.connect (() => {
|
|
|
|
destroy ();
|
|
|
|
dialog = null;
|
|
|
|
});
|
2019-03-11 14:14:37 +00:00
|
|
|
|
2018-05-20 12:43:42 +00:00
|
|
|
show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void open () {
|
|
|
|
if (dialog == null)
|
2019-03-11 14:14:37 +00:00
|
|
|
dialog = new Preferences ();
|
2018-05-20 12:43:42 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:14:37 +00:00
|
|
|
protected class SettingsLabel : Label {
|
2018-05-20 12:43:42 +00:00
|
|
|
public SettingsLabel (string text) {
|
|
|
|
label = text;
|
2019-03-11 14:14:37 +00:00
|
|
|
halign = Align.END;
|
2018-05-20 12:43:42 +00:00
|
|
|
margin_start = 12;
|
|
|
|
margin_end = 12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-11 14:14:37 +00:00
|
|
|
protected class SettingsSwitch : Switch {
|
2018-05-20 12:43:42 +00:00
|
|
|
public SettingsSwitch (string setting) {
|
2019-03-11 14:14:37 +00:00
|
|
|
halign = Align.START;
|
|
|
|
valign = Align.CENTER;
|
2018-05-20 12:43:42 +00:00
|
|
|
margin_bottom = 6;
|
2020-05-29 12:19:35 +00:00
|
|
|
settings.bind (setting, this, "active", SettingsBindFlags.DEFAULT);
|
2018-05-20 12:43:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|