From 6e1938b0893b47f0673bd773bdbfdbf6465ae018 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 12 Apr 2019 17:43:47 +0200 Subject: Clean up ConversationTitlebar --- .../conversation_titlebar.vala | 93 ++++++++++++++++++++++ main/src/ui/conversation_titlebar/view.vala | 67 ---------------- main/src/ui/conversation_titlebar/view_csd.vala | 36 --------- 3 files changed, 93 insertions(+), 103 deletions(-) create mode 100644 main/src/ui/conversation_titlebar/conversation_titlebar.vala delete mode 100644 main/src/ui/conversation_titlebar/view.vala delete mode 100644 main/src/ui/conversation_titlebar/view_csd.vala (limited to 'main/src/ui/conversation_titlebar') diff --git a/main/src/ui/conversation_titlebar/conversation_titlebar.vala b/main/src/ui/conversation_titlebar/conversation_titlebar.vala new file mode 100644 index 00000000..9836f208 --- /dev/null +++ b/main/src/ui/conversation_titlebar/conversation_titlebar.vala @@ -0,0 +1,93 @@ +using Gtk; +using Gee; +using Pango; + +using Dino.Entities; + +namespace Dino.Ui { + +public interface ConversationTitlebar: Widget { + public abstract string? subtitle { get; set; } + public abstract string? title { get; set; } +} + +public class ConversationTitlebarNoCsd : 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 = "" + value + ""; + this.subtitle_label.visible = (value != null); + } + } + + 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 }; + + 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(" ") { use_markup=true, xalign=0, visible=true }); + content_box.add(placeholder_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 class ConversationTitlebarCsd : ConversationTitlebar, Gtk.HeaderBar { + + public new string? title { get { return this.get_title(); } set { base.set_title(value); } } + public new string? subtitle { get { return this.get_subtitle(); } set { base.set_subtitle(value); } } + + public ConversationTitlebarCsd() { + this.get_style_context().add_class("dino-right"); + show_close_button = true; + hexpand = true; + + Application app = GLib.Application.get_default() as Application; + ArrayList widgets = new ArrayList(); + 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); + } + } +} + +} diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala deleted file mode 100644 index 9706b516..00000000 --- a/main/src/ui/conversation_titlebar/view.vala +++ /dev/null @@ -1,67 +0,0 @@ -using Gtk; -using Gee; -using Pango; - -using Dino.Entities; - -namespace Dino.Ui { - -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 = "" + value + ""; - this.subtitle_label.visible = (value != null); - } - } - - private StreamInteractor stream_interactor; - - 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 }; - - 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(" ") { use_markup=true, xalign=0, visible=true }); - content_box.add(placeholder_box); - } - - public ConversationTitlebar(StreamInteractor stream_interactor) { - this.stream_interactor = stream_interactor; - - 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); - } - } - } -} - -} diff --git a/main/src/ui/conversation_titlebar/view_csd.vala b/main/src/ui/conversation_titlebar/view_csd.vala deleted file mode 100644 index 62360c42..00000000 --- a/main/src/ui/conversation_titlebar/view_csd.vala +++ /dev/null @@ -1,36 +0,0 @@ -using Gtk; -using Gee; - -using Dino.Entities; - -namespace Dino.Ui { - -public class ConversationTitlebarCsd : Gtk.HeaderBar { - - private StreamInteractor stream_interactor; - private Window window; - - 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 widgets = new ArrayList(); - 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); - } - } -} - -} -- cgit v1.2.3-54-g00ecf