aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_titlebar')
-rw-r--r--main/src/ui/conversation_titlebar/menu_entry.vala16
-rw-r--r--main/src/ui/conversation_titlebar/occupants_entry.vala16
-rw-r--r--main/src/ui/conversation_titlebar/search_entry.vala6
-rw-r--r--main/src/ui/conversation_titlebar/view.vala98
-rw-r--r--main/src/ui/conversation_titlebar/view_csd.vala38
5 files changed, 97 insertions, 77 deletions
diff --git a/main/src/ui/conversation_titlebar/menu_entry.vala b/main/src/ui/conversation_titlebar/menu_entry.vala
index e77204a8..e62989a0 100644
--- a/main/src/ui/conversation_titlebar/menu_entry.vala
+++ b/main/src/ui/conversation_titlebar/menu_entry.vala
@@ -8,6 +8,7 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
public string id { get { return "menu"; } }
StreamInteractor stream_interactor;
+ MenuWidget widget;
public MenuEntry(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
@@ -16,30 +17,27 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
public double order { get { return 0; } }
public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
if (type == Plugins.WidgetType.GTK) {
- return new MenuWidget(stream_interactor) { visible=true };
+ if (widget == null) {
+ widget = new MenuWidget(stream_interactor) { visible=true };
+ }
+ return widget;
}
return null;
}
}
-class MenuWidget : MenuButton, Plugins.ConversationTitlebarWidget {
+class MenuWidget : Button, Plugins.ConversationTitlebarWidget {
private Conversation? conversation;
public MenuWidget(StreamInteractor stream_interactor) {
image = new Image.from_icon_name("open-menu-symbolic", IconSize.MENU);
- Builder builder = new Builder.from_resource("/im/dino/Dino/menu_conversation.ui");
- MenuModel menu = builder.get_object("menu_conversation") as MenuModel;
- set_menu_model(menu);
-
- SimpleAction contact_details_action = new SimpleAction("contact_details", null);
- contact_details_action.activate.connect(() => {
+ clicked.connect(() => {
ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
contact_details_dialog.set_transient_for((Window) get_toplevel());
contact_details_dialog.present();
});
- GLib.Application.get_default().add_action(contact_details_action);
}
public new void set_conversation(Conversation conversation) {
diff --git a/main/src/ui/conversation_titlebar/occupants_entry.vala b/main/src/ui/conversation_titlebar/occupants_entry.vala
index 0646eee7..af553e35 100644
--- a/main/src/ui/conversation_titlebar/occupants_entry.vala
+++ b/main/src/ui/conversation_titlebar/occupants_entry.vala
@@ -8,17 +8,19 @@ class OccupantsEntry : Plugins.ConversationTitlebarEntry, Object {
public string id { get { return "occupants"; } }
StreamInteractor stream_interactor;
- Window window;
+ OccupantsWidget widget;
- public OccupantsEntry(StreamInteractor stream_interactor, Window window) {
+ public OccupantsEntry(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- this.window = window;
}
public double order { get { return 3; } }
public Plugins.ConversationTitlebarWidget? get_widget(Plugins.WidgetType type) {
if (type == Plugins.WidgetType.GTK) {
- return new OccupantsWidget(stream_interactor, window) { visible=true };
+ if (widget == null) {
+ widget = new OccupantsWidget(stream_interactor) { visible=true };
+ }
+ return widget;
}
return null;
}
@@ -28,14 +30,12 @@ class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget {
private Conversation? conversation;
private StreamInteractor stream_interactor;
- private Window window;
private OccupantMenu.View menu = null;
- public OccupantsWidget(StreamInteractor stream_interactor, Window window) {
+ public OccupantsWidget(StreamInteractor stream_interactor) {
image = new Image.from_icon_name("system-users-symbolic", IconSize.MENU);
this.stream_interactor = stream_interactor;
- this.window = window;
set_use_popover(true);
}
@@ -44,7 +44,7 @@ class OccupantsWidget : MenuButton, Plugins.ConversationTitlebarWidget {
visible = conversation.type_ == Conversation.Type.GROUPCHAT;
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
- OccupantMenu.View new_menu = new OccupantMenu.View(stream_interactor, window, conversation);
+ OccupantMenu.View new_menu = new OccupantMenu.View(stream_interactor, conversation);
set_popover(new_menu);
if (menu != null) menu.destroy();
menu = new_menu;
diff --git a/main/src/ui/conversation_titlebar/search_entry.vala b/main/src/ui/conversation_titlebar/search_entry.vala
index b452bdce..ff0ff325 100644
--- a/main/src/ui/conversation_titlebar/search_entry.vala
+++ b/main/src/ui/conversation_titlebar/search_entry.vala
@@ -8,10 +8,10 @@ namespace Dino.Ui {
public class SearchMenuEntry : Plugins.ConversationTitlebarEntry, Object {
public string id { get { return "search"; } }
- Plugins.ConversationTitlebarWidget search_button;
+ public GlobalSearchButton search_button = new GlobalSearchButton() { visible = true };
- public SearchMenuEntry(Plugins.ConversationTitlebarWidget search_button) {
- this.search_button = search_button;
+ public SearchMenuEntry() {
+ search_button.set_image(new Gtk.Image.from_icon_name("system-search-symbolic", Gtk.IconSize.MENU) { visible = true });
}
public double order { get { return 1; } }
diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala
index 7ced9830..cb31527e 100644
--- a/main/src/ui/conversation_titlebar/view.vala
+++ b/main/src/ui/conversation_titlebar/view.vala
@@ -1,82 +1,66 @@
using Gtk;
using Gee;
+using Pango;
using Dino.Entities;
namespace Dino.Ui {
-public class ConversationTitlebar : Gtk.HeaderBar {
+public class ConversationTitlebar : Gtk.Box {
+
+ public string? title {
+ get { return title_label.label; }
+ set { this.title_label.label = value; }
+ }
+
+ public string? subtitle {
+ get { return subtitle_label.label; }
+ set {
+ this.subtitle_label.label = "<span size='small'>" + value + "</span>";
+ this.subtitle_label.visible = (value != null);
+ }
+ }
private StreamInteractor stream_interactor;
- private Window window;
private Conversation? conversation;
- private Gee.List<Plugins.ConversationTitlebarWidget> widgets = new ArrayList<Plugins.ConversationTitlebarWidget>();
+
+ private Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin=5, margin_start=15, margin_end=5, hexpand=true, visible=true };
+ private Label title_label = new Label("") { visible=true };
+ private Label subtitle_label = new Label("") { use_markup=true, ellipsize=EllipsizeMode.END, visible=false };
public GlobalSearchButton search_button = new GlobalSearchButton() { visible = true };
- public ConversationTitlebar(StreamInteractor stream_interactor, Window window) {
+ construct {
+ this.add(content_box);
+
+ Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true, visible=true };
+ content_box.add(titles_box);
+
+ titles_box.add(title_label);
+ subtitle_label.attributes = new AttrList();
+ subtitle_label.get_style_context().add_class("dim-label");
+ titles_box.add(subtitle_label);
+
+ Box placeholder_box = new Box(Orientation.VERTICAL, 0) { visible=true };
+ placeholder_box.add(new Label("") { xalign=0, visible=true });
+ placeholder_box.add(new Label("<span size='small'> </span>") { use_markup=true, xalign=0, visible=true });
+ content_box.add(placeholder_box);
+ }
+
+ public ConversationTitlebar(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- this.window = window;
- this.get_style_context().add_class("dino-right");
- show_close_button = true;
+ this.get_style_context().add_class("dino-header-right");
hexpand = true;
search_button.set_image(new Gtk.Image.from_icon_name("system-search-symbolic", Gtk.IconSize.MENU) { visible = 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 SearchMenuEntry(search_button));
- 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(Plugins.WidgetType.GTK);
if (widget != null) {
- widgets.add(widget);
- pack_end((Gtk.Widget)widget);
- }
- }
-
-
- stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => {
- if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) {
- update_title();
- }
- });
-
- stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect((account, room, occupant) => {
- if (conversation != null && conversation.counterpart.equals_bare(room.bare_jid) && conversation.account.equals(account)) {
- update_title();
+ Button gtk_widget = (Gtk.Button)widget;
+ gtk_widget.relief = ReliefStyle.NONE;
+ content_box.add(gtk_widget);
}
- });
-
- stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => {
- if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) {
- update_subtitle(subject);
- }
- });
- }
-
- 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);
}
}
}
diff --git a/main/src/ui/conversation_titlebar/view_csd.vala b/main/src/ui/conversation_titlebar/view_csd.vala
new file mode 100644
index 00000000..83a1a474
--- /dev/null
+++ b/main/src/ui/conversation_titlebar/view_csd.vala
@@ -0,0 +1,38 @@
+using Gtk;
+using Gee;
+
+using Dino.Entities;
+
+namespace Dino.Ui {
+
+public class ConversationTitlebarCsd : Gtk.HeaderBar {
+
+ private StreamInteractor stream_interactor;
+ private Window window;
+ private Conversation? conversation;
+
+ public ConversationTitlebarCsd(StreamInteractor stream_interactor, Window window) {
+ this.stream_interactor = stream_interactor;
+ this.window = window;
+
+ this.get_style_context().add_class("dino-right");
+ show_close_button = true;
+ hexpand = true;
+
+ Application app = GLib.Application.get_default() as Application;
+ ArrayList<Plugins.ConversationTitlebarWidget> widgets = new ArrayList<Plugins.ConversationTitlebarWidget>();
+ foreach(var e in app.plugin_registry.conversation_titlebar_entries) {
+ Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK);
+ if (widget != null) {
+ widgets.insert(0, widget);
+ }
+ }
+ foreach (var w in widgets) {
+ Button gtk_widget = (Gtk.Button)w;
+ gtk_widget.relief = ReliefStyle.NONE;
+ this.pack_end(gtk_widget);
+ }
+ }
+}
+
+}