From be185c2fbc7da088a950009e4af08f9412371fb5 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 15 Oct 2018 18:57:13 -0700 Subject: [PATCH] theme: add development highlight to headerbar --- meson.build | 5 +++++ src/resources/sysprof.gresource.xml | 1 + src/resources/theme/Adwaita-shared.css | 13 +++++++++++++ src/sp-application.c | 11 +++++++++++ src/sp-window.c | 8 ++++++++ 5 files changed, 38 insertions(+) create mode 100644 src/resources/theme/Adwaita-shared.css diff --git a/meson.build b/meson.build index 2f0f1dab..8150709d 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,8 @@ project('sysprof', ['c', 'cpp'], ] ) +version_split = meson.project_version().split('.') + cc = meson.get_compiler('c') config_h = configuration_data() @@ -32,6 +34,9 @@ config_h.set10('ENABLE_NLS', true) config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale')) config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR') +# Development build setup +config_h.set('DEVELOPMENT_BUILD', version_split[1].to_int().is_odd()) + has_use_clockid = cc.has_member('struct perf_event_attr', 'use_clockid', prefix: '#include ') has_clockid = cc.has_member('struct perf_event_attr', 'clockid', prefix: '#include ') if has_use_clockid and has_clockid diff --git a/src/resources/sysprof.gresource.xml b/src/resources/sysprof.gresource.xml index 8fed68dc..2d45c46d 100644 --- a/src/resources/sysprof.gresource.xml +++ b/src/resources/sysprof.gresource.xml @@ -6,6 +6,7 @@ theme/shared.css + theme/Adwaita-shared.css ui/sp-window.ui diff --git a/src/resources/theme/Adwaita-shared.css b/src/resources/theme/Adwaita-shared.css new file mode 100644 index 00000000..244172f1 --- /dev/null +++ b/src/resources/theme/Adwaita-shared.css @@ -0,0 +1,13 @@ + +/* development styles */ +window.development-version headerbar { + background: transparent -gtk-icontheme("system-run-symbolic") 80% 0/128px 128px no-repeat, + linear-gradient(to left, + mix(@theme_fg_color, @theme_bg_color, 0.5) 0%, + @theme_bg_color 25%); + color: alpha(@theme_fg_color, 0.2); +} + +window.development-version headerbar label { + color: @theme_fg_color; +} diff --git a/src/sp-application.c b/src/sp-application.c index b7f39e07..21bee637 100644 --- a/src/sp-application.c +++ b/src/sp-application.c @@ -100,6 +100,9 @@ static void sp_application_startup (GApplication *application) { g_autoptr(GtkCssProvider) provider = NULL; +#ifdef DEVELOPMENT_BUILD + g_autoptr(GtkCssProvider) adwaita = NULL; +#endif g_assert (SP_IS_APPLICATION (application)); @@ -111,6 +114,14 @@ sp_application_startup (GApplication *application) GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +#ifdef DEVELOPMENT_BUILD + adwaita = gtk_css_provider_new (); + gtk_css_provider_load_from_resource (adwaita, "/org/gnome/sysprof/theme/Adwaita-shared.css"); + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (adwaita), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +#endif + for (guint i = 0; default_accels[i].action_name; i++) gtk_application_set_accels_for_action (GTK_APPLICATION (application), default_accels[i].action_name, diff --git a/src/sp-window.c b/src/sp-window.c index 5d0485e8..46430573 100644 --- a/src/sp-window.c +++ b/src/sp-window.c @@ -16,6 +16,10 @@ * along with this program. If not, see . */ +#include "config.h" + +#define G_LOG_DOMAIN "sp-window" + #include #include #include @@ -859,6 +863,10 @@ sp_window_init (SpWindow *self) gtk_widget_init_template (GTK_WIDGET (self)); +#ifdef DEVELOPMENT_BUILD + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "development-version"); +#endif + /* * Hookup widget signals. */