diff options
author | bobufa <bobufa@users.noreply.github.com> | 2018-08-07 16:03:00 +0200 |
---|---|---|
committer | bobufa <bobufa@users.noreply.github.com> | 2018-08-13 22:39:18 +0200 |
commit | dfc7d2a890d755bcaf526e586e14046b581ed094 (patch) | |
tree | 1dda124153814a60c565d7e0176567d80f5dabed /main | |
parent | b35abad05455970da36aafafd4afc9148aa43ced (diff) | |
download | dino-dfc7d2a890d755bcaf526e586e14046b581ed094.tar.gz dino-dfc7d2a890d755bcaf526e586e14046b581ed094.zip |
add button that scrolls to the bottom of the conversation
Diffstat (limited to 'main')
-rw-r--r-- | main/data/unified_main_content.ui | 49 | ||||
-rw-r--r-- | main/src/ui/conversation_summary/conversation_view.vala | 5 | ||||
-rw-r--r-- | main/src/ui/unified_window.vala | 13 |
3 files changed, 56 insertions, 11 deletions
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 @@ <object class="GtkOverlay"> <property name="visible">True</property> <child> - <object class="GtkBox"> - <property name="orientation">vertical</property> + <object class="GtkOverlay"> <property name="visible">True</property> - <style> - <class name="dino-conversation"/> - </style> <child> - <object class="DinoUiConversationSummaryConversationView" id="conversation_frame"> + <object class="GtkBox"> + <property name="orientation">vertical</property> <property name="visible">True</property> + <style> + <class name="dino-conversation"/> + </style> + <child> + <object class="DinoUiConversationSummaryConversationView" id="conversation_frame"> + <property name="visible">True</property> + </object> + </child> + <child> + <object class="DinoUiChatInputView" id="chat_input"> + <property name="visible">True</property> + </object> + </child> </object> </child> - <child> - <object class="DinoUiChatInputView" id="chat_input"> + <child type="overlay"> + <object class="GtkRevealer" id="goto_end_revealer"> + <property name="halign">end</property> + <property name="valign">end</property> + <property name="transition-type">crossfade</property> <property name="visible">True</property> + <child> + <object class="GtkButton" id="goto_end_button"> + <property name="vexpand">False</property> + <property name="halign">end</property> + <property name="valign">end</property> + <property name="margin-end">70</property> + <property name="margin-bottom">100</property> + <property name="visible">True</property> + <style> + <class name="circular"/> + </style> + <child> + <object class="GtkImage"> + <property name="icon-name">go-down-symbolic</property> + <property name="icon-size">1</property> + <property name="visible">True</property> + </object> + </child> + </object> + </child> </object> </child> </object> 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"); |