Fix compiler warnings ('cast between incompatible function types') by not connecting closures

This commit is contained in:
fiaxh 2021-10-12 16:23:25 +02:00
parent 76e425ed27
commit bea85c8ab5
5 changed files with 105 additions and 88 deletions

View File

@ -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 {

View File

@ -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();
}
}
}

View File

@ -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);

View File

@ -28,56 +28,62 @@ 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(); });
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<MessageItem> 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);
}
});
results_scrolled.vadjustment.notify["upper"].connect_after(() => {
reloading_mutex.trylock();
reloading_mutex.unlock();
});
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((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;
}
}
// TODO: Handle cursor movement in results
// TODO: Direct all keystrokes to text input
return false;
});
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<MessageItem> 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);
}
}
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;
}
}
// TODO: Handle cursor movement in results
// TODO: Direct all keystrokes to text input
return false;
}
private void update_auto_complete() {
Gee.List<SearchSuggestion> suggestions = stream_interactor.get_module(SearchProcessor.IDENTITY).suggest_auto_complete(search_entry.text, search_entry.cursor_position);
auto_complete_overlay.visible = suggestions.size > 0;

View File

@ -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<Account> acc_list = new ArrayList<Account>(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<Account> acc_list = new ArrayList<Account>(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();
}
}
}