"No accounts active, add?" stack in main view
This commit is contained in:
parent
b65c71412b
commit
582cc78edd
|
@ -8,6 +8,7 @@ namespace Dino {
|
|||
public class StreamInteractor {
|
||||
|
||||
public signal void account_added(Account account);
|
||||
public signal void account_removed(Account account);
|
||||
public signal void stream_negotiated(Account account);
|
||||
|
||||
public ModuleManager module_manager;
|
||||
|
@ -29,6 +30,7 @@ public class StreamInteractor {
|
|||
|
||||
public void disconnect(Account account) {
|
||||
connection_manager.disconnect(account);
|
||||
account_removed(account);
|
||||
}
|
||||
|
||||
public ArrayList<Account> get_accounts() {
|
||||
|
|
|
@ -46,7 +46,7 @@ set(RESOURCE_LIST
|
|||
occupant_list.ui
|
||||
occupant_list_item.ui
|
||||
settings_dialog.ui
|
||||
unified_window.ui
|
||||
unified_window_placeholder.ui
|
||||
)
|
||||
|
||||
compile_gresources(
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="DinoUiWindow">
|
||||
<property name="default-width">1200</property>
|
||||
<property name="default-height">700</property>
|
||||
<child type="titlebar">
|
||||
<object class="GtkPaned">
|
||||
<property name="position" bind-source="main_paned" bind-property="position" bind-flags="bidirectional|sync-create"/>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="header_bar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkHeaderBar" id="left_toolbar">
|
||||
<property name="hexpand">False</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="left_toolbar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="add_button">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">list-add-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHeaderBar" id="right_toolbar">
|
||||
<property name="title"></property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="show_close_button">True</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="right_toolbar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="menu_button">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">open-menu-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack_type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="encryption_button">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack_type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="groupchat_button">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">system-users-symbolic</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack_type">end</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="main_paned">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="DinoUiRosterWrapper" id="roster_wrapper">
|
||||
<style>
|
||||
<class name="roster_wrapper"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="shadow-type">GTK_SHADOW_NONE</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="some_frame"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="conversation_grid"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="conversation_frame_scrolled">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="scrolled_window"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="DinoUiConversationFrame" id="conversation_frame">
|
||||
<property name="shadow-type">GTK_SHADOW_NONE</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="conversation_frame"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator" />
|
||||
</child>
|
||||
<child>
|
||||
<object class="DinoUiChatInput" id="chat_input">
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
50
main/data/unified_window_placeholder.ui
Normal file
50
main/data/unified_window_placeholder.ui
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="DinoUiUnifiedWindowPlaceholder">
|
||||
<property name="valign">center</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">10</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
<property name="icon-name">dino-symbolic</property>
|
||||
<property name="pixel-size">144</property>
|
||||
<property name="margin">30</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">No accounts active</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="no_accounts_add">
|
||||
<property name="label">Manage accounts</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
|
@ -5,11 +5,7 @@ using Dino.Ui;
|
|||
|
||||
public class Dino.Ui.Application : Dino.Application {
|
||||
private Notifications notifications;
|
||||
private UnifiedWindow? window;
|
||||
private ConversationSelector.View? filterable_conversation_list;
|
||||
private ConversationSelector.List? conversation_list;
|
||||
private ConversationSummary.View? conversation_frame;
|
||||
private ChatInput? chat_input;
|
||||
private UnifiedWindow window;
|
||||
|
||||
public Application() throws Error {
|
||||
Notify.init("dino");
|
||||
|
@ -21,20 +17,11 @@ public class Dino.Ui.Application : Dino.Application {
|
|||
|
||||
public override void activate() {
|
||||
create_set_app_menu();
|
||||
create_window();
|
||||
window = new UnifiedWindow(this, stream_interaction);
|
||||
window.show_all();
|
||||
restore();
|
||||
}
|
||||
|
||||
private void create_window() {
|
||||
window = new UnifiedWindow(this, stream_interaction);
|
||||
|
||||
filterable_conversation_list = window.filterable_conversation_list;
|
||||
conversation_list = window.filterable_conversation_list.conversation_list;
|
||||
conversation_frame = window.conversation_frame;
|
||||
chat_input = window.chat_input;
|
||||
}
|
||||
|
||||
private void show_accounts_window() {
|
||||
ManageAccounts.Dialog dialog = new ManageAccounts.Dialog(stream_interaction, db);
|
||||
dialog.set_transient_for(window);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue