2011-10-07 [colin] 3.7.10cvs23
[claws.git] / src / gtk / gtkshruler.c
index 41839e6..aaeb0fd 100644 (file)
@@ -1,6 +1,6 @@
 /* GtkSHRuler
  *
- *  Copyright (C) 2000-2005 Alfons Hoogervorst & The Claws Mail Team
+ *  Copyright (C) 2000-2011 Alfons Hoogervorst & The Claws Mail Team
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
-#include <gtk/gtkhruler.h>
+#include <gtk/gtk.h>
 #include "gtkshruler.h"
+#include "utils.h"
+#include "gtkutils.h"
+
+#if !GTK_CHECK_VERSION(2,24,0)
 
 #define RULER_HEIGHT          14
 #define MINIMUM_INCR          5
@@ -113,23 +117,25 @@ static void
 gtk_shruler_draw_ticks(GtkRuler *ruler)
 {
        GtkWidget *widget;
-       GdkGC *gc, *bg_gc;
+       cairo_t *cr;
        gint i;
        gint width, height;
        gint xthickness;
        gint ythickness;
        gint pos;
 
-       g_return_if_fail (ruler != NULL);
-       g_return_if_fail (GTK_IS_HRULER (ruler));
+       cm_return_if_fail (ruler != NULL);
+       cm_return_if_fail (GTK_IS_HRULER (ruler));
 
-       if (!GTK_WIDGET_DRAWABLE (ruler)) 
+       if (!gtkut_widget_is_drawable (GTK_WIDGET(ruler))) 
                return;
 
        widget = GTK_WIDGET (ruler);
        
-       gc = widget->style->fg_gc[GTK_STATE_NORMAL];
-       bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL];
+       cr = gdk_cairo_create(ruler->backing_store);
+       cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+       cairo_set_line_width(cr, 1.);
+       gdk_cairo_set_source_color(cr, &gtk_widget_get_style(widget)->text[GTK_STATE_NORMAL]);
 
        xthickness = widget->style->xthickness;
        ythickness = widget->style->ythickness;
@@ -152,9 +158,9 @@ gtk_shruler_draw_ticks(GtkRuler *ruler)
                if ( pos % 10 == 0 ) length = ( 2 * height / 3 );
                else if ( pos % 5 == 0 ) length = ( height / 3 );
                
-               gdk_draw_line(ruler->backing_store, gc,
-                             i, height + ythickness,
-                             i, height - length);                      
+               cairo_move_to(cr, i, height + ythickness);
+               cairo_line_to(cr, i, height - length);
+               cairo_stroke(cr);
                
                if ( pos % 10 == 0 ) {
                        gchar buf[8];
@@ -166,10 +172,13 @@ gtk_shruler_draw_ticks(GtkRuler *ruler)
                        layout = gtk_widget_create_pango_layout
                                (GTK_WIDGET(ruler), buf);
 
-                       gdk_draw_layout(ruler->backing_store, gc, i + 2,
-                                       0, layout);
+                       cairo_move_to(cr, i+2, 0);
+                       pango_cairo_show_layout(cr, layout);
 
                        g_object_unref(layout);
                }
        }
+
+       cairo_destroy(cr);
 }
+#endif