diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-08-26 15:01:29 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-08-26 15:01:29 -0400 |
| commit | 2ba1fe874070fc372c1a522c5c5b97173fbe1459 (patch) | |
| tree | a7da63605cc3210bc0288600b9b42737d0f3c073 /main | |
| parent | 3a4aa40217276ac0d864c392f9a4b875ff8970ab (diff) | |
feat: add tweaks page to preferences, as well as an option for avatar roundness
Diffstat (limited to 'main')
| -rw-r--r-- | main/data/gresource.xml | 1 | ||||
| -rw-r--r-- | main/data/preferences_window/preferences_dialog.ui | 10 | ||||
| -rw-r--r-- | main/data/preferences_window/tweaks_preferences_page.ui | 27 | ||||
| -rw-r--r-- | main/meson.build | 1 | ||||
| -rw-r--r-- | main/src/ui/widgets/avatar_picture.vala | 21 | ||||
| -rw-r--r-- | main/src/view_model/preferences_dialog.vala | 7 | ||||
| -rw-r--r-- | main/src/windows/preferences_window/preferences_dialog.vala | 3 | ||||
| -rw-r--r-- | main/src/windows/preferences_window/tweaks_preferences_page.vala | 27 |
8 files changed, 95 insertions, 2 deletions
diff --git a/main/data/gresource.xml b/main/data/gresource.xml index b1dc2c40..8f23c48a 100644 --- a/main/data/gresource.xml +++ b/main/data/gresource.xml @@ -92,6 +92,7 @@ <file>preferences_window/change_password_dialog.ui</file> <file>preferences_window/general_preferences_page.ui</file> <file>preferences_window/preferences_dialog.ui</file> + <file>preferences_window/tweaks_preferences_page.ui</file> <file>join_room_dialog.ui</file> <file>join_room_dialog1.ui</file> diff --git a/main/data/preferences_window/preferences_dialog.ui b/main/data/preferences_window/preferences_dialog.ui index 3a35b63f..dae1ce7c 100644 --- a/main/data/preferences_window/preferences_dialog.ui +++ b/main/data/preferences_window/preferences_dialog.ui @@ -28,5 +28,13 @@ <property name="model" bind-source="model" bind-property="general-page" bind-flags="sync-create" /> </object> </child> + <child> + <object class="DinoUiTweaksPreferencesPage" id="tweaks_page"> + <property name="title" translatable="yes">Tweaks</property> + <property name="name">tweaks</property> + <property name="icon-name">preferences-desktop-appearance-symbolic</property> + <property name="model" bind-source="model" bind-property="tweaks-page" bind-flags="sync-create" /> + </object> + </child> </template> -</interface>
\ No newline at end of file +</interface> diff --git a/main/data/preferences_window/tweaks_preferences_page.ui b/main/data/preferences_window/tweaks_preferences_page.ui new file mode 100644 index 00000000..ae9b26e8 --- /dev/null +++ b/main/data/preferences_window/tweaks_preferences_page.ui @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk" version="4.0"/> + <object class="GtkAdjustment" id="avatar_roundness_adjustment"> + <property name="lower">0</property> + <property name="upper">100</property> + <property name="step-increment">1</property> + <property name="page-increment">10</property> + </object> + <template class="DinoUiTweaksPreferencesPage" parent="AdwPreferencesPage"> + <child> + <object class="AdwPreferencesGroup"> + <property name="title" translatable="yes">Appearance</property> + <child> + <object class="AdwSpinRow" id="avatar_roundness_row"> + <property name="title" translatable="yes">Profile Picture Roundness (%)</property> + <property name="subtitle" translatable="yes">Set to 0 for square pictures or 100 for circular pictures</property> + <property name="adjustment">avatar_roundness_adjustment</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="snap-to-ticks">True</property> + </object> + </child> + </object> + </child> + </template> +</interface> diff --git a/main/meson.build b/main/meson.build index 4959b7c5..e387914f 100644 --- a/main/meson.build +++ b/main/meson.build @@ -101,6 +101,7 @@ sources = files( 'src/windows/preferences_window/encryption_preferences_page.vala', 'src/windows/preferences_window/general_preferences_page.vala', 'src/windows/preferences_window/preferences_dialog.vala', + 'src/windows/preferences_window/tweaks_preferences_page.vala', 'src/windows/conversation_details.vala', ) sources += gnome.compile_resources( diff --git a/main/src/ui/widgets/avatar_picture.vala b/main/src/ui/widgets/avatar_picture.vala index 155c9440..18e4d02f 100644 --- a/main/src/ui/widgets/avatar_picture.vala +++ b/main/src/ui/widgets/avatar_picture.vala @@ -217,6 +217,13 @@ public class Dino.Ui.CompatAvatarDrawer { public int width_request { get; set; default = 35; } public string font_family { get; set; default = "Sans"; } + public CompatAvatarDrawer() { + Dino.Application? application = Dino.Application.get_default(); + if (application != null && application.settings != null) { + radius_percent = (float) application.settings.avatar_roundness / 100.0f; + } + } + public Cairo.ImageSurface draw_image_surface() { Cairo.ImageSurface surface = new Cairo.ImageSurface(Cairo.Format.ARGB32, width_request, height_request); draw_on_context(new Cairo.Context(surface)); @@ -337,12 +344,17 @@ public class Dino.Ui.AvatarPicture : Gtk.Widget { private ViewModel.AvatarPictureModel? old_model; private ulong model_tiles_items_changed_handler; + private Binding? avatar_roundness_binding; construct { height_request = 35; width_request = 35; set_css_name("picture"); add_css_class("avatar"); + Dino.Application? application = Dino.Application.get_default(); + if (application != null && application.settings != null) { + avatar_roundness_binding = application.settings.bind_property("avatar-roundness", this, "radius-percent", BindingFlags.SYNC_CREATE, avatar_roundness_to_radius_percent); + } notify["radius-percent"].connect(queue_draw); notify["model"].connect(on_model_changed); check_widget_leak(this); @@ -433,11 +445,20 @@ public class Dino.Ui.AvatarPicture : Gtk.Widget { } public override void dispose() { + if (avatar_roundness_binding != null) { + avatar_roundness_binding.unbind(); + avatar_roundness_binding = null; + } model = null; on_model_changed(); base.dispose(); } + private static bool avatar_roundness_to_radius_percent(Binding binding, Value from_value, ref Value to_value) { + to_value.set_float((float) from_value.get_int() / 100.0f); + return true; + } + private class Tile : Gtk.Widget { public ViewModel.AvatarPictureTileModel? model { get; set; } public Gdk.RGBA background_color { get; set; default = Gdk.RGBA(){ red = 1.0f, green = 1.0f, blue = 1.0f, alpha = 0.0f }; } diff --git a/main/src/view_model/preferences_dialog.vala b/main/src/view_model/preferences_dialog.vala index 5b5412f8..d7bad93a 100644 --- a/main/src/view_model/preferences_dialog.vala +++ b/main/src/view_model/preferences_dialog.vala @@ -14,6 +14,7 @@ public class Dino.Ui.ViewModel.PreferencesDialog : Object { public Database db; public GeneralPreferencesPage general_page { get; set; default=new GeneralPreferencesPage(); } + public TweaksPreferencesPage tweaks_page { get; set; default=new TweaksPreferencesPage(); } public void populate(Database db, StreamInteractor stream_interactor) { this.db = db; @@ -36,6 +37,7 @@ public class Dino.Ui.ViewModel.PreferencesDialog : Object { stream_interactor.account_removed.connect(update_data); bind_general_page(); + bind_tweaks_page(); update_data(); } @@ -119,6 +121,11 @@ public class Dino.Ui.ViewModel.PreferencesDialog : Object { settings.bind_property("notifications-connection-errors", general_page, "notifications-connection-errors", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); settings.bind_property("convert-utf8-smileys", general_page, "convert-emojis", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); } + + private void bind_tweaks_page() { + var settings = Dino.Application.get_default().settings; + settings.bind_property("avatar-roundness", tweaks_page, "avatar-roundness", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + } } public class Dino.Ui.ViewModel.ChangePasswordDialog : Object { 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..6da43348 --- /dev/null +++ b/main/src/windows/preferences_window/tweaks_preferences_page.vala @@ -0,0 +1,27 @@ +using Gtk; + +public class Dino.Ui.ViewModel.TweaksPreferencesPage : Object { + public int avatar_roundness { get; set; } +} + +[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; + + public ViewModel.TweaksPreferencesPage model { get; set; default = new ViewModel.TweaksPreferencesPage(); } + private Binding? avatar_roundness_binding; + + construct { + this.notify["model"].connect(on_model_changed); + } + + private void on_model_changed() { + if (avatar_roundness_binding != null) { + avatar_roundness_binding.unbind(); + avatar_roundness_binding = null; + } + if (model != null) { + avatar_roundness_binding = model.bind_property("avatar-roundness", avatar_roundness_row, "value", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + } + } +} |
