Change contact details dialog container to HdyClamp and enable label wrap (#948)

This commit is contained in:
Michel Le Bihan 2021-01-15 16:58:59 +01:00 committed by fiaxh
parent bf5f83c073
commit ceaccdeefb
2 changed files with 96 additions and 91 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<template class="DinoUiContactDetailsDialog"> <template class="DinoUiContactDetailsDialog">
<property name="default_width">800</property>
<property name="modal">True</property> <property name="modal">True</property>
<child type="titlebar"> <child type="titlebar">
<object class="GtkHeaderBar"> <object class="GtkHeaderBar">
@ -21,98 +22,102 @@
<property name="expand">True</property> <property name="expand">True</property>
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkBox"> <object class="HdyClamp">
<property name="orientation">vertical</property> <property name="margin-right">18</property>
<property name="margin-left">18</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property>
<child> <child>
<object class="GtkGrid"> <object class="GtkBox">
<property name="margin-top">20</property>
<property name="margin-bottom">12</property>
<property name="margin-right">100</property>
<property name="margin-left">100</property>
<property name="column-spacing">10</property>
<property name="visible">True</property>
<child>
<object class="DinoUiAvatarImage" id="avatar">
<property name="height">50</property>
<property name="width">50</property>
<property name="visible">True</property>
<property name="allow_gray">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="DinoUiUtilEntryLabelHybrid" id="name_hybrid">
<property name="xalign">0</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="name_label">
<property name="xalign">0</property>
<property name="expand">True</property>
<property name="visible">True</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="jid_label">
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="selectable">True</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="account_label">
<property name="xalign">1</property>
<property name="yalign">1</property>
<property name="margin">5</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="main_box">
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="margin-right">100</property>
<property name="margin-left">100</property>
<property name="visible">True</property> <property name="visible">True</property>
<child>
<object class="GtkGrid">
<property name="margin-top">20</property>
<property name="margin-bottom">12</property>
<property name="column-spacing">10</property>
<property name="visible">True</property>
<child>
<object class="DinoUiAvatarImage" id="avatar">
<property name="height">50</property>
<property name="width">50</property>
<property name="visible">True</property>
<property name="allow_gray">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="DinoUiUtilEntryLabelHybrid" id="name_hybrid">
<property name="xalign">0</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="name_label">
<property name="xalign">0</property>
<property name="expand">True</property>
<property name="visible">True</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="jid_label">
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="selectable">True</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="account_label">
<property name="xalign">1</property>
<property name="yalign">1</property>
<property name="margin">5</property>
<property name="expand">True</property>
<property name="visible">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="main_box">
<property name="orientation">vertical</property>
<property name="visible">True</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View file

@ -85,11 +85,11 @@ public class Dialog : Gtk.Dialog {
ListBoxRow list_row = new ListBoxRow() { activatable=false, visible=true }; 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 }; Box row = new Box(Orientation.HORIZONTAL, 20) { margin_start=15, margin_end=15, margin_top=3, margin_bottom=3, visible=true };
list_row.add(row); list_row.add(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, wrap=true, visible=true };
if (description != null && description != "") { if (description != null && description != "") {
Box box = new Box(Orientation.VERTICAL, 0) { visible=true }; Box box = new Box(Orientation.VERTICAL, 0) { visible=true };
box.add(label_label); box.add(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, wrap=true, visible=true };
desc_label.set_markup("<span size='small'>%s</span>".printf(Markup.escape_text(description))); 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.get_style_context().add_class("dim-label");
box.add(desc_label); box.add(desc_label);
@ -117,7 +117,7 @@ public class Dialog : Gtk.Dialog {
int pref_height, pref_width; int pref_height, pref_width;
get_content_area().get_preferred_height(null, out pref_height); get_content_area().get_preferred_height(null, out pref_height);
get_preferred_width(out pref_width, null); get_default_size(out pref_width, null);
resize(pref_width, int.min(500, pref_height)); resize(pref_width, int.min(500, pref_height));
} }