[yocto] [matchbox-desktop-2][PATCH 04/16] main: load a custom CSS stylesheet if present
Jussi Kukkonen
jussi.kukkonen at intel.com
Thu Apr 28 06:02:57 PDT 2016
From: Ross Burton <ross.burton at intel.com>
---
src/Makefile.am | 7 ++++++-
src/main.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index e8fa7e2..5f5e961 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,9 @@
-AM_CPPFLAGS = $(GTK_CFLAGS) $(DBUS_CFLAGS) $(SN_CFLAGS) -I$(top_srcdir)
+AM_CPPFLAGS = \
+ $(GTK_CFLAGS) \
+ $(DBUS_CFLAGS) \
+ $(SN_CFLAGS) \
+ -I$(top_srcdir) \
+ -DPKGDATADIR=\"$(pkgdatadir)\"
AM_CFLAGS = $(WARN_CFLAGS)
bin_PROGRAMS = matchbox-desktop
diff --git a/src/main.c b/src/main.c
index e6d7231..7b8a276 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,32 +43,53 @@ emit_loaded_signal (gpointer user_data)
dbus_connection_send (conn, msg, NULL);
dbus_message_unref (msg);
-
+
/* Flush explicitly because we're too lazy to integrate DBus into the main
loop. We're only sending a signal, so if we got as far as here it's
unlikely to block. */
dbus_connection_flush (conn);
dbus_connection_unref (conn);
-
+
return FALSE;
}
#endif
+static void
+load_style (GtkWidget *widget)
+{
+ GtkCssProvider *provider;
+ GError *error = NULL;
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_path (GTK_CSS_PROVIDER (provider),
+ PKGDATADIR "/style.css", &error);
+ if (error) {
+ g_warning ("Cannot load CSS: %s", error->message);
+ g_error_free (error);
+ } else {
+ gtk_style_context_add_provider_for_screen
+ (gtk_widget_get_screen (widget),
+ GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+ g_object_unref (provider);
+}
+
int
main (int argc, char **argv)
{
GtkWidget *desktop;
-
+
gtk_init (&argc, &argv);
g_set_application_name (_("Desktop"));
#if WITH_DBUS
g_idle_add (emit_loaded_signal, NULL);
#endif
-
+
desktop = create_desktop ();
+ load_style (desktop);
gtk_main ();
destroy_desktop ();
-
+
return 0;
}
--
2.8.1
More information about the yocto
mailing list