Code

Correcting statements collapsed to a single line.
[inkscape.git] / src / widgets / sp-color-slider.cpp
index 4b7771e630b4c2397dfcc8315810828fb00f7bcd..0e30b1ce64928402194a77bc9fda295504c2ed08 100644 (file)
  * This code is in public domain
  */
 
+#include <gtk/gtkversion.h>
 #include <gtk/gtksignal.h>
 #include "sp-color-scales.h"
+#include "preferences.h"
 
 #define SLIDER_WIDTH 96
 #define SLIDER_HEIGHT 8
@@ -58,10 +60,14 @@ static guint slider_signals[LAST_SIGNAL] = {0};
 GtkType
 sp_color_slider_get_type (void)
 {
+    //TODO: switch to GObject
+    // GtkType and such calls were deprecated a while back with the
+    // introduction of GObject as a separate layer, with GType instead. --JonCruz
+
        static GtkType type = 0;
        if (!type) {
                GtkTypeInfo info = {
-                       "SPColorSlider",
+                       (gchar*) "SPColorSlider",
                        sizeof (SPColorSlider),
                        sizeof (SPColorSliderClass),
                        (GtkClassInitFunc) sp_color_slider_class_init,
@@ -330,8 +336,14 @@ sp_color_slider_set_adjustment (SPColorSlider *slider, GtkAdjustment *adjustment
        g_return_if_fail (SP_IS_COLOR_SLIDER (slider));
 
        if (!adjustment) {
-               adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.1, 0.1);
+               adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.0, 0.0);
        }
+#if GTK_CHECK_VERSION (2,14,0)
+    else {
+        gtk_adjustment_set_page_increment(adjustment, 0.0);
+        gtk_adjustment_set_page_size(adjustment, 0.0);
+    }
+#endif
 
        if (slider->adjustment != adjustment) {
                if (slider->adjustment) {
@@ -449,6 +461,7 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
        GdkRectangle wpaint, cpaint, apaint;
        const guchar *b;
        gint w, x, y1, y2;
+       gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false);
 
        widget = GTK_WIDGET (slider);
 
@@ -471,10 +484,21 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
        aarea.height = carea.height;
 
        /* Actual paintable area */
-       if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return;
+       if (!gdk_rectangle_intersect (area, &warea, &wpaint)) {
+         return;
+       }
 
        b = NULL;
 
+        // Draw shadow
+        if (colorsOnTop) {
+            gtk_paint_shadow( widget->style, widget->window,
+                              (GtkStateType)widget->state, GTK_SHADOW_IN,
+                              area, widget, "colorslider",
+                              0, 0,
+                              warea.width, warea.height);
+        }
+
        /* Paintable part of color gradient area */
        if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
                if (slider->map) {
@@ -545,12 +569,14 @@ sp_color_slider_paint (SPColorSlider *slider, GdkRectangle *area)
                }
        }
 
-       /* Draw shadow */
-       gtk_paint_shadow (widget->style, widget->window,
-                         (GtkStateType)widget->state, GTK_SHADOW_IN,
-                         area, widget, "colorslider",
-                         0, 0,
-                         warea.width, warea.height);
+        /* Draw shadow */
+        if (!colorsOnTop) {
+            gtk_paint_shadow( widget->style, widget->window,
+                              (GtkStateType)widget->state, GTK_SHADOW_IN,
+                              area, widget, "colorslider",
+                              0, 0,
+                              warea.width, warea.height);
+        }
 
 
        if (gdk_rectangle_intersect (area, &aarea, &apaint)) {