aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2023-10-30 21:48:08 +0100
committerMiquel Lionel <lionel@les-miquelots.net>2023-10-30 21:48:08 +0100
commitd761e8ccd5293d2f30a889b0cbe302c985aee68c (patch)
tree922bb248a7fee4cdff3da114abc7d77200f3d0da /main/src/ui
parent302e954c99c71d670201828c6746dfaa40276d6d (diff)
parent3de716446819550514d50a8112f5b6dd0c662702 (diff)
downloaddino-add_conversation_account_indicator.tar.gz
dino-add_conversation_account_indicator.zip
Show which account is currently used in conversation details in the about sectionadd_conversation_account_indicator
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/call_window/call_window.vala3
-rw-r--r--main/src/ui/chat_input/chat_input_controller.vala5
-rw-r--r--main/src/ui/contact_details/blocking_provider.vala36
-rw-r--r--main/src/ui/contact_details/dialog.vala159
-rw-r--r--main/src/ui/contact_details/muc_config_form_provider.vala93
-rw-r--r--main/src/ui/contact_details/permissions_provider.vala2
-rw-r--r--main/src/ui/contact_details/settings_provider.vala67
-rw-r--r--main/src/ui/conversation_content_view/conversation_view.vala2
-rw-r--r--main/src/ui/conversation_content_view/file_image_widget.vala1
-rw-r--r--main/src/ui/conversation_details.vala196
-rw-r--r--main/src/ui/conversation_selector/conversation_selector.vala1
-rw-r--r--main/src/ui/conversation_titlebar/menu_entry.vala5
-rw-r--r--main/src/ui/notifier_gnotifications.vala2
-rw-r--r--main/src/ui/occupant_menu/list.vala1
-rw-r--r--main/src/ui/util/data_forms.vala93
-rw-r--r--main/src/ui/util/helper.vala6
-rw-r--r--main/src/ui/util/label_hybrid.vala4
-rw-r--r--main/src/ui/widgets/avatar_picture.vala4
-rw-r--r--main/src/ui/widgets/fixed_ratio_picture.vala4
19 files changed, 311 insertions, 373 deletions
diff --git a/main/src/ui/call_window/call_window.vala b/main/src/ui/call_window/call_window.vala
index 14b67449..08ea4b21 100644
--- a/main/src/ui/call_window/call_window.vala
+++ b/main/src/ui/call_window/call_window.vala
@@ -253,11 +253,12 @@ namespace Dino.Ui {
}
private bool on_get_child_position(Widget widget, out Gdk.Rectangle allocation) {
+ allocation = Gdk.Rectangle();
+
if (widget == own_video_box) {
int width = get_size(Orientation.HORIZONTAL);
int height = get_size(Orientation.VERTICAL);
- allocation = Gdk.Rectangle();
allocation.width = own_video_width;
allocation.height = own_video_height;
allocation.x = width - own_video_width - 20;
diff --git a/main/src/ui/chat_input/chat_input_controller.vala b/main/src/ui/chat_input/chat_input_controller.vala
index d9608a85..d1c42d35 100644
--- a/main/src/ui/chat_input/chat_input_controller.vala
+++ b/main/src/ui/chat_input/chat_input_controller.vala
@@ -54,9 +54,8 @@ public class ChatInputController : Object {
status_description_label.activate_link.connect((uri) => {
if (uri == OPEN_CONVERSATION_DETAILS_URI){
- ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
- contact_details_dialog.set_transient_for((Gtk.Window) chat_input.get_root());
- contact_details_dialog.present();
+ var conversation_details = ConversationDetails.setup_dialog(conversation, stream_interactor, (Window)chat_input.get_root());
+ conversation_details.present();
}
return true;
});
diff --git a/main/src/ui/contact_details/blocking_provider.vala b/main/src/ui/contact_details/blocking_provider.vala
deleted file mode 100644
index 7e4a475d..00000000
--- a/main/src/ui/contact_details/blocking_provider.vala
+++ /dev/null
@@ -1,36 +0,0 @@
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui.ContactDetails {
-
-public class BlockingProvider : Plugins.ContactDetailsProvider, Object {
- public string id { get { return "blocking"; } }
-
- private StreamInteractor stream_interactor;
-
- public BlockingProvider(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
- }
-
- public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
- if (type != Plugins.WidgetType.GTK4) return;
- if (conversation.type_ != Conversation.Type.CHAT) return;
-
- if (stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(conversation.account)) {
- bool is_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(conversation.account, conversation.counterpart);
- Switch sw = new Switch() { active=is_blocked, valign=Align.CENTER };
- sw.state_set.connect((state) => {
- if (state) {
- stream_interactor.get_module(BlockingManager.IDENTITY).block(conversation.account, conversation.counterpart);
- } else {
- stream_interactor.get_module(BlockingManager.IDENTITY).unblock(conversation.account, conversation.counterpart);
- }
- return false;
- });
- contact_details.add(_("Settings"), _("Block"), _("Communication and status updates in either direction are blocked"), sw);
- }
- }
-}
-
-}
diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala
deleted file mode 100644
index c897fe4e..00000000
--- a/main/src/ui/contact_details/dialog.vala
+++ /dev/null
@@ -1,159 +0,0 @@
-using Gee;
-using Gtk;
-using Markup;
-using Pango;
-
-using Dino.Entities;
-
-namespace Dino.Ui.ContactDetails {
-
-[GtkTemplate (ui = "/im/dino/Dino/contact_details_dialog.ui")]
-public class Dialog : Gtk.Dialog {
-
- [GtkChild] public unowned AvatarPicture avatar;
- [GtkChild] public unowned Util.EntryLabelHybrid name_hybrid;
- [GtkChild] public unowned Label name_label;
- [GtkChild] public unowned Label jid_label;
- [GtkChild] public unowned Label account_label;
- [GtkChild] public unowned Box main_box;
-
- private StreamInteractor stream_interactor;
- private Conversation conversation;
-
- private Plugins.ContactDetails contact_details = new Plugins.ContactDetails();
- private HashMap<string, ListBox> categories = new HashMap<string, ListBox>();
- private Util.LabelHybridGroup hybrid_group = new Util.LabelHybridGroup();
-
- construct {
- name_hybrid.label.attributes = new AttrList();
- name_hybrid.label.attributes.insert(attr_weight_new(Weight.BOLD));
- }
-
- public Dialog(StreamInteractor stream_interactor, Conversation conversation) {
- Object(use_header_bar : Util.use_csd() ? 1 : 0);
- this.stream_interactor = stream_interactor;
- this.conversation = conversation;
-
- title = conversation.type_ == Conversation.Type.GROUPCHAT ? _("Conference Details") : _("Contact Details");
- if (Util.use_csd()) {
- // TODO get_header_bar directly returns a HeaderBar in vala > 0.48
- Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER };
- var title_label = new Label(title);
- title_label.attributes = new AttrList();
- title_label.attributes.insert(Pango.attr_weight_new(Weight.BOLD));
- titles_box.append(title_label);
- var subtitle_label = new Label(Util.get_conversation_display_name(stream_interactor, conversation));
- subtitle_label.attributes = new AttrList();
- subtitle_label.attributes.insert(Pango.attr_scale_new(Pango.Scale.SMALL));
- subtitle_label.add_css_class("dim-label");
- titles_box.append(subtitle_label);
-
- get_header_bar().set_title_widget(titles_box);
- }
- setup_top();
-
- contact_details.add.connect(add_entry);
-
- Application app = GLib.Application.get_default() as Application;
- app.plugin_registry.register_contact_details_entry(new SettingsProvider(stream_interactor));
- app.plugin_registry.register_contact_details_entry(new BlockingProvider(stream_interactor));
- app.plugin_registry.register_contact_details_entry(new MucConfigFormProvider(stream_interactor));
- app.plugin_registry.register_contact_details_entry(new PermissionsProvider(stream_interactor));
-
- foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) {
- provider.populate(conversation, contact_details, Plugins.WidgetType.GTK4);
- }
-
- close_request.connect(() => {
- contact_details.save();
- return false;
- });
- }
-
- private void setup_top() {
- if (conversation.type_ == Conversation.Type.CHAT) {
- name_label.visible = false;
- jid_label.margin_start = new Button().get_style_context().get_padding().left + 1;
- name_hybrid.text = Util.get_conversation_display_name(stream_interactor, conversation);
- close_request.connect(() => {
- if (name_hybrid.text != Util.get_conversation_display_name(stream_interactor, conversation)) {
- stream_interactor.get_module(RosterManager.IDENTITY).set_jid_handle(conversation.account, conversation.counterpart, name_hybrid.text);
- }
- return false;
- });
- } else {
- name_hybrid.visible = false;
- name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
- }
- jid_label.label = conversation.counterpart.to_string();
- account_label.label = "via " + conversation.account.bare_jid.to_string();
- avatar.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conversation);
- }
-
- private void add_entry(string category, string label, string? description, Object wo) {
- if (!(wo is Widget)) return;
- Widget w = (Widget) wo;
- add_category(category);
-
- ListBoxRow list_row = new ListBoxRow() { activatable=false };
- Box row = new Box(Orientation.HORIZONTAL, 20) { margin_start=15, margin_end=15, margin_top=3, margin_bottom=3 };
- list_row.set_child(row);
- Label label_label = new Label(label) { xalign=0, yalign=0.5f, hexpand=true };
- if (description != null && description != "") {
- Box box = new Box(Orientation.VERTICAL, 0);
- box.append(label_label);
- Label desc_label = new Label("") { xalign=0, yalign=0.5f, hexpand=true };
- desc_label.set_markup("<span size='small'>%s</span>".printf(Markup.escape_text(description)));
- desc_label.add_css_class("dim-label");
- box.append(desc_label);
- row.append(box);
- } else {
- row.append(label_label);
- }
-
- Widget widget = w;
- if (widget.get_type().is_a(typeof(Entry))) {
- Util.EntryLabelHybrid hybrid = new Util.EntryLabelHybrid.wrap(widget as Entry) { xalign=1 };
- hybrid_group.add(hybrid);
- widget = hybrid;
- } else if (widget.get_type().is_a(typeof(ComboBoxText))) {
- Util.ComboBoxTextLabelHybrid hybrid = new Util.ComboBoxTextLabelHybrid.wrap(widget as ComboBoxText) { xalign=1 };
- hybrid_group.add(hybrid);
- widget = hybrid;
- }
- widget.margin_bottom = 5;
- widget.margin_top = 5;
-
-
- row.append(widget);
- categories[category].append(list_row);
-
- int width = get_content_area().get_width();
- int pref_height, pref_width;
- get_content_area().measure(Orientation.VERTICAL, width, null, out pref_height, null, null);
- default_height = pref_height + 48;
- }
-
- private void add_category(string category) {
- if (!categories.has_key(category)) {
- ListBox list_box = new ListBox() { selection_mode=SelectionMode.NONE };
- categories[category] = list_box;
- list_box.set_header_func((row, before_row) => {
- if (row.get_header() == null && before_row != null) {
- row.set_header(new Separator(Orientation.HORIZONTAL));
- }
- });
- Box box = new Box(Orientation.VERTICAL, 5) { margin_top=12, margin_bottom=12 };
- Label category_label = new Label("") { xalign=0 };
- category_label.set_markup(@"<b>$(Markup.escape_text(category))</b>");
- box.append(category_label);
- Frame frame = new Frame(null);
- frame.set_child(list_box);
- box.append(frame);
- main_box.append(box);
- }
- }
-}
-
-}
-
diff --git a/main/src/ui/contact_details/muc_config_form_provider.vala b/main/src/ui/contact_details/muc_config_form_provider.vala
deleted file mode 100644
index 1244a759..00000000
--- a/main/src/ui/contact_details/muc_config_form_provider.vala
+++ /dev/null
@@ -1,93 +0,0 @@
-using Gee;
-using Gtk;
-
-using Dino.Entities;
-using Xmpp.Xep;
-
-namespace Dino.Ui.ContactDetails {
-
-public class MucConfigFormProvider : Plugins.ContactDetailsProvider, Object {
- public string id { get { return "muc_config_form"; } }
- private StreamInteractor stream_interactor;
-
- public MucConfigFormProvider(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
- }
-
- public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
- if (type != Plugins.WidgetType.GTK4) return;
- if (conversation.type_ == Conversation.Type.GROUPCHAT) {
- Xmpp.XmppStream? stream = stream_interactor.get_stream(conversation.account);
- if (stream == null) return;
-
- stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
- DataForms.DataForm? data_form = stream_interactor.get_module(MucManager.IDENTITY).get_config_form.end(res);
- if (data_form == null) return;
-
- for (int i = 0; i < data_form.fields.size; i++) {
- DataForms.DataForm.Field field = data_form.fields[i];
- add_field(field, contact_details);
- }
-
- string config_backup = data_form.stanza_node.to_string();
- contact_details.save.connect(() => {
- // Only send the config form if something was changed
- if (config_backup != data_form.stanza_node.to_string()) {
- stream_interactor.get_module(MucManager.IDENTITY).set_config_form.begin(conversation.account, conversation.counterpart, data_form);
- }
- });
- });
- }
- }
-
- public static void add_field(DataForms.DataForm.Field field, Plugins.ContactDetails contact_details) {
- string label = field.label ?? "";
- string? desc = null;
-
- if (field.var != null) {
- switch (field.var) {
- case "muc#roomconfig_roomname":
- label = _("Name of the room");
- break;
- case "muc#roomconfig_roomdesc":
- label = _("Description of the room");
- break;
- case "muc#roomconfig_persistentroom":
- label = _("Persistent");
- desc = _("The room will persist after the last occupant leaves");
- break;
- case "muc#roomconfig_publicroom":
- label = _("Publicly searchable");
- break;
- case "muc#roomconfig_changesubject":
- label = _("Occupants may change the subject");
- break;
- case "muc#roomconfig_whois":
- label = _("Permission to view JIDs");
- desc = _("Who is allowed to view the occupants' JIDs?");
- break;
- case "muc#roomconfig_roomsecret":
- label = _("Password");
- desc = _("A password to restrict access to the room");
- break;
- case "muc#roomconfig_moderatedroom":
- label = _("Moderated");
- desc = _("Only occupants with voice may send messages");
- break;
- case "muc#roomconfig_membersonly":
- label = _("Members only");
- desc = _("Only members may enter the room");
- break;
- case "muc#roomconfig_historylength":
- label = _("Message history");
- desc = _("Maximum amount of backlog issued by the room");
- break;
- }
- }
-
- Widget? widget = Util.get_data_form_field_widget(field);
- if (widget != null) contact_details.add(_("Room Configuration"), label, desc, widget);
- }
-}
-
-}
diff --git a/main/src/ui/contact_details/permissions_provider.vala b/main/src/ui/contact_details/permissions_provider.vala
index ed0756e8..c7ea4a1c 100644
--- a/main/src/ui/contact_details/permissions_provider.vala
+++ b/main/src/ui/contact_details/permissions_provider.vala
@@ -22,7 +22,7 @@ public class PermissionsProvider : Plugins.ContactDetailsProvider, Object {
if (stream_interactor.get_module(MucManager.IDENTITY).get_role(own_jid, conversation.account) == Xmpp.Xep.Muc.Role.VISITOR){
Button voice_request = new Button.with_label(_("Request"));
voice_request.clicked.connect(()=>stream_interactor.get_module(MucManager.IDENTITY).request_voice(conversation.account, conversation.counterpart));
- contact_details.add(_("Permissions"), _("Request permission to send messages"), "", voice_request);
+ contact_details.add("Permissions", _("Request permission to send messages"), "", voice_request);
}
}
}
diff --git a/main/src/ui/contact_details/settings_provider.vala b/main/src/ui/contact_details/settings_provider.vala
index 8121e5b1..6a680f64 100644
--- a/main/src/ui/contact_details/settings_provider.vala
+++ b/main/src/ui/contact_details/settings_provider.vala
@@ -9,8 +9,8 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
private StreamInteractor stream_interactor;
- private string DETAILS_HEADLINE_CHAT = _("Settings");
- private string DETAILS_HEADLINE_ROOM = _("Local Settings");
+ private string DETAILS_HEADLINE_CHAT = "Settings";
+ private string DETAILS_HEADLINE_ROOM = "Local Settings";
public SettingsProvider(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
@@ -33,28 +33,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
contact_details.add(DETAILS_HEADLINE_CHAT, _("Send read receipts"), "", combobox_marker);
combobox_marker.active_id = get_setting_id(conversation.send_marker);
combobox_marker.changed.connect(() => { conversation.send_marker = get_setting(combobox_marker.active_id); } );
-
- ComboBoxText combobox_notifications = get_combobox(Dino.Application.get_default().settings.notifications);
- contact_details.add(DETAILS_HEADLINE_CHAT, _("Notifications"), "", combobox_notifications);
- combobox_notifications.active_id = get_notify_setting_id(conversation.notify_setting);
- combobox_notifications.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox_notifications.active_id); } );
- } else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
- ComboBoxText combobox = new ComboBoxText();
- combobox.append("default", get_notify_setting_string(Conversation.NotifySetting.DEFAULT, conversation.get_notification_default_setting(stream_interactor)));
- combobox.append("highlight", get_notify_setting_string(Conversation.NotifySetting.HIGHLIGHT));
- combobox.append("on", get_notify_setting_string(Conversation.NotifySetting.ON));
- combobox.append("off", get_notify_setting_string(Conversation.NotifySetting.OFF));
- contact_details.add(DETAILS_HEADLINE_ROOM, _("Notifications"), "", combobox);
-
- combobox.active_id = get_notify_setting_id(conversation.notify_setting);
- combobox.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox.active_id); } );
}
-
- Switch pinned_switch = new Switch() { valign=Align.CENTER };
- string category = conversation.type_ == Conversation.Type.GROUPCHAT ? DETAILS_HEADLINE_ROOM : DETAILS_HEADLINE_CHAT;
- contact_details.add(category, _("Pin conversation"), _("Pins the conversation to the top of the conversation list"), pinned_switch);
- pinned_switch.state = conversation.pinned != 0;
- pinned_switch.state_set.connect((state) => { conversation.pinned = state ? 1 : 0; return false; });
}
private Conversation.Setting get_setting(string id) {
@@ -69,34 +48,6 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
assert_not_reached();
}
- private Conversation.NotifySetting get_notify_setting(string id) {
- switch (id) {
- case "default":
- return Conversation.NotifySetting.DEFAULT;
- case "on":
- return Conversation.NotifySetting.ON;
- case "off":
- return Conversation.NotifySetting.OFF;
- case "highlight":
- return Conversation.NotifySetting.HIGHLIGHT;
- }
- assert_not_reached();
- }
-
- private string get_notify_setting_string(Conversation.NotifySetting setting, Conversation.NotifySetting? default_setting = null) {
- switch (setting) {
- case Conversation.NotifySetting.ON:
- return _("On");
- case Conversation.NotifySetting.OFF:
- return _("Off");
- case Conversation.NotifySetting.HIGHLIGHT:
- return _("Only when mentioned");
- case Conversation.NotifySetting.DEFAULT:
- return _("Default: %s").printf(get_notify_setting_string(default_setting));
- }
- assert_not_reached();
- }
-
private string get_setting_id(Conversation.Setting setting) {
switch (setting) {
case Conversation.Setting.DEFAULT:
@@ -109,20 +60,6 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
assert_not_reached();
}
- private string get_notify_setting_id(Conversation.NotifySetting setting) {
- switch (setting) {
- case Conversation.NotifySetting.DEFAULT:
- return "default";
- case Conversation.NotifySetting.ON:
- return "on";
- case Conversation.NotifySetting.OFF:
- return "off";
- case Conversation.NotifySetting.HIGHLIGHT:
- return "highlight";
- }
- assert_not_reached();
- }
-
private ComboBoxText get_combobox(bool default_val) {
ComboBoxText combobox = new ComboBoxText();
combobox = new ComboBoxText();
diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala
index 4006a02f..33cb3b22 100644
--- a/main/src/ui/conversation_content_view/conversation_view.vala
+++ b/main/src/ui/conversation_content_view/conversation_view.vala
@@ -329,7 +329,7 @@ public class ConversationView : Widget, Plugins.ConversationItemCollection, Plug
do_insert_item(item);
}
ContentMetaItem meta_item = content_populator.get_content_meta_item(content_item);
- Widget w = insert_new(meta_item);
+ insert_new(meta_item);
content_items.add(meta_item);
meta_items.add(meta_item);
diff --git a/main/src/ui/conversation_content_view/file_image_widget.vala b/main/src/ui/conversation_content_view/file_image_widget.vala
index 43c3b74d..a3579185 100644
--- a/main/src/ui/conversation_content_view/file_image_widget.vala
+++ b/main/src/ui/conversation_content_view/file_image_widget.vala
@@ -45,7 +45,6 @@ public class FileImageWidget : Box {
image.add_controller(gesture_click_controller);
FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
- string? mime_type = file_info.get_content_type();
MenuButton button = new MenuButton();
button.icon_name = "view-more";
diff --git a/main/src/ui/conversation_details.vala b/main/src/ui/conversation_details.vala
new file mode 100644
index 00000000..8a09193e
--- /dev/null
+++ b/main/src/ui/conversation_details.vala
@@ -0,0 +1,196 @@
+using Dino.Entities;
+using Xmpp;
+using Xmpp.Xep;
+using Gee;
+using Gtk;
+
+namespace Dino.Ui.ConversationDetails {
+
+ public void populate_dialog(Model.ConversationDetails model, Conversation conversation, StreamInteractor stream_interactor) {
+ model.conversation = conversation;
+ model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation);
+ model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart);
+
+ if (conversation.type_ == Conversation.Type.GROUPCHAT) {
+ stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
+ model.data_form = stream_interactor.get_module(MucManager.IDENTITY).get_config_form.end(res);
+ model.data_form_bak = model.data_form.stanza_node.to_string();
+ });
+ }
+ }
+
+ public void bind_dialog(Model.ConversationDetails model, ViewModel.ConversationDetails view_model, StreamInteractor stream_interactor) {
+ view_model.avatar = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(model.conversation);
+ view_model.show_blocked = model.conversation.type_ == Conversation.Type.CHAT && stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(model.conversation.account);
+
+ model.display_name.bind_property("display-name", view_model, "name", BindingFlags.SYNC_CREATE);
+ model.conversation.bind_property("notify-setting", view_model, "notification", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
+ switch (model.conversation.get_notification_setting(stream_interactor)) {
+ case ON:
+ to = ViewModel.ConversationDetails.NotificationSetting.ON;
+ break;
+ case OFF:
+ to = ViewModel.ConversationDetails.NotificationSetting.OFF;
+ break;
+ case HIGHLIGHT:
+ to = ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT;
+ break;
+ case DEFAULT:
+ // A "default" setting should have been resolved to the actual default value
+ assert_not_reached();
+ }
+ return true;
+ });
+ model.conversation.bind_property("notify-setting", view_model, "notification-is-default", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
+ var notify_setting = (Conversation.NotifySetting) from;
+ to = notify_setting == Conversation.NotifySetting.DEFAULT;
+ return true;
+ });
+ model.conversation.bind_property("pinned", view_model, "pinned", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
+ var from_int = (int) from;
+ to = from_int > 0;
+ return true;
+ });
+ model.conversation.bind_property("type-", view_model, "notification-options", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
+ var ty = (Conversation.Type) from;
+ to = ty == Conversation.Type.GROUPCHAT ? ViewModel.ConversationDetails.NotificationOptions.ON_HIGHLIGHT_OFF : ViewModel.ConversationDetails.NotificationOptions.ON_OFF;
+ return true;
+ });
+ model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE);
+ model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
+ var data_form = (DataForms.DataForm) from;
+ if (data_form == null) return true;
+ var list_store = new GLib.ListStore(typeof(ViewModel.PreferencesRow.Any));
+
+ foreach (var field in data_form.fields) {
+ var field_view_model = Util.get_data_form_field_view_model(field);
+ if (field_view_model != null) {
+ list_store.append(field_view_model);
+ }
+ }
+
+ to = list_store;
+ return true;
+ });
+
+ view_model.pin_changed.connect(() => {
+ model.conversation.pinned = model.conversation.pinned == 1 ? 0 : 1;
+ });
+ view_model.block_changed.connect(() => {
+ if (view_model.blocked) {
+ stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
+ } else {
+ stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
+ }
+ view_model.blocked = !view_model.blocked;
+ });
+ view_model.notification_changed.connect((setting) => {
+ switch (setting) {
+ case ON:
+ model.conversation.notify_setting = ON;
+ break;
+ case OFF:
+ model.conversation.notify_setting = OFF;
+ break;
+ case HIGHLIGHT:
+ model.conversation.notify_setting = HIGHLIGHT;
+ break;
+ case DEFAULT:
+ model.conversation.notify_setting = DEFAULT;
+ break;
+ }
+ });
+
+ view_model.notification_flipped.connect(() => {
+ model.conversation.notify_setting = view_model.notification == ON ? Conversation.NotifySetting.OFF : Conversation.NotifySetting.ON;
+ });
+ }
+
+ public Window setup_dialog(Conversation conversation, StreamInteractor stream_interactor, Window parent) {
+ var dialog = new Dialog() { transient_for = parent };
+ var model = new Model.ConversationDetails();
+ populate_dialog(model, conversation, stream_interactor);
+ bind_dialog(model, dialog.model, stream_interactor);
+
+ dialog.model.about_rows.append(new ViewModel.PreferencesRow.Text() {
+ title = _("Account used for this conversation"),
+ text = conversation.account.bare_jid.to_string()
+ });
+
+ dialog.model.about_rows.append(new ViewModel.PreferencesRow.Text() {
+ title = _("XMPP Address"),
+ text = conversation.counterpart.to_string()
+ });
+ if (model.conversation.type_ == Conversation.Type.CHAT) {
+ var about_row = new ViewModel.PreferencesRow.Entry() {
+ title = _("Display name"),
+ text = dialog.model.name
+ };
+ about_row.changed.connect(() => {
+ if (about_row.text != Util.get_conversation_display_name(stream_interactor, conversation)) {
+ stream_interactor.get_module(RosterManager.IDENTITY).set_jid_handle(conversation.account, conversation.counterpart, about_row.text);
+ }
+ });
+ dialog.model.about_rows.append(about_row);
+ }
+ if (model.conversation.type_ == Conversation.Type.GROUPCHAT) {
+ var topic = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
+ if (topic != null && topic != "") {
+ dialog.model.about_rows.append(new ViewModel.PreferencesRow.Text() {
+ title = _("Topic"),
+ text = Util.parse_add_markup(topic, null, true, true)
+ });
+ }
+ }
+ dialog.close_request.connect(() => {
+ // Only send the config form if something was changed
+ if (model.data_form_bak != null && model.data_form_bak != model.data_form.stanza_node.to_string()) {
+ stream_interactor.get_module(MucManager.IDENTITY).set_config_form.begin(conversation.account, conversation.counterpart, model.data_form);
+ }
+ return false;
+ });
+
+ Plugins.ContactDetails contact_details = new Plugins.ContactDetails();
+ contact_details.add.connect((c, l, d, wo) => {
+ add_entry(c, l, d, wo, dialog);
+ });
+ Application app = GLib.Application.get_default() as Application;
+ app.plugin_registry.register_contact_details_entry(new ContactDetails.SettingsProvider(stream_interactor));
+ app.plugin_registry.register_contact_details_entry(new ContactDetails.PermissionsProvider(stream_interactor));
+
+ foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) {
+ provider.populate(conversation, contact_details, Plugins.WidgetType.GTK4);
+ }
+
+ return dialog;
+ }
+
+ private void add_entry(string category, string label, string? description, Object wo, Dialog dialog) {
+ if (!(wo is Widget)) return;
+
+ Widget widget = (Widget) wo;
+ if (widget.get_type().is_a(typeof(Entry))) {
+ Util.EntryLabelHybrid hybrid = new Util.EntryLabelHybrid.wrap(widget as Entry) { xalign=1 };
+ widget = hybrid;
+ } else if (widget.get_type().is_a(typeof(ComboBoxText))) {
+ Util.ComboBoxTextLabelHybrid hybrid = new Util.ComboBoxTextLabelHybrid.wrap(widget as ComboBoxText) { xalign=1 };
+ widget = hybrid;
+ }
+
+ var view_model = new ViewModel.PreferencesRow.WidgetDeprecated() {
+ title = label,
+ widget = widget
+ };
+
+ switch (category) {
+ case "Encryption":
+ dialog.model.encryption_rows.append(view_model);
+ break;
+ case "Permissions":
+ case "Local Settings":
+ case "Settings":
+ dialog.model.settings_rows.append(view_model);
+ break;
+ }
+ }
+}
diff --git a/main/src/ui/conversation_selector/conversation_selector.vala b/main/src/ui/conversation_selector/conversation_selector.vala
index 535a61b0..d16ef3ee 100644
--- a/main/src/ui/conversation_selector/conversation_selector.vala
+++ b/main/src/ui/conversation_selector/conversation_selector.vala
@@ -14,7 +14,6 @@ public class ConversationSelector : Widget {
ListBox list_box = new ListBox() { hexpand=true };
private StreamInteractor stream_interactor;
- private uint? drag_timeout;
private HashMap<Conversation, ConversationSelectorRow> rows = new HashMap<Conversation, ConversationSelectorRow>(Conversation.hash_func, Conversation.equals_func);
public ConversationSelector init(StreamInteractor stream_interactor) {
diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala
index d0b9fbcd..479a228c 100644
--- a/main/src/ui/conversation_titlebar/menu_entry.vala
+++ b/main/src/ui/conversation_titlebar/menu_entry.vala
@@ -34,9 +34,8 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
}
private void on_clicked() {
- ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
- contact_details_dialog.set_transient_for((Window) button.get_root());
- contact_details_dialog.present();
+ var conversation_details = ConversationDetails.setup_dialog(conversation, stream_interactor, (Window)button.get_root());
+ conversation_details.present();
}
public Object? get_widget(Plugins.WidgetType type) {
diff --git a/main/src/ui/notifier_gnotifications.vala b/main/src/ui/notifier_gnotifications.vala
index 90c8ca8c..4d36620d 100644
--- a/main/src/ui/notifier_gnotifications.vala
+++ b/main/src/ui/notifier_gnotifications.vala
@@ -109,6 +109,8 @@ namespace Dino.Ui {
case ConnectionManager.ConnectionError.Source.TLS:
notification.set_body("Invalid TLS certificate");
break;
+ default:
+ break;
}
GLib.Application.get_default().send_notification(account.id.to_string() + "-connection-error", notification);
}
diff --git a/main/src/ui/occupant_menu/list.vala b/main/src/ui/occupant_menu/list.vala
index b9a4a74f..ce5a1981 100644
--- a/main/src/ui/occupant_menu/list.vala
+++ b/main/src/ui/occupant_menu/list.vala
@@ -153,7 +153,6 @@ public class List : Box {
if (affiliation1 < affiliation2) return -1;
else if (affiliation1 > affiliation2) return 1;
else return row_wrapper1.name_label.label.collate(row_wrapper2.name_label.label);
- return 0;
}
private int get_affiliation_ranking(Xmpp.Xep.Muc.Affiliation affiliation) {
diff --git a/main/src/ui/util/data_forms.vala b/main/src/ui/util/data_forms.vala
index 1f598025..39dce3ee 100644
--- a/main/src/ui/util/data_forms.vala
+++ b/main/src/ui/util/data_forms.vala
@@ -6,6 +6,99 @@ using Xmpp.Xep;
namespace Dino.Ui.Util {
+public static ViewModel.PreferencesRow.Any? get_data_form_field_view_model(DataForms.DataForm.Field field) {
+ if (field.type_ == null) return null;
+
+ ViewModel.PreferencesRow.Any? view_model = null;
+
+ string? label = null;
+ string? desc = null;
+
+ if (field.var != null) {
+ switch (field.var) {
+ case "muc#roomconfig_roomname":
+ label = _("Name of the room");
+ break;
+ case "muc#roomconfig_roomdesc":
+ label = _("Description of the room");
+ break;
+ case "muc#roomconfig_persistentroom":
+ label = _("Persistent");
+ desc = _("The room will persist after the last occupant leaves");
+ break;
+ case "muc#roomconfig_publicroom":
+ label = _("Publicly searchable");
+ break;
+ case "muc#roomconfig_changesubject":
+ label = _("Occupants may change the subject");
+ break;
+ case "muc#roomconfig_whois":
+ label = _("Permission to view JIDs");
+ desc = _("Who is allowed to view the occupants' JIDs?");
+ break;
+ case "muc#roomconfig_roomsecret":
+ label = _("Password");
+// desc = _("A password to restrict access to the room");
+ break;
+ case "muc#roomconfig_moderatedroom":
+ label = _("Moderated");
+ desc = _("Only occupants with voice may send messages");
+ break;
+ case "muc#roomconfig_membersonly":
+ label = _("Members only");
+ desc = _("Only members may enter the room");
+ break;
+// case "muc#roomconfig_historylength":
+// label = _("Message history");
+// desc = _("Maximum amount of backlog issued by the room");
+// break;
+ }
+ }
+
+ if (label == null) label = field.label;
+
+ switch (field.type_) {
+ case DataForms.DataForm.Type.BOOLEAN:
+ DataForms.DataForm.BooleanField boolean_field = field as DataForms.DataForm.BooleanField;
+ var toggle_model = new ViewModel.PreferencesRow.Toggle() { subtitle = desc, state = boolean_field.value };
+ boolean_field.bind_property("value", toggle_model, "state", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ view_model = toggle_model;
+ break;
+ case DataForms.DataForm.Type.JID_MULTI:
+ return null;
+ case DataForms.DataForm.Type.LIST_SINGLE:
+ DataForms.DataForm.ListSingleField list_single_field = field as DataForms.DataForm.ListSingleField;
+ var combobox_model = new ViewModel.PreferencesRow.ComboBox();
+ for (int i = 0; i < list_single_field.options.size; i++) {
+ DataForms.DataForm.Option option = list_single_field.options[i];
+ combobox_model.items.add(option.label);
+ if (option.value == list_single_field.value) combobox_model.active_item = i;
+ }
+ combobox_model.bind_property("active-item", list_single_field, "value", BindingFlags.DEFAULT, (binding, from, ref to) => {
+ var active_item = (int) from;
+ to = list_single_field.options[active_item].value;
+ return true;
+ });
+ view_model = combobox_model;
+ break;
+ case DataForms.DataForm.Type.LIST_MULTI:
+ return null;
+ case DataForms.DataForm.Type.TEXT_PRIVATE:
+ return null;
+ case DataForms.DataForm.Type.TEXT_SINGLE:
+ DataForms.DataForm.TextSingleField text_single_field = field as DataForms.DataForm.TextSingleField;
+ var entry_model = new ViewModel.PreferencesRow.Entry() { text = text_single_field.value };
+ text_single_field.bind_property("value", entry_model, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ view_model = entry_model;
+ break;
+ default:
+ return null;
+ }
+
+ view_model.title = label;
+ return view_model;
+}
+
public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) {
if (field.type_ == null) return null;
switch (field.type_) {
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index d6da72dd..63288fc2 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -103,7 +103,13 @@ private const string force_color_css = "%s { color: %s; }";
public static Gtk.CssProvider force_css(Gtk.Widget widget, string css) {
var p = new Gtk.CssProvider();
try {
+#if GTK_4_12 && (VALA_0_56_GREATER_11 || VALA_0_58)
+ p.load_from_string(css);
+#elif (VALA_0_56_11 || VALA_0_56_12)
+ p.load_from_data(css, css.length);
+#else
p.load_from_data(css.data);
+#endif
widget.get_style_context().add_provider(p, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} catch (GLib.Error err) {
// handle err
diff --git a/main/src/ui/util/label_hybrid.vala b/main/src/ui/util/label_hybrid.vala
index f426de7e..0059d2ae 100644
--- a/main/src/ui/util/label_hybrid.vala
+++ b/main/src/ui/util/label_hybrid.vala
@@ -97,10 +97,6 @@ public class EntryLabelHybrid : LabelHybrid {
}
}
- private void on_focus_leave() {
- show_label();
- }
-
private void update_label() {
if (visibility) {
label.label = entry.text;
diff --git a/main/src/ui/widgets/avatar_picture.vala b/main/src/ui/widgets/avatar_picture.vala
index e632413c..fb254915 100644
--- a/main/src/ui/widgets/avatar_picture.vala
+++ b/main/src/ui/widgets/avatar_picture.vala
@@ -454,7 +454,7 @@ public class Dino.Ui.AvatarPicture : Gtk.Widget {
label.insert_after(this, null);
label.attributes = new Pango.AttrList();
label.attributes.insert(Pango.attr_foreground_new(uint16.MAX, uint16.MAX, uint16.MAX));
-#if GTK_4_8 && VALA_0_58
+#if GTK_4_8 && (VALA_0_56_GREATER_5 || VALA_0_58)
picture.content_fit = Gtk.ContentFit.COVER;
#elif GTK_4_8
picture.@set("content-fit", 2);
@@ -516,4 +516,4 @@ public class Dino.Ui.AvatarPicture : Gtk.Widget {
base.snapshot(snapshot);
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/ui/widgets/fixed_ratio_picture.vala b/main/src/ui/widgets/fixed_ratio_picture.vala
index 79c60141..3e83ec0c 100644
--- a/main/src/ui/widgets/fixed_ratio_picture.vala
+++ b/main/src/ui/widgets/fixed_ratio_picture.vala
@@ -8,7 +8,7 @@ class Dino.Ui.FixedRatioPicture : Gtk.Widget {
public int max_height { get; set; default = int.MAX; }
public File file { get { return inner.file; } set { inner.file = value; } }
public Gdk.Paintable paintable { get { return inner.paintable; } set { inner.paintable = value; } }
-#if GTK_4_8 && VALA_0_58
+#if GTK_4_8 && (VALA_0_56_GREATER_5 || VALA_0_58)
public Gtk.ContentFit content_fit { get { return inner.content_fit; } set { inner.content_fit = value; } }
#endif
private Gtk.Picture inner = new Gtk.Picture();
@@ -85,4 +85,4 @@ class Dino.Ui.FixedRatioPicture : Gtk.Widget {
inner.unparent();
base.dispose();
}
-} \ No newline at end of file
+}