Add an application specific CSS file

Add the ability to load an application specific CSS file called from
share/gnucash/ui/gnucash.css
This commit is contained in:
Robert Fewell 2017-07-23 11:40:08 +01:00 committed by John Ralls
parent 8fa2b0a67d
commit 8ab3aadffa
4 changed files with 24 additions and 6 deletions

View File

@ -172,26 +172,38 @@ gnc_configure_date_completion (void)
void
gnc_add_css_file (void)
{
GtkCssProvider *provider;
GtkCssProvider *provider_user, *provider_app;
GdkDisplay *display;
GdkScreen *screen;
const gchar *var;
gchar* pkgdatadir = gnc_path_get_pkgdatadir ();
gchar *str;
GError *error = 0;
provider = gtk_css_provider_new ();
provider_user = gtk_css_provider_new ();
provider_app = gtk_css_provider_new ();
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_app), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider_user), GTK_STYLE_PROVIDER_PRIORITY_USER);
if (pkgdatadir)
{
str = g_build_filename (pkgdatadir, "ui", "gnucash.css", (char *)NULL);
gtk_css_provider_load_from_path (provider_app, str, &error);
g_free (str);
}
g_free (pkgdatadir);
var = g_get_home_dir ();
if (var)
{
str = g_build_filename (var, ".gtk-3.0-gnucash.css", (char *)NULL);
gtk_css_provider_load_from_path (provider, str, &error);
gtk_css_provider_load_from_path (provider_user, str, &error);
g_free (str);
}
g_object_unref (provider);
g_object_unref (provider_user);
g_object_unref (provider_app);
}
#ifdef MAC_INTEGRATION

View File

@ -15,6 +15,7 @@ SET(gnome_utils_ui_DIST_local
gnc-windows-menu-ui.xml
Makefile.am
osx_accel_map
gnucash.css
)
SET_DIST_LIST(gnome_utils_ui_DIST ${gnome_utils_ui_DIST_local})

View File

@ -3,6 +3,7 @@ ui_DATA = \
gnc-main-window-ui.xml \
gnc-windows-menu-ui.xml \
gnc-windows-menu-ui-quartz.xml \
osx_accel_map
osx_accel_map \
gnucash.css
EXTRA_DIST = $(ui_DATA) CMakeLists.txt

View File

@ -0,0 +1,4 @@
/* Note: Widgets obtained from Glade files will not be addressable
directly by name as these are not brought in when loaded, only
the widget type can be configured unless they are named in code */