From b4b115df48cabd796f0499def22505cb18223787 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 29 Aug 2017 21:55:15 +0200 Subject: main: extend theming capabilities --- main/CMakeLists.txt | 3 +- main/data/conversation_list_titlebar.ui | 2 +- main/data/conversation_titlebar.ui | 62 ----------------------------- main/data/pre_theme.css | 10 +++++ main/src/ui/application.vala | 9 +++-- main/src/ui/conversation_list_titlebar.vala | 4 ++ main/src/ui/conversation_titlebar/view.vala | 1 + main/src/ui/unified_window.vala | 1 + 8 files changed, 25 insertions(+), 67 deletions(-) delete mode 100644 main/data/conversation_titlebar.ui create mode 100644 main/data/pre_theme.css (limited to 'main') diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index cebd6d4c..c9fe88f1 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -34,7 +34,6 @@ set(RESOURCE_LIST conversation_selector/conversation_row.ui conversation_summary/message_item.ui conversation_summary/view.ui - conversation_titlebar.ui manage_accounts/account_row.ui manage_accounts/add_account_dialog.ui manage_accounts/dialog.ui @@ -46,6 +45,8 @@ set(RESOURCE_LIST occupant_list_item.ui settings_dialog.ui unified_window_placeholder.ui + + pre_theme.css ) compile_gresources( diff --git a/main/data/conversation_list_titlebar.ui b/main/data/conversation_list_titlebar.ui index 6c08881c..f8fabedc 100644 --- a/main/data/conversation_list_titlebar.ui +++ b/main/data/conversation_list_titlebar.ui @@ -5,7 +5,7 @@ True True diff --git a/main/data/conversation_titlebar.ui b/main/data/conversation_titlebar.ui deleted file mode 100644 index 30779079..00000000 --- a/main/data/conversation_titlebar.ui +++ /dev/null @@ -1,62 +0,0 @@ - - - - diff --git a/main/data/pre_theme.css b/main/data/pre_theme.css new file mode 100644 index 00000000..392e603f --- /dev/null +++ b/main/data/pre_theme.css @@ -0,0 +1,10 @@ +/** + * This theme file is applied before the operating system theme and any user configuration. + * It provides sane defaults for things that are very Dino-specific. + */ + +window.dino-main headerbar.dino-left label.title { + opacity: 0; + font-size: 0; + color: transparent; +} \ No newline at end of file diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index 0183e30d..708c63b0 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -14,12 +14,15 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application { public SearchPathGenerator? search_path_generator { get; set; } public Application() throws Error { - Object(application_id: "im.dino.Dino", flags: ApplicationFlags.HANDLES_OPEN); + Object(application_id: "im.dino", flags: ApplicationFlags.HANDLES_OPEN); init(); Notify.init("dino"); Environment.set_application_name("Dino"); - Gtk.Window.set_default_icon_name("dino"); - IconTheme.get_default().add_resource_path("/im/dino/icons"); + Window.set_default_icon_name("dino"); + + CssProvider provider = new CssProvider(); + provider.load_from_resource("/im/dino/pre_theme.css"); + StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, STYLE_PROVIDER_PRIORITY_THEME - 1); activate.connect(() => { if (window == null) { diff --git a/main/src/ui/conversation_list_titlebar.vala b/main/src/ui/conversation_list_titlebar.vala index b9a902c8..815807f2 100644 --- a/main/src/ui/conversation_list_titlebar.vala +++ b/main/src/ui/conversation_list_titlebar.vala @@ -16,6 +16,10 @@ public class ConversationListTitlebar : Gtk.HeaderBar { public ConversationListTitlebar(StreamInteractor stream_interactor, Window window) { this.stream_interactor = stream_interactor; + + custom_title = new Label("Dino") { visible = true, hexpand = true, xalign = 0 }; + custom_title.get_style_context().add_class("title"); + create_add_menu(window); } diff --git a/main/src/ui/conversation_titlebar/view.vala b/main/src/ui/conversation_titlebar/view.vala index 34191995..9949f4fc 100644 --- a/main/src/ui/conversation_titlebar/view.vala +++ b/main/src/ui/conversation_titlebar/view.vala @@ -16,6 +16,7 @@ public class ConversationTitlebar : Gtk.HeaderBar { this.stream_interactor = stream_interactor; this.window = window; + this.get_style_context().add_class("dino-right"); show_close_button = true; hexpand = true; diff --git a/main/src/ui/unified_window.vala b/main/src/ui/unified_window.vala index 3a419161..b3c02189 100644 --- a/main/src/ui/unified_window.vala +++ b/main/src/ui/unified_window.vala @@ -26,6 +26,7 @@ public class UnifiedWindow : Window { Object(application : application, default_width : 1200, default_height : 700); this.stream_interactor = stream_interactor; + this.get_style_context().add_class("dino-main"); setup_headerbar(); setup_unified(); setup_stack(); -- cgit v1.2.3-70-g09d2