diff options
author | fiaxh <git@mx.ax.lt> | 2017-11-11 21:29:13 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-11-16 17:43:00 +0100 |
commit | 3f531d6b91edab6c79fa232143db828bad13853c (patch) | |
tree | 1083046c94e0b4a43cf16ac4a388fcea8ef91e84 /main/src | |
parent | 1d0745177e7a116455811dfd26e07b848cb89b75 (diff) | |
download | dino-3f531d6b91edab6c79fa232143db828bad13853c.tar.gz dino-3f531d6b91edab6c79fa232143db828bad13853c.zip |
Read+(write) stream async
Diffstat (limited to 'main/src')
18 files changed, 58 insertions, 117 deletions
diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala index 5e5698fb..d840ff2a 100644 --- a/main/src/ui/add_conversation/add_conference_dialog.vala +++ b/main/src/ui/add_conversation/add_conference_dialog.vala @@ -36,7 +36,7 @@ public class AddConferenceDialog : Gtk.Dialog { setup_conference_details_view(); show_jid_add_view(); - stream_interactor.get_module(MucManager.IDENTITY).joined.connect((account, jid, nick) => { Idle.add(() => { on_joined(account, jid, nick); return false; } ); }); + stream_interactor.get_module(MucManager.IDENTITY).joined.connect(on_joined); } private void show_jid_add_view() { diff --git a/main/src/ui/add_conversation/conference_details_fragment.vala b/main/src/ui/add_conversation/conference_details_fragment.vala index 064d1053..fbe9245d 100644 --- a/main/src/ui/add_conversation/conference_details_fragment.vala +++ b/main/src/ui/add_conversation/conference_details_fragment.vala @@ -99,12 +99,7 @@ protected class ConferenceDetailsFragment : Box { jid_entry.key_release_event.connect(() => { done = true; return false; }); // just for notifying nick_entry.key_release_event.connect(() => { done = true; return false; }); - stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect((account, jid, error) => { - Idle.add(() => { - on_enter_error(account, jid, error); - return false; - }); - }); + stream_interactor.get_module(MucManager.IDENTITY).enter_error.connect(on_enter_error); notification_button.clicked.connect(() => { notification_revealer.set_reveal_child(false); }); ok_button.clicked.connect(() => { ok_button.label = _("Joining..."); diff --git a/main/src/ui/add_conversation/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala index 570166b1..8338558c 100644 --- a/main/src/ui/add_conversation/conference_list.vala +++ b/main/src/ui/add_conversation/conference_list.vala @@ -21,11 +21,8 @@ protected class ConferenceList : FilterableList { set_sort_func(sort); stream_interactor.get_module(MucManager.IDENTITY).bookmarks_updated.connect((account, conferences) => { - Idle.add(() => { - lists[account] = conferences; - refresh_conferences(); - return false; - }); + lists[account] = conferences; + refresh_conferences(); }); foreach (Account account in stream_interactor.get_accounts()) { @@ -43,11 +40,8 @@ protected class ConferenceList : FilterableList { } private void on_conference_bookmarks_received(Core.XmppStream stream, Account account, Gee.List<Xep.Bookmarks.Conference> conferences) { - Idle.add(() => { - lists[account] = conferences; - refresh_conferences(); - return false; - }); + lists[account] = conferences; + refresh_conferences(); } private void header(ListBoxRow row, ListBoxRow? before_row) { diff --git a/main/src/ui/add_conversation/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala index 70e4bc14..3107dc47 100644 --- a/main/src/ui/add_conversation/roster_list.vala +++ b/main/src/ui/add_conversation/roster_list.vala @@ -25,12 +25,12 @@ protected class RosterList : FilterableList { handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).removed_roster_item.connect( (account, jid, roster_item) => { if (accounts.contains(account)) { - Idle.add(() => { on_removed_roster_item(account, jid, roster_item); return false;}); + on_removed_roster_item(account, jid, roster_item); } }); handler_ids += stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect( (account, jid, roster_item) => { if (accounts.contains(account)) { - Idle.add(() => { on_updated_roster_item(account, jid, roster_item); return false;}); + on_updated_roster_item(account, jid, roster_item); } }); destroy.connect(() => { diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index e4fdd9eb..b7809890 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -23,7 +23,7 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { provider.load_from_resource("/im/dino/theme.css"); StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, STYLE_PROVIDER_PRIORITY_APPLICATION); - activate.connect(() => { + startup.connect(() => { if (window == null) { create_set_app_menu(); window = new UnifiedWindow(this, stream_interactor); diff --git a/main/src/ui/contact_details/dialog.vala b/main/src/ui/contact_details/dialog.vala index 2f1fc81e..61044857 100644 --- a/main/src/ui/contact_details/dialog.vala +++ b/main/src/ui/contact_details/dialog.vala @@ -111,13 +111,10 @@ public class Dialog : Gtk.Dialog { row.add(widget); categories[category].add(list_row); - Idle.add(() => { - int pref_height, pref_width; - get_content_area().get_preferred_height(null, out pref_height); - get_preferred_width(out pref_width, null); - resize(pref_width, int.min(500, pref_height)); - return false; - }); + int pref_height, pref_width; + get_content_area().get_preferred_height(null, out pref_height); + get_preferred_width(out pref_width, null); + resize(pref_width, int.min(500, pref_height)); } private void add_category(string category) { diff --git a/main/src/ui/contact_details/muc_config_form_provider.vala b/main/src/ui/contact_details/muc_config_form_provider.vala index 47bbbe28..d4598265 100644 --- a/main/src/ui/contact_details/muc_config_form_provider.vala +++ b/main/src/ui/contact_details/muc_config_form_provider.vala @@ -21,13 +21,10 @@ public class MucConfigFormProvider : Plugins.ContactDetailsProvider, Object { if (stream == null) return; stream_interactor.get_module(MucManager.IDENTITY).get_config_form(conversation.account, conversation.counterpart, (jid, data_form) => { contact_details.save.connect(() => { data_form.submit(); }); - Idle.add(() => { - for (int i = 0; i < data_form.fields.size; i++) { - DataForms.DataForm.Field field = data_form.fields[i]; - add_field(field, contact_details); - } - return false; - }); + for (int i = 0; i < data_form.fields.size; i++) { + DataForms.DataForm.Field field = data_form.fields[i]; + add_field(field, contact_details); + } }); } } diff --git a/main/src/ui/conversation_selector/conversation_row.vala b/main/src/ui/conversation_selector/conversation_row.vala index 13f8a8f7..64b2aeaf 100644 --- a/main/src/ui/conversation_selector/conversation_row.vala +++ b/main/src/ui/conversation_selector/conversation_row.vala @@ -70,13 +70,10 @@ public abstract class ConversationRow : ListBoxRow { bool counterpart_online = stream_interactor.get_module(PresenceManager.IDENTITY).get_full_jids(conversation.counterpart, conversation.account) != null; bool greyscale = !self_online || !counterpart_online; - Idle.add(() => { - Pixbuf pixbuf = ((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor)) + Pixbuf pixbuf = ((new AvatarGenerator(AVATAR_SIZE, AVATAR_SIZE, image.scale_factor)) .set_greyscale(greyscale) .draw_conversation(stream_interactor, conversation)); - Util.image_set_from_scaled_pixbuf(image, pixbuf, image.get_scale_factor()); - return false; - }); + Util.image_set_from_scaled_pixbuf(image, pixbuf, image.get_scale_factor()); } protected void update_name_label(string? new_name = null) { diff --git a/main/src/ui/conversation_selector/list.vala b/main/src/ui/conversation_selector/list.vala index dbad72a8..08958cb5 100644 --- a/main/src/ui/conversation_selector/list.vala +++ b/main/src/ui/conversation_selector/list.vala @@ -22,35 +22,21 @@ public class List : ListBox { set_header_func(header); set_sort_func(sort); - stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect((conversation) => { - Idle.add(() => { add_conversation(conversation); return false; }); - }); - stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect((conversation) => { - Idle.add(() => { remove_conversation(conversation); return false; }); - }); - stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect((message, conversation) => { - Idle.add(() => { on_message_received(message, conversation); return false; }); - }); - stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect((message, conversation) => { - Idle.add(() => { on_message_received(message, conversation); return false; }); - }); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(add_conversation); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(remove_conversation); + stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(on_message_received); + stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(on_message_received); stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((show, jid, account) => { - Idle.add(() => { - foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_conversations_for_presence(show, account)) { - if (rows.has_key(conversation)) rows[conversation].on_show_received(show); - } - return false; - }); + foreach (Conversation conversation in stream_interactor.get_module(ConversationManager.IDENTITY).get_conversations_for_presence(show, account)) { + if (rows.has_key(conversation)) rows[conversation].on_show_received(show); + } }); stream_interactor.get_module(AvatarManager.IDENTITY).received_avatar.connect((avatar, jid, account) => { - Idle.add(() => { - Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account); - if (conversation != null && rows.has_key(conversation)) { - ChatRow row = rows[conversation] as ChatRow; - if (row != null) row.update_avatar(); - } - return false; - }); + Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account); + if (conversation != null && rows.has_key(conversation)) { + ChatRow row = rows[conversation] as ChatRow; + if (row != null) row.update_avatar(); + } }); Timeout.add_seconds(60, () => { foreach (ConversationRow row in rows.values) row.update(); diff --git a/main/src/ui/conversation_summary/chat_state_populator.vala b/main/src/ui/conversation_summary/chat_state_populator.vala index e491fe44..6f397249 100644 --- a/main/src/ui/conversation_summary/chat_state_populator.vala +++ b/main/src/ui/conversation_summary/chat_state_populator.vala @@ -21,12 +21,12 @@ class ChatStatePopulator : Plugins.ConversationItemPopulator, Object { stream_interactor.get_module(CounterpartInteractionManager.IDENTITY).received_state.connect((account, jid, state) => { if (current_conversation != null && current_conversation.account.equals(account) && current_conversation.counterpart.equals_bare(jid)) { - Idle.add(() => { update_chat_state(account, jid, state); return false; }); + update_chat_state(account, jid, state); } }); stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect((message, conversation) => { if (conversation.equals(current_conversation)) { - Idle.add(() => { update_chat_state(conversation.account, conversation.counterpart); return false; }); + update_chat_state(conversation.account, conversation.counterpart); } }); } diff --git a/main/src/ui/conversation_summary/conversation_item_skeleton.vala b/main/src/ui/conversation_summary/conversation_item_skeleton.vala index 03114227..1eb76840 100644 --- a/main/src/ui/conversation_summary/conversation_item_skeleton.vala +++ b/main/src/ui/conversation_summary/conversation_item_skeleton.vala @@ -39,7 +39,7 @@ public class ConversationItemSkeleton : Grid { } else { set_title_widget(widget); } - item.notify["mark"].connect_after(() => { Idle.add(() => { update_received(); return false; }); }); + item.notify["mark"].connect_after(update_received); update_received(); } diff --git a/main/src/ui/conversation_summary/message_populator.vala b/main/src/ui/conversation_summary/message_populator.vala index f6d55a92..dc4b5770 100644 --- a/main/src/ui/conversation_summary/message_populator.vala +++ b/main/src/ui/conversation_summary/message_populator.vala @@ -19,12 +19,8 @@ public class MessagePopulator : Object { app.plugin_registry.register_message_display(new SlashmeMessageDisplay(stream_interactor)); - stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect((message, conversation) => { - Idle.add(() => { handle_message(message, conversation); return false; }); - }); - stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect((message, conversation) => { - Idle.add(() => { handle_message(message, conversation); return false; }); - }); + stream_interactor.get_module(MessageProcessor.IDENTITY).message_received.connect(handle_message); + stream_interactor.get_module(MessageProcessor.IDENTITY).message_sent.connect(handle_message); } public void init(Conversation conversation, Plugins.ConversationItemCollection item_collection) { diff --git a/main/src/ui/conversation_titlebar/file_entry.vala b/main/src/ui/conversation_titlebar/file_entry.vala index cb7d0807..0f0eb6d6 100644 --- a/main/src/ui/conversation_titlebar/file_entry.vala +++ b/main/src/ui/conversation_titlebar/file_entry.vala @@ -55,12 +55,9 @@ public class FileWidget : Button, Plugins.ConversationTitlebarWidget { } public void on_upload_available(Account account) { - Idle.add(() => { - if (conversation != null && conversation.account.equals(account)) { - visible = true; - } - return false; - }); + if (conversation != null && conversation.account.equals(account)) { + visible = true; + } } public new void set_conversation(Conversation conversation) { diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index bd8fe8c9..baa036a8 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -35,12 +35,9 @@ public class ConversationTitlebar : Gtk.HeaderBar { stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => { - Idle.add(() => { - if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { - update_subtitle(subject); - } - return false; - }); + if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { + update_subtitle(subject); + } }); } diff --git a/main/src/ui/manage_accounts/account_row.vala b/main/src/ui/manage_accounts/account_row.vala index 911d48f4..8ac2c213 100644 --- a/main/src/ui/manage_accounts/account_row.vala +++ b/main/src/ui/manage_accounts/account_row.vala @@ -21,16 +21,14 @@ public class AccountRow : Gtk.ListBoxRow { jid_label.set_label(account.bare_jid.to_string()); stream_interactor.connection_manager.connection_error.connect((account, error) => { - Idle.add(() => { - if (account.equals(this.account)) update_warning_icon(); - return false; - }); + if (account.equals(this.account)) { + update_warning_icon(); + } }); stream_interactor.connection_manager.connection_state_changed.connect((account, state) => { - Idle.add(() => { - if (account.equals(this.account)) update_warning_icon(); - return false; - }); + if (account.equals(this.account)) { + update_warning_icon(); + } }); } diff --git a/main/src/ui/manage_accounts/dialog.vala b/main/src/ui/manage_accounts/dialog.vala index 6fdce712..f82e90c0 100644 --- a/main/src/ui/manage_accounts/dialog.vala +++ b/main/src/ui/manage_accounts/dialog.vala @@ -84,23 +84,16 @@ public class Dialog : Gtk.Dialog { add_account(account); } - stream_interactor.get_module(AvatarManager.IDENTITY).received_avatar.connect((pixbuf, jid, account) => { - Idle.add(() => { - on_received_avatar(pixbuf, jid, account); - return false; - }); - }); + stream_interactor.get_module(AvatarManager.IDENTITY).received_avatar.connect(on_received_avatar); stream_interactor.connection_manager.connection_error.connect((account, error) => { - Idle.add(() => { - if (account.equals(selected_account)) update_status_label(account); - return false; - }); + if (account.equals(selected_account)) { + update_status_label(account); + } }); stream_interactor.connection_manager.connection_state_changed.connect((account, state) => { - Idle.add(() => { - if (account.equals(selected_account)) update_status_label(account); - return false; - }); + if (account.equals(selected_account)) { + update_status_label(account); + } }); if (account_list.get_row_at_index(0) != null) account_list.select_row(account_list.get_row_at_index(0)); diff --git a/main/src/ui/occupant_menu/list.vala b/main/src/ui/occupant_menu/list.vala index 47adccb6..904ab3a7 100644 --- a/main/src/ui/occupant_menu/list.vala +++ b/main/src/ui/occupant_menu/list.vala @@ -25,9 +25,7 @@ public class List : Box { list_box.set_filter_func(filter); search_entry.search_changed.connect(search_changed); - stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect((show, jid, account) => { - Idle.add(() => { on_show_received(show, jid, account); return false; }); - }); + stream_interactor.get_module(PresenceManager.IDENTITY).show_received.connect(on_show_received); stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect(on_updated_roster_item); initialize_for_conversation(conversation); diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 69b530d7..be5b0805 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -40,12 +40,8 @@ public class UnifiedWindow : Window { stream_interactor.account_added.connect((account) => { check_stack(true); }); stream_interactor.account_removed.connect((account) => { check_stack(); }); - stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect( (conversation) => { - Idle.add( () => { check_stack(); return false; }); - }); - stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect( (conversation) => { - Idle.add( () => { check_stack(); return false; }); - }); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(() => check_stack()); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(() => check_stack()); accounts_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("accounts", null); }); conversations_placeholder.primary_button.clicked.connect(() => { get_application().activate_action("add_chat", null); }); conversations_placeholder.secondary_button.clicked.connect(() => { get_application().activate_action("add_conference", null); }); |