mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move the CSS files to a Gresource file
Move the source CSS files to the gnucash directory and load them from a gresource file. As pseudo class 'insensative' is deprecated, add a second main css file to be used after Gtk3.20
This commit is contained in:
@@ -325,6 +325,9 @@ AC_CHECK_HEADERS(dirent.h dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.
|
||||
|
||||
GLIB_GSETTINGS
|
||||
|
||||
GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
|
||||
AC_SUBST(GLIB_COMPILE_RESOURCES)
|
||||
|
||||
# I'm sure we (used to?) require this in various places, so don't remove
|
||||
# this test unless you've done sufficient code review/testing.
|
||||
AC_MSG_CHECKING(if unsigned long is at least as big as guint32)
|
||||
|
||||
@@ -27,6 +27,7 @@ ENDIF (WIN32)
|
||||
|
||||
SET (gnucash_SOURCES
|
||||
gnucash-bin.c
|
||||
gnucash-gresources.c
|
||||
${GNUCASH_RESOURCE_FILE}
|
||||
)
|
||||
|
||||
@@ -42,6 +43,40 @@ TARGET_LINK_LIBRARIES (gnucash
|
||||
${GUILE_LDFLAGS} ${GLIB2_LDFLAGS} ${GTK3_LDFLAGS} ${GTK_MAC_LDFLAGS}
|
||||
)
|
||||
|
||||
# Get glib executable for generating the gresource file
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND
|
||||
${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_resources
|
||||
OUTPUT_VARIABLE
|
||||
GLIB_COMPILE_RESOURCES_EXECUTABLE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Get the dependencies of the gresource
|
||||
EXECUTE_PROCESS(
|
||||
OUTPUT_VARIABLE
|
||||
gr_files
|
||||
COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
|
||||
--sourcedir=${CMAKE_CURRENT_SOURCE_DIR}
|
||||
--generate-dependencies
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnucash-gresources.xml
|
||||
)
|
||||
|
||||
STRING (REPLACE "\n" ";" gresource_files ${gr_files})
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT gnucash-gresources.c
|
||||
COMMAND
|
||||
${GLIB_COMPILE_RESOURCES_EXECUTABLE}
|
||||
--target=gnucash-gresources.c
|
||||
--sourcedir=${CMAKE_CURRENT_SOURCE_DIR}
|
||||
--generate-source
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnucash-gresources.xml
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnucash-gresources.xml ${gresource_files}
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
IF (MAC_INTEGRATION)
|
||||
TARGET_COMPILE_OPTIONS(gnucash PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
|
||||
@@ -202,7 +237,7 @@ ENDIF(WIN32)
|
||||
|
||||
|
||||
SET_LOCAL_DIST(gnucash_DIST_local CMakeLists.txt environment.in generate-gnc-script
|
||||
gnucash-bin.c gnucash.rc.in gnucash-valgrind.in
|
||||
gnucash-bin.c gnucash.rc.in gnucash-valgrind.in gnucash-gresourses.xml ${gresource_files}
|
||||
Makefile.am ${gnucash_EXTRA_DIST})
|
||||
|
||||
SET(gnucash_DIST ${gnucash_DIST_local} ${gnome_DIST} ${gnome_search_DIST}
|
||||
|
||||
@@ -55,9 +55,14 @@ PLATFORM_FILES = gnucash-valgrind
|
||||
|
||||
endif !PLATFORM_WIN32
|
||||
|
||||
# gresource for css
|
||||
gresource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/gnucash-gresources.xml)
|
||||
gnucash-gresources.c: gnucash-gresources.xml $(gresource_files)
|
||||
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $<
|
||||
|
||||
BIN_NAME = gnucash
|
||||
bin_PROGRAMS = ${BIN_NAME}
|
||||
gnucash_SOURCES = gnucash-bin.c ${GNUCASH_RESOURCE_FILE}
|
||||
gnucash_SOURCES = gnucash-bin.c gnucash-gresources.c ${GNUCASH_RESOURCE_FILE}
|
||||
gnucash_LDADD = \
|
||||
${top_builddir}/gnucash/register/ledger-core/libgncmod-ledger-core.la \
|
||||
${top_builddir}/gnucash/report/report-gnome/libgncmod-report-gnome.la \
|
||||
@@ -156,6 +161,8 @@ EXTRA_DIST = \
|
||||
generate-gnc-script \
|
||||
gnucash-valgrind.in \
|
||||
environment.in \
|
||||
gnucash-gresources.xml \
|
||||
${gresource_files} \
|
||||
CMakeLists.txt
|
||||
|
||||
AM_CPPFLAGS += -DG_LOG_DOMAIN=\"gnc.bin\"
|
||||
|
||||
@@ -169,6 +169,33 @@ gnc_configure_date_completion (void)
|
||||
qof_date_completion_set(dc, backmonths);
|
||||
}
|
||||
|
||||
/* This function was copied from GTK3.22 as it was only introduced in
|
||||
* version 3.16 */
|
||||
#if !GTK_CHECK_VERSION(3,16,0)
|
||||
static void
|
||||
gtk_css_provider_load_from_resource (GtkCssProvider *css_provider,
|
||||
const gchar *resource_path)
|
||||
{
|
||||
GFile *file;
|
||||
gchar *uri, *escaped;
|
||||
|
||||
g_return_if_fail (GTK_IS_CSS_PROVIDER (css_provider));
|
||||
g_return_if_fail (resource_path != NULL);
|
||||
|
||||
escaped = g_uri_escape_string (resource_path,
|
||||
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
|
||||
uri = g_strconcat ("resource://", escaped, NULL);
|
||||
g_free (escaped);
|
||||
|
||||
file = g_file_new_for_uri (uri);
|
||||
g_free (uri);
|
||||
|
||||
gtk_css_provider_load_from_file (css_provider, file, NULL);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gnc_add_css_file (void)
|
||||
{
|
||||
@@ -176,8 +203,6 @@ gnc_add_css_file (void)
|
||||
GdkDisplay *display;
|
||||
GdkScreen *screen;
|
||||
const gchar *var;
|
||||
gchar* pkgdatadir = gnc_path_get_pkgdatadir ();
|
||||
gchar *str;
|
||||
GError *error = 0;
|
||||
|
||||
provider_user = gtk_css_provider_new ();
|
||||
@@ -190,21 +215,17 @@ gnc_add_css_file (void)
|
||||
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-fallback.css", (char *)NULL);
|
||||
gtk_css_provider_load_from_path (provider_fallback, str, &error);
|
||||
g_free (str);
|
||||
|
||||
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);
|
||||
#if GTK_CHECK_VERSION(3,20,0)
|
||||
gtk_css_provider_load_from_resource (provider_app, "/org/gnucash/gnucash-320.css");
|
||||
#else
|
||||
gtk_css_provider_load_from_resource (provider_app, "/org/gnucash/gnucash-310.css");
|
||||
#endif
|
||||
gtk_css_provider_load_from_resource (provider_fallback, "/org/gnucash/gnucash-fallback-310.css");
|
||||
|
||||
var = g_get_home_dir ();
|
||||
if (var)
|
||||
{
|
||||
gchar *str;
|
||||
str = g_build_filename (var, ".gtk-3.0-gnucash.css", (char *)NULL);
|
||||
gtk_css_provider_load_from_path (provider_user, str, &error);
|
||||
g_free (str);
|
||||
|
||||
@@ -15,8 +15,6 @@ SET(gnome_utils_ui_DIST_local
|
||||
gnc-windows-menu-ui.xml
|
||||
Makefile.am
|
||||
osx_accel_map
|
||||
gnucash.css
|
||||
gnucash-fallback.css
|
||||
)
|
||||
|
||||
SET_DIST_LIST(gnome_utils_ui_DIST ${gnome_utils_ui_DIST_local})
|
||||
|
||||
@@ -3,8 +3,6 @@ ui_DATA = \
|
||||
gnc-main-window-ui.xml \
|
||||
gnc-windows-menu-ui.xml \
|
||||
gnc-windows-menu-ui-quartz.xml \
|
||||
osx_accel_map \
|
||||
gnucash.css \
|
||||
gnucash-fallback.css
|
||||
osx_accel_map
|
||||
|
||||
EXTRA_DIST = $(ui_DATA) CMakeLists.txt
|
||||
|
||||
81
gnucash/gnucash-310.css
Normal file
81
gnucash/gnucash-310.css
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Note: Widgets obtained from Glade files will not be addressable
|
||||
unless they have been named or have style classes added. Only
|
||||
the widget type can be configured unless they are named in code */
|
||||
|
||||
|
||||
/* Negative value label colors */
|
||||
.default-color {
|
||||
color: @default-color;
|
||||
}
|
||||
|
||||
.negative-numbers {
|
||||
color: @negative-numbers;
|
||||
}
|
||||
|
||||
/* Change font color by mixing with grey */
|
||||
.lighter-grey-mix {
|
||||
color: mix (currentColor, grey, 0.8);
|
||||
}
|
||||
|
||||
.darker-grey-mix {
|
||||
color: mix (currentColor, grey, 0.2);
|
||||
}
|
||||
|
||||
/* Register Cursor padding settings, make sure entry matches sheet.h */
|
||||
cursor entry {
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
|
||||
cursor button {
|
||||
padding: 1px 1px 1px 1px;
|
||||
}
|
||||
|
||||
/* Register defaults */
|
||||
@define-color register_header_bg_color #96B183;
|
||||
@define-color register_primary_bg_color #BFDEB9;
|
||||
@define-color register_secondary_bg_color #F6FFDA;
|
||||
@define-color register_split_bg_color #EDE7D3;
|
||||
@define-color register_cursor_bg_color #FFEF98;
|
||||
|
||||
.register-header {
|
||||
background-color: @register_header_bg_color;
|
||||
}
|
||||
|
||||
*.register-primary {
|
||||
background-color: @register_primary_bg_color;
|
||||
}
|
||||
|
||||
*.register-primary:insensitive {
|
||||
background-color: mix (@register_primary_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
*.register-secondary {
|
||||
background-color: @register_secondary_bg_color;
|
||||
}
|
||||
|
||||
*.register-secondary:insensitive {
|
||||
background-color: mix (@register_secondary_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
*.register-split {
|
||||
background-color: @register_split_bg_color;
|
||||
}
|
||||
|
||||
*.register-split:insensitive {
|
||||
background-color: mix (@register_split_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
*.register-cursor {
|
||||
background-color: @register_cursor_bg_color;
|
||||
}
|
||||
|
||||
*.register-cursor:insensitive {
|
||||
background-color: mix (@register_cursor_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
/* Some tweaks for the about dialog */
|
||||
dialog#GnuCash > box > box > label
|
||||
{
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Note: Widgets obtained from Glade files will not be addressable
|
||||
unless they have been named or have style classes added. Only
|
||||
unless they have been named or have style classes added. Only
|
||||
the widget type can be configured unless they are named in code */
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ cursor button {
|
||||
background-color: @register_primary_bg_color;
|
||||
}
|
||||
|
||||
*.register-primary:insensitive {
|
||||
*.register-primary:disabled {
|
||||
background-color: mix (@register_primary_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ cursor button {
|
||||
background-color: @register_secondary_bg_color;
|
||||
}
|
||||
|
||||
*.register-secondary:insensitive {
|
||||
*.register-secondary:disabled {
|
||||
background-color: mix (@register_secondary_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ cursor button {
|
||||
background-color: @register_split_bg_color;
|
||||
}
|
||||
|
||||
*.register-split:insensitive {
|
||||
*.register-split:disabled {
|
||||
background-color: mix (@register_split_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,13 @@ cursor button {
|
||||
background-color: @register_cursor_bg_color;
|
||||
}
|
||||
|
||||
*.register-cursor:insensitive {
|
||||
*.register-cursor:disabled {
|
||||
background-color: mix (@register_cursor_bg_color, grey, 0.2);
|
||||
}
|
||||
|
||||
/* Some tweaks for the about dialog */
|
||||
dialog#GnuCash > box > box > label
|
||||
{
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Note: Widgets obtained from Glade files will not be addressable
|
||||
unless they have been named or have style classes added. Only
|
||||
unless they have been named or have style classes added. Only
|
||||
the widget type can be configured unless they are named in code */
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
@define-color marker_bg_color yellow;
|
||||
|
||||
*.primary {
|
||||
background-color: @primary_bg_color;
|
||||
background-color: @primary_bg_color;
|
||||
}
|
||||
|
||||
*.primary-dark {
|
||||
9
gnucash/gnucash-gresources.xml
Normal file
9
gnucash/gnucash-gresources.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnucash">
|
||||
<file>gnucash-310.css</file>
|
||||
<file>gnucash-320.css</file>
|
||||
<file>gnucash-fallback-310.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
Reference in New Issue
Block a user