aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-03-20 22:12:20 +0100
committerfiaxh <git@mx.ax.lt>2017-03-20 22:28:32 +0100
commit6f3225979cb497db99381556adb7e42119b44ec3 (patch)
tree1f7352d12eaf1aec7a38d388d3b1917bcd06e479 /main
parentdb57a973534f099af2b150f1a1307d1948553d9f (diff)
downloaddino-6f3225979cb497db99381556adb7e42119b44ec3.tar.gz
dino-6f3225979cb497db99381556adb7e42119b44ec3.zip
Select conversation on startup, placeholder for "No conversation selected", start services before UI
Diffstat (limited to 'main')
-rw-r--r--main/data/chat_input.ui2
-rw-r--r--main/data/conversation_summary/view.ui3
-rw-r--r--main/data/unified_window_placeholder.ui17
-rw-r--r--main/src/ui/application.vala25
-rw-r--r--main/src/ui/conversation_selector/conversation_row.vala2
-rw-r--r--main/src/ui/conversation_selector/list.vala20
-rw-r--r--main/src/ui/conversation_selector/view.vala2
-rw-r--r--main/src/ui/unified_window.vala81
8 files changed, 88 insertions, 64 deletions
diff --git a/main/data/chat_input.ui b/main/data/chat_input.ui
index 455286ab..f8a1c2f7 100644
--- a/main/data/chat_input.ui
+++ b/main/data/chat_input.ui
@@ -10,8 +10,10 @@
<object class="GtkScrolledWindow" id="scrolled">
<property name="max_content_height">300</property>
<property name="propagate_natural_height">True</property>
+ <property name="visible">True</property>
<child>
<object class="GtkFrame">
+ <property name="visible">True</property>
<child>
<object class="GtkTextView" id="text_input">
<property name="wrap-mode">GTK_WRAP_WORD_CHAR</property>
diff --git a/main/data/conversation_summary/view.ui b/main/data/conversation_summary/view.ui
index d455c888..d00314fc 100644
--- a/main/data/conversation_summary/view.ui
+++ b/main/data/conversation_summary/view.ui
@@ -2,9 +2,9 @@
<interface>
<template class="DinoUiConversationSummaryView">
<property name="expand">True</property>
- <property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
+ <property name="visible">True</property>
<child>
<object class="GtkStack" id="stack">
<property name="transition_type">crossfade</property>
@@ -16,6 +16,7 @@
<object class="GtkBox">
<property name="margin">15</property>
<property name="orientation">vertical</property>
+ <property name="visible">True</property>
<child>
<object class="GtkBox" id="main">
<property name="expand">False</property>
diff --git a/main/data/unified_window_placeholder.ui b/main/data/unified_window_placeholder.ui
index b22d6a11..70307e6e 100644
--- a/main/data/unified_window_placeholder.ui
+++ b/main/data/unified_window_placeholder.ui
@@ -4,7 +4,7 @@
<property name="valign">center</property>
<property name="visible">True</property>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<property name="valign">center</property>
@@ -23,8 +23,7 @@
</object>
</child>
<child>
- <object class="GtkLabel">
- <property name="label">No accounts active</property>
+ <object class="GtkLabel" id="label">
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="visible">True</property>
@@ -34,8 +33,7 @@
</object>
</child>
<child>
- <object class="GtkButton" id="no_accounts_add">
- <property name="label">Manage accounts</property>
+ <object class="GtkButton" id="primary_button">
<property name="halign">center</property>
<property name="visible">True</property>
<style>
@@ -44,6 +42,15 @@
</style>
</object>
</child>
+ <child>
+ <object class="GtkButton" id="secondary_button">
+ <property name="halign">center</property>
+ <property name="no_show_all">True</property>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index e6f01822..e78fa90a 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -13,13 +13,12 @@ public class Dino.Ui.Application : Dino.Application {
notifications.start();
Environment.set_application_name("Dino");
IconTheme.get_default().add_resource_path("/org/dino-im/icons");
- }
- public override void activate() {
- create_set_app_menu();
- window = new UnifiedWindow(this, stream_interaction);
- window.show_all();
- restore();
+ activate.connect(() => {
+ create_set_app_menu();
+ window = new UnifiedWindow(this, stream_interaction);
+ window.show();
+ });
}
private void show_accounts_window() {
@@ -55,19 +54,5 @@ public class Dino.Ui.Application : Dino.Application {
set_app_menu(menu);
}
-
- private void restore() {
- foreach (Account account in db.get_accounts()) {
- if (account.enabled) add_connection(account);
- }
- }
-
- private void add_connection(Account account) {
- stream_interaction.connect(account);
- }
-
- private void remove_connection(Account account) {
- stream_interaction.disconnect(account);
- }
}
diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala
index c16da287..6930db67 100644
--- a/main/src/ui/conversation_selector/conversation_row.vala
+++ b/main/src/ui/conversation_selector/conversation_row.vala
@@ -125,7 +125,7 @@ public abstract class ConversationRow : ListBoxRow {
main_revealer.set_reveal_child(false);
closed();
main_revealer.notify["child-revealed"].connect(() => {
- conversation.active = false;
+ stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation);
disappeared();
});
}
diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala
index d95128f1..dee70e4b 100644
--- a/main/src/ui/conversation_selector/list.vala
+++ b/main/src/ui/conversation_selector/list.vala
@@ -76,6 +76,17 @@ public class List : ListBox {
foreach (ConversationRow row in rows.values) row.update();
return true;
});
+
+ foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations()) {
+ add_conversation(conversation);
+ }
+ realize.connect(() => {
+ ListBoxRow? first_row = get_row_at_index(0);
+ if (first_row != null) {
+ select_row(first_row);
+ row_activated(first_row);
+ }
+ });
}
public override void row_activated(ListBoxRow r) {
@@ -117,15 +128,14 @@ public class List : ListBox {
}
rows[conversation] = row;
add(row);
- row.closed.connect(() => { on_conversation_closed(conversation); });
- row.disappeared.connect(() => { on_conversation_disappeared(conversation); });
+ row.closed.connect(() => { select_next_conversation(conversation); });
+ row.disappeared.connect(() => { remove_conversation(conversation); });
row.main_revealer.set_reveal_child(true);
}
invalidate_sort();
- queue_draw();
}
- private void on_conversation_closed(Conversation conversation) {
+ private void select_next_conversation(Conversation conversation) {
if (get_selected_row() == rows[conversation]) {
int index = rows[conversation].get_index();
ListBoxRow? index_p1 = get_row_at_index(index + 1);
@@ -142,7 +152,7 @@ public class List : ListBox {
}
}
- private void on_conversation_disappeared(Conversation conversation) {
+ private void remove_conversation(Conversation conversation) {
if (rows.has_key(conversation) && !conversation.active) {
remove(rows[conversation]);
rows.unset(conversation);
diff --git a/main/src/ui/conversation_selector/view.vala b/main/src/ui/conversation_selector/view.vala
index 5c1b4dfd..304c6bbe 100644
--- a/main/src/ui/conversation_selector/view.vala
+++ b/main/src/ui/conversation_selector/view.vala
@@ -15,7 +15,7 @@ public class View : Box {
[GtkChild] private ScrolledWindow scrolled;
public View(StreamInteractor stream_interactor) {
- conversation_list = new List(stream_interactor);
+ conversation_list = new List(stream_interactor) { visible=true };
scrolled.add(conversation_list);
search_entry.key_release_event.connect(search_key_release_event);
search_entry.search_changed.connect(search_changed);
diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala
index 8feb9a05..2eb4317a 100644
--- a/main/src/ui/unified_window.vala
+++ b/main/src/ui/unified_window.vala
@@ -7,16 +7,17 @@ namespace Dino.Ui {
public class UnifiedWindow : Window {
- private UnifiedWindowPlaceholder main_placeholder = new UnifiedWindowPlaceholder();
+ private NoAccountsPlaceholder accounts_placeholder = new NoAccountsPlaceholder() { visible=true };
+ private NoConversationsPlaceholder conversations_placeholder = new NoConversationsPlaceholder() { visible=true };
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 Paned headerbar_paned = new Paned(Orientation.HORIZONTAL) { visible=true };
+ private Paned paned = new Paned(Orientation.HORIZONTAL) { visible=true };
+ private Stack headerbar_stack = new Stack() { visible=true };
+ private Stack stack = new Stack() { visible=true };
private StreamInteractor stream_interactor;
private Conversation? conversation;
@@ -27,7 +28,7 @@ public class UnifiedWindow : Window {
setup_headerbar();
setup_unified();
- setup_stacks();
+ setup_stack();
conversation_list_titlebar.search_button.bind_property("active", filterable_conversation_list.search_bar, "search-mode-enabled",
BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
@@ -38,7 +39,11 @@ public class UnifiedWindow : Window {
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); });
+ stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect((conversation) => { check_stack(); });
+ stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect((conversation) => { check_stack(); });
+ accounts_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("accounts", null); });
+ conversations_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("add_chat", null); });
+ conversations_placeholder.secondary_button.clicked.connect(() => { get_application().activate_action("add_conference", null); });
filterable_conversation_list.conversation_list.conversation_selected.connect(on_conversation_selected);
conversation_list_titlebar.conversation_opened.connect(on_conversation_selected);
@@ -46,54 +51,49 @@ public class UnifiedWindow : Window {
}
private void setup_unified() {
- chat_input = new ChatInput(stream_interactor);
- conversation_frame = new ConversationSummary.View(stream_interactor);
- filterable_conversation_list = new ConversationSelector.View(stream_interactor);
+ chat_input = new ChatInput(stream_interactor) { visible=true };
+ conversation_frame = new ConversationSummary.View(stream_interactor) { visible=true };
+ filterable_conversation_list = new ConversationSelector.View(stream_interactor) { visible=true };
- Grid grid = new Grid() { orientation=Orientation.VERTICAL };
+ Grid grid = new Grid() { orientation=Orientation.VERTICAL, visible=true };
grid.add(conversation_frame);
- grid.add(new Separator(Orientation.HORIZONTAL));
+ grid.add(new Separator(Orientation.HORIZONTAL) { visible=true });
grid.add(chat_input);
paned.set_position(300);
paned.add1(filterable_conversation_list);
paned.add2(grid);
-
- conversation_frame.show_all();
}
private void setup_headerbar() {
- conversation_titlebar = new ConversationTitlebar(stream_interactor);
- conversation_list_titlebar = new ConversationListTitlebar(this, stream_interactor);
+ conversation_titlebar = new ConversationTitlebar(stream_interactor) { visible=true };
+ conversation_list_titlebar = new ConversationListTitlebar(this, stream_interactor) { visible=true };
headerbar_paned.add1(conversation_list_titlebar);
headerbar_paned.add2(conversation_titlebar);
}
- private void setup_stacks() {
+ private void setup_stack() {
stack.add_named(paned, "main");
- stack.add_named(main_placeholder, "placeholder");
+ stack.add_named(accounts_placeholder, "accounts_placeholder");
+ stack.add_named(conversations_placeholder, "conversations_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");
+ 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) {
+ if (!know_exists && accounts.size == 0) {
+ stack.set_visible_child_name("accounts_placeholder");
+ headerbar_stack.set_visible_child_name("placeholder");
+ } else if (stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations().size == 0) {
+ stack.set_visible_child_name("conversations_placeholder");
+ headerbar_stack.set_visible_child_name("placeholder");
+ } else {
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");
}
}
@@ -119,9 +119,28 @@ public class UnifiedWindow : Window {
}
}
+public class NoAccountsPlaceholder : UnifiedWindowPlaceholder {
+ public NoAccountsPlaceholder() {
+ label.label = "No accounts active";
+ primary_button.label = "Manage accounts";
+ secondary_button.visible = false;
+ }
+}
+
+public class NoConversationsPlaceholder : UnifiedWindowPlaceholder {
+ public NoConversationsPlaceholder() {
+ label.label = "No conversation active";
+ primary_button.label = "Add Chat";
+ secondary_button.label = "Join Conference";
+ secondary_button.visible = true;
+ }
+}
+
[GtkTemplate (ui = "/org/dino-im/unified_window_placeholder.ui")]
public class UnifiedWindowPlaceholder : Box {
- [GtkChild] public Button no_accounts_add;
+ [GtkChild] public Label label;
+ [GtkChild] public Button primary_button;
+ [GtkChild] public Button secondary_button;
}
} \ No newline at end of file