aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-06-16 14:29:02 +0200
committerfiaxh <git@mx.ax.lt>2017-06-17 16:13:23 +0200
commit26973c89e391de673b6ac1db024a3098b1191393 (patch)
treeeb17d5006c1e70e7e88b71700455c40081b4af47 /main/src/ui/util
parent7bbbb738fdb233f4ad91ffdd7d9247b28849d715 (diff)
downloaddino-26973c89e391de673b6ac1db024a3098b1191393.tar.gz
dino-26973c89e391de673b6ac1db024a3098b1191393.zip
Set jid handle in ContactDetails, use LabelHybrids more, remove edit from StartConversation
Diffstat (limited to 'main/src/ui/util')
-rw-r--r--main/src/ui/util/helper.vala2
-rw-r--r--main/src/ui/util/label_hybrid.vala64
2 files changed, 51 insertions, 15 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index c65acfc9..d493def2 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -118,4 +118,4 @@ public static bool is_24h_format() {
return settings_format == "24h" || p_format == " ";
}
-} \ No newline at end of file
+}
diff --git a/main/src/ui/util/label_hybrid.vala b/main/src/ui/util/label_hybrid.vala
index 4486f25b..a16bccf7 100644
--- a/main/src/ui/util/label_hybrid.vala
+++ b/main/src/ui/util/label_hybrid.vala
@@ -8,7 +8,7 @@ public class LabelHybrid : Stack {
public Label label = new Label("") { visible=true };
protected Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
- public void init(Widget widget) {
+ internal virtual void init(Widget widget) {
button.add(label);
add_named(button, "label");
add_named(widget, "widget");
@@ -33,7 +33,13 @@ public class EntryLabelHybrid : LabelHybrid {
get { return entry.text; }
set {
entry.text = value;
- label.label = value;
+ if (visibility) {
+ label.label = value;
+ } else {
+ string filler = "";
+ for (int i = 0; i < value.length; i++) filler += entry.get_invisible_char().to_string();
+ label.label = filler;
+ }
}
}
@@ -50,11 +56,26 @@ public class EntryLabelHybrid : LabelHybrid {
}
}
- private Entry entry;
+ private Entry? entry_;
+ public Entry entry {
+ get {
+ if (entry_ == null) {
+ entry_ = new Entry() { visible=true };
+ init(entry_);
+ }
+ return entry_;
+ }
+ set { entry_ = value; }
+ }
+
+ public EntryLabelHybrid.wrap(Entry e) {
+ init(e);
+ }
- public EntryLabelHybrid(Entry? e = null) {
- entry = e ?? new Entry() { visible=true };
- init(entry);
+ internal override void init(Widget widget) {
+ Entry? e = widget as Entry; if (e == null) return;
+ entry = e;
+ base.init(entry);
update_label();
entry.key_release_event.connect((event) => {
@@ -84,11 +105,29 @@ public class ComboBoxTextLabelHybrid : LabelHybrid {
set { label.xalign = value; }
}
- private ComboBoxText combobox;
+ private ComboBoxText combobox_;
+ public ComboBoxText combobox {
+ get {
+ if (combobox_ == null) {
+ combobox_ = new ComboBoxText() { visible=true };
+ init(combobox_);
+ }
+ return combobox_;
+ }
+ set { combobox_ = combobox; }
+ }
- public ComboBoxTextLabelHybrid(ComboBoxText? cb = null) {
- combobox = cb ?? new ComboBoxText() { visible=true };
- init(combobox);
+ public ComboBoxTextLabelHybrid.wrap(ComboBoxText cb) {
+ combobox_ = cb;
+ init(cb);
+ }
+
+ public void append(string id, string text) { combobox.append(id, text); }
+ public string get_active_text() { return combobox.get_active_text(); }
+
+ internal override void init(Widget widget) {
+ ComboBoxText? combobox = widget as ComboBoxText; if (combobox == null) return;
+ base.init(combobox);
update_label();
combobox.changed.connect(() => {
@@ -100,9 +139,6 @@ public class ComboBoxTextLabelHybrid : LabelHybrid {
});
}
- public void append(string id, string text) { combobox.append(id, text); }
- public string get_active_text() { return combobox.get_active_text(); }
-
private void update_label() {
label.label = combobox.get_active_text();
}
@@ -126,4 +162,4 @@ public class LabelHybridGroup {
}
}
-} \ No newline at end of file
+}