From dfc7d2a890d755bcaf526e586e14046b581ed094 Mon Sep 17 00:00:00 2001 From: bobufa Date: Tue, 7 Aug 2018 16:03:00 +0200 Subject: add button that scrolls to the bottom of the conversation --- main/data/unified_main_content.ui | 49 ++++++++++++++++++---- .../ui/conversation_summary/conversation_view.vala | 5 +-- main/src/ui/unified_window.vala | 13 ++++++ 3 files changed, 56 insertions(+), 11 deletions(-) (limited to 'main') diff --git a/main/data/unified_main_content.ui b/main/data/unified_main_content.ui index 61781ac4..d5897b1a 100644 --- a/main/data/unified_main_content.ui +++ b/main/data/unified_main_content.ui @@ -17,20 +17,53 @@ True - - vertical + True - - + + vertical True + + + + True + + + + + True + + - - + + + end + end + crossfade True + + + False + end + end + 70 + 100 + True + + + + go-down-symbolic + 1 + True + + + + diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index 7fce6673..e6a564de 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -11,7 +11,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { public Conversation? conversation { get; private set; } - [GtkChild] private ScrolledWindow scrolled; + [GtkChild] public ScrolledWindow scrolled; [GtkChild] private Revealer notification_revealer; [GtkChild] private Box notifications; [GtkChild] private Box main; @@ -307,8 +307,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { } private void on_upper_notify() { - if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1 || - scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size + if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size if (at_current_content) { scrolled.vadjustment.value = scrolled.vadjustment.upper - scrolled.vadjustment.page_size; // scroll down } diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 22b8f49a..97ef7ed4 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -18,6 +18,8 @@ public class UnifiedWindow : Gtk.Window { 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; + private Revealer goto_end_revealer; + private Button goto_end_button; private Revealer search_revealer; private SearchEntry search_entry; private GlobalSearch search_box; @@ -40,6 +42,13 @@ public class UnifiedWindow : Gtk.Window { setup_unified(); setup_stack(); + var vadjustment = conversation_frame.scrolled.vadjustment; + vadjustment.notify["value"].connect(() => { + goto_end_revealer.reveal_child = vadjustment.value < vadjustment.upper - vadjustment.page_size; + }); + goto_end_button.clicked.connect(() => { + conversation_frame.initialize_for_conversation(conversation); + }); conversation_titlebar.search_button.clicked.connect(() => { search_revealer.reveal_child = conversation_titlebar.search_button.active; @@ -55,11 +64,13 @@ public class UnifiedWindow : Gtk.Window { search_box.selected_item.connect((item) => { on_conversation_selected(item.conversation, false, false); conversation_frame.initialize_around_message(item.conversation, item); + close_search(); }); event.connect((event) => { if (event.type == EventType.BUTTON_PRESS) { int dest_x, dest_y; bool ret = search_box.translate_coordinates(this, 0, 0, out dest_x, out dest_y); + print(@"ret $(ret) button-x $(event.button.x_root) !< dest_x $(dest_x)\n"); if (ret && event.button.x_root < dest_x) { close_search(); } @@ -132,6 +143,8 @@ public class UnifiedWindow : Gtk.Window { 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); + goto_end_revealer = (Revealer) builder.get_object("goto_end_revealer"); + goto_end_button = (Button) builder.get_object("goto_end_button"); search_box = ((GlobalSearch) builder.get_object("search_box")).init(stream_interactor); search_revealer = (Revealer) builder.get_object("search_revealer"); search_entry = (SearchEntry) builder.get_object("search_entry"); -- cgit v1.2.3-70-g09d2