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(+) (limited to 'endless/eosapplication.c') 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