[goffice] css: move css to central place
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] css: move css to central place
- Date: Sun, 3 Dec 2017 00:39:09 +0000 (UTC)
commit 68eb6050afdf11c2cd8d5b6bb89dd0b12e493c64
Author: Morten Welinder <terra gnome org>
Date: Sat Dec 2 19:38:41 2017 -0500
css: move css to central place
goffice/Makefile.am | 1 +
goffice/goffice.c | 1 +
goffice/gtk/go-rotation-sel.c | 18 +-----------------
goffice/gtk/goffice-gtk.c | 26 ++++++++++++++++++++++++++
goffice/gtk/goffice-gtk.h | 5 +++++
goffice/gtk/goffice.css | 13 +++++++++++++
6 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/goffice/Makefile.am b/goffice/Makefile.am
index 0fce905..bcff801 100644
--- a/goffice/Makefile.am
+++ b/goffice/Makefile.am
@@ -616,6 +616,7 @@ embedded_stuff_compress = \
utils/go-style-prefs.ui
embedded_stuff_raw = \
+ gtk/goffice.css \
utils/svg-patterns.xml \
utils/unknown_image.png \
graph/bar-none.png \
diff --git a/goffice/goffice.c b/goffice/goffice.c
index 5d2b450..a30cee8 100644
--- a/goffice/goffice.c
+++ b/goffice/goffice.c
@@ -264,6 +264,7 @@ libgoffice_shutdown (void)
_go_fonts_shutdown ();
_go_conf_shutdown ();
#ifdef GOFFICE_WITH_GTK
+ _go_gtk_shutdown ();
_goc_plugin_services_shutdown ();
#endif
_gog_plugin_services_shutdown ();
diff --git a/goffice/gtk/go-rotation-sel.c b/goffice/gtk/go-rotation-sel.c
index 4387554..3537d38 100644
--- a/goffice/gtk/go-rotation-sel.c
+++ b/goffice/gtk/go-rotation-sel.c
@@ -42,10 +42,7 @@ struct _GORotationSel {
typedef struct {
GtkGridClass parent_class;
void (* rotation_changed) (GORotationSel *grs, int angle);
-
- GtkCssProvider *css_canvas;
} GORotationSelClass;
-#define GO_ROTATION_SEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GO_TYPE_ROTATION_SEL,
GORotationSelClass))
enum {
ROTATION_CHANGED,
@@ -238,10 +235,7 @@ grs_init (GORotationSel *grs)
w = go_gtk_builder_get_widget (grs->gui, "toplevel");
gtk_grid_attach (GTK_GRID (grs), w, 0, 0, 1, 1);
- gtk_style_context_add_provider
- (gtk_widget_get_style_context (GTK_WIDGET (grs->rotate_canvas)),
- GTK_STYLE_PROVIDER (GO_ROTATION_SEL_GET_CLASS (grs)->css_canvas),
- GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
+ _go_gtk_widget_add_css_provider (GTK_WIDGET (grs->rotate_canvas));
gtk_widget_show_all (GTK_WIDGET (grs));
}
@@ -262,7 +256,6 @@ grs_finalize (GObject *obj)
static void
grs_class_init (GObjectClass *klass)
{
- GORotationSelClass *gors_class = (GORotationSelClass *) klass;
klass->finalize = grs_finalize;
grs_parent_class = g_type_class_peek (gtk_box_get_type ());
@@ -272,15 +265,6 @@ grs_class_init (GObjectClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
-
- gors_class->css_canvas = gtk_css_provider_new ();
- gtk_css_provider_load_from_data
- (gors_class->css_canvas,
- "GORotationSel GocCanvas {\n"
- " background-image: none;\n"
- " background-color: white;\n"
- "}\n",
- -1, NULL);
}
GSF_CLASS (GORotationSel, go_rotation_sel,
diff --git a/goffice/gtk/goffice-gtk.c b/goffice/gtk/goffice-gtk.c
index 8ed1085..91ce5b1 100644
--- a/goffice/gtk/goffice-gtk.c
+++ b/goffice/gtk/goffice-gtk.c
@@ -1633,3 +1633,29 @@ go_gtk_widget_render_icon_pixbuf (GtkWidget *widget,
return res;
}
+
+static GtkCssProvider *css_provider;
+
+void
+_go_gtk_widget_add_css_provider (GtkWidget *w)
+{
+ g_return_if_fail (GTK_IS_WIDGET (w));
+
+ if (!css_provider) {
+ const char *data = go_rsm_lookup ("go:gtk/goffice.css", NULL);
+ css_provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (css_provider, data, -1, NULL);
+ }
+
+ // NOTE: This applies to *just* this widget.
+ gtk_style_context_add_provider
+ (gtk_widget_get_style_context (w),
+ GTK_STYLE_PROVIDER (css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
+}
+
+void
+_go_gtk_shutdown (void)
+{
+ g_clear_object (&css_provider);
+}
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index 33d2e24..52ca7e6 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -56,6 +56,11 @@
G_BEGIN_DECLS
+void _go_gtk_shutdown (void);
+
+// Add goffice-specific css provider
+void _go_gtk_widget_add_css_provider (GtkWidget *w);
+
void go_gtk_editable_enters (GtkWindow *window, GtkWidget *w);
GtkBuilder *go_gtk_builder_load_internal (char const *uifile,
diff --git a/goffice/gtk/goffice.css b/goffice/gtk/goffice.css
new file mode 100644
index 0000000..c54011d
--- /dev/null
+++ b/goffice/gtk/goffice.css
@@ -0,0 +1,13 @@
+/*
+ * css bindings for goffice.
+ *
+ * These are loaded with "fallback" priority, i.e., everything else will
+ * override them.
+ */
+
+/* ------------------------------------------------------------------------- */
+
+GORotationSel GocCanvas {
+ background-image: none;
+ background-color: blue;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]