[gthumb/gthumb-3-4] fixed theme errors with gtk+ 3.20



commit dda7a53d2e3d19f634d390d39a217e50027fdc4a
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Apr 4 10:45:19 2016 +0200

    fixed theme errors with gtk+ 3.20

 .../file_tools/data/ui/adjust-colors-options.ui    |   30 +-
 gthumb/gth-color-scale.c                           |  195 ++++++++-------
 gthumb/gth-grid-view.c                             |  269 ++++++++++++--------
 gthumb/gth-window.c                                |    4 +-
 gthumb/gthumb.gresource.xml                        |    1 +
 gthumb/resources/Makefile.am                       |    3 +-
 gthumb/resources/gthumb-gtk320.css                 |   94 +++++++
 gthumb/resources/gthumb.css                        |   20 +-
 8 files changed, 399 insertions(+), 217 deletions(-)
---
diff --git a/extensions/file_tools/data/ui/adjust-colors-options.ui 
b/extensions/file_tools/data/ui/adjust-colors-options.ui
index 5701629..387b2a0 100644
--- a/extensions/file_tools/data/ui/adjust-colors-options.ui
+++ b/extensions/file_tools/data/ui/adjust-colors-options.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
   <object class="GtkAdjustment" id="crop_height_adjustment">
@@ -91,10 +91,10 @@
                   <object class="GtkLabel" id="brightness_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">B_rightness:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -110,10 +110,10 @@
                   <object class="GtkLabel" id="contrast_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">Con_trast:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -129,10 +129,10 @@
                   <object class="GtkLabel" id="saturation_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">_Saturation:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -210,10 +210,10 @@
                   <object class="GtkLabel" id="gamma_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">G_amma:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -227,10 +227,10 @@
                   <object class="GtkLabel" id="cyan_red_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">Cyan-_Red:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -246,10 +246,10 @@
                   <object class="GtkLabel" id="magenta_green_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">_Magenta-Green:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
@@ -265,10 +265,10 @@
                   <object class="GtkLabel" id="yellow_blue_label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="xalign">1</property>
-                    <property name="yalign">0</property>
                     <property name="label" translatable="yes">_Yellow-Blue:</property>
                     <property name="use_underline">True</property>
+                    <property name="xalign">1</property>
+                    <property name="yalign">0.5</property>
                     <attributes>
                       <attribute name="size" value="8000"/>
                     </attributes>
diff --git a/gthumb/gth-color-scale.c b/gthumb/gth-color-scale.c
index b856e5a..f7387ac 100644
--- a/gthumb/gth-color-scale.c
+++ b/gthumb/gth-color-scale.c
@@ -26,6 +26,8 @@
 
 
 #define _GTK_STYLE_CLASS_COLOR "color"
+#define FOCUS_LINE_WIDTH 1
+#define FOCUS_PADDING 4
 
 
 enum {
@@ -108,65 +110,39 @@ gth_color_scale_get_property (GObject    *object,
 
 
 static void
-_gth_color_scale_get_surface_size (GthColorScale *self,
-                                  int           *x_out,
-                                  int           *y_out,
-                                  int           *width_out,
-                                  int           *height_out,
-                                  int           *slider_width_out,
-                                  int           *slider_length_out,
-                                  int           *slider_spacing_out)
+_gth_color_scale_get_range_rect (GthColorScale *self,
+                                GdkRectangle  *range_rect)
 {
-       GtkWidget             *widget = GTK_WIDGET (self);
-       int                    focus_line_width;
-       int                    focus_padding;
-       int                    slider_width;
-       int                    slider_length;
-       cairo_rectangle_int_t  bounding_box;
-       cairo_rectangle_int_t  trough_rect;
-
-       gtk_widget_style_get (widget,
-                             "focus-line-width", &focus_line_width,
-                             "focus-padding", &focus_padding,
-                             "slider-width", &slider_width,
-                             "slider-length", &slider_length,
-                             NULL);
-
-       bounding_box.width = gtk_widget_get_allocated_width (widget) - 2 * (focus_line_width + focus_padding);
-       bounding_box.height = gtk_widget_get_allocated_height (widget) - 2 * (focus_line_width + 
focus_padding);
-       bounding_box.x = focus_line_width + focus_padding;
-       bounding_box.y = focus_line_width + focus_padding;
+       gboolean gtk320 = ((gtk_major_version >= 3) && (gtk_minor_version >= 20));
 
-       if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_HORIZONTAL) {
-               trough_rect.x = bounding_box.x;
-               trough_rect.width = bounding_box.width;
-               trough_rect.height = bounding_box.height / 2;
-               trough_rect.y = bounding_box.y;
+       if (gtk320) {
+               gtk_range_get_range_rect (GTK_RANGE (self), range_rect);
        }
        else {
-               trough_rect.y = bounding_box.y;
-               trough_rect.height = bounding_box.height;
-               trough_rect.width = bounding_box.width / 2;
-               trough_rect.x = bounding_box.x;
+               int new_height = 4;
+               int slider_width;
+               int slider_length;
+
+               gtk_widget_style_get (GTK_WIDGET (self),
+                                     "slider-width", &slider_width,
+                                     "slider-length", &slider_length,
+                                     NULL);
+
+               gtk_range_get_range_rect (GTK_RANGE (self), range_rect);
+               range_rect->y = range_rect->y + (range_rect->height / 2) - (new_height / 2);
+               range_rect->height = new_height;
+               range_rect->x += slider_length / 2;
+               range_rect->width -= slider_length;
        }
-
-       if (x_out) *x_out = trough_rect.x;
-       if (y_out) *y_out = trough_rect.y;
-       if (width_out) *width_out = trough_rect.width;
-       if (height_out) *height_out = trough_rect.height;
-       if (slider_width_out) *slider_width_out = slider_width;
-       if (slider_length_out) *slider_length_out = slider_length;
-       if (slider_spacing_out) *slider_spacing_out = focus_line_width + focus_padding;
 }
 
 
 static void
 _gth_color_scale_update_surface (GthColorScale *self)
 {
-       int              width;
-       int              height;
-       cairo_pattern_t *pattern;
-       cairo_t         *cr;
+       cairo_rectangle_int_t  range_rect;
+       cairo_pattern_t       *pattern;
+       cairo_t               *cr;
 
        if (! gtk_widget_get_realized (GTK_WIDGET (self)))
                return;
@@ -174,11 +150,11 @@ _gth_color_scale_update_surface (GthColorScale *self)
        if (self->priv->scale_type == GTH_COLOR_SCALE_DEFAULT)
                return;
 
-       _gth_color_scale_get_surface_size (self, NULL, NULL, &width, &height, NULL, NULL, NULL);
+       _gth_color_scale_get_range_rect (self, &range_rect);
 
        if ((self->priv->surface != NULL)
-           && (self->priv->width == width)
-           && (self->priv->height == height))
+           && (self->priv->width == range_rect.width)
+           && (self->priv->height == range_rect.height))
        {
                return;
        }
@@ -186,7 +162,7 @@ _gth_color_scale_update_surface (GthColorScale *self)
        cairo_surface_destroy (self->priv->surface);
        self->priv->surface = NULL;
 
-       pattern = cairo_pattern_create_linear (0.0, 0.0, width, 0.0);
+       pattern = cairo_pattern_create_linear (0.0, 0.0, range_rect.width, 0.0);
 
        switch (self->priv->scale_type) {
        case GTH_COLOR_SCALE_DEFAULT:
@@ -229,10 +205,10 @@ _gth_color_scale_update_surface (GthColorScale *self)
                break;
        }
 
-       self->priv->surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
+       self->priv->surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, range_rect.width, 
range_rect.height);
        cr = cairo_create (self->priv->surface);
        cairo_set_source (cr, pattern);
-       cairo_rectangle (cr, 0, 0, width, height);
+       cairo_rectangle (cr, 0, 0, range_rect.width, range_rect.height);
        cairo_paint (cr);
 
        cairo_pattern_destroy (pattern);
@@ -243,8 +219,8 @@ _gth_color_scale_update_surface (GthColorScale *self)
 static void
 _gth_color_scale_update_slider_position (GthColorScale *self)
 {
-       int focus_line_width;
-       int focus_padding;
+       int focus_line_width = FOCUS_LINE_WIDTH;
+       int focus_padding = FOCUS_PADDING;
        int slider_width;
        int slider_length;
        int slider_start;
@@ -254,8 +230,6 @@ _gth_color_scale_update_slider_position (GthColorScale *self)
                return;
 
        gtk_widget_style_get (GTK_WIDGET (self),
-                             "focus-line-width", &focus_line_width,
-                             "focus-padding", &focus_padding,
                              "slider-width", &slider_width,
                              "slider-length", &slider_length,
                              NULL);
@@ -264,7 +238,7 @@ _gth_color_scale_update_slider_position (GthColorScale *self)
        if (gtk_orientable_get_orientation (GTK_ORIENTABLE (self)) == GTK_ORIENTATION_HORIZONTAL) {
                self->priv->slider.x = slider_start;
                self->priv->slider.y = focus_line_width + focus_padding;
-               self->priv->slider.width = slider_length;
+               self->priv->slider.width = slider_end - slider_start;
                self->priv->slider.height = slider_width;
        }
 
@@ -277,7 +251,6 @@ gth_color_scale_draw (GtkWidget *widget,
                      cairo_t   *cr)
 {
        GthColorScale         *self;
-       cairo_rectangle_int_t  surface_rect;
        cairo_pattern_t       *pattern;
        GtkStyleContext       *context;
        GtkOrientation         orientation;
@@ -289,6 +262,7 @@ gth_color_scale_draw (GtkWidget *widget,
        int                    slider_spacing;
        GtkStateFlags          widget_state;
        GtkStateFlags          slider_state;
+       gboolean               gtk320 = ((gtk_major_version >= 3) && (gtk_minor_version >= 20));
 
        self = GTH_COLOR_SCALE (widget);
 
@@ -300,32 +274,30 @@ gth_color_scale_draw (GtkWidget *widget,
        context = gtk_widget_get_style_context (widget);
        orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
        widget_state = gtk_widget_get_state_flags (widget);
-       gtk_range_get_range_rect (GTK_RANGE (self), &range_rect);
+       _gth_color_scale_get_range_rect (self, &range_rect);
        gtk_range_get_slider_range (GTK_RANGE (self), &slider_start, &slider_end);
 
        /* background */
 
        _gth_color_scale_update_surface (self);
-       _gth_color_scale_get_surface_size (self,
-                                          &surface_rect.x,
-                                          &surface_rect.y,
-                                          &surface_rect.width,
-                                          &surface_rect.height,
-                                          &slider_width,
-                                          &slider_length,
-                                          &slider_spacing);
 
        cairo_save (cr);
-       cairo_translate (cr, surface_rect.x, surface_rect.y);
+       cairo_translate (cr, range_rect.x, range_rect.y);
        pattern = cairo_pattern_create_for_surface (self->priv->surface);
-       cairo_rectangle (cr, 0.0, 0.0, surface_rect.width, surface_rect.height);
+
+       cairo_rectangle (cr,
+                        0,
+                        0,
+                        range_rect.width,
+                        range_rect.height);
+
        if ((orientation == GTK_ORIENTATION_HORIZONTAL)
            && (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL))
        {
                cairo_matrix_t matrix;
 
                cairo_matrix_init_scale (&matrix, -1, 1);
-               cairo_matrix_translate (&matrix, -surface_rect.width, 0);
+               cairo_matrix_translate (&matrix, -range_rect.width, 0);
                cairo_pattern_set_matrix (pattern, &matrix);
        }
        cairo_set_source (cr, pattern);
@@ -333,14 +305,37 @@ gth_color_scale_draw (GtkWidget *widget,
        cairo_pattern_destroy (pattern);
        cairo_restore (cr);
 
+       /* border */
+
+       cairo_save (cr);
+       cairo_set_line_width (cr, 0.5);
+       cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.75);
+       cairo_rectangle (cr,
+                        range_rect.x,
+                        range_rect.y,
+                        range_rect.width,
+                        range_rect.height);
+       cairo_stroke (cr);
+       cairo_restore (cr);
+
        /* focus */
 
-       if (! (widget_state & GTK_STATE_FLAG_INSENSITIVE) && gtk_widget_has_visible_focus (widget))
-                 gtk_render_focus (context, cr,
-                                   range_rect.x,
-                                   range_rect.y,
-                                   range_rect.width,
-                                   range_rect.height);
+       if (! (widget_state & GTK_STATE_FLAG_INSENSITIVE) && gtk_widget_has_visible_focus (widget)) {
+               int                    focus_line_width = FOCUS_LINE_WIDTH;
+               int                    focus_padding = FOCUS_PADDING;
+               cairo_rectangle_int_t  focus_box;
+
+               focus_box.width = range_rect.width + 2 * (focus_line_width + focus_padding);
+               focus_box.height = range_rect.height + 2 * (focus_line_width + focus_padding);
+               focus_box.x = range_rect.x - (focus_line_width + focus_padding);
+               focus_box.y = range_rect.y - (focus_line_width + focus_padding);
+
+               gtk_render_focus (context, cr,
+                                 focus_box.x,
+                                 focus_box.y,
+                                 focus_box.width,
+                                 focus_box.height);
+       }
 
        /* slider */
 
@@ -353,17 +348,39 @@ gth_color_scale_draw (GtkWidget *widget,
 
        _gth_color_scale_update_slider_position (self);
 
-       gtk_style_context_save (context);
-       gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
-       gtk_style_context_set_state (context, slider_state);
-       gtk_render_slider (context,
-                          cr,
-                          self->priv->slider.x,
-                          self->priv->slider.y,
-                          self->priv->slider.width,
-                          self->priv->slider.height,
-                          orientation);
-       gtk_style_context_restore (context);
+       if (gtk320) {
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, slider_state);
+               if (orientation == GTK_ORIENTATION_HORIZONTAL) {
+                       cairo_save (cr);
+                       cairo_move_to (cr, self->priv->slider.x + (self->priv->slider.width / 2), 
range_rect.y);
+                       cairo_rel_line_to (cr, 0, range_rect.height);
+                       cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
+                       cairo_stroke (cr);
+                       cairo_restore (cr);
+
+                       gtk_render_arrow (context,
+                                         cr,
+                                         G_PI,
+                                         self->priv->slider.x - (self->priv->slider.height / 2) + 
(self->priv->slider.width / 2),
+                                         self->priv->slider.y,
+                                         self->priv->slider.height);
+               }
+               gtk_style_context_restore (context);
+       }
+       else {
+               gtk_style_context_save (context);
+               gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
+               gtk_style_context_set_state (context, slider_state);
+               gtk_render_slider (context,
+                                  cr,
+                                  self->priv->slider.x,
+                                  self->priv->slider.y - 1,
+                                  self->priv->slider.width,
+                                  self->priv->slider.height,
+                                  orientation);
+               gtk_style_context_restore (context);
+       }
 
        return FALSE;
 }
diff --git a/gthumb/gth-grid-view.c b/gthumb/gth-grid-view.c
index 48d6753..75aa72b 100644
--- a/gthumb/gth-grid-view.c
+++ b/gthumb/gth-grid-view.c
@@ -1011,7 +1011,6 @@ gth_grid_view_realize (GtkWidget *widget)
        GdkWindowAttr    attributes;
        int              attributes_mask;
        GdkWindow       *window;
-       GtkStyleContext *style_context;
 
        self = GTH_GRID_VIEW (widget);
 
@@ -1057,12 +1056,6 @@ gth_grid_view_realize (GtkWidget *widget)
 
        /* style */
 
-       style_context = gtk_widget_get_style_context (widget);
-       gtk_style_context_save (style_context);
-       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_VIEW);
-       gtk_style_context_set_background (style_context, self->priv->bin_window);
-       gtk_style_context_restore (style_context);
-
        self->priv->caption_layout = gtk_widget_create_pango_layout (widget, NULL);
        pango_layout_set_wrap (self->priv->caption_layout, PANGO_WRAP_WORD_CHAR);
        pango_layout_set_alignment (self->priv->caption_layout, PANGO_ALIGN_LEFT);
@@ -1103,28 +1096,9 @@ gth_grid_view_unrealize (GtkWidget *widget)
 
 
 static void
-_gth_grid_view_update_background (GthGridView *self)
-{
-       GtkWidget       *widget = GTK_WIDGET (self);
-       GtkStyleContext *style_context;
-
-       if (! gtk_widget_get_realized (widget))
-               return;
-
-       style_context = gtk_widget_get_style_context (widget);
-       gtk_style_context_save (style_context);
-       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_VIEW);
-       gtk_style_context_set_background (style_context, gtk_widget_get_window (widget));
-       gtk_style_context_set_background (style_context, self->priv->bin_window);
-       gtk_style_context_restore (style_context);
-}
-
-
-static void
 gth_grid_view_state_flags_changed (GtkWidget     *widget,
                                    GtkStateFlags  previous_state)
 {
-       _gth_grid_view_update_background (GTH_GRID_VIEW (widget));
        gtk_widget_queue_draw (widget);
 }
 
@@ -1134,7 +1108,6 @@ gth_grid_view_style_updated (GtkWidget *widget)
 {
        GTK_WIDGET_CLASS (gth_grid_view_parent_class)->style_updated (widget);
 
-       _gth_grid_view_update_background (GTH_GRID_VIEW (widget));
        gtk_widget_queue_resize (widget);
 }
 
@@ -1310,9 +1283,7 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
        cairo_surface_t       *image;
        GtkStyleContext       *style_context;
        cairo_rectangle_int_t  frame_rect;
-       GdkRGBA                background_color;
-       GdkRGBA                lighter_color;
-       GdkRGBA                darker_color;
+       gboolean               gtk320 = ((gtk_major_version >= 3) && (gtk_minor_version >= 20));
 
        image = item->thumbnail;
        if (image == NULL)
@@ -1323,8 +1294,13 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
        cairo_save (cr);
        style_context = gtk_widget_get_style_context (widget);
        gtk_style_context_save (style_context);
-       gtk_style_context_remove_class (style_context, GTK_STYLE_CLASS_VIEW);
-       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_CELL);
+       if (gtk320) {
+               gtk_style_context_set_state (style_context, item_state);
+       }
+       else {
+               gtk_style_context_remove_class (style_context, GTK_STYLE_CLASS_VIEW);
+               gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_CELL);
+       }
 
        frame_rect = item->pixbuf_area;
 
@@ -1336,23 +1312,31 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
                /* use a gray rounded box for icons or when the original size
                 * is smaller than the thumbnail size... */
 
-               gtk_style_context_get_background_color (style_context, item_state, &background_color);
-               gdk_cairo_set_source_rgba (cr, &background_color);
+               if (gtk320) {
+                       gtk_style_context_save (style_context);
+                       gtk_style_context_add_class (style_context, "icon");
+                       gtk_render_background (style_context,
+                                              cr,
+                                              item->thumbnail_area.x,
+                                              item->thumbnail_area.y,
+                                              item->thumbnail_area.width,
+                                              item->thumbnail_area.height);
+                       gtk_style_context_restore (style_context);
+               }
+               else {
+                       gtk_style_context_get_background_color (style_context, item_state, &background_color);
+                       gdk_cairo_set_source_rgba (cr, &background_color);
 
-               _cairo_draw_rounded_box (cr,
-                                        item->thumbnail_area.x,
-                                        item->thumbnail_area.y,
-                                        item->thumbnail_area.width,
-                                        item->thumbnail_area.height,
-                                        4);
-               cairo_fill (cr);
+                       _cairo_draw_rounded_box (cr,
+                                                item->thumbnail_area.x,
+                                                item->thumbnail_area.y,
+                                                item->thumbnail_area.width,
+                                                item->thumbnail_area.height,
+                                                4);
+                       cairo_fill (cr);
+               }
        }
 
-       gdk_rgba_parse (&background_color, "#edeceb");
-       gtk_style_context_get_background_color (style_context, item_state, &background_color);
-       _gdk_rgba_darker (&background_color, &lighter_color);
-       _gdk_rgba_darker (&lighter_color, &darker_color);
-
        if (item->style == ITEM_STYLE_IMAGE) {
 
                /* ...draw a frame with a drop-shadow effect */
@@ -1397,7 +1381,7 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
 
                /* the drop shadow */
 
-               gdk_cairo_set_source_rgba (cr, &darker_color);
+               cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.33);
                cairo_rectangle (cr,
                                 frame_rect.x + 2,
                                 frame_rect.y + 2,
@@ -1471,20 +1455,32 @@ _gth_grid_view_item_draw_thumbnail (GthGridViewItem *item,
        }
 
        if ((item_state & GTK_STATE_FLAG_SELECTED) || (item_state & GTK_STATE_FLAG_FOCUSED)) {
-               GdkRGBA color;
-
-               gtk_style_context_get_background_color (style_context, item_state, &color);
-               cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5);
-               cairo_rectangle (cr,
-                                frame_rect.x,
-                                frame_rect.y,
-                                frame_rect.width,
-                                frame_rect.height);
-               cairo_fill_preserve (cr);
+               if (gtk320) {
+                       gtk_style_context_save (style_context);
+                       gtk_style_context_add_class (style_context, "icon-effect");
+                       gtk_render_background (style_context,
+                                              cr,
+                                              frame_rect.x,
+                                              frame_rect.y,
+                                              frame_rect.width,
+                                              frame_rect.height);
+                       gtk_style_context_restore (style_context);
+               }
+               else {
+                       GdkRGBA color;
+                       gtk_style_context_get_background_color (style_context, item_state, &color);
+                       cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5);
+                       cairo_rectangle (cr,
+                                        frame_rect.x,
+                                        frame_rect.y,
+                                        frame_rect.width,
+                                        frame_rect.height);
+                       cairo_fill_preserve (cr);
 
-               cairo_set_line_width (cr, 2);
-               cairo_set_source_rgb (cr, color.red, color.green, color.blue);
-               cairo_stroke (cr);
+                       cairo_set_line_width (cr, 2);
+                       cairo_set_source_rgb (cr, color.red, color.green, color.blue);
+                       cairo_stroke (cr);
+               }
        }
 
        gtk_style_context_restore (style_context);
@@ -1592,44 +1588,77 @@ _gth_grid_view_draw_item (GthGridView     *self,
                item_state ^= GTK_STATE_FLAG_ACTIVE;
 
        if (item_state ^ GTK_STATE_FLAG_NORMAL) {
+               gboolean         gtk320 = ((gtk_major_version >= 3) && (gtk_minor_version >= 20));
                GtkStyleContext *style_context;
                GdkRGBA          color;
 
                cairo_save (cr);
                style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
                gtk_style_context_save (style_context);
-               gtk_style_context_remove_class (style_context, GTK_STYLE_CLASS_VIEW);
-               gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_CELL);
-               gtk_style_context_set_state (style_context, item_state);
-               gtk_style_context_get_background_color (style_context, item_state, &color);
-               _gdk_rgba_lighter (&color, &color);
-               cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
 
-               if (item->style != ITEM_STYLE_ICON) {
-                       cairo_region_t           *area;
-                       cairo_rectangle_int_t     extents;
+               if (gtk320) {
+                       gtk_style_context_set_state (style_context, item_state);
 
-                       area = cairo_region_create_rectangle (&item->thumbnail_area);
-                       cairo_region_union_rectangle (area, &item->caption_area);
-                       cairo_region_get_extents (area, &extents);
+                       if (item->style != ITEM_STYLE_ICON) {
+                               cairo_region_t           *area;
+                               cairo_rectangle_int_t     extents;
 
-                       _cairo_draw_rounded_box (cr,
-                                                extents.x - self->priv->cell_padding,
-                                                extents.y - self->priv->cell_padding,
-                                                extents.width + (self->priv->cell_padding * 2),
-                                                extents.height + (self->priv->cell_padding * 2),
-                                                4);
+                               area = cairo_region_create_rectangle (&item->thumbnail_area);
+                               cairo_region_union_rectangle (area, &item->caption_area);
+                               cairo_region_get_extents (area, &extents);
 
-                       cairo_region_destroy (area);
+                               gtk_render_background (style_context,
+                                                      cr,
+                                                      extents.x - self->priv->cell_padding,
+                                                      extents.y - self->priv->cell_padding,
+                                                      extents.width + (self->priv->cell_padding * 2),
+                                                      extents.height + (self->priv->cell_padding * 2));
+
+                               cairo_region_destroy (area);
+                       }
+                       else
+                               gtk_render_background (style_context,
+                                                      cr,
+                                                      item->area.x,
+                                                      item->area.y,
+                                                      item->area.width,
+                                                      item->area.height);
+               }
+               else {
+                       gtk_style_context_remove_class (style_context, GTK_STYLE_CLASS_VIEW);
+                       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_CELL);
+                       gtk_style_context_set_state (style_context, item_state);
+                       gtk_style_context_get_background_color (style_context, item_state, &color);
+                       _gdk_rgba_lighter (&color, &color);
+                       cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
+
+                       if (item->style != ITEM_STYLE_ICON) {
+                               cairo_region_t           *area;
+                               cairo_rectangle_int_t     extents;
+
+                               area = cairo_region_create_rectangle (&item->thumbnail_area);
+                               cairo_region_union_rectangle (area, &item->caption_area);
+                               cairo_region_get_extents (area, &extents);
+
+                               _cairo_draw_rounded_box (cr,
+                                                        extents.x - self->priv->cell_padding,
+                                                        extents.y - self->priv->cell_padding,
+                                                        extents.width + (self->priv->cell_padding * 2),
+                                                        extents.height + (self->priv->cell_padding * 2),
+                                                        4);
+
+                               cairo_region_destroy (area);
+                       }
+                       else
+                               _cairo_draw_rounded_box (cr,
+                                                        item->area.x,
+                                                        item->area.y,
+                                                        item->area.width,
+                                                        item->area.height,
+                                                        4);
+
+                       cairo_fill (cr);
                }
-               else
-                       _cairo_draw_rounded_box (cr,
-                                                item->area.x,
-                                                item->area.y,
-                                                item->area.width,
-                                                item->area.height,
-                                                4);
-               cairo_fill (cr);
 
                gtk_style_context_restore (style_context);
                cairo_restore (cr);
@@ -1706,41 +1735,59 @@ _gth_grid_view_draw_drop_target (GthGridView *self,
 }
 
 
+static void
+_gth_grid_draw_background (GthGridView *self,
+                          cairo_t     *cr)
+{
+       GtkAllocation allocation;
+
+       gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
+       gtk_render_background (gtk_widget_get_style_context (GTK_WIDGET (self)),
+                              cr,
+                              0,
+                              gtk_adjustment_get_value (self->priv->vadjustment),
+                              allocation.width,
+                              allocation.height);
+}
+
+
 static gboolean
 gth_grid_view_draw (GtkWidget *widget,
                    cairo_t   *cr)
 {
        GthGridView *self = (GthGridView*) widget;
        int          first_visible;
-       int          last_visible;
-       int          i;
-       GList       *scan;
 
        if (! gtk_cairo_should_draw_window (cr, self->priv->bin_window))
                return FALSE;
 
-       first_visible = gth_grid_view_get_first_visible (GTH_FILE_VIEW (self));
-       if (first_visible == -1)
-               return TRUE;
-
-       last_visible = gth_grid_view_get_last_visible (GTH_FILE_VIEW (self));
-
        cairo_save (cr);
        gtk_cairo_transform_to_window (cr, widget, self->priv->bin_window);
        cairo_set_line_width (cr, 1.0);
 
-       for (i = first_visible, scan = g_list_nth (self->priv->items, first_visible);
-            (i <= last_visible) && scan;
-            i++, scan = scan->next)
-       {
-               _gth_grid_view_draw_item (self, GTH_GRID_VIEW_ITEM (scan->data), cr);
-       }
+       _gth_grid_draw_background (self, cr);
+
+       first_visible = gth_grid_view_get_first_visible (GTH_FILE_VIEW (self));
+       if (first_visible >= 0) {
+               int    last_visible;
+               int    i;
+               GList *scan;
+
+               last_visible = gth_grid_view_get_last_visible (GTH_FILE_VIEW (self));
+
+               for (i = first_visible, scan = g_list_nth (self->priv->items, first_visible);
+                    (i <= last_visible) && scan;
+                    i++, scan = scan->next)
+               {
+                       _gth_grid_view_draw_item (self, GTH_GRID_VIEW_ITEM (scan->data), cr);
+               }
 
-       if (self->priv->selecting || self->priv->multi_selecting_with_keyboard)
-               _gth_grid_view_draw_rubberband (self, cr);
+               if (self->priv->selecting || self->priv->multi_selecting_with_keyboard)
+                       _gth_grid_view_draw_rubberband (self, cr);
 
-       if (self->priv->drop_pos != GTH_DROP_POSITION_NONE)
-               _gth_grid_view_draw_drop_target (self, cr);
+               if (self->priv->drop_pos != GTH_DROP_POSITION_NONE)
+                       _gth_grid_view_draw_drop_target (self, cr);
+       }
 
        cairo_restore (cr);
 
@@ -3782,6 +3829,10 @@ gth_grid_view_class_init (GthGridViewClass *grid_view_class)
                                      "activate-cursor-item", 0);
        gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0,
                                      "activate-cursor-item", 0);
+
+#if GTK_CHECK_VERSION(3,20,0)
+       gtk_widget_class_set_css_name (widget_class, "iconview");
+#endif
 }
 
 
@@ -3824,6 +3875,12 @@ gth_grid_view_gth_file_view_interface_init (GthFileViewInterface *iface)
 static void
 gth_grid_view_init (GthGridView *self)
 {
+       GtkStyleContext *style_context;
+
+       style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_VIEW);
+       gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_FRAME);
+
        gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
 
        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_GRID_VIEW, GthGridViewPrivate);
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index ef8a8c6..87941f6 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -292,7 +292,9 @@ gth_window_realize (GtkWidget *widget)
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)), 
GTHUMB_ICON_DIR);
 
        _gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb.css");
-       if ((gtk_major_version >= 3) && (gtk_minor_version >= 14))
+       if ((gtk_major_version >= 3) && (gtk_minor_version >= 20))
+               _gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb-gtk320.css");
+       else if ((gtk_major_version >= 3) && (gtk_minor_version >= 14))
                _gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb-gtk314.css");
        else if ((gtk_major_version >= 3) && (gtk_minor_version >= 10))
                _gth_window_add_css_provider (widget, "/org/gnome/gThumb/resources/gthumb-gtk312.css");
diff --git a/gthumb/gthumb.gresource.xml b/gthumb/gthumb.gresource.xml
index 5d508e1..8fc4176 100644
--- a/gthumb/gthumb.gresource.xml
+++ b/gthumb/gthumb.gresource.xml
@@ -9,6 +9,7 @@
     <file compressed="true">resources/gthumb.css</file>
     <file compressed="true">resources/gthumb-gtk312.css</file>
     <file compressed="true">resources/gthumb-gtk314.css</file>
+    <file compressed="true">resources/gthumb-gtk320.css</file>
     <file compressed="true">resources/history-menu.ui</file>
   </gresource>
 </gresources>
diff --git a/gthumb/resources/Makefile.am b/gthumb/resources/Makefile.am
index 58b771d..ef8c894 100644
--- a/gthumb/resources/Makefile.am
+++ b/gthumb/resources/Makefile.am
@@ -7,6 +7,7 @@ EXTRA_DIST =                    \
        gthumb.css              \
        gthumb-gtk312.css       \
        gthumb-gtk314.css       \
+       gthumb-gtk320.css       \
        history-menu.ui
 
--include $(top_srcdir)/git.mk
\ No newline at end of file
+-include $(top_srcdir)/git.mk
diff --git a/gthumb/resources/gthumb-gtk320.css b/gthumb/resources/gthumb-gtk320.css
new file mode 100644
index 0000000..e0189ef
--- /dev/null
+++ b/gthumb/resources/gthumb-gtk320.css
@@ -0,0 +1,94 @@
+/* GthGridView  */
+
+iconview.icon {
+       background: @theme_bg_color;
+       color: @theme_fg_color;
+       border-radius: 4px;
+}
+
+iconview.icon:selected,
+iconview.icon:selected:focus {
+       background-color: @theme_selected_bg_color;
+       color: @theme_selected_fg_color;
+}
+
+iconview.icon-effect {
+       background-color: alpha(@theme_bg_color, 0.5);
+       color: @theme_fg_color;
+       border-radius: 0;
+}
+
+iconview.icon-effect:selected,
+iconview.icon-effect:selected:focus {
+       background-color: alpha(@theme_selected_bg_color, 0.5);
+       color: @theme_selected_fg_color;
+       border-radius: 0;
+}
+
+/* -- comment -- */
+
+scrolledwindow.comment {
+       background-color: @comment_bg;
+       padding: 5px 0 5px 5px;
+}
+
+scrolledwindow.comment:backdrop {
+       background-color: @comment_bg_backdrop;
+}
+
+scrolledwindow.comment {
+       border-color: transparent;
+}
+
+scrolledwindow.comment scrollbar trough {
+       background-color: @comment_bg;
+}
+
+scrolledwindow.comment scrollbar trough:backdrop {
+       background-color: @comment_bg_backdrop;
+}
+
+scrolledwindow.comment scrollbar slider {
+       background-color: @comment_border;
+}
+
+scrolledwindow.comment scrollbar slider:backdrop {
+       background-color: @comment_border_backdrop;
+}
+
+scrolledwindow.comment.overshoot {
+       background-color: transparent;
+}
+
+scrolledwindow.comment.undershoot {
+       background-color: transparent;
+}
+
+textview.comment,
+textview.comment text {
+       background-color: @comment_bg;
+       color: #000000;
+}
+
+textview.comment text:backdrop {
+       background-color: @comment_bg_backdrop;
+       color: #666666;
+}
+
+textview.comment text:selected {
+       background-color: @theme_selected_bg_color;
+       color: @theme_selected_fg_color;
+}
+
+textview.comment text:backdrop:selected {
+       background-color: @theme_unfocused_selected_bg_color;
+       color: @theme_unfocused_selected_fg_color;
+}
+
+/* -- preview button in the filter grid -- */
+
+button.filter-preview:checked {
+       background-image: none;
+       background-color: @theme_selected_bg_color;
+       color: @theme_selected_fg_color;
+}
diff --git a/gthumb/resources/gthumb.css b/gthumb/resources/gthumb.css
index 8e799ff..595d20c 100644
--- a/gthumb/resources/gthumb.css
+++ b/gthumb/resources/gthumb.css
@@ -113,21 +113,21 @@ GtkScrolledWindow.comment.undershoot {
 
 /* -- highlighed text on the destination button in the import dialog -- */
 
-GtkLabel.highlighted-text {
+.highlighted-text {
        color: #8fb1e0;
 }
 
-GtkLabel.highlighted-text:backdrop {
+.highlighted-text:backdrop {
        color: #333333;
 }
 
 /* -- extension list in the preferences dialog -- */
 
-GtkLabel.extension-name {
+.extension-name {
        font-weight: bold;
 }
 
-GtkLabel.extension-description {
+.extension-description {
        font-size: 80%;
        color: @theme_unfocused_fg_color;
 }
@@ -140,7 +140,17 @@ GtkLabel.extension-description {
 
 /* -- header-bar inside the toolbox -- */
 
-GthToolbox .header-bar {
+GthToolbox .header-bar,
+.toolbox headerbar {
+       border-radius: 0;
+       box-shadow: none;
+       background-image: none;
+}
+
+/* -- header-bar in fullscreen -- */
+
+.window-overlay .header-bar,
+.window-overlay headerbar {
        border-radius: 0;
        box-shadow: none;
        background-image: none;


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