aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-10-12 16:23:25 +0200
committerfiaxh <git@lightrise.org>2021-10-12 19:43:57 +0200
commitbea85c8ab5f74d96f37c1b3a6ea1e83edd0de500 (patch)
tree973d1211daa374679d87c27312b4d1d671fe7944 /main
parent76e425ed2705349b201444e78719896419862b00 (diff)
downloaddino-bea85c8ab5f74d96f37c1b3a6ea1e83edd0de500.tar.gz
dino-bea85c8ab5f74d96f37c1b3a6ea1e83edd0de500.zip
Fix compiler warnings ('cast between incompatible function types') by not connecting closures
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/conversation_titlebar/menu_entry.vala14
-rw-r--r--main/src/ui/conversation_view_controller.vala4
-rw-r--r--main/src/ui/global_search.vala94
-rw-r--r--main/src/ui/occupant_menu/view.vala59
4 files changed, 92 insertions, 79 deletions
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<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);
+ 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<MessageItem> 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<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();
+ }
}
}