From bea85c8ab5f74d96f37c1b3a6ea1e83edd0de500 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 12 Oct 2021 16:23:25 +0200 Subject: Fix compiler warnings ('cast between incompatible function types') by not connecting closures --- libdino/src/service/notification_events.vala | 22 +++--- main/src/ui/conversation_titlebar/menu_entry.vala | 14 ++-- main/src/ui/conversation_view_controller.vala | 4 +- main/src/ui/global_search.vala | 94 ++++++++++++----------- main/src/ui/occupant_menu/view.vala | 59 +++++++------- 5 files changed, 105 insertions(+), 88 deletions(-) diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala index 7039d1cf..f87ebe0d 100644 --- a/libdino/src/service/notification_events.vala +++ b/libdino/src/service/notification_events.vala @@ -26,18 +26,11 @@ public class NotificationEvents : StreamInteractionModule, Object { stream_interactor.get_module(PresenceManager.IDENTITY).received_subscription_request.connect(on_received_subscription_request); stream_interactor.get_module(MucManager.IDENTITY).invite_received.connect(on_invite_received); - stream_interactor.get_module(MucManager.IDENTITY).voice_request_received.connect((account, room_jid, from_jid, nick) => { - Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(room_jid, account, Conversation.Type.GROUPCHAT); - if (conversation == null) return; - notifier.notify_voice_request.begin(conversation, from_jid); - }); + stream_interactor.get_module(MucManager.IDENTITY).voice_request_received.connect(on_voice_request_received); stream_interactor.get_module(Calls.IDENTITY).call_incoming.connect(on_call_incoming); stream_interactor.connection_manager.connection_error.connect((account, error) => notifier.notify_connection_error.begin(account, error)); - stream_interactor.get_module(ChatInteraction.IDENTITY).focused_in.connect((conversation) => { - notifier.retract_content_item_notifications.begin(); - notifier.retract_conversation_notifications.begin(conversation); - }); + stream_interactor.get_module(ChatInteraction.IDENTITY).focused_in.connect(on_focused_in); } public void register_notification_provider(NotificationProvider notification_provider) { @@ -100,6 +93,12 @@ public class NotificationEvents : StreamInteractionModule, Object { } } + private void on_voice_request_received(Account account, Jid room_jid, Jid from_jid, string nick) { + Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(room_jid, account, Conversation.Type.GROUPCHAT); + if (conversation == null) return; + notifier.notify_voice_request.begin(conversation, from_jid); + } + private void on_received_subscription_request(Jid jid, Account account) { Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT); if (stream_interactor.get_module(ChatInteraction.IDENTITY).is_active_focus(conversation)) return; @@ -129,6 +128,11 @@ public class NotificationEvents : StreamInteractionModule, Object { } notifier.notify_muc_invite.begin(account, room_jid, from_jid, inviter_display_name); } + + private void on_focused_in(Conversation conversation) { + notifier.retract_content_item_notifications.begin(); + notifier.retract_conversation_notifications.begin(conversation); + } } public interface NotificationProvider : Object { diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala index e72cb629..9b3b6ee2 100644 --- a/main/src/ui/conversation_titlebar/menu_entry.vala +++ b/main/src/ui/conversation_titlebar/menu_entry.vala @@ -28,16 +28,14 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object { class MenuWidget : Button, Plugins.ConversationTitlebarWidget { + private StreamInteractor stream_interactor; private Conversation? conversation; public MenuWidget(StreamInteractor stream_interactor) { + this.stream_interactor = stream_interactor; image = new Image.from_icon_name("open-menu-symbolic", IconSize.MENU); - clicked.connect(() => { - ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation); - contact_details_dialog.set_transient_for((Window) get_toplevel()); - contact_details_dialog.present(); - }); + clicked.connect(on_clicked); } public new void set_conversation(Conversation conversation) { @@ -54,6 +52,12 @@ class MenuWidget : Button, Plugins.ConversationTitlebarWidget { this.sensitive = false; } + private void on_clicked() { + ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation); + contact_details_dialog.set_transient_for((Window) get_toplevel()); + contact_details_dialog.present(); + } + } } diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala index 87657b37..32b69835 100644 --- a/main/src/ui/conversation_view_controller.vala +++ b/main/src/ui/conversation_view_controller.vala @@ -37,8 +37,8 @@ public class ConversationViewController : Object { this.app = GLib.Application.get_default() as Application; this.chat_input_controller = new ChatInputController(view.chat_input, stream_interactor); - chat_input_controller.activate_last_message_correction.connect(() => view.conversation_frame.activate_last_message_correction()); - chat_input_controller.file_picker_selected.connect(() => open_file_picker()); + chat_input_controller.activate_last_message_correction.connect(view.conversation_frame.activate_last_message_correction); + chat_input_controller.file_picker_selected.connect(open_file_picker); chat_input_controller.clipboard_pasted.connect(on_clipboard_paste); view.conversation_frame.init(stream_interactor); diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala index f765d4d9..abefccac 100644 --- a/main/src/ui/global_search.vala +++ b/main/src/ui/global_search.vala @@ -28,54 +28,60 @@ public class GlobalSearch : Overlay { search_entry.search_changed.connect(() => { set_search(search_entry.text); }); - search_entry.notify["text"].connect_after(() => { update_auto_complete(); }); - search_entry.notify["cursor-position"].connect_after(() => { update_auto_complete(); }); - - results_scrolled.vadjustment.notify["value"].connect(() => { - if (results_scrolled.vadjustment.upper - (results_scrolled.vadjustment.value + results_scrolled.vadjustment.page_size) < 100) { - if (!reloading_mutex.trylock()) return; - Gee.List new_messages = stream_interactor.get_module(SearchProcessor.IDENTITY).match_messages(search, loaded_results); - if (new_messages.size == 0) { - reloading_mutex.unlock(); - return; - } - loaded_results += new_messages.size; - append_messages(new_messages); + search_entry.notify["text"].connect_after(update_auto_complete); + search_entry.notify["cursor-position"].connect_after(update_auto_complete); + + results_scrolled.vadjustment.notify["value"].connect(on_scrolled_window_vadjustment_value); + results_scrolled.vadjustment.notify["upper"].connect_after(on_scrolled_window_vadjustment_upper); + + event.connect(on_event); + + return this; + } + + private void on_scrolled_window_vadjustment_value() { + if (results_scrolled.vadjustment.upper - (results_scrolled.vadjustment.value + results_scrolled.vadjustment.page_size) < 100) { + if (!reloading_mutex.trylock()) return; + Gee.List new_messages = stream_interactor.get_module(SearchProcessor.IDENTITY).match_messages(search, loaded_results); + if (new_messages.size == 0) { + reloading_mutex.unlock(); + return; } - }); - results_scrolled.vadjustment.notify["upper"].connect_after(() => { - reloading_mutex.trylock(); - reloading_mutex.unlock(); - }); + loaded_results += new_messages.size; + append_messages(new_messages); + } + } - event.connect((event) => { - if (auto_complete_overlay.visible) { - if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Up) { - var row = auto_complete_list.get_selected_row(); - var index = row == null ? -1 : row.get_index() - 1; - if (index == -1) index = (int)auto_complete_list.get_children().length() - 1; - auto_complete_list.select_row(auto_complete_list.get_row_at_index(index)); - return true; - } - if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Down) { - var row = auto_complete_list.get_selected_row(); - var index = row == null ? 0 : row.get_index() + 1; - if (index == auto_complete_list.get_children().length()) index = 0; - auto_complete_list.select_row(auto_complete_list.get_row_at_index(index)); - return true; - } - if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Tab || + private void on_scrolled_window_vadjustment_upper() { + reloading_mutex.trylock(); + reloading_mutex.unlock(); + } + + private bool on_event(Gdk.Event event) { + if (auto_complete_overlay.visible) { + if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Up) { + var row = auto_complete_list.get_selected_row(); + var index = row == null ? -1 : row.get_index() - 1; + if (index == -1) index = (int)auto_complete_list.get_children().length() - 1; + auto_complete_list.select_row(auto_complete_list.get_row_at_index(index)); + return true; + } + if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Down) { + var row = auto_complete_list.get_selected_row(); + var index = row == null ? 0 : row.get_index() + 1; + if (index == auto_complete_list.get_children().length()) index = 0; + auto_complete_list.select_row(auto_complete_list.get_row_at_index(index)); + return true; + } + if (event.type == Gdk.EventType.KEY_PRESS && event.key.keyval == Gdk.Key.Tab || event.type == Gdk.EventType.KEY_RELEASE && event.key.keyval == Gdk.Key.Return) { - auto_complete_list.get_selected_row().activate(); - return true; - } + auto_complete_list.get_selected_row().activate(); + return true; } - // TODO: Handle cursor movement in results - // TODO: Direct all keystrokes to text input - return false; - }); - - return this; + } + // TODO: Handle cursor movement in results + // TODO: Direct all keystrokes to text input + return false; } private void update_auto_complete() { diff --git a/main/src/ui/occupant_menu/view.vala b/main/src/ui/occupant_menu/view.vala index 4675dca4..ebad6f09 100644 --- a/main/src/ui/occupant_menu/view.vala +++ b/main/src/ui/occupant_menu/view.vala @@ -11,8 +11,9 @@ public class View : Popover { private Conversation conversation; private Stack stack = new Stack() { vhomogeneous=false, visible=true }; + private Box list_box = new Box(Orientation.VERTICAL, 1) { visible=true }; private List? list = null; - private ListBox invite_list; + private ListBox invite_list = new ListBox() { visible=true }; private Box? jid_menu = null; private Jid? selected_jid; @@ -21,37 +22,12 @@ public class View : Popover { this.stream_interactor = stream_interactor; this.conversation = conversation; - Box list_box = new Box(Orientation.VERTICAL, 1) { visible=true }; - this.show.connect(() => { - if (list == null) { - list = new List(stream_interactor, conversation) { visible=true }; - list_box.add(list); - list_box.reorder_child(list, 0); + this.show.connect(initialize_list); - list.list_box.row_activated.connect((row) => { - ListRow list_row = row as ListRow; - show_menu(list_row.jid, list_row.name_label.label); - }); - } - }); - - invite_list = new ListBox() { visible=true }; invite_list.add(new ListRow.label("+", _("Invite")) {visible=true}); list_box.add(invite_list); - invite_list.row_activated.connect((row) => { - hide(); - Gee.List acc_list = new ArrayList(Account.equals_func); - acc_list.add(conversation.account); - SelectContactDialog add_chat_dialog = new SelectContactDialog(stream_interactor, acc_list); - add_chat_dialog.set_transient_for((Window) get_toplevel()); - add_chat_dialog.title = _("Invite to Conference"); - add_chat_dialog.ok_button.label = _("Invite"); - add_chat_dialog.selected.connect((account, jid) => { - stream_interactor.get_module(MucManager.IDENTITY).invite(conversation.account, conversation.counterpart, jid); - }); - add_chat_dialog.present(); - }); + invite_list.row_activated.connect(on_invite_clicked); stack.add_named(list_box, "list"); add(stack); @@ -67,6 +43,19 @@ public class View : Popover { invite_list.unselect_all(); } + private void initialize_list() { + if (list == null) { + list = new List(stream_interactor, conversation) { visible=true }; + list_box.add(list); + list_box.reorder_child(list, 0); + + list.list_box.row_activated.connect((row) => { + ListRow list_row = row as ListRow; + show_menu(list_row.jid, list_row.name_label.label); + }); + } + } + private void show_list() { if (list != null) list.list_box.unselect_all(); stack.transition_type = StackTransitionType.SLIDE_RIGHT; @@ -146,6 +135,20 @@ public class View : Popover { stream_interactor.get_module(MucManager.IDENTITY).change_role(conversation.account, conversation.counterpart, selected_jid.resourcepart, role); } + + private void on_invite_clicked() { + hide(); + Gee.List acc_list = new ArrayList(Account.equals_func); + acc_list.add(conversation.account); + SelectContactDialog add_chat_dialog = new SelectContactDialog(stream_interactor, acc_list); + add_chat_dialog.set_transient_for((Window) get_toplevel()); + add_chat_dialog.title = _("Invite to Conference"); + add_chat_dialog.ok_button.label = _("Invite"); + add_chat_dialog.selected.connect((account, jid) => { + stream_interactor.get_module(MucManager.IDENTITY).invite(conversation.account, conversation.counterpart, jid); + }); + add_chat_dialog.present(); + } } } -- cgit v1.2.3-54-g00ecf