aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar/view.vala
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-08-02 17:29:55 +0200
committerfiaxh <git@mx.ax.lt>2017-08-03 15:59:04 +0200
commitea174ab632ced082eb0f1c51cea1bc9dc5c7c89e (patch)
tree8f83d1379a48e7aa49af5a5146d76a4c595f2363 /main/src/ui/conversation_titlebar/view.vala
parentf83e1188c5dcf1981832f296203f94503b467e30 (diff)
downloaddino-ea174ab632ced082eb0f1c51cea1bc9dc5c7c89e.tar.gz
dino-ea174ab632ced082eb0f1c51cea1bc9dc5c7c89e.zip
Http file upload
Diffstat (limited to 'main/src/ui/conversation_titlebar/view.vala')
-rw-r--r--main/src/ui/conversation_titlebar/view.vala69
1 files changed, 69 insertions, 0 deletions
diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala
new file mode 100644
index 00000000..7debddd6
--- /dev/null
+++ b/main/src/ui/conversation_titlebar/view.vala
@@ -0,0 +1,69 @@
+using Gtk;
+using Gee;
+
+using Dino.Entities;
+
+namespace Dino.Ui {
+
+public class ConversationTitlebar : Gtk.HeaderBar {
+
+ private StreamInteractor stream_interactor;
+ private Window window;
+ private Conversation? conversation;
+ private Gee.List<Plugins.ConversationTitlebarWidget> widgets = new ArrayList<Plugins.ConversationTitlebarWidget>();
+
+ public ConversationTitlebar(StreamInteractor stream_interactor, Window window) {
+ this.stream_interactor = stream_interactor;
+ this.window = window;
+
+ show_close_button = true;
+ hexpand = true;
+
+ Application app = GLib.Application.get_default() as Application;
+ app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor));
+ app.plugin_registry.register_contact_titlebar_entry(new EncryptionEntry());
+ app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor, window));
+
+ foreach(var e in app.plugin_registry.conversation_titlebar_entries) {
+ Plugins.ConversationTitlebarWidget widget = e.get_widget();
+ widgets.add(widget);
+ pack_end(widget);
+ }
+
+ stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => {
+ Idle.add(() => {
+ if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) {
+ update_subtitle(subject);
+ }
+ return false;
+ });
+ });
+ }
+
+ public void initialize_for_conversation(Conversation conversation) {
+ this.conversation = conversation;
+ update_title();
+ update_subtitle();
+
+ foreach (Plugins.ConversationTitlebarWidget widget in widgets) {
+ widget.set_conversation(conversation);
+ }
+ }
+
+ private void update_title() {
+ set_title(Util.get_conversation_display_name(stream_interactor, conversation));
+ }
+
+ private void update_subtitle(string? subtitle = null) {
+ if (subtitle != null) {
+ set_subtitle(subtitle);
+ } else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
+ string subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
+ set_subtitle(subject != "" ? subject : null);
+ } else {
+ set_subtitle(null);
+ }
+ }
+}
+
+}