diff options
Diffstat (limited to 'main/src/windows')
4 files changed, 103 insertions, 5 deletions
diff --git a/main/src/windows/preferences_window/account_preferences_subpage.vala b/main/src/windows/preferences_window/account_preferences_subpage.vala index cc1e7b5e..d52a8c83 100644 --- a/main/src/windows/preferences_window/account_preferences_subpage.vala +++ b/main/src/windows/preferences_window/account_preferences_subpage.vala @@ -12,6 +12,7 @@ public class Dino.Ui.AccountPreferencesSubpage : Adw.NavigationPage { [GtkChild] public unowned AvatarPicture avatar; [GtkChild] public unowned Adw.ActionRow xmpp_address; [GtkChild] public unowned Adw.EntryRow local_alias; + [GtkChild] public unowned Box account_color_box; [GtkChild] public unowned Adw.ActionRow password_change; [GtkChild] public unowned Adw.ActionRow connection_status; [GtkChild] public unowned Button enter_password_button; @@ -28,6 +29,12 @@ public class Dino.Ui.AccountPreferencesSubpage : Adw.NavigationPage { private Binding[] bindings = new Binding[0]; private ulong[] account_notify_ids = new ulong[0]; private ulong alias_entry_changed = 0; + private bool updating_account_color = false; +#if GTK_4_12 + private ColorDialogButton account_color_button; +#else + private ColorButton account_color_button; +#endif construct { title = "Account"; @@ -45,6 +52,23 @@ public class Dino.Ui.AccountPreferencesSubpage : Adw.NavigationPage { remove_account_button.clicked.connect(() => { show_remove_account_dialog(); }); + +#if GTK_4_12 + var color_dialog = new ColorDialog() { + title = _("Choose account color"), + with_alpha = false + }; + account_color_button = new ColorDialogButton((owned) color_dialog) { valign=Align.CENTER }; +#else + account_color_button = new ColorButton() { + title = _("Choose account color"), + use_alpha = false, + valign = Align.CENTER + }; +#endif + account_color_button.notify["rgba"].connect(on_account_color_changed); + account_color_box.append(account_color_button); + password_change.activatable_widget = new Label(""); password_change.activated.connect(() => { var dialog = new ChangePasswordDialog(model.get_change_password_dialog_model()); @@ -121,6 +145,12 @@ public class Dino.Ui.AccountPreferencesSubpage : Adw.NavigationPage { account.alias = local_alias.text; }); + Gdk.RGBA account_color = Gdk.RGBA(); + account_color.parse(Dino.Application.get_default().settings.get_account_color(account)); + updating_account_color = true; + account_color_button.rgba = account_color; + updating_account_color = false; + bindings += account.bind_property("enabled", disable_account_button, "label", BindingFlags.SYNC_CREATE, account_enabled_to_disable_button_label); bindings += account.bind_property("enabled", avatar_menu_box, "visible", BindingFlags.SYNC_CREATE); bindings += account.bind_property("enabled", password_change, "visible", BindingFlags.SYNC_CREATE); @@ -137,6 +167,19 @@ public class Dino.Ui.AccountPreferencesSubpage : Adw.NavigationPage { on_connection_error_updated(); } + private void on_account_color_changed() { + if (updating_account_color) return; + +#if GTK_4_12 + unowned Gdk.RGBA? selected_color = account_color_button.get_rgba(); + if (selected_color != null) { + Dino.Application.get_default().settings.set_account_color(account, Util.rgba_to_hex(selected_color)); + } +#else + Dino.Application.get_default().settings.set_account_color(account, Util.rgba_to_hex(account_color_button.rgba)); +#endif + } + private void show_select_avatar() { FileChooserNative chooser = new FileChooserNative(_("Select avatar"), (Window)this.get_root(), FileChooserAction.OPEN, _("Select"), _("Cancel")); FileFilter filter = new FileFilter(); @@ -261,4 +304,4 @@ public class Dino.Ui.NaturalDirectionBoxLayout : LayoutManager { } } } -}
\ No newline at end of file +} diff --git a/main/src/windows/preferences_window/general_preferences_page.vala b/main/src/windows/preferences_window/general_preferences_page.vala index 0dcf2118..733de889 100644 --- a/main/src/windows/preferences_window/general_preferences_page.vala +++ b/main/src/windows/preferences_window/general_preferences_page.vala @@ -4,7 +4,14 @@ public class Dino.Ui.ViewModel.GeneralPreferencesPage : Object { public bool send_typing { get; set; } public bool send_marker { get; set; } public bool share_time { get; set; } - public bool notifications { get; set; } + public bool notifications_messages { get; set; } + public bool notifications_files { get; set; } + public bool notifications_calls { get; set; } + public bool notifications_subscription_requests { get; set; } + public bool notifications_group_chat_invitations { get; set; } + public bool notifications_permission_requests { get; set; } + public bool notifications_connection_errors { get; set; } + public bool notifications_badge { get; set; } public bool convert_emojis { get; set; } } @@ -13,7 +20,14 @@ public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage { [GtkChild] private unowned Adw.SwitchRow typing_row; [GtkChild] private unowned Adw.SwitchRow marker_row; [GtkChild] private unowned Adw.SwitchRow time_row; - [GtkChild] private unowned Adw.SwitchRow notification_row; + [GtkChild] private unowned Adw.SwitchRow notification_messages_row; + [GtkChild] private unowned Adw.SwitchRow notification_files_row; + [GtkChild] private unowned Adw.SwitchRow notification_calls_row; + [GtkChild] private unowned Adw.SwitchRow notification_subscription_requests_row; + [GtkChild] private unowned Adw.SwitchRow notification_group_chat_invitations_row; + [GtkChild] private unowned Adw.SwitchRow notification_permission_requests_row; + [GtkChild] private unowned Adw.SwitchRow notification_connection_errors_row; + [GtkChild] private unowned Adw.SwitchRow notification_badge_row; [GtkChild] private unowned Adw.SwitchRow emoji_row; public ViewModel.GeneralPreferencesPage model { get; set; default = new ViewModel.GeneralPreferencesPage(); } @@ -32,7 +46,14 @@ public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage { model.bind_property("send-typing", typing_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), model.bind_property("send-marker", marker_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), model.bind_property("share-time", time_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), - model.bind_property("notifications", notification_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-messages", notification_messages_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-files", notification_files_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-calls", notification_calls_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-subscription-requests", notification_subscription_requests_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-group-chat-invitations", notification_group_chat_invitations_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-permission-requests", notification_permission_requests_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-connection-errors", notification_connection_errors_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("notifications-badge", notification_badge_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), model.bind_property("convert-emojis", emoji_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL) }; } else { diff --git a/main/src/windows/preferences_window/preferences_dialog.vala b/main/src/windows/preferences_window/preferences_dialog.vala index 4baced96..a92575f0 100644 --- a/main/src/windows/preferences_window/preferences_dialog.vala +++ b/main/src/windows/preferences_window/preferences_dialog.vala @@ -10,6 +10,7 @@ public class Dino.Ui.PreferencesDialog : Adw.PreferencesDialog { [GtkChild] public unowned Dino.Ui.PreferencesWindowAccounts accounts_page; [GtkChild] public unowned Dino.Ui.PreferencesWindowEncryption encryption_page; [GtkChild] public unowned Dino.Ui.GeneralPreferencesPage general_page; + [GtkChild] public unowned Dino.Ui.TweaksPreferencesPage tweaks_page; [GtkChild] public unowned ViewModel.PreferencesDialog model { get; } @@ -24,4 +25,4 @@ public class Dino.Ui.PreferencesDialog : Adw.PreferencesDialog { this.push_subpage(account_page); }); } -}
\ No newline at end of file +} diff --git a/main/src/windows/preferences_window/tweaks_preferences_page.vala b/main/src/windows/preferences_window/tweaks_preferences_page.vala new file mode 100644 index 00000000..906ca1ae --- /dev/null +++ b/main/src/windows/preferences_window/tweaks_preferences_page.vala @@ -0,0 +1,33 @@ +using Gtk; + +public class Dino.Ui.ViewModel.TweaksPreferencesPage : Object { + public int avatar_roundness { get; set; } + public string custom_css { get; set; default = ""; } +} + +[GtkTemplate (ui = "/im/dino/Dino/preferences_window/tweaks_preferences_page.ui")] +public class Dino.Ui.TweaksPreferencesPage : Adw.PreferencesPage { + [GtkChild] private unowned Adw.SpinRow avatar_roundness_row; + [GtkChild] private unowned Gtk.TextBuffer custom_css_buffer; + + public ViewModel.TweaksPreferencesPage model { get; set; default = new ViewModel.TweaksPreferencesPage(); } + private Binding[] model_bindings = new Binding[0]; + + construct { + this.notify["model"].connect(on_model_changed); + } + + private void on_model_changed() { + foreach (Binding binding in model_bindings) { + binding.unbind(); + } + if (model != null) { + model_bindings = new Binding[] { + model.bind_property("avatar-roundness", avatar_roundness_row, "value", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("custom-css", custom_css_buffer, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL) + }; + } else { + model_bindings = new Binding[0]; + } + } +} |
