diff options
Diffstat (limited to 'main/src/ui/add_conversation')
-rw-r--r-- | main/src/ui/add_conversation/conference_list.vala | 26 | ||||
-rw-r--r-- | main/src/ui/add_conversation/select_jid_fragment.vala | 6 |
2 files changed, 25 insertions, 7 deletions
diff --git a/main/src/ui/add_conversation/conference_list.vala b/main/src/ui/add_conversation/conference_list.vala index 181c6219..454362d0 100644 --- a/main/src/ui/add_conversation/conference_list.vala +++ b/main/src/ui/add_conversation/conference_list.vala @@ -15,12 +15,14 @@ protected class ConferenceList { private ListBox list_box = new ListBox(); private HashMap<Account, Set<Conference>> lists = new HashMap<Account, Set<Conference>>(Account.hash_func, Account.equals_func); - private HashMap<Account, HashMap<Jid, Widget>> widgets = new HashMap<Account, HashMap<Jid, Widget>>(Account.hash_func, Account.equals_func); + private HashMap<Account, HashMap<Jid, ListBoxRow>> widgets = new HashMap<Account, HashMap<Jid, ListBoxRow>>(Account.hash_func, Account.equals_func); + + ulong bookmarks_updated_handler_id = -1; public ConferenceList(StreamInteractor stream_interactor) { this.stream_interactor = stream_interactor; - stream_interactor.get_module(MucManager.IDENTITY).bookmarks_updated.connect((account, conferences) => { + bookmarks_updated_handler_id = stream_interactor.get_module(MucManager.IDENTITY).bookmarks_updated.connect((account, conferences) => { lists[account] = conferences; refresh_conferences(); }); @@ -36,13 +38,21 @@ protected class ConferenceList { stream_interactor.get_module(MucManager.IDENTITY).conference_removed.connect(remove_conference); } + ~ConferenceList() { + stream_interactor.get_module(MucManager.IDENTITY).disconnect(bookmarks_updated_handler_id); + stream_interactor.get_module(MucManager.IDENTITY).conference_added.disconnect(add_conference); + stream_interactor.get_module(MucManager.IDENTITY).conference_removed.disconnect(remove_conference); + } + private void add_conference(Account account, Conference conference) { if (!widgets.has_key(account)) { - widgets[account] = new HashMap<Jid, Widget>(Jid.hash_func, Jid.equals_func); + widgets[account] = new HashMap<Jid, ListBoxRow>(Jid.hash_func, Jid.equals_func); } var widget = new ConferenceListRow(stream_interactor, conference, account); - widgets[account][conference.jid] = widget; - list_box.append(widget); + var list_box_row = new ListBoxRow(); + list_box_row.set_child(widget); + widgets[account][conference.jid] = list_box_row; + list_box.append(list_box_row); } private void remove_conference(Account account, Jid jid) { @@ -54,7 +64,11 @@ protected class ConferenceList { public void refresh_conferences() { foreach (Account account in widgets.keys) { - foreach (Jid jid in widgets[account].keys) { + + var account_widgets_cpy = new HashMap<Jid, ListBoxRow>(); + account_widgets_cpy.set_all(widgets[account]); + + foreach (Jid jid in account_widgets_cpy.keys) { remove_conference(account, jid); } } diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala index a6cf0864..25b0b11f 100644 --- a/main/src/ui/add_conversation/select_jid_fragment.vala +++ b/main/src/ui/add_conversation/select_jid_fragment.vala @@ -44,7 +44,11 @@ public class SelectJidFragment : Gtk.Box { list.row_selected.connect(() => { done = true; }); // just for notifying entry.changed.connect(() => { set_filter(entry.text); }); add_button.clicked.connect(() => { add_jid(); }); - remove_button.clicked.connect(() => { remove_jid(list.get_selected_row() as ListRow); }); + remove_button.clicked.connect(() => { + var list_row = list.get_selected_row(); + if (list_row == null) return; + remove_jid(list_row.child as ListRow); + }); } public void set_filter(string str) { |