aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/application.vala29
-rw-r--r--main/src/ui/conversation_list_titlebar.vala18
-rw-r--r--main/src/ui/main_window.vala7
3 files changed, 51 insertions, 3 deletions
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 706a61e6..ba8d411e 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -231,6 +231,35 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
call_state.reject();
});
add_action(deny_call_action);
+
+ SimpleAction p_online_action = new SimpleAction("presence_online", null);
+ p_online_action.activate.connect( () => {
+ stream_interactor.get_module(PresenceManager.IDENTITY).send_presence(Xmpp.Presence.Stanza.SHOW_ONLINE);
+ window.refresh_presence_button(Xmpp.Presence.Stanza.SHOW_ONLINE);
+ });
+ add_action(p_online_action);
+
+ SimpleAction p_dnd_action = new SimpleAction("presence_dnd", null);
+ p_dnd_action.activate.connect( () => {
+ stream_interactor.get_module(PresenceManager.IDENTITY).send_presence(Xmpp.Presence.Stanza.SHOW_DND);
+ window.refresh_presence_button(Xmpp.Presence.Stanza.SHOW_DND);
+ });
+ add_action(p_dnd_action);
+
+ SimpleAction p_away_action = new SimpleAction("presence_away", null);
+ p_away_action.activate.connect( () => {
+ stream_interactor.get_module(PresenceManager.IDENTITY).send_presence(Xmpp.Presence.Stanza.SHOW_AWAY);
+ window.refresh_presence_button(Xmpp.Presence.Stanza.SHOW_AWAY);
+ });
+ add_action(p_away_action);
+
+ SimpleAction p_xaway_action = new SimpleAction("presence_xaway", null);
+ p_xaway_action.activate.connect( () => {
+ stream_interactor.get_module(PresenceManager.IDENTITY).send_presence(Xmpp.Presence.Stanza.SHOW_XA);
+ window.refresh_presence_button(Xmpp.Presence.Stanza.SHOW_XA);
+ });
+ add_action(p_xaway_action);
+
}
private void show_preferences_window() {
diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala
index 51dbdcf6..340a6389 100644
--- a/main/src/ui/conversation_list_titlebar.vala
+++ b/main/src/ui/conversation_list_titlebar.vala
@@ -4,21 +4,33 @@ using Dino.Entities;
namespace Dino.Ui {
-public static Adw.HeaderBar get_conversation_list_titlebar() {
+public static Adw.HeaderBar get_conversation_list_titlebar(string presence = "") {
Builder builder = new Builder.from_resource("/im/dino/Dino/conversation_list_titlebar.ui");
MenuButton add_button = (MenuButton) builder.get_object("add_button");
+ MenuButton presence_button = (MenuButton) builder.get_object("presence_button");
MenuButton menu_button = (MenuButton) builder.get_object("menu_button");
- create_add_menu(add_button, menu_button);
+ switch(presence) {
+ case Xmpp.Presence.Stanza.SHOW_AWAY: presence_button.set_icon_name("dino-status-away"); break;
+ case Xmpp.Presence.Stanza.SHOW_DND: presence_button.set_icon_name("dino-status-dnd"); break;
+ case Xmpp.Presence.Stanza.SHOW_XA: presence_button.set_icon_name("dino-status-xa"); break;
+ case "offline": presence_button.set_icon_name("dino-status-offline"); break;
+ default: presence_button.set_icon_name("dino-status-online"); break;
+ }
+ create_add_menu(add_button, presence_button, menu_button);
return (Adw.HeaderBar) builder.get_object("header_bar");
}
-private static void create_add_menu(MenuButton add_button, MenuButton menu_button) {
+private static void create_add_menu(MenuButton add_button, MenuButton presence_button, MenuButton menu_button) {
add_button.tooltip_text = Util.string_if_tooltips_active(_("Start Conversation"));
Builder add_builder = new Builder.from_resource("/im/dino/Dino/menu_add.ui");
MenuModel add_menu_model = add_builder.get_object("menu_add") as MenuModel;
add_button.set_menu_model(add_menu_model);
+ Builder presence_builder = new Builder.from_resource("/im/dino/Dino/menu_presence.ui");
+ MenuModel presence_menu_model = presence_builder.get_object("menu_presence") as MenuModel;
+ presence_button.set_menu_model(presence_menu_model);
+
Builder menu_builder = new Builder.from_resource("/im/dino/Dino/menu_app.ui");
MenuModel menu_menu_model = menu_builder.get_object("menu_app") as MenuModel;
menu_button.set_menu_model(menu_menu_model);
diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala
index e3110336..765ecc25 100644
--- a/main/src/ui/main_window.vala
+++ b/main/src/ui/main_window.vala
@@ -87,6 +87,13 @@ public class MainWindow : Adw.ApplicationWindow {
conversation_titlebar.back_pressed.connect(() => leaflet.navigate(Adw.NavigationDirection.BACK));
}
+ public void refresh_presence_button(string presence = "") {
+ conversation_list_titlebar.unparent();
+ conversation_list_titlebar = get_conversation_list_titlebar(presence);
+ leaflet.bind_property("folded", conversation_list_titlebar, "show-end-title-buttons", BindingFlags.SYNC_CREATE);
+ left_box.prepend(conversation_list_titlebar);
+ }
+
private void setup_stack() {
stack.add_named(box, "main");
stack.add_named(welcome_placeholder, "welcome_placeholder");