diff options
| author | fiaxh <git@lightrise.org> | 2025-10-05 13:35:41 +0200 |
|---|---|---|
| committer | fiaxh <git@lightrise.org> | 2025-10-05 17:59:08 +0200 |
| commit | e14c7d933bfa0bdd97781857b9341854232058a2 (patch) | |
| tree | e302c07398dad3196a87a99843d9383ef116cb25 | |
| parent | 6d8ccb414529c017ef1b8a52499b7bbdb6432adb (diff) | |
Adjust to Adw 1.4: Use specialized ActionRows
| -rw-r--r-- | main/data/preferences_window/general_preferences_page.ui | 33 | ||||
| -rw-r--r-- | main/meson.build | 3 | ||||
| -rw-r--r-- | main/src/ui/util/preference_group.vala | 12 | ||||
| -rw-r--r-- | main/src/windows/conversation_details.vala | 3 | ||||
| -rw-r--r-- | main/src/windows/preferences_window/account_preferences_subpage.vala | 7 | ||||
| -rw-r--r-- | main/src/windows/preferences_window/general_preferences_page.vala | 16 | ||||
| -rw-r--r-- | main/src/windows/preferences_window/preferences_window.vala | 1 | ||||
| -rw-r--r-- | meson.build | 2 | ||||
| -rw-r--r-- | plugins/omemo/data/encryption_preferences_entry.ui | 18 | ||||
| -rw-r--r-- | plugins/omemo/src/ui/encryption_preferences_entry.vala | 16 | ||||
| -rw-r--r-- | plugins/openpgp/src/contact_details_provider.vala | 4 | ||||
| -rw-r--r-- | plugins/openpgp/src/encryption_preferences_entry.vala | 8 |
12 files changed, 27 insertions, 96 deletions
diff --git a/main/data/preferences_window/general_preferences_page.ui b/main/data/preferences_window/general_preferences_page.ui index 33d1a2c9..9e76e17a 100644 --- a/main/data/preferences_window/general_preferences_page.ui +++ b/main/data/preferences_window/general_preferences_page.ui @@ -5,28 +5,15 @@ <child> <object class="AdwPreferencesGroup"> <child> - <object class="AdwActionRow"> + <object class="AdwSwitchRow" id="typing_row"> <property name="title" translatable="yes">Send _Typing Notifications</property> <property name="use-underline">True</property> - <property name="activatable-widget">typing_switch</property> - <child type="suffix"> - <object class="GtkSwitch" id="typing_switch"> -<!-- <property name="active" bind-source="DinoUiGeneralPreferencesPage" bind-property="send-typing" bind-flags="sync-create|bidirectional" />--> - <property name="valign">center</property> - </object> - </child> </object> </child> <child> - <object class="AdwActionRow"> + <object class="AdwSwitchRow" id="marker_row"> <property name="title" translatable="yes">Send _Read Receipts</property> <property name="use-underline">True</property> - <property name="activatable-widget">marker_switch</property> - <child type="suffix"> - <object class="GtkSwitch" id="marker_switch"> - <property name="valign">center</property> - </object> - </child> </object> </child> </object> @@ -34,16 +21,10 @@ <child> <object class="AdwPreferencesGroup"> <child> - <object class="AdwActionRow"> + <object class="AdwSwitchRow" id="notification_row"> <property name="title" translatable="yes">_Notifications</property> <property name="subtitle" translatable="yes">Notify when a new message arrives</property> <property name="use-underline">True</property> - <property name="activatable-widget">notification_switch</property> - <child type="suffix"> - <object class="GtkSwitch" id="notification_switch"> - <property name="valign">center</property> - </object> - </child> </object> </child> </object> @@ -51,15 +32,9 @@ <child> <object class="AdwPreferencesGroup"> <child> - <object class="AdwActionRow"> + <object class="AdwSwitchRow" id="emoji_row"> <property name="title" translatable="yes">_Convert Smileys to Emoji</property> <property name="use-underline">True</property> - <property name="activatable-widget">emoji_switch</property> - <child type="suffix"> - <object class="GtkSwitch" id="emoji_switch"> - <property name="valign">center</property> - </object> - </child> </object> </child> </object> diff --git a/main/meson.build b/main/meson.build index be7e531c..af9523e5 100644 --- a/main/meson.build +++ b/main/meson.build @@ -127,9 +127,6 @@ if dep_gtk4.version() == 'unknown' or dep_gtk4.version().version_compare('>=4.14 vala_args += ['-D', 'GTK_4_14'] sources += files('src/ui/conversation_content_view/file_transmission_progress.c') endif -if dep_libadwaita.version() == 'unknown' or dep_libadwaita.version().version_compare('>=1.3') - vala_args += ['-D', 'Adw_1_3'] -endif if dep_libadwaita.version() == 'unknown' or dep_libadwaita.version().version_compare('>=1.4') vala_args += ['-D', 'Adw_1_4'] endif diff --git a/main/src/ui/util/preference_group.vala b/main/src/ui/util/preference_group.vala index 6056f2c8..efb5253a 100644 --- a/main/src/ui/util/preference_group.vala +++ b/main/src/ui/util/preference_group.vala @@ -61,9 +61,7 @@ namespace Dino.Ui.Util { var view = new Adw.ActionRow() { title = row_text.title, subtitle = row_text.text, -#if Adw_1_3 - subtitle_selectable = true, -#endif + subtitle_selectable = true }; view.add_css_class("property"); @@ -88,17 +86,9 @@ namespace Dino.Ui.Util { foreach (string text in combobox_view_model.items) { string_list.append(text); } -#if Adw_1_4 var view = new Adw.ComboRow() { title = combobox_view_model.title }; view.model = string_list; combobox_view_model.bind_property("active-item", view, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); -#else - var view = new Adw.ActionRow() { title = combobox_view_model.title }; - var drop_down = new DropDown(string_list, null) { valign = Align.CENTER }; - combobox_view_model.bind_property("active-item", drop_down, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); - view.activatable_widget = drop_down; - view.add_suffix(drop_down); -#endif return view; } diff --git a/main/src/windows/conversation_details.vala b/main/src/windows/conversation_details.vala index f6f420d2..bce9c423 100644 --- a/main/src/windows/conversation_details.vala +++ b/main/src/windows/conversation_details.vala @@ -78,10 +78,9 @@ namespace Dino.Ui.ConversationDetails { } block_button.menu_model = block_menu_model; -#if Adw_1_4 // TODO: replace with putting buttons in new line on small screens notification_button_menu_content.can_shrink = true; -#endif + update_blocked_button(); } diff --git a/main/src/windows/preferences_window/account_preferences_subpage.vala b/main/src/windows/preferences_window/account_preferences_subpage.vala index 1a7d5696..92fffa76 100644 --- a/main/src/windows/preferences_window/account_preferences_subpage.vala +++ b/main/src/windows/preferences_window/account_preferences_subpage.vala @@ -31,13 +31,11 @@ public class Dino.Ui.AccountPreferencesSubpage : Gtk.Box { private ulong alias_entry_changed = 0; construct { -#if Adw_1_4 headerbar.show_title = false; -#endif button_container.layout_manager = new NaturalDirectionBoxLayout((BoxLayout)button_container.layout_manager); back_button.clicked.connect(() => { var window = (Adw.PreferencesWindow) this.get_root(); - window.close_subpage(); + window.pop_subpage(); }); edit_avatar_button.clicked.connect(() => { show_select_avatar(); @@ -173,8 +171,7 @@ public class Dino.Ui.AccountPreferencesSubpage : Gtk.Box { model.remove_account(account); // Close the account subpage var window = (Adw.PreferencesWindow) this.get_root(); - window.close_subpage(); -// window.pop_subpage(); + window.pop_subpage(); } dialog.close(); }); diff --git a/main/src/windows/preferences_window/general_preferences_page.vala b/main/src/windows/preferences_window/general_preferences_page.vala index 6f8dd771..1e81a1b7 100644 --- a/main/src/windows/preferences_window/general_preferences_page.vala +++ b/main/src/windows/preferences_window/general_preferences_page.vala @@ -9,10 +9,10 @@ public class Dino.Ui.ViewModel.GeneralPreferencesPage : Object { [GtkTemplate (ui = "/im/dino/Dino/preferences_window/general_preferences_page.ui")] public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage { - [GtkChild] private unowned Switch typing_switch; - [GtkChild] private unowned Switch marker_switch; - [GtkChild] private unowned Switch notification_switch; - [GtkChild] private unowned Switch emoji_switch; + [GtkChild] private unowned Adw.SwitchRow typing_row; + [GtkChild] private unowned Adw.SwitchRow marker_row; + [GtkChild] private unowned Adw.SwitchRow notification_row; + [GtkChild] private unowned Adw.SwitchRow emoji_row; public ViewModel.GeneralPreferencesPage model { get; set; default = new ViewModel.GeneralPreferencesPage(); } private Binding[] model_bindings = new Binding[0]; @@ -27,10 +27,10 @@ public class Dino.Ui.GeneralPreferencesPage : Adw.PreferencesPage { } if (model != null) { model_bindings = new Binding[] { - model.bind_property("send-typing", typing_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), - model.bind_property("send-marker", marker_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), - model.bind_property("notifications", notification_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), - model.bind_property("convert-emojis", emoji_switch, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL) + 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("notifications", notification_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL), + model.bind_property("convert-emojis", emoji_row, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL) }; } else { model_bindings = new Binding[0]; diff --git a/main/src/windows/preferences_window/preferences_window.vala b/main/src/windows/preferences_window/preferences_window.vala index 662a6924..cee4e34e 100644 --- a/main/src/windows/preferences_window/preferences_window.vala +++ b/main/src/windows/preferences_window/preferences_window.vala @@ -15,7 +15,6 @@ public class Dino.Ui.PreferencesWindow : Adw.PreferencesWindow { [GtkChild] public unowned ViewModel.PreferencesWindow model { get; } construct { - this.can_navigate_back = true; // remove once we require Adw > 1.4 this.bind_property("model", accounts_page, "model", BindingFlags.SYNC_CREATE); this.bind_property("model", account_page, "model", BindingFlags.SYNC_CREATE); this.bind_property("model", encryption_page, "model", BindingFlags.SYNC_CREATE); diff --git a/meson.build b/meson.build index ae5b4fac..c5aa7c8d 100644 --- a/meson.build +++ b/meson.build @@ -31,7 +31,7 @@ dep_gstreamer_rtp = dependency('gstreamer-rtp-1.0', disabler: true, required: ge dep_gstreamer_video = dependency('gstreamer-video-1.0', disabler: true, required: get_option('plugin-rtp')) dep_gtk4 = dependency('gtk4') dep_icu_uc = dependency('icu-uc') -dep_libadwaita = dependency('libadwaita-1', version: '>=1.2') +dep_libadwaita = dependency('libadwaita-1', version: '>=1.4') dep_libcanberra = dependency('libcanberra', disabler: true, required: get_option('plugin-notification-sound')) dep_libgcrypt = dependency('libgcrypt', disabler: true, required: plugin_crypto) dep_libqrencode = dependency('libqrencode', disabler: true, required: get_option('plugin-omemo')) diff --git a/plugins/omemo/data/encryption_preferences_entry.ui b/plugins/omemo/data/encryption_preferences_entry.ui index 6987c202..1aa1a541 100644 --- a/plugins/omemo/data/encryption_preferences_entry.ui +++ b/plugins/omemo/data/encryption_preferences_entry.ui @@ -12,24 +12,10 @@ <child> <object class="AdwPreferencesGroup"> <child> - <object class="AdwActionRow" id="encrypt_by_default_row"> - <child type="suffix"> - <object class="GtkSwitch" id="encrypt_by_default_switch"> - <property name="valign">center</property> - </object> - </child> - </object> + <object class="AdwSwitchRow" id="encrypt_by_default_row" /> </child> <child> - <!-- TODO: make this a SwitchRow once we depend on Adwaita 1.4--> - <object class="AdwActionRow" id="automatically_accept_new_row"> - <property name="activatable-widget">automatically_accept_new_switch</property> - <child type="suffix"> - <object class="GtkSwitch" id="automatically_accept_new_switch"> - <property name="valign">center</property> - </object> - </child> - </object> + <object class="AdwSwitchRow" id="automatically_accept_new_row" /> </child> </object> </child> diff --git a/plugins/omemo/src/ui/encryption_preferences_entry.vala b/plugins/omemo/src/ui/encryption_preferences_entry.vala index 42b5d0aa..b620b320 100644 --- a/plugins/omemo/src/ui/encryption_preferences_entry.vala +++ b/plugins/omemo/src/ui/encryption_preferences_entry.vala @@ -36,10 +36,8 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { private Store store; private Set<uint32> displayed_ids = new HashSet<uint32>(); - [GtkChild] private unowned Adw.ActionRow automatically_accept_new_row; - [GtkChild] private Switch automatically_accept_new_switch; - [GtkChild] private unowned Adw.ActionRow encrypt_by_default_row; - [GtkChild] private Switch encrypt_by_default_switch; + [GtkChild] private unowned Adw.SwitchRow automatically_accept_new_row; + [GtkChild] private unowned Adw.SwitchRow encrypt_by_default_row; [GtkChild] private unowned Label new_keys_label; [GtkChild] private unowned Adw.PreferencesGroup keys_preferences_group; @@ -71,12 +69,12 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { return; } - automatically_accept_new_switch.set_active(plugin.db.trust.get_blind_trust(identity_id, jid.bare_jid.to_string(), true)); - automatically_accept_new_switch.state_set.connect(on_auto_accept_toggled); + automatically_accept_new_row.active = plugin.db.trust.get_blind_trust(identity_id, jid.bare_jid.to_string(), true); + automatically_accept_new_row.notify["active"].connect((obj, _) => { on_auto_accept_toggled(((Adw.SwitchRow) obj).active); }); encrypt_by_default_row.visible = account.bare_jid.equals_bare(jid); - encrypt_by_default_switch.set_active(plugin.app.settings.get_default_encryption(account) != Encryption.NONE); - encrypt_by_default_switch.state_set.connect(on_omemo_by_default_toggled); + encrypt_by_default_row.active = plugin.app.settings.get_default_encryption(account) != Encryption.NONE; + encrypt_by_default_row.notify["active"].connect((obj, _) => { on_omemo_by_default_toggled(((Adw.SwitchRow) obj).active); }); Dino.Application? app = Application.get_default() as Dino.Application; if (app != null) { @@ -269,7 +267,7 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { case TrustLevel.VERIFIED: plugin.trust_manager.set_device_trust(account, jid, device[plugin.db.identity_meta.device_id], TrustLevel.VERIFIED); plugin.trust_manager.set_blind_trust(account, jid, false); - automatically_accept_new_switch.set_active(false); + automatically_accept_new_row.active = false; break; } } diff --git a/plugins/openpgp/src/contact_details_provider.vala b/plugins/openpgp/src/contact_details_provider.vala index 3b727121..353c0b85 100644 --- a/plugins/openpgp/src/contact_details_provider.vala +++ b/plugins/openpgp/src/contact_details_provider.vala @@ -39,9 +39,7 @@ public class ContactDetailsProvider : Plugins.ContactDetailsProvider, Object { var view = new Adw.ActionRow() { title = _("Fingerprint"), subtitle = str, -#if Adw_1_3 - subtitle_selectable = true, -#endif + subtitle_selectable = true }; preferences_group.add(view); diff --git a/plugins/openpgp/src/encryption_preferences_entry.vala b/plugins/openpgp/src/encryption_preferences_entry.vala index 26b982b8..28b253fc 100644 --- a/plugins/openpgp/src/encryption_preferences_entry.vala +++ b/plugins/openpgp/src/encryption_preferences_entry.vala @@ -38,17 +38,9 @@ namespace Dino.Plugins.OpenPgp { } StringList string_list = new StringList(null); -#if Adw_1_4 var drop_down = new Adw.ComboRow() { title = _("Announce key") }; drop_down.model = string_list; preferences_group.add(drop_down); -#else - var view = new Adw.ActionRow() { title = "Announce key" }; - var drop_down = new DropDown(string_list, null) { valign = Align.CENTER }; - view.activatable_widget = drop_down; - view.add_suffix(drop_down); - preferences_group.add(view); -#endif string_list.append(_("Disabled")); for (int i = 0; i < keys.size; i++) { |
