diff options
Diffstat (limited to 'main/src/ui/main_window_controller.vala')
-rw-r--r-- | main/src/ui/main_window_controller.vala | 97 |
1 files changed, 58 insertions, 39 deletions
diff --git a/main/src/ui/main_window_controller.vala b/main/src/ui/main_window_controller.vala index dceb4094..7049aa40 100644 --- a/main/src/ui/main_window_controller.vala +++ b/main/src/ui/main_window_controller.vala @@ -30,18 +30,18 @@ public class MainWindowController : Object { this.conversation_view_controller = new ConversationViewController(window.conversation_view, window.conversation_titlebar, stream_interactor); - conversation_view_controller.search_menu_entry.search_button.bind_property("active", window.search_revealer, "reveal_child"); + conversation_view_controller.search_menu_entry.button.bind_property("active", window.search_revealer, "reveal_child", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL); window.search_revealer.notify["child-revealed"].connect(() => { if (window.search_revealer.child_revealed) { - if (window.conversation_view.conversation_frame.conversation != null && window.search_box.search_entry.text == "") { + if (window.conversation_view.conversation_frame.conversation != null && window.global_search.search_entry.text == "") { reset_search_entry(); } - window.search_box.search_entry.grab_focus_without_selecting(); - window.search_box.search_entry.set_position((int)window.search_box.search_entry.text_length); + window.global_search.search_entry.grab_focus(); + window.global_search.search_entry.set_position((int)window.global_search.search_entry.text.length); } }); - window.search_box.selected_item.connect((item) => { + window.global_search.selected_item.connect((item) => { select_conversation(item.conversation, false, false); window.conversation_view.conversation_frame.initialize_around_message(item.conversation, item); close_search(); @@ -55,30 +55,53 @@ public class MainWindowController : Object { window.accounts_placeholder.primary_button.clicked.connect(() => { app.activate_action("accounts", null); }); window.conversation_selector.conversation_selected.connect((conversation) => select_conversation(conversation)); - window.event.connect((event) => { - if (event.type == EventType.BUTTON_PRESS) { - int dest_x, dest_y; - bool ret = window.search_box.translate_coordinates(window, 0, 0, out dest_x, out dest_y); - int geometry_x, geometry_y, geometry_width, geometry_height; - window.get_window().get_geometry(out geometry_x, out geometry_y, out geometry_width, out geometry_height); - if (ret && event.button.x_root - geometry_x < dest_x || event.button.y_root - geometry_y < dest_y) { - close_search(); - } - } else if (event.type == EventType.KEY_RELEASE) { - if (event.key.keyval == Gdk.Key.Escape) { - close_search(); - } +// ConversationListModel list_model = new ConversationListModel(stream_interactor); +// list_model.closed_conversation.connect((conversation) => { +// print(@"closed $(conversation.counterpart.bare_jid)\n"); +// stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation); +// }); +// SingleSelection selection_model = new SingleSelection(list_model) { autoselect=false }; +// selection_model.notify["selected-item"].connect(() => { +// ConversationViewModel view_model = (ConversationViewModel) selection_model.selected_item; +// if (view_model.conversation.equals(conversation)) return; +// print(@"selected conversation $(view_model.conversation.counterpart)\n"); +// select_conversation(view_model.conversation); +// }); +// window.conversation_list_view.set_model(selection_model); +// print(list_model.get_n_items().to_string() + " " + selection_model.get_n_items().to_string() + "<<"); +// print(selection_model.get_selected().to_string() + "<<"); +// window.conversation_list_view.realize.connect(() => { +// selection_model.set_selected(0); +// }); + + Widget window_widget = ((Widget) window); + + GestureClick gesture_click_controller = new GestureClick(); + window_widget.add_controller(gesture_click_controller); + gesture_click_controller.pressed.connect((n_press, click_x, click_y) => { + double search_x, search_y; + bool ret = window.search_revealer.translate_coordinates(window, 0, 0, out search_x, out search_y); + if (ret && click_x < search_x) { + close_search(); + } + }); + + EventControllerKey key_event_controller = new EventControllerKey(); + window_widget.add_controller(key_event_controller); + // TODO GTK4: Why doesn't this work with key_pressed signal + key_event_controller.key_released.connect((keyval) => { + if (keyval == Gdk.Key.Escape) { + close_search(); } - return false; }); - window.focus_in_event.connect(() => { + + EventControllerFocus focus_event_controller = new EventControllerFocus(); + window_widget.add_controller(focus_event_controller); + focus_event_controller.enter.connect(() => { stream_interactor.get_module(ChatInteraction.IDENTITY).on_window_focus_in(conversation); - window.urgency_hint = false; - return false; }); - window.focus_out_event.connect(() => { + focus_event_controller.leave.connect(() => { stream_interactor.get_module(ChatInteraction.IDENTITY).on_window_focus_out(conversation); - return false; }); window.conversation_selected.connect(conversation => select_conversation(conversation)); @@ -89,12 +112,12 @@ public class MainWindowController : Object { stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => update_stack_state()); update_stack_state(); - AccelGroup accel_group = new AccelGroup(); - accel_group.connect(Gdk.Key.F, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE, () => { - window.search_revealer.reveal_child = true; - return false; - }); - window.add_accel_group(accel_group); +// AccelGroup accel_group = new AccelGroup(); +// accel_group.connect(Gdk.Key.F, ModifierType.CONTROL_MASK, AccelFlags.VISIBLE, () => { +// window.search_revealer.reveal_child = true; +// return false; +// }); +// window.add_accel_group(accel_group); } public void select_conversation(Conversation? conversation, bool do_reset_search = true, bool default_initialize_conversation = true) { @@ -122,11 +145,8 @@ public class MainWindowController : Object { conversation_view_controller.unset_conversation(); - foreach(var e in this.app.plugin_registry.conversation_titlebar_entries) { - Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK); - if (widget != null) { - widget.unset_conversation(); - } + foreach(Plugins.ConversationTitlebarEntry e in this.app.plugin_registry.conversation_titlebar_entries) { + e.unset_conversation(); } } @@ -150,18 +170,17 @@ public class MainWindowController : Object { switch (conversation.type_) { case Conversation.Type.CHAT: case Conversation.Type.GROUPCHAT_PM: - window.search_box.search_entry.text = @"with:$(conversation.counterpart) "; + window.global_search.search_entry.text = @"with:$(conversation.counterpart) "; break; case Conversation.Type.GROUPCHAT: - window.search_box.search_entry.text = @"in:$(conversation.counterpart) "; + window.global_search.search_entry.text = @"in:$(conversation.counterpart) "; break; } } } private void close_search() { - conversation_view_controller.search_menu_entry.search_button.active = false; - window.search_revealer.reveal_child = false; + conversation_view_controller.search_menu_entry.button.active = false; } } |