diff options
Diffstat (limited to 'main/src/ui')
-rw-r--r-- | main/src/ui/conversation_summary/conversation_view.vala | 10 | ||||
-rw-r--r-- | main/src/ui/unified_window.vala | 65 |
2 files changed, 38 insertions, 37 deletions
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index c74884a4..07259cc5 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -112,7 +112,6 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { widget.get_preferred_height_for_width(main.get_allocated_width() - 2 * main.margin, out minimum_height, out natural_height); h += minimum_height + 15; }); - print(@"height_for_w: $(h)\n"); } reload_messages = false; @@ -124,7 +123,6 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { i += sk != null ? sk.items.size : 1; h += widget.get_allocated_height() + 15; }); - print(@"timeout: $(h)\n"); scrolled.vadjustment.value = h - scrolled.vadjustment.page_size * 1/3; w.get_style_context().add_class("highlight-once"); reload_messages = true; @@ -334,15 +332,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { private void load_later_messages() { if (!reloading_mutex.trylock()) return; if (meta_items.size > 0 && !at_current_content) { - foreach (Plugins.MetaConversationItem a in content_items) { - ContentMetaItem b = a as ContentMetaItem; - MessageItem c = b.content_item as MessageItem; - } Gee.List<ContentMetaItem> items = content_populator.populate_after(conversation, (content_items.last() as ContentMetaItem).content_item, 20); - - ContentMetaItem b = content_items.last() as ContentMetaItem; - MessageItem c = b.content_item as MessageItem; - if (items.size == 0) { at_current_content = true; } diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 60aeb832..115e392c 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -1,11 +1,12 @@ using Gee; +using Gdk; using Gtk; using Dino.Entities; namespace Dino.Ui { -public class UnifiedWindow : Window { +public class UnifiedWindow : Gtk.Window { private NoAccountsPlaceholder accounts_placeholder = new NoAccountsPlaceholder() { visible=true }; private NoConversationsPlaceholder conversations_placeholder = new NoConversationsPlaceholder() { visible=true }; @@ -45,26 +46,30 @@ public class UnifiedWindow : Window { }); search_revealer.notify["child-revealed"].connect(() => { if (search_revealer.child_revealed) { - if (conversation_frame.conversation != null) { - switch (conversation_frame.conversation.type_) { - case Conversation.Type.CHAT: - case Conversation.Type.GROUPCHAT_PM: - search_box.search_entry.text = @"with:$(conversation_frame.conversation.counterpart) "; - break; - case Conversation.Type.GROUPCHAT: - search_box.search_entry.text = @"in:$(conversation_frame.conversation.counterpart) "; - break; - } + if (conversation_frame.conversation != null && search_box.search_entry.text == "") { + reset_search_entry(); } search_box.search_entry.grab_focus(); - } else { - search_box.search_entry.text = ""; } }); search_box.selected_item.connect((item) => { on_conversation_selected(item.conversation, false, false); conversation_frame.initialize_around_message(item.conversation, item); }); + 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); + if (ret && event.button.x_root < dest_x) { + close_search(); + } + } else if (event.type == EventType.KEY_RELEASE) { + if (event.key.keyval == Gdk.Key.Escape) { + close_search(); + } + } + return false; + }); paned.bind_property("position", headerbar_paned, "position", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); @@ -84,28 +89,29 @@ 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; + private void reset_search_entry() { + if (conversation_frame.conversation != null) { + switch (conversation_frame.conversation.type_) { + case Conversation.Type.CHAT: + case Conversation.Type.GROUPCHAT_PM: + search_box.search_entry.text = @"with:$(conversation_frame.conversation.counterpart) "; + break; + case Conversation.Type.GROUPCHAT: + search_box.search_entry.text = @"in:$(conversation_frame.conversation.counterpart) "; + break; + } + } } - public void on_conversation_selected(Conversation conversation, bool close_search = true, bool default_initialize_conversation = true) { + public void on_conversation_selected(Conversation conversation, bool do_reset_search = true, bool default_initialize_conversation = true) { if (this.conversation == null || !this.conversation.equals(conversation)) { this.conversation = conversation; stream_interactor.get_module(ChatInteraction.IDENTITY).on_conversation_selected(conversation); conversation.active = true; // only for conversation_selected filterable_conversation_list.conversation_list.on_conversation_selected(conversation); // only for conversation_opened - if (close_search) { - conversation_titlebar.search_button.active = false; - search_revealer.reveal_child = false; + if (do_reset_search) { + reset_search_entry(); } chat_input.initialize_for_conversation(conversation); if (default_initialize_conversation) { @@ -115,6 +121,11 @@ public class UnifiedWindow : Window { } } + private void close_search() { + conversation_titlebar.search_button.active = false; + search_revealer.reveal_child = false; + } + private void setup_unified() { Builder builder = new Builder.from_resource("/im/dino/Dino/unified_main_content.ui"); paned = (Paned) builder.get_object("paned"); |