[gtk+/rendering-cleanup-next: 107/153] printunixdialog: Connect to draw vfunc



commit 1d10a07a15fb4478f7a7681c2ba27f4ff481c41c
Author: Benjamin Otte <otte redhat com>
Date:   Wed Sep 8 21:35:03 2010 +0200

    printunixdialog: Connect to draw vfunc

 gtk/gtkprintunixdialog.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 4d796d5..38e4a6f 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -2578,13 +2578,13 @@ dialog_get_number_up_layout (GtkPrintUnixDialog *dialog)
 
 static gboolean
 draw_page_cb (GtkWidget          *widget,
-              GdkEventExpose     *event,
+              cairo_t            *cr,
+              int                 width,
+              int                 height,
               GtkPrintUnixDialog *dialog)
 {
   GtkPrintUnixDialogPrivate *priv = dialog->priv;
-  GtkAllocation allocation;
   GtkStyle *style;
-  cairo_t *cr;
   gdouble ratio;
   gint w, h, tmp, shadow_offset;
   gint pages_x, pages_y, i, x, y, layout_w, layout_h;
@@ -2612,8 +2612,6 @@ draw_page_cb (GtkWidget          *widget,
 
   number_up_layout = dialog_get_number_up_layout (dialog);
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-
   cairo_save (cr);
 
   page_setup = gtk_print_unix_dialog_get_page_setup (dialog);  
@@ -2694,9 +2692,8 @@ draw_page_cb (GtkWidget          *widget,
 
   style = gtk_widget_get_style (widget);
 
-  gtk_widget_get_allocation (widget, &allocation);
-  pos_x = allocation.x + (allocation.width - w) / 2;
-  pos_y = allocation.y + (allocation.height - h) / 2 - 10;
+  pos_x = (width - w) / 2;
+  pos_y = (height - h) / 2 - 10;
   cairo_translate (cr, pos_x, pos_y);
 
   shadow_offset = 3;
@@ -2906,13 +2903,12 @@ draw_page_cb (GtkWidget          *widget,
 
       ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR;
 
-      gtk_widget_get_allocation (widget, &allocation);
       if (ltr)
         cairo_translate (cr, pos_x - layout_w / PANGO_SCALE - 2 * RULER_DISTANCE,
-                             allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2);
+                             (height - layout_h / PANGO_SCALE) / 2);
       else
         cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE,
-                             allocation.y + (allocation.height - layout_h / PANGO_SCALE) / 2);
+                             (height - layout_h / PANGO_SCALE) / 2);
 
       pango_cairo_show_layout (cr, layout);
 
@@ -2928,7 +2924,7 @@ draw_page_cb (GtkWidget          *widget,
       g_free (text);
       pango_layout_get_size (layout, &layout_w, &layout_h);
 
-      cairo_translate (cr, allocation.x + (allocation.width - layout_w / PANGO_SCALE) / 2,
+      cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2,
                            pos_y + h + shadow_offset + 2 * RULER_DISTANCE);
 
       pango_cairo_show_layout (cr, layout);
@@ -2981,8 +2977,6 @@ draw_page_cb (GtkWidget          *widget,
       cairo_stroke (cr);
     }
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 
@@ -3517,7 +3511,7 @@ create_page_setup_page (GtkPrintUnixDialog *dialog)
   gtk_widget_set_has_window (draw, FALSE);
   priv->page_layout_preview = draw;
   gtk_widget_set_size_request (draw, 350, 200);
-  g_signal_connect (draw, "expose-event", G_CALLBACK (draw_page_cb), dialog);
+  g_signal_connect (draw, "draw", G_CALLBACK (draw_page_cb), dialog);
   gtk_widget_show (draw);
 
   gtk_box_pack_start (GTK_BOX (hbox2), draw, TRUE, FALSE, 0);



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