aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-02-22 03:00:55 +0100
committerfiaxh <git@lightrise.org>2020-02-22 03:00:55 +0100
commit420fcb909f4cc10a854fc640698bdea2fc48cad1 (patch)
tree0f84fc40a62ccb56b9ee3dd7ebbec58c7c2a605c
parentf282ef68a44d6b1924869160b4ddcb88d8d8e715 (diff)
downloaddino-420fcb909f4cc10a854fc640698bdea2fc48cad1.tar.gz
dino-420fcb909f4cc10a854fc640698bdea2fc48cad1.zip
Move widget insertion logic from ConversationTitlebar to controller
-rw-r--r--libdino/src/plugin/registry.vala8
-rw-r--r--main/src/ui/conversation_titlebar/conversation_titlebar.vala47
-rw-r--r--main/src/ui/conversation_view_controller.vala7
3 files changed, 23 insertions, 39 deletions
diff --git a/libdino/src/plugin/registry.vala b/libdino/src/plugin/registry.vala
index 73c28a02..e3f73855 100644
--- a/libdino/src/plugin/registry.vala
+++ b/libdino/src/plugin/registry.vala
@@ -10,13 +10,7 @@ public class Registry {
internal Gee.List<ConversationAdditionPopulator> conversation_addition_populators = new ArrayList<ConversationAdditionPopulator>();
internal Gee.List<NotificationPopulator> notification_populators = new ArrayList<NotificationPopulator>();
internal Gee.Collection<ConversationTitlebarEntry> conversation_titlebar_entries = new Gee.TreeSet<ConversationTitlebarEntry>((a, b) => {
- if (a.order < b.order) {
- return 1;
- } else if (a.order > b.order) {
- return -1;
- } else {
- return 0;
- }
+ return (int)(a.order - b.order);
});
public bool register_encryption_list_entry(EncryptionListEntry entry) {
diff --git a/main/src/ui/conversation_titlebar/conversation_titlebar.vala b/main/src/ui/conversation_titlebar/conversation_titlebar.vala
index c3990e09..1302bdfa 100644
--- a/main/src/ui/conversation_titlebar/conversation_titlebar.vala
+++ b/main/src/ui/conversation_titlebar/conversation_titlebar.vala
@@ -9,6 +9,8 @@ namespace Dino.Ui {
public interface ConversationTitlebar : Widget {
public abstract string? subtitle { get; set; }
public abstract string? title { get; set; }
+
+ public abstract void insert_entry(Plugins.ConversationTitlebarEntry entry);
}
public class ConversationTitlebarNoCsd : ConversationTitlebar, Gtk.Box {
@@ -26,12 +28,12 @@ public class ConversationTitlebarNoCsd : ConversationTitlebar, Gtk.Box {
}
}
- private Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin=5, margin_start=15, margin_end=5, hexpand=true, visible=true };
+ private Box widgets_box = new Box(Orientation.HORIZONTAL, 0) { margin_start=15, valign=Align.END, 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 };
construct {
+ Box content_box = new Box(Orientation.HORIZONTAL, 0) { margin=5, margin_start=15, margin_end=10, hexpand=true, visible=true };
this.add(content_box);
Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER, hexpand=true, visible=true };
@@ -42,25 +44,19 @@ public class ConversationTitlebarNoCsd : ConversationTitlebar, Gtk.Box {
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);
+ content_box.add(widgets_box);
}
public ConversationTitlebarNoCsd() {
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;
- foreach(var e in app.plugin_registry.conversation_titlebar_entries) {
- Plugins.ConversationTitlebarWidget widget = e.get_widget(Plugins.WidgetType.GTK);
- if (widget != null) {
- Button gtk_widget = (Gtk.Button)widget;
- gtk_widget.relief = ReliefStyle.NONE;
- content_box.add(gtk_widget);
- }
+ }
+
+ public void insert_entry(Plugins.ConversationTitlebarEntry entry) {
+ Plugins.ConversationTitlebarWidget widget = entry.get_widget(Plugins.WidgetType.GTK);
+ if (widget != null) {
+ Button gtk_widget = (Gtk.Button) widget;
+ gtk_widget.relief = ReliefStyle.NONE;
+ widgets_box.pack_end(gtk_widget);
}
}
}
@@ -74,19 +70,12 @@ public class ConversationTitlebarCsd : ConversationTitlebar, Gtk.HeaderBar {
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;
- this.pack_end(gtk_widget);
- }
+ public void insert_entry(Plugins.ConversationTitlebarEntry entry) {
+ Plugins.ConversationTitlebarWidget widget = entry.get_widget(Plugins.WidgetType.GTK);
+ Button gtk_widget = (Gtk.Button)widget;
+ this.pack_end(gtk_widget);
}
}
diff --git a/main/src/ui/conversation_view_controller.vala b/main/src/ui/conversation_view_controller.vala
index 149a1f76..cb5d4dce 100644
--- a/main/src/ui/conversation_view_controller.vala
+++ b/main/src/ui/conversation_view_controller.vala
@@ -77,12 +77,13 @@ public class ConversationViewController : Object {
}
});
- // Register headerbar plugins
+ // Headerbar plugins
app.plugin_registry.register_contact_titlebar_entry(new MenuEntry(stream_interactor));
app.plugin_registry.register_contact_titlebar_entry(search_menu_entry);
app.plugin_registry.register_contact_titlebar_entry(new OccupantsEntry(stream_interactor));
-
-
+ foreach(var entry in app.plugin_registry.conversation_titlebar_entries) {
+ titlebar.insert_entry(entry);
+ }
}
public void select_conversation(Conversation? conversation, bool default_initialize_conversation) {