aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/add_conversation/chat
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-10-28 22:02:32 +0200
committerfiaxh <git@mx.ax.lt>2017-10-31 15:41:45 +0100
commitd9b91206c0291fa8aa58df572292784a4f8ff878 (patch)
tree09721f9fdffbb87ec8ab25fd1c44a7bc535fffab /main/src/ui/add_conversation/chat
parent7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (diff)
downloaddino-d9b91206c0291fa8aa58df572292784a4f8ff878.tar.gz
dino-d9b91206c0291fa8aa58df572292784a4f8ff878.zip
Keep MUC join dialog open until joined, show errors
Diffstat (limited to 'main/src/ui/add_conversation/chat')
-rw-r--r--main/src/ui/add_conversation/chat/add_contact_dialog.vala58
-rw-r--r--main/src/ui/add_conversation/chat/dialog.vala78
-rw-r--r--main/src/ui/add_conversation/chat/roster_list.vala94
3 files changed, 0 insertions, 230 deletions
diff --git a/main/src/ui/add_conversation/chat/add_contact_dialog.vala b/main/src/ui/add_conversation/chat/add_contact_dialog.vala
deleted file mode 100644
index 9c14883a..00000000
--- a/main/src/ui/add_conversation/chat/add_contact_dialog.vala
+++ /dev/null
@@ -1,58 +0,0 @@
-using Gee;
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui.AddConversation.Chat {
-
-[GtkTemplate (ui = "/im/dino/add_conversation/add_contact_dialog.ui")]
-protected class AddContactDialog : Gtk.Dialog {
-
- public Account? account {
- get { return account_combobox.selected; }
- set { account_combobox.selected = value; }
- }
-
- public string jid {
- get { return jid_entry.text; }
- set { jid_entry.text = value; }
- }
-
- [GtkChild] private AccountComboBox account_combobox;
- [GtkChild] private Button ok_button;
- [GtkChild] private Button cancel_button;
- [GtkChild] private Entry jid_entry;
- [GtkChild] private Entry alias_entry;
- [GtkChild] private CheckButton subscribe_checkbutton;
-
- private StreamInteractor stream_interactor;
-
- public AddContactDialog(StreamInteractor stream_interactor) {
- Object(use_header_bar : 1);
- this.stream_interactor = stream_interactor;
- account_combobox.initialize(stream_interactor);
-
- cancel_button.clicked.connect(() => { close(); });
- ok_button.clicked.connect(on_ok_button_clicked);
- jid_entry.changed.connect(on_jid_entry_changed);
- }
-
- private void on_ok_button_clicked() {
- string? alias = alias_entry.text == "" ? null : alias_entry.text;
- Jid jid = new Jid(jid_entry.text);
- stream_interactor.get_module(RosterManager.IDENTITY).add_jid(account, jid, alias);
- if (subscribe_checkbutton.active) {
- stream_interactor.get_module(PresenceManager.IDENTITY).request_subscription(account, jid);
- }
- close();
- }
-
- private void on_jid_entry_changed() {
- Jid parsed_jid = Jid.parse(jid_entry.text);
- bool sensitive = parsed_jid != null && parsed_jid.resourcepart == null &&
- stream_interactor.get_module(RosterManager.IDENTITY).get_roster_item(account, parsed_jid) == null;
- ok_button.set_sensitive(sensitive);
- }
-}
-
-}
diff --git a/main/src/ui/add_conversation/chat/dialog.vala b/main/src/ui/add_conversation/chat/dialog.vala
deleted file mode 100644
index 361f70ba..00000000
--- a/main/src/ui/add_conversation/chat/dialog.vala
+++ /dev/null
@@ -1,78 +0,0 @@
-using Gee;
-using Gdk;
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui.AddConversation.Chat {
-
-public class Dialog : Gtk.Dialog {
-
- public signal void selected(Account account, Jid jid);
-
- public Button ok_button;
-
- private RosterList roster_list;
- private SelectJidFragment select_jid_fragment;
- private StreamInteractor stream_interactor;
- private Gee.List<Account> accounts;
-
- public Dialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
- Object(use_header_bar : 1);
- modal = true;
-
- this.stream_interactor = stream_interactor;
- this.accounts = accounts;
-
- setup_headerbar();
- setup_view();
- }
-
- public void set_filter(string str) {
- select_jid_fragment.set_filter(str);
- }
-
- private void setup_headerbar() {
- HeaderBar header_bar = get_header_bar() as HeaderBar;
- header_bar.show_close_button = false;
-
- Button cancel_button = new Button();
- cancel_button.set_label(_("Cancel"));
- cancel_button.visible = true;
- header_bar.pack_start(cancel_button);
-
- ok_button = new Button();
- ok_button.get_style_context().add_class("suggested-action");
- ok_button.sensitive = false;
- ok_button.visible = true;
- header_bar.pack_end(ok_button);
-
- cancel_button.clicked.connect(() => { close(); });
- ok_button.clicked.connect(() => {
- ListRow? selected_row = roster_list.get_selected_row() as ListRow;
- if (selected_row != null) selected(selected_row.account, selected_row.jid);
- close();
- });
- }
-
- private void setup_view() {
- roster_list = new RosterList(stream_interactor, accounts);
- roster_list.row_activated.connect(() => { ok_button.clicked(); });
- select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list, accounts);
- select_jid_fragment.add_jid.connect((row) => {
- AddContactDialog add_contact_dialog = new AddContactDialog(stream_interactor);
- add_contact_dialog.set_transient_for(this);
- add_contact_dialog.present();
- });
- select_jid_fragment.remove_jid.connect((row) => {
- ListRow list_row = roster_list.get_selected_row() as ListRow;
- stream_interactor.get_module(RosterManager.IDENTITY).remove_jid(list_row.account, list_row.jid);
- });
- select_jid_fragment.notify["done"].connect(() => {
- ok_button.sensitive = select_jid_fragment.done;
- });
- get_content_area().add(select_jid_fragment);
- }
-}
-
-}
diff --git a/main/src/ui/add_conversation/chat/roster_list.vala b/main/src/ui/add_conversation/chat/roster_list.vala
deleted file mode 100644
index f4b42cc4..00000000
--- a/main/src/ui/add_conversation/chat/roster_list.vala
+++ /dev/null
@@ -1,94 +0,0 @@
-using Gee;
-using Gtk;
-
-using Dino.Entities;
-using Xmpp;
-
-namespace Dino.Ui.AddConversation.Chat {
-
-protected class RosterList : FilterableList {
-
- public signal void conversation_selected(Conversation? conversation);
- private StreamInteractor stream_interactor;
- private Gee.List<Account> accounts;
- private ulong[] handler_ids = new ulong[0];
-
- private HashMap<Account, HashMap<Jid, ListRow>> rows = new HashMap<Account, HashMap<Jid, ListRow>>(Account.hash_func, Account.equals_func);
-
- public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
- this.stream_interactor = stream_interactor;
- this.accounts = accounts;
-
- set_filter_func(filter);
- set_header_func(header);
- set_sort_func(sort);
-
- 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;});
- }
- });
- 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;});
- }
- });
- destroy.connect(() => {
- foreach (ulong handler_id in handler_ids) stream_interactor.get_module(RosterManager.IDENTITY).disconnect(handler_id);
- });
-
- foreach (Account a in accounts) fetch_roster_items(a);
- }
-
- private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
- if (rows.has_key(account) && rows[account].has_key(jid)) {
- remove(rows[account][jid]);
- rows[account].unset(jid);
- }
- }
-
- private void on_updated_roster_item(Account account, Jid jid, Roster.Item roster_item) {
- on_removed_roster_item(account, jid, roster_item);
- ListRow row = new ListRow.from_jid(stream_interactor, new Jid(roster_item.jid), account, accounts.size > 1);
- rows[account][jid] = row;
- add(row);
- invalidate_sort();
- invalidate_filter();
- }
-
- private void fetch_roster_items(Account account) {
- rows[account] = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
- foreach (Roster.Item roster_item in stream_interactor.get_module(RosterManager.IDENTITY).get_roster(account)) {
- on_updated_roster_item(account, new Jid(roster_item.jid), roster_item);
- }
- }
-
- private void header(ListBoxRow row, ListBoxRow? before_row) {
- if (row.get_header() == null && before_row != null) {
- row.set_header(new Separator(Orientation.HORIZONTAL));
- }
- }
-
- private bool filter(ListBoxRow r) {
- if (r.get_type().is_a(typeof(ListRow))) {
- ListRow row = r as ListRow;
- if (filter_values != null) {
- foreach (string filter in filter_values) {
- if (!(row.name_label.label.down().contains(filter.down()) ||
- row.jid.to_string().down().contains(filter.down()))) {
- return false;
- }
- }
- }
- }
- return true;
- }
-
- public override int sort(ListBoxRow row1, ListBoxRow row2) {
- ListRow c1 = (row1 as ListRow);
- ListRow c2 = (row2 as ListRow);
- return c1.name_label.label.collate(c2.name_label.label);
- }
-}
-
-}