aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/occupant_menu/view.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-04-03 19:20:31 +0200
committerfiaxh <git@mx.ax.lt>2017-04-03 19:48:01 +0200
commitea5d3e50c6fd63ae3a151c883f691e76b9cb1018 (patch)
tree633d269bd20fbfacfe8bea79f87cd3374d4199a0 /main/src/ui/occupant_menu/view.vala
parent2a49d4a1aaf1d1fb644d3e4586989c696f657bcc (diff)
downloaddino-ea5d3e50c6fd63ae3a151c883f691e76b9cb1018.tar.gz
dino-ea5d3e50c6fd63ae3a151c883f691e76b9cb1018.zip
Start private conversation with MUC occupant via occupant menu
Diffstat (limited to 'main/src/ui/occupant_menu/view.vala')
-rw-r--r--main/src/ui/occupant_menu/view.vala79
1 files changed, 79 insertions, 0 deletions
diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala
new file mode 100644
index 00000000..b7fe15ba
--- /dev/null
+++ b/main/src/ui/occupant_menu/view.vala
@@ -0,0 +1,79 @@
+using Gtk;
+
+using Dino.Entities;
+
+namespace Dino.Ui.OccupantMenu {
+public class View : Popover {
+
+ private StreamInteractor stream_interactor;
+ private Conversation conversation;
+
+ private Stack stack = new Stack() { vhomogeneous=false, visible=true };
+ private List list;
+ private Label header_label = new Label("") { xalign=0.5f, hexpand=true, visible=true };
+
+ public View(StreamInteractor stream_interactor, Conversation conversation) {
+ this.stream_interactor = stream_interactor;
+ this.conversation = conversation;
+
+ list = new List(stream_interactor, conversation) { visible=true };
+ stack.add_named(list, "list");
+ setup_menu();
+ add(stack);
+ stack.visible_child_name = "list";
+
+ list.list_box.row_activated.connect((row) => {
+ ListRow list_row = row as ListRow;
+ header_label.label = list_row.name_label.label;
+ show_menu();
+ });
+
+ hide.connect(reset);
+ }
+
+ public void reset() {
+ stack.transition_type = StackTransitionType.NONE;
+ stack.visible_child_name = "list";
+ list.list_box.unselect_all();
+ }
+
+ private void setup_menu() {
+ Box header_box = new Box(Orientation.HORIZONTAL, 5) { visible=true };
+ header_box.add(new Image.from_icon_name("pan-start-symbolic", IconSize.SMALL_TOOLBAR) { visible=true });
+ header_box.add(header_label);
+
+ Button header_button = new Button() { relief=ReliefStyle.NONE, visible=true };
+ header_button.add(header_box);
+
+ ModelButton private_button = new ModelButton() { active=true, text="Start private conversation", visible=true };
+
+ Box outer_box = new Box(Orientation.VERTICAL, 5) { margin=10, visible=true };
+ outer_box.add(header_button);
+ outer_box.add(private_button);
+ stack.add_named(outer_box, "menu");
+
+ header_button.clicked.connect(show_list);
+ private_button.clicked.connect(private_conversation_button_clicked);
+ }
+
+ private void show_list() {
+ list.list_box.unselect_all();
+ stack.transition_type = StackTransitionType.SLIDE_RIGHT;
+ stack.visible_child_name = "list";
+ }
+
+ private void show_menu() {
+ stack.transition_type = StackTransitionType.SLIDE_LEFT;
+ stack.visible_child_name = "menu";
+ }
+
+ private void private_conversation_button_clicked() {
+ ListRow? list_row = list.list_box.get_selected_row() as ListRow;
+ if (list_row == null) return;
+
+ Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(list_row.jid, list_row.account, Conversation.Type.GROUPCHAT_PM);
+ stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
+ }
+}
+
+} \ No newline at end of file