aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/occupant_menu
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-07-22 18:40:33 +0200
committerfiaxh <git@lightrise.org>2020-07-22 18:40:33 +0200
commita8f127b32ed05ddca960c023f9df87c84632c854 (patch)
treeb514be535765972683d7349daa759ce10b632a68 /main/src/ui/occupant_menu
parentb104be4842c4f5c309055052bd7b9d2fc9337113 (diff)
downloaddino-a8f127b32ed05ddca960c023f9df87c84632c854.tar.gz
dino-a8f127b32ed05ddca960c023f9df87c84632c854.zip
Lazy generate occupant menu list
Diffstat (limited to 'main/src/ui/occupant_menu')
-rw-r--r--main/src/ui/occupant_menu/view.vala26
1 files changed, 16 insertions, 10 deletions
diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala
index a512ff24..14955416 100644
--- a/main/src/ui/occupant_menu/view.vala
+++ b/main/src/ui/occupant_menu/view.vala
@@ -11,7 +11,7 @@ public class View : Popover {
private Conversation conversation;
private Stack stack = new Stack() { vhomogeneous=false, visible=true };
- private List list;
+ private List? list = null;
private ListBox invite_list;
private Box? jid_menu = null;
@@ -22,8 +22,19 @@ public class View : Popover {
this.conversation = conversation;
Box list_box = new Box(Orientation.VERTICAL, 1) { visible=true };
- list = new List(stream_interactor, conversation) { visible=true };
- list_box.add(list);
+
+ this.show.connect(() => {
+ if (list == null) {
+ list = new List(stream_interactor, conversation) { visible=true };
+ list_box.add(list);
+ list_box.reorder_child(list, 0);
+
+ list.list_box.row_activated.connect((row) => {
+ ListRow list_row = row as ListRow;
+ show_menu(list_row.jid, list_row.name_label.label);
+ });
+ }
+ });
invite_list = new ListBox() { visible=true };
invite_list.add(new ListRow.label("+", _("Invite")) {visible=true});
@@ -46,23 +57,18 @@ public class View : Popover {
add(stack);
stack.visible_child_name = "list";
- list.list_box.row_activated.connect((row) => {
- ListRow list_row = row as ListRow;
- show_menu(list_row.jid, list_row.name_label.label);
- });
-
hide.connect(reset);
}
public void reset() {
stack.transition_type = StackTransitionType.NONE;
stack.visible_child_name = "list";
- list.list_box.unselect_all();
+ if (list != null) list.list_box.unselect_all();
invite_list.unselect_all();
}
private void show_list() {
- list.list_box.unselect_all();
+ if (list != null) list.list_box.unselect_all();
stack.transition_type = StackTransitionType.SLIDE_RIGHT;
stack.visible_child_name = "list";
}