]> Pileus Git - ~andy/gtk/commitdiff
entry: use the CSS margin for the progress margin offset
authorCosimo Cecchi <cosimoc@gnome.org>
Mon, 30 Jan 2012 22:26:05 +0000 (17:26 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Tue, 31 Jan 2012 15:04:27 +0000 (10:04 -0500)
The progressbar inside GtkEntry has a progress-border style property,
which is actually the margin of the progressbar inside the GtkEntry
allocation.
Use a CSS margin instead of reading the progress-border property.

gtk/gtkentry.c

index 0b832a09550e6a2427746bf1dc9cc3b561c921ca..f73ccb48cfc328d223eaa5bd25576b1c989b7a4a 100644 (file)
@@ -3497,6 +3497,18 @@ gtk_entry_draw_frame (GtkWidget       *widget,
   cairo_restore (cr);
 }
 
+static void
+gtk_entry_prepare_context_for_progress (GtkEntry *entry,
+                                        GtkStyleContext *context)
+{
+  GtkEntryPrivate *private = entry->priv;
+
+  gtk_style_context_save (context);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+  if (private->progress_pulse_mode)
+    gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
+}
+
 static void
 get_progress_area (GtkWidget *widget,
                    gint       *x,
@@ -3506,9 +3518,12 @@ get_progress_area (GtkWidget *widget,
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *private = entry->priv;
-  GtkBorder *progress_border;
+  GtkStyleContext *context;
+  GtkBorder margin;
 
-  get_text_area_size (entry, x, y, width, height);
+  get_frame_size (GTK_ENTRY (widget), FALSE, NULL, NULL, width, height);
+  *x = 0;
+  *y = 0;
 
   if (!private->interior_focus)
     {
@@ -3518,17 +3533,16 @@ get_progress_area (GtkWidget *widget,
       *height += 2 * private->focus_width;
     }
 
-  gtk_widget_style_get (widget, "progress-border", &progress_border, NULL);
+  context = gtk_widget_get_style_context (widget);
+  gtk_entry_prepare_context_for_progress (entry, context);
+  gtk_style_context_get_margin (context, 0, &margin);
 
-  if (progress_border)
-    {
-      *x += progress_border->left;
-      *y += progress_border->top;
-      *width -= progress_border->left + progress_border->right;
-      *height -= progress_border->top + progress_border->bottom;
+  gtk_style_context_restore (context);
 
-      gtk_border_free (progress_border);
-    }
+  *x += margin.left;
+  *y += margin.top;
+  *width -= margin.left + margin.right;
+  *height -= margin.top + margin.bottom;
 
   if (private->progress_pulse_mode)
     {
@@ -3574,12 +3588,8 @@ gtk_entry_draw_progress (GtkWidget       *widget,
 
   if ((width <= 0) || (height <= 0))
     return;
-
-  gtk_style_context_save (context);
-  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
-  if (private->progress_pulse_mode)
-    gtk_style_context_add_class (context, GTK_STYLE_CLASS_PULSE);
-
+  gtk_entry_prepare_context_for_progress (entry, context);
   gtk_render_activity (context, cr,
                        x, y, width, height);
 
@@ -5779,8 +5789,7 @@ gtk_entry_draw_text (GtkEntry *entry,
   gtk_style_context_get_color (context, state, &text_color);
 
   /* Get foreground color for progressbars */
-  gtk_style_context_save (context);
-  gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR);
+  gtk_entry_prepare_context_for_progress (entry, context);
   gtk_style_context_get_color (context, state, &bar_text_color);
   gtk_style_context_restore (context);