aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_titlebar
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 /main/src/ui/conversation_titlebar
parentf282ef68a44d6b1924869160b4ddcb88d8d8e715 (diff)
downloaddino-420fcb909f4cc10a854fc640698bdea2fc48cad1.tar.gz
dino-420fcb909f4cc10a854fc640698bdea2fc48cad1.zip
Move widget insertion logic from ConversationTitlebar to controller
Diffstat (limited to 'main/src/ui/conversation_titlebar')
-rw-r--r--main/src/ui/conversation_titlebar/conversation_titlebar.vala47
1 files changed, 18 insertions, 29 deletions
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);
}
}