[gnumeric] GUI: Improve theming of sheet cursors.



commit d2a60f4249e553eb949a244d3395b97aeee239b2
Author: Morten Welinder <terra gnome org>
Date:   Tue Mar 26 11:57:08 2013 -0400

    GUI: Improve theming of sheet cursors.

 ChangeLog         |    6 ++++++
 src/gnumeric.css  |    7 ++++---
 src/item-cursor.c |   53 +++++++++++++++++++++++++++++++++++------------------
 3 files changed, 45 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c84a857..48de2be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-26  Morten Welinder  <terra gnome org>
+
+       * src/item-cursor.c (ic_reload_style): Use class, not state, to
+       separate the different cursor types.  Separate autofill colouring
+       from drag ditto.
+
 2013-03-25  Morten Welinder  <terra gnome org>
 
        * src/item-cursor.c (gnm_item_cursor_class_init): Change type of
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 8bca018..267ea5d 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -25,19 +25,20 @@ GnmItemGrid pane-divider {
 }
 
 /* The default cursor.  */
-GnmItemCursor {
+GnmItemCursor.normal {
   color: #000000;
 }
 
 /* The anted cursor.  We clearly should be using an animation, but neither
    we not gtk are ready for that.  */
-GnmItemCursor:hover {
+GnmItemCursor.ant {
   color: #333333;
   background-color: #c7c7c7;
 }
 
 /* The dragging/autofill cursor.  These colors are combined in a stipple.  */
-GnmItemCursor:selected {
+GnmItemCursor.drag,
+GnmItemCursor.autofill {
   color: white;
   background-color: black;
 }
diff --git a/src/item-cursor.c b/src/item-cursor.c
index 981c5ff..b644636 100644
--- a/src/item-cursor.c
+++ b/src/item-cursor.c
@@ -91,6 +91,7 @@ struct _GnmItemCursor {
        GdkRGBA normal_color;
        GdkRGBA ant_color, ant_background_color;
        GdkRGBA drag_color, drag_background_color;
+       GdkRGBA autofill_color, autofill_background_color;
 };
 typedef GocItemClass GnmItemCursorClass;
 
@@ -110,24 +111,33 @@ ic_reload_style (GnmItemCursor *ic)
 {
        GocItem *item = GOC_ITEM (ic);
        GtkStyleContext *context = goc_item_get_style_context (item);
-
-       gtk_style_context_get_color
-               (context, GTK_STATE_FLAG_NORMAL,
-                &ic->normal_color);
-
-       gtk_style_context_get_color
-               (context, GTK_STATE_FLAG_PRELIGHT,
-                &ic->ant_color);
-       gtk_style_context_get_background_color
-               (context, GTK_STATE_FLAG_PRELIGHT,
-                &ic->ant_background_color);
-
-       gtk_style_context_get_color
-               (context, GTK_STATE_FLAG_SELECTED,
-                &ic->drag_color);
-       gtk_style_context_get_background_color
-               (context, GTK_STATE_FLAG_SELECTED,
-                &ic->drag_background_color);
+       GtkStateFlags state = GTK_STATE_FLAG_NORMAL;
+
+       gtk_style_context_save (context);
+       gtk_style_context_add_class (context, "normal");
+       gtk_style_context_get_color (context, state, &ic->normal_color);
+       gtk_style_context_restore (context);
+
+       gtk_style_context_save (context);
+       gtk_style_context_add_class (context, "ant");
+       gtk_style_context_get_color (context, state, &ic->ant_color);
+       gtk_style_context_get_background_color (context, state,
+                                               &ic->ant_background_color);
+       gtk_style_context_restore (context);
+
+       gtk_style_context_save (context);
+       gtk_style_context_add_class (context, "drag");
+       gtk_style_context_get_color (context, state, &ic->drag_color);
+       gtk_style_context_get_background_color (context, state,
+                                               &ic->drag_background_color);
+       gtk_style_context_restore (context);
+
+       gtk_style_context_save (context);
+       gtk_style_context_add_class (context, "autofill");
+       gtk_style_context_get_color (context, state, &ic->autofill_color);
+       gtk_style_context_get_background_color (context, state,
+                                               &ic->autofill_background_color);
+       gtk_style_context_restore (context);
 }
 
 static int
@@ -269,6 +279,13 @@ item_cursor_draw (GocItem const *item, cairo_t *cr)
 
        switch (ic->style) {
        case GNM_ITEM_CURSOR_AUTOFILL:
+               draw_center   = TRUE;
+               draw_thick    = 3;
+               draw_stippled = TRUE;
+               fore          = &ic->autofill_color;
+               back          = &ic->autofill_background_color;
+               break;
+
        case GNM_ITEM_CURSOR_DRAG:
                draw_center   = TRUE;
                draw_thick    = 3;


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