[gimp/gtk3-port: 231/232] app: port gimpwidgets-utils.c to GTK+ 3.x



commit 5de5b338ee8cb73f68b69860ffb66a621932ab25
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 11 17:25:33 2018 +0100

    app: port gimpwidgets-utils.c to GTK+ 3.x

 app/widgets/gimpwidgets-utils.c |   75 ++++++++++++--------------------------
 1 files changed, 24 insertions(+), 51 deletions(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index c5dcee9..e550696 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1231,65 +1231,38 @@ gimp_pango_layout_set_weight (PangoLayout *layout,
 }
 
 static gboolean
-gimp_highlight_widget_expose (GtkWidget      *widget,
-                              GdkEventExpose *event,
-                              gpointer        data)
+gimp_highlight_widget_draw (GtkWidget *widget,
+                            cairo_t   *cr,
+                            gpointer   data)
 {
   /* this code is a modified version of gtk+'s gtk_drag_highlight_expose(),
    * changing the highlight color from black to the widget's text color, which
    * improves its visibility when using a dark theme.
    */
 
-  gint x, y, width, height;
+  GtkAllocation    allocation;
+  GtkStyleContext *style;
+  const GdkColor  *color;
 
-  if (gtk_widget_is_drawable (widget))
-    {
-      GdkWindow      *window;
-      GtkStyle       *style;
-      const GdkColor *color;
-      cairo_t        *cr;
+  style  = gtk_widget_get_style_context (widget);
 
-      window = gtk_widget_get_window (widget);
-      style  = gtk_widget_get_style (widget);
+  gtk_widget_get_allocation (widget, &allocation);
 
-      if (!gtk_widget_get_has_window (widget))
-        {
-          GtkAllocation allocation;
+  gtk_render_frame (style, cr,
+                    allocation.x, allocation.y,
+                    allocation.width, allocation.height);
 
-          gtk_widget_get_allocation (widget, &allocation);
+  color = &(gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL]);
 
-          x = allocation.x;
-          y = allocation.y;
-          width = allocation.width;
-          height = allocation.height;
-        }
-      else
-        {
-          x = 0;
-          y = 0;
-          width = gdk_window_get_width (window);
-          height = gdk_window_get_height (window);
-        }
-
-      gtk_paint_shadow (style, window,
-                        GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-                        &event->area, widget, "dnd",
-                        x, y, width, height);
-
-      color = &style->text[GTK_STATE_NORMAL];
-
-      cr = gdk_cairo_create (gtk_widget_get_window (widget));
-      cairo_set_source_rgb (cr,
-                            (gdouble) color->red   / 0xffff,
-                            (gdouble) color->green / 0xffff,
-                            (gdouble) color->blue  / 0xffff);
-      cairo_set_line_width (cr, 1.0);
-      cairo_rectangle (cr,
-                       x + 0.5, y + 0.5,
-                       width - 1, height - 1);
-      cairo_stroke (cr);
-      cairo_destroy (cr);
-    }
+  cairo_set_source_rgb (cr,
+                        (gdouble) color->red   / 0xffff,
+                        (gdouble) color->green / 0xffff,
+                        (gdouble) color->blue  / 0xffff);
+  cairo_set_line_width (cr, 1.0);
+  cairo_rectangle (cr,
+                   allocation.x + 0.5, allocation.y + 0.5,
+                   allocation.width - 1, allocation.height - 1);
+  cairo_stroke (cr);
 
   return FALSE;
 }
@@ -1311,14 +1284,14 @@ gimp_highlight_widget (GtkWidget *widget,
 
   if (highlight)
     {
-      g_signal_connect_after (widget, "expose-event",
-                              G_CALLBACK (gimp_highlight_widget_expose),
+      g_signal_connect_after (widget, "draw",
+                              G_CALLBACK (gimp_highlight_widget_draw),
                               NULL);
     }
   else
     {
       g_signal_handlers_disconnect_by_func (widget,
-                                            gimp_highlight_widget_expose,
+                                            gimp_highlight_widget_draw,
                                             NULL);
     }
 


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