[gnome-software] trivial: Save the custom CSS in a GResource rather than loading it from a file
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Save the custom CSS in a GResource rather than loading it from a file
- Date: Tue, 29 Jan 2013 16:32:31 +0000 (UTC)
commit f5a12169da7950e6a6cc52b16227db126ddbc606
Author: Richard Hughes <richard hughsie com>
Date: Tue Jan 29 15:49:17 2013 +0000
trivial: Save the custom CSS in a GResource rather than loading it from a file
data/Makefile.am | 3 +--
src/Makefile.am | 1 +
src/gnome-software.gresource.xml | 1 +
src/gs-main.c | 33 ++++++++++++++++++++++-----------
{data => src}/gtk-style.css | 0
5 files changed, 25 insertions(+), 13 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 4b12afe..b171df1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,8 +2,7 @@ resourcesdir = $(datadir)/gnome-software
dist_resources_DATA = \
featured-gimp.png \
featured-firefox.png \
- featured-xchat.png \
- gtk-style.css
+ featured-xchat.png
MAINTAINERCLEANFILES = \
*~ \
diff --git a/src/Makefile.am b/src/Makefile.am
index b6d8738..ed239c3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,7 @@ BUILT_SOURCES = \
EXTRA_DIST = \
core-apps.txt \
gnome-software.gresource.xml \
+ gtk-style.css \
$(desktop_in_files) \
$(UI_FILES)
diff --git a/src/gnome-software.gresource.xml b/src/gnome-software.gresource.xml
index d35caa2..c8d1de2 100644
--- a/src/gnome-software.gresource.xml
+++ b/src/gnome-software.gresource.xml
@@ -3,5 +3,6 @@
<gresource prefix="/org/gnome/software">
<file compressed="true">gnome-software.ui</file>
<file>core-apps.txt</file>
+ <file>gtk-style.css</file>
</gresource>
</gresources>
diff --git a/src/gs-main.c b/src/gs-main.c
index 1b79903..498741c 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -30,7 +30,6 @@
#include "gs-app-widget.h"
#include "gs-resources.h"
-#define CSS_FILE DATADIR "/gnome-software/gtk-style.css"
#define GS_MAIN_ICON_SIZE 64
typedef enum {
@@ -1228,29 +1227,41 @@ gs_main_installed_sort_func (gconstpointer a,
static void
gs_main_startup_cb (GApplication *application, GsMainPrivate *priv)
{
+ GBytes *data = NULL;
GError *error = NULL;
gint retval;
GtkWidget *main_window;
GtkWidget *widget;
+ gboolean ret;
/* get CSS */
if (priv->provider == NULL) {
priv->provider = gtk_css_provider_new ();
-
-
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER (priv->provider),
G_MAXUINT);
-
- gtk_css_provider_load_from_path (priv->provider, CSS_FILE, &error);
- if (error != NULL) {
- g_warning ("Error loading stylesheet from file %s. %s", CSS_FILE, error->message);
+ data = g_resource_lookup_data (gs_get_resource (),
+ "/org/gnome/software/gtk-style.css",
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ &error);
+ if (data == NULL) {
+ g_warning ("failed to load stylesheet data: %s",
+ error->message);
g_error_free (error);
- error = NULL;
+ goto out;
+ }
+ ret = gtk_css_provider_load_from_data (priv->provider,
+ g_bytes_get_data (data, NULL),
+ g_bytes_get_size (data),
+ &error);
+ if (!ret) {
+ g_warning ("failed to load stylesheet: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
}
}
-
/* get UI */
priv->builder = gtk_builder_new ();
retval = gtk_builder_add_from_resource (priv->builder,
@@ -1286,7 +1297,6 @@ gs_main_startup_cb (GApplication *application, GsMainPrivate *priv)
/* setup featured tiles */
gs_main_setup_featured (priv);
-
/* setup installed */
priv->list_box_installed = egg_list_box_new ();
egg_list_box_set_separator_funcs (priv->list_box_installed,
@@ -1349,7 +1359,8 @@ gs_main_startup_cb (GApplication *application, GsMainPrivate *priv)
/* show main UI */
gtk_widget_show (main_window);
out:
- return;
+ if (data != NULL)
+ g_bytes_unref (data);
}
/**
diff --git a/data/gtk-style.css b/src/gtk-style.css
similarity index 100%
rename from data/gtk-style.css
rename to src/gtk-style.css
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]