aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_selector/view.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-11 23:52:12 +0100
committerMarvin W <git@larma.de>2017-03-11 23:58:35 +0100
commite27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 (patch)
tree80e547d0e02e770e8bcd912e42f8afa753aeb0f6 /main/src/ui/conversation_selector/view.vala
parentcd6b904e970291a63551d0f1d80bbd550e778ec8 (diff)
downloaddino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.tar.gz
dino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.zip
Move UI code into main dir
Diffstat (limited to 'main/src/ui/conversation_selector/view.vala')
-rw-r--r--main/src/ui/conversation_selector/view.vala52
1 files changed, 52 insertions, 0 deletions
diff --git a/main/src/ui/conversation_selector/view.vala b/main/src/ui/conversation_selector/view.vala
new file mode 100644
index 00000000..ae641664
--- /dev/null
+++ b/main/src/ui/conversation_selector/view.vala
@@ -0,0 +1,52 @@
+using Gee;
+using Gtk;
+using Gdk;
+
+using Dino.Entities;
+
+namespace Dino.Ui.ConversationSelector {
+
+[GtkTemplate (ui = "/org/dino-im/conversation_selector/view.ui")]
+public class View : Grid {
+ public List conversation_list;
+
+ [GtkChild] public SearchEntry search_entry;
+ [GtkChild] public SearchBar search_bar;
+ [GtkChild] private ScrolledWindow scrolled;
+
+ public View(StreamInteractor stream_interactor) {
+ conversation_list = new List(stream_interactor);
+ scrolled.add(conversation_list);
+ search_entry.key_release_event.connect(search_key_release_event);
+ search_entry.search_changed.connect(search_changed);
+ }
+
+ 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;
+ }
+}
+
+} \ No newline at end of file