[gtk+] entry: Simplify drawing code



commit 3316d69abbb05146a2e54e2876500f47845087a9
Author: Benjamin Otte <otte redhat com>
Date:   Tue Feb 2 15:44:28 2016 +0100

    entry: Simplify drawing code

 gtk/gtkentry.c |   52 +++++++++++++++++++++++-----------------------------
 1 files changed, 23 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index a471e25..d304706 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -428,7 +428,6 @@ static void  gtk_entry_get_preferred_height_and_baseline_for_width (GtkWidget *w
 static void   gtk_entry_size_allocate        (GtkWidget        *widget,
                                              GtkAllocation    *allocation);
 static void   gtk_entry_draw_progress        (GtkWidget        *widget,
-                                              GtkStyleContext  *context,
                                               cairo_t          *cr);
 static gint   gtk_entry_draw                 (GtkWidget        *widget,
                                               cairo_t          *cr);
@@ -3863,13 +3862,14 @@ get_progress_area (GtkWidget *widget,
 
 static void
 gtk_entry_draw_progress (GtkWidget       *widget,
-                         GtkStyleContext *context,
                          cairo_t         *cr)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
+  GtkStyleContext *context;
   GtkAllocation allocation;
   gint x, y, width, height;
 
+  context = gtk_widget_get_style_context (widget);
   get_progress_area (widget, &x, &y, &width, &height);
   gtk_widget_get_allocation (widget, &allocation);
   x -= allocation.x;
@@ -3942,7 +3942,6 @@ gtk_entry_render (GtkCssGadget *gadget,
 {
   GtkWidget *widget;
   GtkEntry *entry;
-  GtkStyleContext *context;
   GtkEntryPrivate *priv;
   int i;
 
@@ -3950,41 +3949,36 @@ gtk_entry_render (GtkCssGadget *gadget,
   entry = GTK_ENTRY (widget);
   priv = entry->priv;
 
-  if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
-    {
-      context = gtk_widget_get_style_context (widget);
-
-      /* Draw progress */
-      gtk_entry_draw_progress (widget, context, cr);
+  /* Draw progress */
+  gtk_entry_draw_progress (widget, cr);
 
-      /* Draw text and cursor */
-      cairo_save (cr);
+  /* Draw text and cursor */
+  cairo_save (cr);
 
-      if (priv->dnd_position != -1)
-        gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_DND);
+  if (priv->dnd_position != -1)
+    gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_DND);
 
-      gtk_entry_draw_text (GTK_ENTRY (widget), cr);
+  gtk_entry_draw_text (GTK_ENTRY (widget), cr);
 
-      /* When no text is being displayed at all, don't show the cursor */
-      if (gtk_entry_get_display_mode (entry) != DISPLAY_BLANK &&
-          gtk_widget_has_focus (widget) &&
-          priv->selection_bound == priv->current_pos && priv->cursor_visible)
-        gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
+  /* When no text is being displayed at all, don't show the cursor */
+  if (gtk_entry_get_display_mode (entry) != DISPLAY_BLANK &&
+      gtk_widget_has_focus (widget) &&
+      priv->selection_bound == priv->current_pos && priv->cursor_visible)
+    gtk_entry_draw_cursor (GTK_ENTRY (widget), cr, CURSOR_STANDARD);
 
-      cairo_restore (cr);
-
-      /* Draw icons */
-      for (i = 0; i < MAX_ICONS; i++)
-        {
-          EntryIconInfo *icon_info = priv->icons[i];
+  cairo_restore (cr);
 
-          if (icon_info != NULL)
-            gtk_css_gadget_draw (icon_info->gadget, cr);
-        }
+  /* Draw icons */
+  for (i = 0; i < MAX_ICONS; i++)
+    {
+      EntryIconInfo *icon_info = priv->icons[i];
 
-      gtk_entry_draw_undershoot (entry, cr);
+      if (icon_info != NULL)
+        gtk_css_gadget_draw (icon_info->gadget, cr);
     }
 
+  gtk_entry_draw_undershoot (entry, cr);
+
   return FALSE;
 }
 


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