diff options
author | Marvin W <git@larma.de> | 2017-03-11 23:52:12 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-03-11 23:58:35 +0100 |
commit | e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 (patch) | |
tree | 80e547d0e02e770e8bcd912e42f8afa753aeb0f6 /main/src/ui/unified_window.vala | |
parent | cd6b904e970291a63551d0f1d80bbd550e778ec8 (diff) | |
download | dino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.tar.gz dino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.zip |
Move UI code into main dir
Diffstat (limited to 'main/src/ui/unified_window.vala')
-rw-r--r-- | main/src/ui/unified_window.vala | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala new file mode 100644 index 00000000..269799c2 --- /dev/null +++ b/main/src/ui/unified_window.vala @@ -0,0 +1,81 @@ +using Gtk; + +using Dino.Entities; + +namespace Dino.Ui { + +public class UnifiedWindow : Window { + public ChatInput chat_input; + public ConversationListTitlebar conversation_list_titlebar; + public ConversationSelector.View filterable_conversation_list; + public ConversationSummary.View conversation_frame; + public ConversationTitlebar conversation_titlebar; + public Paned paned; + + private StreamInteractor stream_interactor; + private Conversation? conversation; + + public UnifiedWindow(Application application, StreamInteractor stream_interactor) { + Object(application : application); + this.stream_interactor = stream_interactor; + focus_in_event.connect(on_focus_in_event); + focus_out_event.connect(on_focus_out_event); + + default_width = 1200; + default_height = 700; + + chat_input = new ChatInput(stream_interactor); + conversation_frame = new ConversationSummary.View(stream_interactor); + conversation_titlebar = new ConversationTitlebar(stream_interactor); + paned = new Paned(Orientation.HORIZONTAL); + paned.set_position(300); + filterable_conversation_list = new ConversationSelector.View(stream_interactor); + conversation_list_titlebar = new ConversationListTitlebar(this, stream_interactor); + conversation_list_titlebar.search_button.bind_property("active", filterable_conversation_list.search_bar, "search-mode-enabled", + BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + Grid grid = new Grid(); + grid.orientation = Orientation.VERTICAL; + Paned toolbar_paned = new Paned(Orientation.HORIZONTAL); + + add(paned); + paned.add1(filterable_conversation_list); + paned.add2(grid); + + grid.add(conversation_frame); + grid.add(new Separator(Orientation.HORIZONTAL)); + grid.add(chat_input); + + conversation_frame.show_all(); + + toolbar_paned.add1(conversation_list_titlebar); + toolbar_paned.add2(conversation_titlebar); + paned.bind_property("position", toolbar_paned, "position", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + set_titlebar(toolbar_paned); + + filterable_conversation_list.conversation_list.conversation_selected.connect(on_conversation_selected); + conversation_list_titlebar.conversation_opened.connect(on_conversation_selected); + } + + private void on_conversation_selected(Conversation conversation) { + this.conversation = conversation; + ChatInteraction.get_instance(stream_interactor).on_conversation_selected(conversation); + conversation.active = true; // only for conversation_selected + filterable_conversation_list.conversation_list.on_conversation_selected(conversation); // only for conversation_opened + + chat_input.initialize_for_conversation(conversation); + conversation_frame.initialize_for_conversation(conversation); + conversation_titlebar.initialize_for_conversation(conversation); + } + + private bool on_focus_in_event() { + ChatInteraction.get_instance(stream_interactor).window_focus_in(conversation); + return false; + } + + private bool on_focus_out_event() { + ChatInteraction.get_instance(stream_interactor).window_focus_out(conversation); + return false; + } +} + +}
\ No newline at end of file |