aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util
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/util
parent7e83529afcd0ccfff5c65c99e4427bd6cf3f82ac (diff)
downloaddino-d9b91206c0291fa8aa58df572292784a4f8ff878.tar.gz
dino-d9b91206c0291fa8aa58df572292784a4f8ff878.zip
Keep MUC join dialog open until joined, show errors
Diffstat (limited to 'main/src/ui/util')
-rw-r--r--main/src/ui/util/accounts_combo_box.vala57
1 files changed, 57 insertions, 0 deletions
diff --git a/main/src/ui/util/accounts_combo_box.vala b/main/src/ui/util/accounts_combo_box.vala
new file mode 100644
index 00000000..5fdd18e6
--- /dev/null
+++ b/main/src/ui/util/accounts_combo_box.vala
@@ -0,0 +1,57 @@
+using Gee;
+using Gtk;
+
+using Dino.Entities;
+
+namespace Dino.Ui {
+
+class AccountComboBox : ComboBox {
+
+ public Account? selected {
+ get {
+ TreeIter selected;
+ if (get_active_iter(out selected)) {
+ Value value;
+ list_store.get_value(selected, 1, out value);
+ return value as Account;
+ }
+ return null;
+ }
+ set {
+ TreeIter iter;
+ if (list_store.get_iter_first(out iter)) {
+ int i = 0;
+ do {
+ Value val;
+ list_store.get_value(iter, 1, out val);
+ if ((val as Account).equals(value)) {
+ active = i;
+ break;
+ }
+ i++;
+ } while (list_store.iter_next(ref iter));
+ }
+ }
+ }
+
+ private StreamInteractor? stream_interactor;
+ private Gtk.ListStore list_store = new Gtk.ListStore(2, typeof(string), typeof(Account));
+
+ public void initialize(StreamInteractor stream_interactor) {
+ this.stream_interactor = stream_interactor;
+
+ CellRendererText renderer = new Gtk.CellRendererText();
+ pack_start(renderer, true);
+ add_attribute(renderer, "text", 0);
+
+ TreeIter iter;
+ foreach (Account account in stream_interactor.get_accounts()) {
+ list_store.append(out iter);
+ list_store.set(iter, 0, account.bare_jid.to_string(), 1, account);
+ }
+ set_model(list_store);
+ active = 0;
+ }
+}
+
+}