aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorbobufa <bobufa@users.noreply.github.com>2018-07-04 23:38:28 +0200
committerbobufa <bobufa@users.noreply.github.com>2018-08-13 22:28:45 +0200
commit8b23ddad2d33a1504cd28c0df583dfe50cadccda (patch)
treec34829ba57aae1ea9d7291d1e4a91e2cfbd337c1 /main/src
parentbabfc3bd36e0cfa50f06648224f33a6a96eb27ea (diff)
downloaddino-8b23ddad2d33a1504cd28c0df583dfe50cadccda.tar.gz
dino-8b23ddad2d33a1504cd28c0df583dfe50cadccda.zip
ui: search sidebar initial
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/chat_input/view.vala3
-rw-r--r--main/src/ui/conversation_list_titlebar.vala1
-rw-r--r--main/src/ui/conversation_selector/view.vala33
-rw-r--r--main/src/ui/conversation_summary/conversation_view.vala3
-rw-r--r--main/src/ui/conversation_titlebar/search_entry.vala32
-rw-r--r--main/src/ui/conversation_titlebar/view.vala3
-rw-r--r--main/src/ui/unified_window.vala46
7 files changed, 72 insertions, 49 deletions
diff --git a/main/src/ui/chat_input/view.vala b/main/src/ui/chat_input/view.vala
index a1c2b83d..dd111997 100644
--- a/main/src/ui/chat_input/view.vala
+++ b/main/src/ui/chat_input/view.vala
@@ -32,7 +32,7 @@ public class View : Box {
[GtkChild] private Separator file_separator;
private EncryptionButton encryption_widget = new EncryptionButton() { margin_top=3, valign=Align.START, visible=true };
- public View(StreamInteractor stream_interactor) {
+ public View init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
occupants_tab_completor = new OccupantsTabCompletor(stream_interactor, text_input);
@@ -70,6 +70,7 @@ public class View : Box {
Util.force_css(frame, "* { border-radius: 3px; }");
stream_interactor.get_module(FileManager.IDENTITY).upload_available.connect(on_upload_available);
+ return this;
}
public void initialize_for_conversation(Conversation conversation) {
diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala
index 65515019..60d9a6fb 100644
--- a/main/src/ui/conversation_list_titlebar.vala
+++ b/main/src/ui/conversation_list_titlebar.vala
@@ -10,7 +10,6 @@ public class ConversationListTitlebar : Gtk.HeaderBar {
public signal void conversation_opened(Conversation conversation);
[GtkChild] private MenuButton add_button;
- [GtkChild] public ToggleButton search_button;
private StreamInteractor stream_interactor;
diff --git a/main/src/ui/conversation_selector/view.vala b/main/src/ui/conversation_selector/view.vala
index b6b02848..d06ad133 100644
--- a/main/src/ui/conversation_selector/view.vala
+++ b/main/src/ui/conversation_selector/view.vala
@@ -10,43 +10,14 @@ namespace Dino.Ui.ConversationSelector {
public class View : Box {
public List conversation_list;
- [GtkChild] public SearchEntry search_entry;
- [GtkChild] public Revealer search_revealer;
[GtkChild] private ScrolledWindow scrolled;
- public View(StreamInteractor stream_interactor) {
+ public View init(StreamInteractor 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);
+ return this;
}
- public void conversation_selected(Conversation? conversation) {
- search_entry.set_text("");
- }
-
- private void refilter() {
- string[]? values = null;
- string str = search_entry.get_text ();
- if (str != "") values = str.split(" ");
- conversation_list.set_filter_values(values);
- }
-
- private void search_changed(Editable editable) {
- refilter();
- }
-
- private bool search_key_release_event(EventKey event) {
- conversation_list.select_row(conversation_list.get_row_at_y(0));
- if (event.keyval == Key.Down) {
- ConversationRow? row = (ConversationRow) conversation_list.get_row_at_index(0);
- if (row != null) {
- conversation_list.select_row(row);
- row.grab_focus();
- }
- }
- return false;
- }
}
}
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala
index 008909e4..870b6ee3 100644
--- a/main/src/ui/conversation_summary/conversation_view.vala
+++ b/main/src/ui/conversation_summary/conversation_view.vala
@@ -35,7 +35,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
private bool firstLoad = true;
private bool at_current_content = true;
- public ConversationView(StreamInteractor stream_interactor) {
+ public ConversationView init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
scrolled.vadjustment.notify["upper"].connect_after(on_upper_notify);
scrolled.vadjustment.notify["value"].connect(on_value_notify);
@@ -58,6 +58,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
});
Util.force_base_background(this);
+ return this;
}
// Workaround GTK TextView issues: Delay first load of contents
diff --git a/main/src/ui/conversation_titlebar/search_entry.vala b/main/src/ui/conversation_titlebar/search_entry.vala
new file mode 100644
index 00000000..e80e5954
--- /dev/null
+++ b/main/src/ui/conversation_titlebar/search_entry.vala
@@ -0,0 +1,32 @@
+using Gtk;
+using Gee;
+
+using Dino.Entities;
+
+namespace Dino.Ui {
+
+public class SearchMenuEntry : Plugins.ConversationTitlebarEntry, Object {
+ public string id { get { return "search"; } }
+
+ Plugins.ConversationTitlebarWidget search_button;
+
+ public SearchMenuEntry(Plugins.ConversationTitlebarWidget search_button) {
+ this.search_button = search_button;
+ }
+
+ public double order { get { return 1; } }
+ public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
+ if (type == Plugins.WidgetType.GTK) {
+ return search_button;
+ }
+ return null;
+ }
+}
+
+public class GlobalSearchButton : Plugins.ConversationTitlebarWidget, Gtk.ToggleButton {
+ public new void set_conversation(Conversation conversation) {
+ active = false;
+ }
+}
+
+}
diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala
index d01cd9bb..13a9bf80 100644
--- a/main/src/ui/conversation_titlebar/view.vala
+++ b/main/src/ui/conversation_titlebar/view.vala
@@ -11,6 +11,7 @@ public class ConversationTitlebar : Gtk.HeaderBar {
private Window window;
private Conversation? conversation;
private Gee.List<Plugins.ConversationTitlebarWidget> widgets = new ArrayList<Plugins.ConversationTitlebarWidget>();
+ public GlobalSearchButton search_button = new GlobalSearchButton() { visible = true };
public ConversationTitlebar(StreamInteractor stream_interactor, Window window) {
this.stream_interactor = stream_interactor;
@@ -19,9 +20,11 @@ public class ConversationTitlebar : Gtk.HeaderBar {
this.get_style_context().add_class("dino-right");
show_close_button = true;
hexpand = true;
+ search_button.set_image(new Gtk.Image.from_icon_name("system-search-symbolic", Gtk.IconSize.MENU) { visible = true });
Application app = GLib.Application.get_default() as Application;
app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor));
+ app.plugin_registry.register_contact_titlebar_entry(new SearchMenuEntry(search_button));
app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor, window));
foreach(var e in app.plugin_registry.conversation_titlebar_entries) {
diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala
index e2798def..3292aa3d 100644
--- a/main/src/ui/unified_window.vala
+++ b/main/src/ui/unified_window.vala
@@ -16,7 +16,9 @@ public class UnifiedWindow : Window {
private ConversationTitlebar conversation_titlebar;
private HeaderBar placeholder_headerbar = new HeaderBar() { title="Dino", show_close_button=true, visible=true };
private Paned headerbar_paned = new Paned(Orientation.HORIZONTAL) { visible=true };
- private Paned paned = new Paned(Orientation.HORIZONTAL) { visible=true };
+ private Paned paned;
+ private Revealer search_revealer;
+ private SearchEntry search_entry;
private Stack stack = new Stack() { visible=true };
private StreamInteractor stream_interactor;
@@ -36,8 +38,15 @@ public class UnifiedWindow : Window {
setup_unified();
setup_stack();
- conversation_list_titlebar.search_button.bind_property("active", filterable_conversation_list.search_revealer, "reveal-child",
- BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ conversation_titlebar.search_button.bind_property("active", search_revealer, "reveal-child", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+ search_revealer.notify["child-revealed"].connect(() => {
+ if (search_revealer.child_revealed) {
+ search_entry.grab_focus();
+ } else {
+ search_entry.text = "";
+ }
+ });
+
paned.bind_property("position", headerbar_paned, "position", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
focus_in_event.connect(on_focus_in_event);
@@ -56,6 +65,18 @@ public class UnifiedWindow : Window {
check_stack();
}
+ private void hide_search_results() {
+ search_revealer.get_style_context().add_class("collapsed");
+ search_revealer.valign = Align.START;
+ // TODO: Make search results box inivisble
+ }
+
+ private void show_search_results() {
+ // TODO: Make search results box visible
+ search_revealer.get_style_context().remove_class("collapsed");
+ search_revealer.valign = Align.FILL;
+ }
+
public void on_conversation_selected(Conversation conversation) {
if (this.conversation == null || !this.conversation.equals(conversation)) {
this.conversation = conversation;
@@ -70,18 +91,13 @@ public class UnifiedWindow : Window {
}
private void setup_unified() {
- chat_input = new ChatInput.View(stream_interactor) { visible=true };
- conversation_frame = new ConversationSummary.ConversationView(stream_interactor) { visible=true };
- filterable_conversation_list = new ConversationSelector.View(stream_interactor) { visible=true };
-
- Grid grid = new Grid() { orientation=Orientation.VERTICAL, visible=true };
- grid.get_style_context().add_class("dino-conversation");
- grid.add(conversation_frame);
- grid.add(chat_input);
-
- paned.set_position(300);
- paned.pack1(filterable_conversation_list, false, false);
- paned.pack2(grid, true, false);
+ Builder builder = new Builder.from_resource("/im/dino/Dino/unified_main_content.ui");
+ paned = (Paned) builder.get_object("paned");
+ chat_input = ((ChatInput.View) builder.get_object("chat_input")).init(stream_interactor);
+ conversation_frame = ((ConversationSummary.ConversationView) builder.get_object("conversation_frame")).init(stream_interactor);
+ filterable_conversation_list = ((ConversationSelector.View) builder.get_object("conversation_list")).init(stream_interactor);
+ search_revealer = (Revealer) builder.get_object("search_revealer");
+ search_entry = (SearchEntry) builder.get_object("search_entry");
}
private void setup_headerbar() {