From bcd585907baac071b78090894992930fbf9410af Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 27 Jun 2013 18:02:04 -0700 Subject: Add CSS files in a GResource resource:///com/endlessm/sdk/ is now the official GResource path for SDK resources. Right now the GResource contains reset.css (from GTK) and endless-widgets.css (from eos-theme). [endlessm/eos-sdk#125] --- .gitignore | 2 ++ configure.ac | 2 ++ data/css/endless-widgets.css | 51 +++++++++++++++++++++++++++++++++ data/css/reset.css | 68 ++++++++++++++++++++++++++++++++++++++++++++ data/eos-sdk.gresource.xml | 7 +++++ endless/Makefile.am | 23 +++++++++++++++ 6 files changed, 153 insertions(+) create mode 100644 data/css/endless-widgets.css create mode 100644 data/css/reset.css create mode 100644 data/eos-sdk.gresource.xml diff --git a/.gitignore b/.gitignore index 2e12801..f9e0fa3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ test/run-tests test/smoke-tests/hello Endless-0.gir Endless-0.typelib +endless/eosresource.c +endless/eosresource-private.h *.py[cod] diff --git a/configure.ac b/configure.ac index 74c167e..43de02c 100644 --- a/configure.ac +++ b/configure.ac @@ -118,6 +118,8 @@ AC_PATH_PROG([GIRDOCTOOL], [g-ir-doc-tool], [notfound]) AC_ARG_VAR([GIRDOCTOOL], [Path to g-ir-doc-tool]) AC_PATH_PROG([YELPBUILD], [yelp-build], [notfound]) AC_ARG_VAR([YELPBUILD], [Path to yelp-build]) +GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0` +AC_SUBST(GLIB_COMPILE_RESOURCES) AC_CACHE_SAVE diff --git a/data/css/endless-widgets.css b/data/css/endless-widgets.css new file mode 100644 index 0000000..faf1e38 --- /dev/null +++ b/data/css/endless-widgets.css @@ -0,0 +1,51 @@ +/* Wipe all theming CSS to start with */ + +@import url("resource:///com/endlessm/sdk/css/reset.css"); + +/* Endless window top bar */ + +.top-bar { + background-image: -gtk-gradient(linear, center top, center bottom, + from(#3c3c3c), to(#292929)); +} + +.top-bar .button { + padding: 0px; + background-image: none; + border-width: 0px; + border-radius: 2px; + border-image: none; +} + +.top-bar .button:hover { + background-image: -gtk-gradient(linear, left bottom, left top, + color-stop(0.98, rgb(131,131,131)), + color-stop(0.95, rgb(108,108,108)), + color-stop(0, rgb(68,68,68))); +} + +.top-bar .button:active { + background-image: -gtk-gradient(linear, left bottom, left top, + color-stop(0.98, rgb(79,79,79)), + color-stop(0.95, rgb(71,71,71)), + color-stop(0, rgb(67,67,67))); +} + +.top-bar .button:backdrop { + color: #8a8a8a; + background-image: none; + background-color: transparent; +} + +/* Topbar icon colors */ +.top-bar .button * { + color: #8a8a8a; +} + +.top-bar .button *:hover { + color: #ffffff; +} + +.top-bar .button *:active { + color: #8a8a8a; +} diff --git a/data/css/reset.css b/data/css/reset.css new file mode 100644 index 0000000..1c27a8e --- /dev/null +++ b/data/css/reset.css @@ -0,0 +1,68 @@ +/* @import this colorsheet to get the default values for every property. + * This is useful when writing special CSS tests that should not be + * inluenced by themes - not even the default ones. + * Keep in mind that the output will be very ugly and not look like + * anything GTK. + * Also, when adding new style properties, please add them here. + */ + +* { + color: inherit; + font-size: inherit; + background-color: initial; + font-family: inherit; + font-style: inherit; + font-variant: inherit; + font-weight: inherit; + text-shadow: inherit; + icon-shadow: inherit; + box-shadow: initial; + margin-top: initial; + margin-left: initial; + margin-bottom: initial; + margin-right: initial; + padding-top: initial; + padding-left: initial; + padding-bottom: initial; + padding-right: initial; + border-top-style: initial; + border-top-width: initial; + border-left-style: initial; + border-left-width: initial; + border-bottom-style: initial; + border-bottom-width: initial; + border-right-style: initial; + border-right-width: initial; + border-top-left-radius: initial; + border-top-right-radius: initial; + border-bottom-right-radius: initial; + border-bottom-left-radius: initial; + outline-style: initial; + outline-width: initial; + outline-offset: initial; + background-clip: initial; + background-origin: initial; + background-size: initial; + background-position: initial; + border-top-color: initial; + border-right-color: initial; + border-bottom-color: initial; + border-left-color: initial; + outline-color: initial; + background-repeat: initial; + background-image: initial; + border-image-source: initial; + border-image-repeat: initial; + border-image-slice: initial; + border-image-width: initial; + transition-property: initial; + transition-duration: initial; + transition-timing-function: initial; + transition-delay: initial; + engine: initial; + gtk-key-bindings: initial; + + -GtkWidget-focus-line-width: 0; + -GtkWidget-focus-padding: 0; + -GtkNotebook-initial-gap: 0; +} diff --git a/data/eos-sdk.gresource.xml b/data/eos-sdk.gresource.xml new file mode 100644 index 0000000..07b7ffd --- /dev/null +++ b/data/eos-sdk.gresource.xml @@ -0,0 +1,7 @@ + + + + css/reset.css + css/endless-widgets.css + + diff --git a/endless/Makefile.am b/endless/Makefile.am index 77f8c95..9b0eb4f 100644 --- a/endless/Makefile.am +++ b/endless/Makefile.am @@ -1,5 +1,27 @@ # Copyright 2013 Endless Mobile, Inc. +# Generate dependencies for make rule from XML resource file description +resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir)/data \ + --generate-dependencies $(srcdir)/data/eos-sdk.gresource.xml) + +# Generated sources for GResource file +endless/eosresource-private.h: data/eos-sdk.gresource.xml $(resource_files) + $(AM_V_GEN) $(MKDIR_P) $(builddir)/data && \ + $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data \ + --generate-header --internal $< +endless/eosresource.c: data/eos-sdk.gresource.xml $(resource_files) + $(AM_V_GEN) $(MKDIR_P) $(builddir)/data && \ + $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/data \ + --generate-source --internal $< + +BUILT_SOURCES = \ + endless/eosresource-private.h \ + endless/eosresource.c \ + $(NULL) +EXTRA_DIST += \ + $(resource_files) \ + data/eos-sdk.gresource.xml + endless_public_installed_headers = endless/endless.h endless_private_installed_headers = \ @@ -20,6 +42,7 @@ endless_library_sources = \ endless/eosinit.c endless/eosinit-private.h \ endless/eospagemanager.c endless/eospagemanager-private.h \ endless/eosmainarea.c endless/eosmainarea-private.h \ + endless/eosresource.c endless/eosresource-private.h \ endless/eossplashpagemanager.c \ endless/eostopbar.c endless/eostopbar-private.h \ endless/eosactionbutton.c \ -- cgit v1.2.3 From 449ea813a440c17c658cf173a44d5fd8d138837b Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 27 Jun 2013 18:05:06 -0700 Subject: Reset the GTK theme when starting up an EosApplication The GTK theme should be zeroed out so that we can develop the SDK with our own theme completely. [endlessm/eos-sdk#125] --- endless/eosapplication.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/endless/eosapplication.c b/endless/eosapplication.c index df7a15e..71ce190 100644 --- a/endless/eosapplication.c +++ b/endless/eosapplication.c @@ -7,6 +7,8 @@ #include "eoswindow.h" +#define CSS_THEME_URI "resource:///com/endlessm/sdk/css/endless-widgets.css" + /** * SECTION:application * @short_description: Start here with your application @@ -74,6 +76,28 @@ eos_application_activate (GApplication *application) /* TODO: Should it be required to override activate() as in GApplication? */ } +static void +eos_application_startup (GApplication *application) +{ + G_APPLICATION_CLASS (eos_application_parent_class)->startup (application); + + GtkCssProvider *provider = gtk_css_provider_new (); + + /* Reset CSS for SDK applications and apply our own theme on top of it. This + is so that we do not interfere with existing, complicated Adwaita theming. + */ + GFile *css_file = g_file_new_for_uri (CSS_THEME_URI); + gtk_css_provider_load_from_file (provider, css_file, NULL); + g_object_unref (css_file); + + gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), + GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); + g_debug ("Initialized theme\n"); + + g_object_unref (provider); +} + static void eos_application_window_added (GtkApplication *application, GtkWindow *window) @@ -130,6 +154,7 @@ eos_application_class_init (EosApplicationClass *klass) g_type_class_add_private (klass, sizeof (EosApplicationPrivate)); g_application_class->activate = eos_application_activate; + g_application_class->startup = eos_application_startup; gtk_application_class->window_added = eos_application_window_added; gtk_application_class->window_removed = eos_application_window_removed; } -- cgit v1.2.3