aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosty <frostinator33@airmail.cc>2026-10-26 13:57:33 -0400
committerfrosty <frostinator33@airmail.cc>2026-10-26 13:57:33 -0400
commitc7426c9fb97f1afdf2b33a055d977762af92c795 (patch)
treeb753f9b7d91e498898094f9b1e1e07f1cfdb6476
parent74aecd8b0986d07b50b7ce310d64e645b8b54e38 (diff)
feat: multiline topic entry
-rw-r--r--main/src/ui/conversation_details.vala4
-rw-r--r--main/src/ui/util/preference_group.vala80
-rw-r--r--main/src/view_model/preferences_row.vala5
3 files changed, 87 insertions, 2 deletions
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala
index f9bae672..ea42e5d8 100644
--- a/main/src/ui/conversation_details.vala
+++ b/main/src/ui/conversation_details.vala
@@ -201,9 +201,9 @@ namespace Dino.Ui.ConversationDetails {
Xep.Muc.Role? own_role = stream_interactor.get_module(MucManager.IDENTITY).get_role(own_muc_jid, conversation.account);
if (own_role != null) {
if (own_role == MODERATOR) {
- var preferences_row_entry = new ViewModel.PreferencesRow.Entry() {
+ var preferences_row_entry = new ViewModel.PreferencesRow.MultilineEntry() {
title = _("Topic"),
- text = topic
+ text = topic ?? ""
};
preferences_row_entry.changed.connect(() => {
if (preferences_row_entry.text != topic) {
diff --git a/main/src/ui/util/preference_group.vala b/main/src/ui/util/preference_group.vala
index f34f0d92..4476bd20 100644
--- a/main/src/ui/util/preference_group.vala
+++ b/main/src/ui/util/preference_group.vala
@@ -6,6 +6,76 @@ using Dino.Entities;
using Xmpp.Xep;
namespace Dino.Ui.Util {
+ public class MultilineEntryRow : Adw.PreferencesRow {
+ public signal void apply();
+
+ public string text {
+ owned get { return text_view.buffer.text; }
+ set {
+ if (text_view.buffer.text == value) return;
+ updating_text = true;
+ text_view.buffer.text = value;
+ updating_text = false;
+ apply_button.visible = false;
+ }
+ }
+
+ public TextView text_view { get; private set; }
+ private Button apply_button;
+ private bool updating_text = false;
+
+ public MultilineEntryRow(string title) {
+ Object(title: title);
+
+ var title_label = new Label(title) { xalign = 0, hexpand = true };
+ apply_button = new Button.from_icon_name("object-select-symbolic") {
+ valign = Align.CENTER,
+ tooltip_text = _("Apply"),
+ visible = false
+ };
+ apply_button.add_css_class("flat");
+ apply_button.clicked.connect(() => {
+ apply_button.visible = false;
+ apply();
+ });
+
+ var header = new Box(Orientation.HORIZONTAL, 6);
+ header.append(title_label);
+ header.append(apply_button);
+
+ text_view = new TextView() {
+ wrap_mode = WrapMode.WORD_CHAR,
+ accepts_tab = false,
+ hexpand = true,
+ left_margin = 6,
+ right_margin = 6,
+ top_margin = 6,
+ bottom_margin = 6
+ };
+ text_view.buffer.changed.connect(() => {
+ if (updating_text) return;
+ apply_button.visible = true;
+ notify_property("text");
+ });
+
+ var text_frame = new Frame(null) {
+ child = text_view,
+ hexpand = true
+ };
+
+ var box = new Box(Orientation.VERTICAL, 6) {
+ hexpand = true,
+ margin_start = 12,
+ margin_end = 12,
+ margin_top = 6,
+ margin_bottom = 6
+ };
+ box.append(header);
+ box.append(text_frame);
+ child = box;
+ }
+ }
+
public Gee.List<Adw.PreferencesGroup> rows_to_preference_window_split_at_text(GLib.ListStore row_view_models) {
var preference_groups = new ArrayList<Adw.PreferencesGroup>();
Adw.PreferencesGroup? preference_group = null;
@@ -70,6 +140,16 @@ namespace Dino.Ui.Util {
});
}
+ var multiline_entry_view_model = preferences_row as ViewModel.PreferencesRow.MultilineEntry;
+ if (multiline_entry_view_model != null) {
+ var multiline_entry_row = new MultilineEntryRow(preferences_row.title);
+ multiline_entry_view_model.bind_property("text", multiline_entry_row, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL, null_string_to_empty);
+ multiline_entry_row.apply.connect(() => {
+ multiline_entry_view_model.changed();
+ });
+ view = multiline_entry_row;
+ }
+
var password_view_model = preferences_row as ViewModel.PreferencesRow.PrivateText;
if (password_view_model != null) {
view = new Adw.PasswordEntryRow() { show_apply_button=true };
diff --git a/main/src/view_model/preferences_row.vala b/main/src/view_model/preferences_row.vala
index d0f64979..e4cb9cf8 100644
--- a/main/src/view_model/preferences_row.vala
+++ b/main/src/view_model/preferences_row.vala
@@ -21,6 +21,11 @@ namespace Dino.Ui.ViewModel.PreferencesRow {
public string text { get; set; }
}
+ public class MultilineEntry : Any {
+ public signal void changed();
+ public string text { get; set; }
+ }
+
public class PrivateText : Any {
public signal void changed();
public string text { get; set; }