diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-17 23:21:23 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-18 00:17:29 +0100 |
commit | 582cc78edd35d7d3a9ab6ddc579919306a2325f5 (patch) | |
tree | 38010daad2a890d3f7e82eb4ef76696df8e492d0 /main/src/ui/unified_window.vala | |
parent | b65c71412b5791b8c7fc7d00d76f0e5b584a7ce2 (diff) | |
download | dino-582cc78edd35d7d3a9ab6ddc579919306a2325f5.tar.gz dino-582cc78edd35d7d3a9ab6ddc579919306a2325f5.zip |
"No accounts active, add?" stack in main view
Diffstat (limited to 'main/src/ui/unified_window.vala')
-rw-r--r-- | main/src/ui/unified_window.vala | 102 |
1 files changed, 74 insertions, 28 deletions
diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 0f33450d..27240a58 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -1,3 +1,4 @@ +using Gee; using Gtk; using Dino.Entities; @@ -5,55 +6,95 @@ 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 UnifiedWindowPlaceholder main_placeholder = new UnifiedWindowPlaceholder(); + private ChatInput chat_input; + private ConversationListTitlebar conversation_list_titlebar; + private ConversationSelector.View filterable_conversation_list; + private ConversationSummary.View conversation_frame; + private ConversationTitlebar conversation_titlebar; + private Paned headerbar_paned = new Paned(Orientation.HORIZONTAL); + private Paned paned = new Paned(Orientation.HORIZONTAL); + private Stack headerbar_stack = new Stack(); + private Stack stack = new Stack(); private StreamInteractor stream_interactor; private Conversation? conversation; public UnifiedWindow(Application application, StreamInteractor stream_interactor) { - Object(application : application); + Object(application : application, default_width : 1200, default_height : 700); this.stream_interactor = stream_interactor; + + setup_headerbar(); + setup_unified(); + setup_stacks(); + + conversation_list_titlebar.search_button.bind_property("active", filterable_conversation_list.search_bar, "search-mode-enabled", + BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + paned.bind_property("position", headerbar_paned, "position", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); + focus_in_event.connect(on_focus_in_event); focus_out_event.connect(on_focus_out_event); - default_width = 1200; - default_height = 700; + stream_interactor.account_added.connect((account) => { check_stack(true); }); + stream_interactor.account_removed.connect((account) => { check_stack(); }); + main_placeholder.no_accounts_add.clicked.connect(() => { get_application().activate_action("accounts", null); }); + filterable_conversation_list.conversation_list.conversation_selected.connect(on_conversation_selected); + conversation_list_titlebar.conversation_opened.connect(on_conversation_selected); + + check_stack(); + } + private void setup_unified() { 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 grid = new Grid() { orientation=Orientation.VERTICAL }; grid.add(conversation_frame); grid.add(new Separator(Orientation.HORIZONTAL)); grid.add(chat_input); + paned.set_position(300); + paned.add1(filterable_conversation_list); + paned.add2(grid); + 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); + private void setup_headerbar() { + conversation_titlebar = new ConversationTitlebar(stream_interactor); + conversation_list_titlebar = new ConversationListTitlebar(this, stream_interactor); + headerbar_paned.add1(conversation_list_titlebar); + headerbar_paned.add2(conversation_titlebar); + } - filterable_conversation_list.conversation_list.conversation_selected.connect(on_conversation_selected); - conversation_list_titlebar.conversation_opened.connect(on_conversation_selected); + private void setup_stacks() { + stack.add_named(paned, "main"); + stack.add_named(main_placeholder, "placeholder"); + add(stack); + + headerbar_stack.add_named(headerbar_paned, "main"); + headerbar_stack.add_named(new HeaderBar() { title="Dino", show_close_button=true, visible=true}, "placeholder"); + set_titlebar(headerbar_stack); + } + + private void check_stack(bool know_exists = false) { + ArrayList<Account> accounts = stream_interactor.get_accounts(); + bool exists_active = know_exists; + foreach (Account account in accounts) { + if (account.enabled) { + exists_active = true; + break; + } + } + if (exists_active) { + stack.set_visible_child_name("main"); + headerbar_stack.set_visible_child_name("main"); + } else { + stack.set_visible_child_name("placeholder"); + headerbar_stack.set_visible_child_name("placeholder"); + } } private void on_conversation_selected(Conversation conversation) { @@ -78,4 +119,9 @@ public class UnifiedWindow : Window { } } +[GtkTemplate (ui = "/org/dino-im/unified_window_placeholder.ui")] +public class UnifiedWindowPlaceholder : Box { + [GtkChild] public Button no_accounts_add; +} + }
\ No newline at end of file |