diff options
5 files changed, 45 insertions, 4 deletions
diff --git a/main/data/add_conversation/select_jid_fragment.ui b/main/data/add_conversation/select_jid_fragment.ui index 787add9f..64c39a0b 100644 --- a/main/data/add_conversation/select_jid_fragment.ui +++ b/main/data/add_conversation/select_jid_fragment.ui @@ -68,6 +68,17 @@ </child> </object> </child> + <child> + <object class="GtkButton" id="filter_online_button"> + <property name="visible">0</property> + <child> + <object class="GtkImage"> + <property name="icon-name">dino-status-chat</property> + <property name="icon-size">normal</property> + </object> + </child> + </object> + </child> </object> </child> </object> diff --git a/main/src/ui/add_conversation/add_conference_dialog.vala b/main/src/ui/add_conversation/add_conference_dialog.vala index 4b7364c7..a78a8aad 100644 --- a/main/src/ui/add_conversation/add_conference_dialog.vala +++ b/main/src/ui/add_conversation/add_conference_dialog.vala @@ -93,7 +93,7 @@ public class AddConferenceDialog : Gtk.Dialog { conference_list_box = conference_list.get_list_box(); conference_list_box.row_activated.connect(() => { ok_button.clicked(); }); - select_fragment = new SelectJidFragment(stream_interactor, conference_list_box, stream_interactor.get_accounts()); + select_fragment = new SelectJidFragment(stream_interactor, conference_list_box, stream_interactor.get_accounts(), true); select_fragment.add_jid.connect((row) => { AddGroupchatDialog dialog = new AddGroupchatDialog(stream_interactor); dialog.set_transient_for(this); diff --git a/main/src/ui/add_conversation/list_row.vala b/main/src/ui/add_conversation/list_row.vala index 8e4cbb9b..02302e25 100644 --- a/main/src/ui/add_conversation/list_row.vala +++ b/main/src/ui/add_conversation/list_row.vala @@ -14,6 +14,7 @@ public class ListRow : Widget { public Image status_dot; public Label via_label; + public string? status_str; public Jid? jid; public Account? account; @@ -50,6 +51,7 @@ public class ListRow : Widget { case "xa": this.status_dot.set_from_icon_name("dino-status-away"); break; case "chat": this.status_dot.set_from_icon_name("dino-status-chat"); break; } + status_str = presence_str; } } else status_dot.set_from_icon_name("dino-status-offline"); diff --git a/main/src/ui/add_conversation/select_contact_dialog.vala b/main/src/ui/add_conversation/select_contact_dialog.vala index b18f4c10..eba7136b 100644 --- a/main/src/ui/add_conversation/select_contact_dialog.vala +++ b/main/src/ui/add_conversation/select_contact_dialog.vala @@ -73,7 +73,7 @@ public class SelectContactDialog : Gtk.Dialog { roster_list = new RosterList(stream_interactor, accounts); roster_list_box = roster_list.get_list_box(); roster_list_box.row_activated.connect(() => { ok_button.clicked(); }); - select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list_box, accounts); + select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list_box, accounts, false); select_jid_fragment.add_jid.connect((row) => { AddContactDialog add_contact_dialog = new AddContactDialog(stream_interactor); add_contact_dialog.set_transient_for(this); diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala index e0682e29..36b6bdae 100644 --- a/main/src/ui/add_conversation/select_jid_fragment.vala +++ b/main/src/ui/add_conversation/select_jid_fragment.vala @@ -20,6 +20,7 @@ public class SelectJidFragment : Gtk.Box { [GtkChild] private unowned Box box; [GtkChild] private unowned Button add_button; [GtkChild] private unowned Button remove_button; + [GtkChild] private unowned Button filter_online_button; private StreamInteractor stream_interactor; private Gee.List<Account> accounts; @@ -27,14 +28,18 @@ public class SelectJidFragment : Gtk.Box { private ListBox list; private string[]? filter_values; + private bool filter_online_toggled = false; - public SelectJidFragment(StreamInteractor stream_interactor, ListBox list, Gee.List<Account> accounts) { + public SelectJidFragment(StreamInteractor stream_interactor, ListBox list, Gee.List<Account> accounts, bool is_conf_dialog) { this.stream_interactor = stream_interactor; this.list = list; this.accounts = accounts; list.activate_on_single_click = false; list.vexpand = true; + + if(!is_conf_dialog) filter_online_button.visible = true; + filter_online_button.set_tooltip_text(_("Only showing online users is not toggled on.")); box.append(list); list.set_sort_func(sort); @@ -49,6 +54,20 @@ public class SelectJidFragment : Gtk.Box { if (list_row == null) return; remove_jid(list_row.child as ListRow); }); + filter_online_button.clicked.connect(() => { + if(!filter_online_toggled){ + filter_online_toggled = true; + list.set_filter_func(filter_online); + Util.force_css(filter_online_button, "* {border: 2px solid limegreen;}"); + filter_online_button.set_tooltip_text(_("Only showing online users is toggled on.")); + } + else{ + filter_online_toggled = false; + list.set_filter_func(filter); + Util.force_css(filter_online_button, "* {border: initial;}"); + filter_online_button.set_tooltip_text(_("Only showing online users is not toggled on.")); + } + }); } public void set_filter(string str) { @@ -59,6 +78,7 @@ public class SelectJidFragment : Gtk.Box { filter_values = str == "" ? null : str.split(" "); list.invalidate_filter(); + filter_online_button.sensitive = str.length > 0 ? false : true; try { Jid parsed_jid = new Jid(str); @@ -114,6 +134,15 @@ public class SelectJidFragment : Gtk.Box { return true; } + private bool filter_online(ListBoxRow r){ + ListRow? row = (r.child as ListRow); + if (row == null) return true; + if(row.status_str == null){ + return false; + } + return true; + } + private void header(ListBoxRow row, ListBoxRow? before_row) { if (row.get_header() == null && before_row != null) { row.set_header(new Separator(Orientation.HORIZONTAL)); @@ -125,7 +154,6 @@ public class SelectJidFragment : Gtk.Box { public AddListRow(StreamInteractor stream_interactor, Jid jid, Account account) { this.account = account; this.jid = jid; - name_label.label = jid.to_string(); if (stream_interactor.get_accounts().size > 1) { via_label.label = account.bare_jid.to_string(); |