aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/ui/add_conversation/chat
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-11 23:52:12 +0100
committerMarvin W <git@larma.de>2017-03-11 23:58:35 +0100
commite27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 (patch)
tree80e547d0e02e770e8bcd912e42f8afa753aeb0f6 /libdino/src/ui/add_conversation/chat
parentcd6b904e970291a63551d0f1d80bbd550e778ec8 (diff)
downloaddino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.tar.gz
dino-e27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9.zip
Move UI code into main dir
Diffstat (limited to 'libdino/src/ui/add_conversation/chat')
-rw-r--r--libdino/src/ui/add_conversation/chat/add_contact_dialog.vala56
-rw-r--r--libdino/src/ui/add_conversation/chat/dialog.vala83
-rw-r--r--libdino/src/ui/add_conversation/chat/roster_list.vala79
3 files changed, 0 insertions, 218 deletions
diff --git a/libdino/src/ui/add_conversation/chat/add_contact_dialog.vala b/libdino/src/ui/add_conversation/chat/add_contact_dialog.vala
deleted file mode 100644
index df8fbeb9..00000000
--- a/libdino/src/ui/add_conversation/chat/add_contact_dialog.vala
+++ /dev/null
@@ -1,56 +0,0 @@
-using Gee;
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui.AddConversation.Chat {
-
-[GtkTemplate (ui = "/org/dino-im/add_conversation/add_contact_dialog.ui")]
-protected class AddContactDialog : Gtk.Dialog {
-
- [GtkChild] private ComboBoxText accounts_comboboxtext;
- [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;
-
- foreach (Account account in stream_interactor.get_accounts()) {
- accounts_comboboxtext.append_text(account.bare_jid.to_string());
- }
- accounts_comboboxtext.set_active(0);
-
- 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;
- Account? account = null;
- Jid jid = new Jid(jid_entry.text);
- foreach (Account account2 in stream_interactor.get_accounts()) {
- print(account2.bare_jid.to_string() + "\n");
- if (accounts_comboboxtext.get_active_text() == account2.bare_jid.to_string()) {
- account = account2;
- }
- }
- RosterManager.get_instance(stream_interactor).add_jid(account, jid, alias);
- if (subscribe_checkbutton.active) {
- PresenceManager.get_instance(stream_interactor).request_subscription(account, jid);
- }
- close();
- }
-
- private void on_jid_entry_changed() {
- Jid parsed_jid = Jid.parse(jid_entry.text);
- ok_button.set_sensitive(parsed_jid != null && parsed_jid.resourcepart == null);
- }
-}
-} \ No newline at end of file
diff --git a/libdino/src/ui/add_conversation/chat/dialog.vala b/libdino/src/ui/add_conversation/chat/dialog.vala
deleted file mode 100644
index cad2b367..00000000
--- a/libdino/src/ui/add_conversation/chat/dialog.vala
+++ /dev/null
@@ -1,83 +0,0 @@
-using Gee;
-using Gdk;
-using Gtk;
-
-using Dino.Entities;
-
-namespace Dino.Ui.AddConversation.Chat {
-
-public class Dialog : Gtk.Dialog {
-
- public signal void conversation_opened(Conversation conversation);
-
- private Button ok_button;
-
- private RosterList roster_list;
- private SelectJidFragment select_jid_fragment;
- private StreamInteractor stream_interactor;
-
- public Dialog(StreamInteractor stream_interactor) {
- Object(use_header_bar : 1);
- this.title = "Start Chat";
- this.modal = true;
- this.stream_interactor = stream_interactor;
-
- setup_headerbar();
- setup_view();
- }
-
- 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.label = "Start";
- ok_button.sensitive = false;
- ok_button.visible = true;
- header_bar.pack_end(ok_button);
-
- cancel_button.clicked.connect(() => { close(); });
- ok_button.clicked.connect(on_ok_button_clicked);
- }
-
- private void setup_view() {
- roster_list = new RosterList(stream_interactor);
- roster_list.row_activated.connect(() => { ok_button.clicked(); });
- select_jid_fragment = new SelectJidFragment(stream_interactor, roster_list);
- 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.show();
- });
- select_jid_fragment.edit_jid.connect(() => {
-
- });
- select_jid_fragment.remove_jid.connect((row) => {
- ListRow list_row = roster_list.get_selected_row() as ListRow;
- RosterManager.get_instance(stream_interactor).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);
- }
-
- protected void on_ok_button_clicked() {
- ListRow? selected_row = roster_list.get_selected_row() as ListRow;
- if (selected_row != null) {
- // TODO move in list to front immediately
- ConversationManager.get_instance(stream_interactor).ensure_start_conversation(selected_row.jid, selected_row.account);
- Conversation conversation = ConversationManager.get_instance(stream_interactor).get_conversation(selected_row.jid, selected_row.account);
- conversation_opened(conversation);
- }
- close();
- }
-}
-
-} \ No newline at end of file
diff --git a/libdino/src/ui/add_conversation/chat/roster_list.vala b/libdino/src/ui/add_conversation/chat/roster_list.vala
deleted file mode 100644
index 92388597..00000000
--- a/libdino/src/ui/add_conversation/chat/roster_list.vala
+++ /dev/null
@@ -1,79 +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 HashMap<Jid, ListRow> rows = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
-
- public RosterList(StreamInteractor stream_interactor) {
- this.stream_interactor = stream_interactor;
-
- set_filter_func(filter);
- set_header_func(header);
- set_sort_func(sort);
-
- RosterManager.get_instance(stream_interactor).removed_roster_item.connect( (account, jid, roster_item) => {
- Idle.add(() => { on_removed_roster_item(account, jid, roster_item); return false;});});
- RosterManager.get_instance(stream_interactor).updated_roster_item.connect( (account, jid, roster_item) => {
- Idle.add(() => { on_updated_roster_item(account, jid, roster_item); return false;});});
-
- foreach (Account account in stream_interactor.get_accounts()) {
- foreach (Roster.Item roster_item in RosterManager.get_instance(stream_interactor).get_roster(account)) {
- on_updated_roster_item(account, new Jid(roster_item.jid), roster_item);
- }
- }
- }
-
- private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
- if (rows.has_key(jid)) {
- remove(rows[jid]);
- rows.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);
- rows[jid] = row;
- add(row);
- invalidate_sort();
- invalidate_filter();
- }
-
- 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);
- }
-}
-
-} \ No newline at end of file