[gnumeric] GUI: Theme GnmPreviewGrid too.



commit 0a9a2736ae633b8f4f1de54438c0dba9bd74bf9f
Author: Morten Welinder <terra gnome org>
Date:   Mon Mar 25 22:31:05 2013 -0400

    GUI: Theme GnmPreviewGrid too.

 src/dialogs/dialog-autoformat.c  |   12 ++++++------
 src/dialogs/dialog-cell-format.c |    6 +++---
 src/gnm-pane.c                   |    2 +-
 src/gnumeric.css                 |    2 +-
 src/item-cursor.c                |    1 -
 src/item-edit.c                  |    2 +-
 src/preview-grid-impl.h          |   14 +++++++-------
 src/preview-grid.c               |   35 +++++++++++++++++------------------
 src/preview-grid.h               |   11 +++++------
 9 files changed, 41 insertions(+), 44 deletions(-)
---
diff --git a/src/dialogs/dialog-autoformat.c b/src/dialogs/dialog-autoformat.c
index 48504e8..08f698b 100644
--- a/src/dialogs/dialog-autoformat.c
+++ b/src/dialogs/dialog-autoformat.c
@@ -121,13 +121,13 @@ typedef struct {
 /********************************************************************************/
 
 typedef struct {
-       PreviewGrid base;
+       GnmPreviewGrid base;
        GnmFormatTemplate *ft;
 } AutoFormatGrid;
-typedef PreviewGridClass AutoFormatGridClass;
+typedef GnmPreviewGridClass AutoFormatGridClass;
 
 static GnmStyle *
-afg_get_cell_style (PreviewGrid *pg, int col, int row)
+afg_get_cell_style (GnmPreviewGrid *pg, int col, int row)
 {
        /* If this happens to be NULL the default style
         * will automatically be used. */
@@ -136,7 +136,7 @@ afg_get_cell_style (PreviewGrid *pg, int col, int row)
 }
 
 static GnmValue *
-afg_get_cell_value (G_GNUC_UNUSED PreviewGrid *pg, int col, int row)
+afg_get_cell_value (G_GNUC_UNUSED GnmPreviewGrid *pg, int col, int row)
 {
        char const *text;
        char *endptr = NULL;
@@ -154,7 +154,7 @@ afg_get_cell_value (G_GNUC_UNUSED PreviewGrid *pg, int col, int row)
 }
 
 static void
-auto_format_grid_class_init (PreviewGridClass *klass)
+auto_format_grid_class_init (GnmPreviewGridClass *klass)
 {
        klass->get_cell_style = afg_get_cell_style;
        klass->get_cell_value = afg_get_cell_value;
@@ -162,7 +162,7 @@ auto_format_grid_class_init (PreviewGridClass *klass)
 
 static GSF_CLASS (AutoFormatGrid, auto_format_grid,
                  auto_format_grid_class_init, NULL,
-                 preview_grid_get_type())
+                 gnm_preview_grid_get_type())
 
 static GocItem *
 auto_format_grid_new (AutoFormatState *state, int i, GnmFormatTemplate *ft)
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index 8ac4915..2925350 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -165,7 +165,7 @@ typedef struct _FormatState {
        } border;
        struct {
                GocCanvas       *canvas;
-               PreviewGrid     *grid;
+               GnmPreviewGrid     *grid;
                GnmStyle        *style;
 
                ColorPicker      back_color;
@@ -1039,9 +1039,9 @@ fmt_dialog_init_background_page (FormatState *state)
                           GTK_WIDGET (state->back.canvas));
        gtk_widget_show_all (widget);
 
-       state->back.grid = PREVIEW_GRID (goc_item_new (
+       state->back.grid = GNM_PREVIEW_GRID (goc_item_new (
                                                 goc_canvas_get_root (state->back.canvas),
-                                                preview_grid_get_type (),
+                                                gnm_preview_grid_get_type (),
                                                 "render-gridlines",    FALSE,
                                                 "default-col-width",   w,
                                                 "default-row-height",  h,
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 06821b5..56c05b3 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -1940,7 +1940,7 @@ gnm_pane_object_autoscroll (GnmPane *pane, GdkDragContext *context,
  * gnm_pane_object_group:
  * @pane: #GnmPane
  *
- * Returns: (transfer none): the #GocGroup including all #ShetObjectiew
+ * Returns: (transfer none): the #GocGroup including all #SheetObjectView
  * instances in @pane.
  **/
 GocGroup *
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 6fda5e8..ba342b3 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -1,6 +1,6 @@
 /* ------------------------------------------------------------------------- */
 /* The GnmItemGrid is the canvas area that holds all the cells.  */
-GnmItemGrid {
+GnmItemGrid, GnmPreviewGrid {
   background-color: white;
 }
 
diff --git a/src/item-cursor.c b/src/item-cursor.c
index f8ea3c1..e3c1d49 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -473,7 +473,6 @@ item_cursor_draw (GocItem const *item, cairo_t *cr)
                        gdk_cairo_set_source_rgba (cr, fore);
                        cairo_stroke (cr);
                }
-
        }
        cairo_restore (cr);
 }
diff --git a/src/item-edit.c b/src/item-edit.c
index 3436329..b15d4eb 100644
--- a/src/item-edit.c
+++ b/src/item-edit.c
@@ -249,7 +249,7 @@ item_edit_draw (GocItem const *item, cairo_t *cr)
 
 static double
 item_edit_distance (GocItem *item, double cx, double cy,
-                GocItem **actual_item)
+                   GocItem **actual_item)
 {
        *actual_item = NULL;
        if ((cx < item->x0) || (cy < item->y0) || (cx >= item->x1) || (cy >= item->y1))
diff --git a/src/preview-grid-impl.h b/src/preview-grid-impl.h
index 65fed06..8c6548f 100644
--- a/src/preview-grid-impl.h
+++ b/src/preview-grid-impl.h
@@ -1,18 +1,18 @@
 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 #ifndef _GNM_PREVIEW_GRID_IMPL_H_
-# define _GNM_PREVIEW_GRID_IMPL_H_
+#define _GNM_PREVIEW_GRID_IMPL_H_
 
 #include "preview-grid.h"
 #include <goffice/goffice.h>
 
 G_BEGIN_DECLS
 
-struct _PreviewGrid {
+struct GnmPreviewGrid_ {
        GocGroup base;
 
        Sheet *sheet;
 
-       struct {
+       struct GnmPreviewGridDefaults_ {
                int     col_width;
                int     row_height;
                GnmStyle *style;
@@ -26,11 +26,11 @@ typedef struct {
        GocGroupClass parent_class;
 
        /* Virtuals */
-       GnmStyle * (* get_cell_style) (PreviewGrid *pg, int col, int row);
-       GnmValue*(* get_cell_value) (PreviewGrid *pg, int col, int row);
-} PreviewGridClass;
+       GnmStyle * (* get_cell_style) (GnmPreviewGrid *pg, int col, int row);
+       GnmValue*(* get_cell_value) (GnmPreviewGrid *pg, int col, int row);
+} GnmPreviewGridClass;
 
-#define PREVIEW_GRID_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), preview_grid_get_type (), 
PreviewGridClass))
+#define GNM_PREVIEW_GRID_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), gnm_preview_grid_get_type (), 
GnmPreviewGridClass))
 
 G_END_DECLS
 
diff --git a/src/preview-grid.c b/src/preview-grid.c
index ac2e45c..c206b46 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -54,9 +54,9 @@ enum {
 /*****************************************************************************/
 
 static GnmStyle *
-pg_get_style (PreviewGrid *pg, int col, int row)
+pg_get_style (GnmPreviewGrid *pg, int col, int row)
 {
-       PreviewGridClass *klass = PREVIEW_GRID_GET_CLASS (pg);
+       GnmPreviewGridClass *klass = GNM_PREVIEW_GRID_GET_CLASS (pg);
        GnmStyle *style;
 
        g_return_val_if_fail (col >= 0 && col < gnm_sheet_get_max_cols (pg->sheet), NULL);
@@ -73,9 +73,9 @@ pg_get_style (PreviewGrid *pg, int col, int row)
 }
 
 static GnmCell *
-pg_fetch_cell (PreviewGrid *pg, int col, int row)
+pg_fetch_cell (GnmPreviewGrid *pg, int col, int row)
 {
-       PreviewGridClass *klass = PREVIEW_GRID_GET_CLASS (pg);
+       GnmPreviewGridClass *klass = GNM_PREVIEW_GRID_GET_CLASS (pg);
        GnmCell *cell;
        GnmValue *v = NULL;
 
@@ -106,7 +106,7 @@ pg_fetch_cell (PreviewGrid *pg, int col, int row)
  * Return value: Row containing pixel y (and origin in @row_origin)
  **/
 static int
-pg_get_row_offset (PreviewGrid *pg, int const y, int *row_origin)
+pg_get_row_offset (GnmPreviewGrid *pg, int const y, int *row_origin)
 {
        int row   = 0;
        int pixel = 1;
@@ -137,7 +137,7 @@ pg_get_row_offset (PreviewGrid *pg, int const y, int *row_origin)
  * Return value: Column containing pixel x (and origin in @col_origin)
  **/
 static int
-pg_get_col_offset (PreviewGrid *pg, int const x, int *col_origin)
+pg_get_col_offset (GnmPreviewGrid *pg, int const x, int *col_origin)
 {
        int col   = 0;
        int pixel = 1;
@@ -171,7 +171,7 @@ preview_grid_update_bounds (GocItem *item)
 }
 
 static void
-preview_grid_draw_background (cairo_t *cr, PreviewGrid const *pg, GnmStyle const *mstyle,
+preview_grid_draw_background (cairo_t *cr, GnmPreviewGrid const *pg, GnmStyle const *mstyle,
                              int col, int row, int x, int y, int w, int h)
 {
        if (gnumeric_background_set (mstyle, cr, FALSE, NULL)) {
@@ -182,7 +182,7 @@ preview_grid_draw_background (cairo_t *cr, PreviewGrid const *pg, GnmStyle const
 }
 
 static void
-pg_style_get_row (PreviewGrid *pg, GnmStyleRow *sr)
+pg_style_get_row (GnmPreviewGrid *pg, GnmStyleRow *sr)
 {
        int const row = sr->row;
        int col;
@@ -207,7 +207,7 @@ preview_grid_draw_region (GocItem const *item, cairo_t *cr,
        gint width  = expose->area.width;
        gint height = expose->area.height;
 #endif
-       PreviewGrid *pg = PREVIEW_GRID (item);
+       GnmPreviewGrid *pg = GNM_PREVIEW_GRID (item);
 
        /* To ensure that far and near borders get drawn we pretend to draw +-2
         * pixels around the target area which would include the surrounding
@@ -254,9 +254,8 @@ preview_grid_draw_region (GocItem const *item, cairo_t *cr,
                colwidths[col] = pg->defaults.col_width;
 
        /* Fill entire region with default background (even past far edge) */
-       cairo_set_source_rgb (cr, 1., 1., 1.);
-       cairo_rectangle (cr, diff_x, diff_y, x1 - x0, y1 - y0);
-       cairo_fill (cr);
+       gtk_render_background (goc_item_get_style_context (item),
+                              cr, diff_x, diff_y, x1 - x0, y1 - y0);
 
        for (y = diff_y; row <= end_row; row = sr.row = next_sr.row) {
                if (++next_sr.row > end_row) {
@@ -311,7 +310,7 @@ static void
 preview_grid_set_property (GObject *obj, guint param_id,
                           GValue const *value, GParamSpec *pspec)
 {
-       PreviewGrid *pg = PREVIEW_GRID (obj);
+       GnmPreviewGrid *pg = GNM_PREVIEW_GRID (obj);
 
        switch (param_id){
        case PREVIEW_GRID_PROP_RENDER_GRIDLINES :
@@ -350,7 +349,7 @@ preview_grid_set_property (GObject *obj, guint param_id,
 static void
 preview_grid_dispose (GObject *obj)
 {
-       PreviewGrid *pg = PREVIEW_GRID (obj);
+       GnmPreviewGrid *pg = GNM_PREVIEW_GRID (obj);
 
        if (pg->defaults.style != NULL) {
                gnm_style_unref (pg->defaults.style);
@@ -368,7 +367,7 @@ preview_grid_dispose (GObject *obj)
 }
 
 static void
-preview_grid_init (PreviewGrid *pg)
+gnm_preview_grid_init (GnmPreviewGrid *pg)
 {
        pg->sheet = g_object_new (GNM_SHEET_TYPE,
                                  "rows", 256,
@@ -382,7 +381,7 @@ preview_grid_init (PreviewGrid *pg)
 }
 
 static void
-preview_grid_class_init (GObjectClass *gobject_klass)
+gnm_preview_grid_class_init (GObjectClass *gobject_klass)
 {
        GocItemClass *item_klass = (GocItemClass *)gobject_klass;
 
@@ -414,6 +413,6 @@ preview_grid_class_init (GObjectClass *gobject_klass)
        item_klass->distance    = preview_grid_distance;
 }
 
-GSF_CLASS (PreviewGrid, preview_grid,
-          preview_grid_class_init, preview_grid_init,
+GSF_CLASS (GnmPreviewGrid, gnm_preview_grid,
+          gnm_preview_grid_class_init, gnm_preview_grid_init,
           GOC_TYPE_GROUP)
diff --git a/src/preview-grid.h b/src/preview-grid.h
index f7ccb51..d4d0acb 100644
--- a/src/preview-grid.h
+++ b/src/preview-grid.h
@@ -1,17 +1,16 @@
-/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 #ifndef _GNM_PREVIEW_GRID_H_
-# define _GNM_PREVIEW_GRID_H_
+#define _GNM_PREVIEW_GRID_H_
 
 #include "gnumeric.h"
 #include <glib-object.h>
 
 G_BEGIN_DECLS
 
-#define PREVIEW_GRID(obj)          (G_TYPE_CHECK_INSTANCE_CAST((obj), preview_grid_get_type (), PreviewGrid))
-#define IS_PREVIEW_GRID(o)         (G_TYPE_CHECK_INSTANCE_TYPE((o), preview_grid_get_type ()))
+#define GNM_PREVIEW_GRID(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), gnm_preview_grid_get_type (), 
GnmPreviewGrid))
+#define GNM_IS_PREVIEW_GRID(o)  (G_TYPE_CHECK_INSTANCE_TYPE((o), gnm_preview_grid_get_type ()))
 
-typedef struct _PreviewGrid PreviewGrid;
-GType preview_grid_get_type (void);
+typedef struct GnmPreviewGrid_ GnmPreviewGrid;
+GType gnm_preview_grid_get_type (void);
 
 G_END_DECLS
 


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