diff --git a/data/calendar.gresource.xml b/data/calendar.gresource.xml
index 1c11d23f..db0ed4ee 100644
--- a/data/calendar.gresource.xml
+++ b/data/calendar.gresource.xml
@@ -20,7 +20,8 @@
ui/week-view.ui
ui/window.ui
ui/year-view.ui
- theme/gtk-styles.css
+
+ theme/Adwaita.css
diff --git a/data/theme/gtk-styles.css b/data/theme/Adwaita.css
similarity index 100%
rename from data/theme/gtk-styles.css
rename to data/theme/Adwaita.css
diff --git a/src/gcal-application.c b/src/gcal-application.c
index 1aa9ca07..470f416d 100644
--- a/src/gcal-application.c
+++ b/src/gcal-application.c
@@ -35,8 +35,6 @@
#include
#include
-#define CSS_FILE "/org/gnome/calendar/gtk-styles.css"
-
struct _GcalApplication
{
GtkApplication parent;
@@ -155,6 +153,37 @@ process_sources (GcalApplication *application)
g_free (new_css_data);
}
+static void
+load_css_provider (GcalApplication *self)
+{
+ g_autoptr (GFile) css_file = NULL;
+ g_autofree gchar *theme_name = NULL;
+ g_autofree gchar *theme_uri = NULL;
+
+ /* Apply the CSS provider */
+ self->provider = gtk_css_provider_new ();
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (self->provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
+
+ /* Retrieve the theme name */
+ g_object_get (gtk_settings_get_default (), "gtk-theme-name", &theme_name, NULL);
+ theme_uri = g_strconcat ("resource:///org/gnome/calendar/theme/", theme_name, ".css", NULL);
+
+ /* Try and load the CSS file */
+ css_file = g_file_new_for_uri (theme_uri);
+
+ if (g_file_query_exists (css_file, NULL))
+ gtk_css_provider_load_from_file (self->provider, css_file, NULL);
+ else
+ gtk_css_provider_load_from_resource (self->provider, "/org/gnome/calendar/theme/Adwaita.css");
+}
+
+
+/*
+ * GObject overrides
+ */
+
static void
gcal_application_finalize (GObject *object)
{
@@ -186,15 +215,7 @@ gcal_application_activate (GApplication *application)
self = GCAL_APPLICATION (application);
if (!self->provider)
- {
- self->provider = gtk_css_provider_new ();
-
- gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
- GTK_STYLE_PROVIDER (self->provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
-
- gtk_css_provider_load_from_resource (self->provider, CSS_FILE);
- }
+ load_css_provider (self);
if (self->colors_provider)
{