Bind Preferences to Settings

This commit is contained in:
Bleak Grey 2020-05-31 23:56:43 +03:00
parent 01b1223982
commit 439bd763a4
3 changed files with 34 additions and 4 deletions

View File

@ -29,7 +29,7 @@
<default>20</default>
</key>
<key name="post-text-size" type="i">
<default>14</default>
<default>0</default>
</key>
<key name="live-updates" type="b">
<default>true</default>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.36.0 -->
<!-- Not generated with glade 3.36.0 and I hate it -->
<interface>
<requires lib="gtk+" version="3.22"/>
<requires lib="libhandy" version="0.0"/>
@ -174,8 +174,8 @@
<property name="step-increment">1</property>
</object>
<object class="GtkAdjustment" id="font_adjustment">
<property name="lower">14</property>
<property name="upper">32</property>
<property name="lower">0</property>
<property name="upper">50</property>
<property name="page-increment">1</property>
<property name="step-increment">1</property>
</object>

View File

@ -3,8 +3,22 @@ using Gtk;
[GtkTemplate (ui = "/com/github/bleakgrey/tootle/ui/dialogs/preferences.ui")]
public class Tootle.Dialogs.Preferences : Hdy.PreferencesWindow {
[GtkChild]
Switch dark_theme;
[GtkChild]
Switch autostart;
[GtkChild]
Switch work_in_background;
[GtkChild]
Hdy.ComboRow default_post_visibility;
[GtkChild]
SpinButton timeline_page_size;
[GtkChild]
SpinButton post_text_size;
[GtkChild]
Switch live_updates;
[GtkChild]
Switch public_live_updates;
construct {
transient_for = window;
@ -16,6 +30,7 @@ public class Tootle.Dialogs.Preferences : Hdy.PreferencesWindow {
return vis.get_name ();
});
bind ();
show ();
}
@ -23,4 +38,19 @@ public class Tootle.Dialogs.Preferences : Hdy.PreferencesWindow {
new Preferences ();
}
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);
}
}