aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/add_conversation/roster_list.vala19
-rw-r--r--main/src/ui/add_conversation/select_contact_dialog.vala15
-rw-r--r--main/src/ui/add_conversation/select_jid_fragment.vala6
-rw-r--r--main/src/ui/application.vala19
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala7
5 files changed, 52 insertions, 14 deletions
diff --git a/main/src/ui/add_conversation/roster_list.vala b/main/src/ui/add_conversation/roster_list.vala
index bb338ce5..33e1e6da 100644
--- a/main/src/ui/add_conversation/roster_list.vala
+++ b/main/src/ui/add_conversation/roster_list.vala
@@ -16,7 +16,7 @@ protected class RosterList {
private ListBox list_box = new ListBox();
private HashMap<Account, HashMap<Jid, ListBoxRow>> rows = new HashMap<Account, HashMap<Jid, ListBoxRow>>(Account.hash_func, Account.equals_func);
- public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
+ public RosterList(StreamInteractor stream_interactor, Gee.List<Account> accounts, bool notes_mode = false) {
this.stream_interactor = stream_interactor;
this.accounts = accounts;
@@ -34,7 +34,7 @@ protected class RosterList {
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);
+ foreach (Account a in accounts) fetch_roster_items(a, notes_mode);
}
private void on_removed_roster_item(Account account, Jid jid, Roster.Item roster_item) {
@@ -54,10 +54,17 @@ protected class RosterList {
list_box.invalidate_filter();
}
- private void fetch_roster_items(Account account) {
- rows[account] = new HashMap<Jid, ListBoxRow>(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, roster_item.jid, roster_item);
+ private void fetch_roster_items(Account account, bool notes_mode = false) {
+ if (notes_mode){
+ ListRow own_account_row = new ListRow.from_jid(stream_interactor, account.bare_jid, account, accounts.size > 1);
+ ListBoxRow own_account_lbrow = new ListBoxRow() { child=own_account_row };
+ list_box.append(own_account_lbrow);
+ }
+ else {
+ rows[account] = new HashMap<Jid, ListBoxRow>(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, roster_item.jid, roster_item);
+ }
}
}
diff --git a/main/src/ui/add_conversation/select_contact_dialog.vala b/main/src/ui/add_conversation/select_contact_dialog.vala
index fb69257e..d02a366f 100644
--- a/main/src/ui/add_conversation/select_contact_dialog.vala
+++ b/main/src/ui/add_conversation/select_contact_dialog.vala
@@ -18,8 +18,9 @@ public class SelectContactDialog : Gtk.Dialog {
private SelectJidFragment select_jid_fragment;
private StreamInteractor stream_interactor;
private Gee.List<Account> accounts;
+ private bool notes_mode;
- public SelectContactDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
+ public SelectContactDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts, bool notes_mode = false) {
Object(use_header_bar : Util.use_csd() ? 1 : 0);
modal = true;
this.default_width = 460;
@@ -27,6 +28,7 @@ public class SelectContactDialog : Gtk.Dialog {
this.stream_interactor = stream_interactor;
this.accounts = accounts;
+ this.notes_mode = notes_mode;
setup_view();
setup_headerbar();
@@ -72,10 +74,10 @@ public class SelectContactDialog : Gtk.Dialog {
}
private void setup_view() {
- roster_list = new RosterList(stream_interactor, accounts);
+ roster_list = new RosterList(stream_interactor, accounts, notes_mode);
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, notes_mode);
select_jid_fragment.add_jid.connect((row) => {
AddContactDialog add_contact_dialog = new AddContactDialog(stream_interactor);
add_contact_dialog.set_transient_for(this);
@@ -96,12 +98,13 @@ public class AddChatDialog : SelectContactDialog {
public signal void added(Conversation conversation);
- public AddChatDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts) {
- base(stream_interactor, accounts);
- title = _("Start Conversation");
+ public AddChatDialog(StreamInteractor stream_interactor, Gee.List<Account> accounts, bool notes_mode = false) {
+ base(stream_interactor, accounts, notes_mode);
+ title = notes_mode ? _("Open notes") : _("Start Conversation");
ok_button.label = _("Start");
selected.connect((account, jid) => {
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.CHAT);
+ if(notes_mode) conversation.pinned = 1;
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation);
added(conversation);
});
diff --git a/main/src/ui/add_conversation/select_jid_fragment.vala b/main/src/ui/add_conversation/select_jid_fragment.vala
index e0682e29..7a1dc747 100644
--- a/main/src/ui/add_conversation/select_jid_fragment.vala
+++ b/main/src/ui/add_conversation/select_jid_fragment.vala
@@ -28,11 +28,15 @@ public class SelectJidFragment : Gtk.Box {
private ListBox list;
private string[]? filter_values;
- public SelectJidFragment(StreamInteractor stream_interactor, ListBox list, Gee.List<Account> accounts) {
+ public SelectJidFragment(StreamInteractor stream_interactor, ListBox list, Gee.List<Account> accounts, bool notes_mode = false) {
this.stream_interactor = stream_interactor;
this.list = list;
this.accounts = accounts;
+ if (notes_mode) {
+ add_button.visible = false;
+ remove_button.visible = false;
+ }
list.activate_on_single_click = false;
list.vexpand = true;
box.append(list);
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 2e785224..1c96e9ce 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -165,6 +165,25 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
add_action(conference_action);
set_accels_for_action("app.add_conference", KEY_COMBINATION_ADD_CONFERENCE);
+ SimpleAction opennotes_action = new SimpleAction("opennotes", null);
+ opennotes_action.activate.connect(() => {
+ Gee.List<Account> accounts = stream_interactor.get_accounts();
+ if (accounts.size == 1){
+ Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(accounts[0].bare_jid, accounts[0], Conversation.Type.CHAT);
+ conversation.pinned = 1;
+ stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation);
+ return;
+ }
+ if (accounts.size > 1){
+ AddChatDialog add_chat_dialog = new AddChatDialog(stream_interactor, accounts, true);
+ add_chat_dialog.set_transient_for(window);
+ add_chat_dialog.added.connect((conversation) => controller.select_conversation(conversation));
+ add_chat_dialog.present();
+ return;
+ }
+ });
+ add_action(opennotes_action);
+
SimpleAction accept_muc_invite_action = new SimpleAction("open-muc-join", VariantType.INT32);
accept_muc_invite_action.activate.connect((variant) => {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation_by_id(variant.get_int32());
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index c180b6b3..40b35429 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -128,7 +128,12 @@ public class ConversationSelectorRow : ListBoxRow {
}
protected void update_name_label() {
- name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
+ if (conversation.counterpart.bare_jid.to_string() == conversation.account.bare_jid.to_string()){ //talking to yourself
+ name_label.set_markup("<u>// Notes to self (" + conversation.account.bare_jid.to_string() + ")</u>");
+ }
+ else {
+ name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
+ }
}
private void update_pinned_icon() {