[goffice] GORotationSel: use css.



commit 8c35550994dbf03c42432e5e6fc29235308a21e7
Author: Morten Welinder <terra gnome org>
Date:   Sat Dec 2 18:46:46 2017 -0500

    GORotationSel: use css.

 ChangeLog                     |    5 +++++
 goffice/gtk/go-rotation-sel.c |   26 ++++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b146d38..c5d7b65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-12-02  Morten Welinder  <terra gnome org>
+
+       * goffice/gtk/go-rotation-sel.c (cb_rotate_canvas_realize): Use
+       css for styling.
+
 2017-12-01  Morten Welinder <terra gnome org>
 
        * configure.ac: Post-release bump.
diff --git a/goffice/gtk/go-rotation-sel.c b/goffice/gtk/go-rotation-sel.c
index 5ff0202..4387554 100644
--- a/goffice/gtk/go-rotation-sel.c
+++ b/goffice/gtk/go-rotation-sel.c
@@ -42,7 +42,10 @@ 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,
@@ -100,12 +103,8 @@ cb_rotate_canvas_realize (GocCanvas *canvas, GORotationSel *grs)
        GocGroup  *group = goc_canvas_get_root (canvas);
        int i, maxint = grs->full? 23: 12;
        GOStyle *go_style;
-       GdkRGBA color = {1., 1., 1., 1.};
        double x0 = grs->full? 100.: 15.;
 
-       gtk_widget_override_background_color (GTK_WIDGET (canvas),
-                                             GTK_STATE_FLAG_NORMAL, &color);
-
        for (i = 0 ; i <= maxint ; i++) {
                double rad = (i-6) * M_PI / 12.;
                double x = x0 + cos (rad) * 80.;
@@ -238,6 +237,12 @@ 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);
+
        gtk_widget_show_all (GTK_WIDGET (grs));
 }
 
@@ -257,8 +262,8 @@ grs_finalize (GObject *obj)
 static void
 grs_class_init (GObjectClass *klass)
 {
-       GObjectClass *gobj_class = (GObjectClass *) klass;
-       gobj_class->finalize = grs_finalize;
+       GORotationSelClass *gors_class = (GORotationSelClass *) klass;
+       klass->finalize = grs_finalize;
 
        grs_parent_class = g_type_class_peek (gtk_box_get_type ());
        grs_signals [ROTATION_CHANGED] = g_signal_new ("rotation-changed",
@@ -267,6 +272,15 @@ 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]