aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/contact_details
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-05-14 14:45:59 +0200
committerfiaxh <git@lightrise.org>2022-07-27 20:34:20 +0200
commitf44cbe02c17df1f02ad49c63cd784fec0ea02d85 (patch)
tree4cab9b5f84d88769d19b0698e24b318f50b6144e /main/src/ui/contact_details
parent2b3ce5fc95c63ed7d54e207db0585c8b8bbcd603 (diff)
downloaddino-f44cbe02c17df1f02ad49c63cd784fec0ea02d85.tar.gz
dino-f44cbe02c17df1f02ad49c63cd784fec0ea02d85.zip
Improve Gtk4 port
Diffstat (limited to 'main/src/ui/contact_details')
-rw-r--r--main/src/ui/contact_details/blocking_provider.vala2
-rw-r--r--main/src/ui/contact_details/dialog.vala50
-rw-r--r--main/src/ui/contact_details/permissions_provider.vala2
-rw-r--r--main/src/ui/contact_details/settings_provider.vala4
4 files changed, 35 insertions, 23 deletions
diff --git a/main/src/ui/contact_details/blocking_provider.vala b/main/src/ui/contact_details/blocking_provider.vala
index 76e5d000..7e4a475d 100644
--- a/main/src/ui/contact_details/blocking_provider.vala
+++ b/main/src/ui/contact_details/blocking_provider.vala
@@ -19,7 +19,7 @@ public class BlockingProvider : Plugins.ContactDetailsProvider, Object {
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, visible=true };
+ 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);
diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala
index b07ab9c9..36bef391 100644
--- a/main/src/ui/contact_details/dialog.vala
+++ b/main/src/ui/contact_details/dialog.vala
@@ -37,7 +37,18 @@ public class Dialog : Gtk.Dialog {
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
-// ((HeaderBar) get_header_bar()).set_subtitle(Util.get_conversation_display_name(stream_interactor, conversation));
+ 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();
@@ -53,9 +64,10 @@ public class Dialog : Gtk.Dialog {
provider.populate(conversation, contact_details, Plugins.WidgetType.GTK4);
}
-// destroy.connect(() => {
-// contact_details.save();
-// });
+ close_request.connect(() => {
+ contact_details.save();
+ return false;
+ });
}
private void setup_top() {
@@ -83,16 +95,16 @@ public class Dialog : Gtk.Dialog {
Widget w = (Widget) wo;
add_category(category);
- ListBoxRow list_row = new ListBoxRow() { activatable=false, visible=true };
- Box row = new Box(Orientation.HORIZONTAL, 20) { margin_start=15, margin_end=15, margin_top=3, margin_bottom=3, visible=true };
+ 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, visible=true };
+ Label label_label = new Label(label) { xalign=0, yalign=0.5f, hexpand=true };
if (description != null && description != "") {
- Box box = new Box(Orientation.VERTICAL, 0) { visible=true };
+ Box box = new Box(Orientation.VERTICAL, 0);
box.append(label_label);
- Label desc_label = new Label("") { xalign=0, yalign=0.5f, hexpand=true, visible=true };
+ 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.get_style_context().add_class("dim-label");
+ desc_label.add_css_class("dim-label");
box.append(desc_label);
row.append(box);
} else {
@@ -101,11 +113,11 @@ public class Dialog : Gtk.Dialog {
Widget widget = w;
if (widget.get_type().is_a(typeof(Entry))) {
- Util.EntryLabelHybrid hybrid = new Util.EntryLabelHybrid.wrap(widget as Entry) { xalign=1, visible=true };
+ 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, visible=true };
+ Util.ComboBoxTextLabelHybrid hybrid = new Util.ComboBoxTextLabelHybrid.wrap(widget as ComboBoxText) { xalign=1 };
hybrid_group.add(hybrid);
widget = hybrid;
}
@@ -116,26 +128,26 @@ public class Dialog : Gtk.Dialog {
row.append(widget);
categories[category].append(list_row);
+ int width = get_content_area().get_width();
int pref_height, pref_width;
-// get_content_area().get_preferred_height(null, out pref_height);
-// get_preferred_width(out pref_width, null);
-// resize(pref_width, int.min(500, pref_height));
+ get_content_area().measure(Orientation.VERTICAL, width, null, out pref_height, null, null);
+ default_height = pref_height;
}
private void add_category(string category) {
if (!categories.has_key(category)) {
- ListBox list_box = new ListBox() { selection_mode=SelectionMode.NONE, visible=true };
+ 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, visible=true };
- Label category_label = new Label("") { xalign=0, visible=true };
+ 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) { visible=true };
+ 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/permissions_provider.vala b/main/src/ui/contact_details/permissions_provider.vala
index d87658ff..ed0756e8 100644
--- a/main/src/ui/contact_details/permissions_provider.vala
+++ b/main/src/ui/contact_details/permissions_provider.vala
@@ -20,7 +20,7 @@ public class PermissionsProvider : Plugins.ContactDetailsProvider, Object {
if (own_jid == null) return;
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")) { visible=true };
+ 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);
}
diff --git a/main/src/ui/contact_details/settings_provider.vala b/main/src/ui/contact_details/settings_provider.vala
index 42c690e5..140ebcab 100644
--- a/main/src/ui/contact_details/settings_provider.vala
+++ b/main/src/ui/contact_details/settings_provider.vala
@@ -39,7 +39,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
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() { visible=true };
+ 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));
@@ -119,7 +119,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
private ComboBoxText get_combobox(bool default_val) {
ComboBoxText combobox = new ComboBoxText();
- combobox = new ComboBoxText() { visible=true };
+ combobox = new ComboBoxText();
string default_setting = default_val ? _("On") : _("Off");
combobox.append("default", _("Default: %s").printf(default_setting) );
combobox.append("on", _("On"));