[gtk+] tests: Remove custom preview from print-editor



commit 17895e746c6d565199bfd9d860176076fb4ef5ce
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 15 05:17:45 2016 +0200

    tests: Remove custom preview from print-editor
    
    It's using gdk_cairo_create() to do the drawing, which is unsupported.

 tests/print-editor.c |  188 --------------------------------------------------
 1 files changed, 0 insertions(+), 188 deletions(-)
---
diff --git a/tests/print-editor.c b/tests/print-editor.c
index fd24973..27ebb67 100644
--- a/tests/print-editor.c
+++ b/tests/print-editor.c
@@ -347,193 +347,6 @@ custom_widget_apply (GtkPrintOperation *operation,
   data->font = g_strdup (selected_font);
 }
 
-typedef struct 
-{
-  GtkPrintOperation *op;
-  GtkPrintOperationPreview *preview;
-  GtkPrintContext   *context;
-  GtkWidget         *spin;
-  GtkWidget         *area;
-  gint               page;
-  PrintData *data;
-  gdouble dpi_x, dpi_y;
-} PreviewOp;
-
-static gboolean
-preview_draw (GtkWidget *widget,
-              cairo_t   *cr,
-              gpointer   data)
-{
-  PreviewOp *pop = data;
-  cairo_t *prev_cr;
-  double dpi_x, dpi_y;
-
-  prev_cr = gtk_print_context_get_cairo_context (pop->context);
-  cairo_reference (prev_cr);
-  dpi_x = gtk_print_context_get_dpi_x (pop->context);
-  dpi_y = gtk_print_context_get_dpi_y (pop->context);
-
-  gtk_print_context_set_cairo_context (pop->context,
-                                       cr, dpi_x, dpi_y);
-  gtk_print_operation_preview_render_page (pop->preview,
-                                          pop->page - 1);
-  gtk_print_context_set_cairo_context (pop->context,
-                                       prev_cr, dpi_x, dpi_y);
-  cairo_destroy (prev_cr);
-
-  return TRUE;
-}
-
-static void
-preview_ready (GtkPrintOperationPreview *preview,
-              GtkPrintContext          *context,
-              gpointer                  data)
-{
-  PreviewOp *pop = data;
-  gint n_pages;
-
-  g_object_get (pop->op, "n-pages", &n_pages, NULL);
-
-  gtk_spin_button_set_range (GTK_SPIN_BUTTON (pop->spin), 
-                            1.0, n_pages);
-
-  g_signal_connect (pop->area, "draw",
-                   G_CALLBACK (preview_draw),
-                   pop);
-
-  gtk_widget_queue_draw (pop->area);
-}
-
-static void
-preview_got_page_size (GtkPrintOperationPreview *preview, 
-                      GtkPrintContext          *context,
-                      GtkPageSetup             *page_setup,
-                      gpointer                  data)
-{
-  PreviewOp *pop = data;
-  GtkAllocation allocation;
-  GtkPaperSize *paper_size;
-  double w, h;
-  cairo_t *cr;
-  gdouble dpi_x, dpi_y;
-
-  paper_size = gtk_page_setup_get_paper_size (page_setup);
-
-  w = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
-  h = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  cr = gdk_cairo_create (gtk_widget_get_window (pop->area));
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-  gtk_widget_get_allocation (pop->area, &allocation);
-  dpi_x = allocation.width/w;
-  dpi_y = allocation.height/h;
-
-  if (fabs (dpi_x - pop->dpi_x) > 0.001 ||
-      fabs (dpi_y - pop->dpi_y) > 0.001)
-    {
-      gtk_print_context_set_cairo_context (context, cr, dpi_x, dpi_y);
-      pop->dpi_x = dpi_x;
-      pop->dpi_y = dpi_y;
-    }
-
-  pango_cairo_update_layout (cr, pop->data->layout);
-  cairo_destroy (cr);
-}
-
-static void
-update_page (GtkSpinButton *widget,
-            gpointer       data)
-{
-  PreviewOp *pop = data;
-
-  pop->page = gtk_spin_button_get_value_as_int (widget);
-  gtk_widget_queue_draw (pop->area);
-}
-
-static void
-preview_destroy (GtkWindow *window, 
-                PreviewOp *pop)
-{
-  gtk_print_operation_preview_end_preview (pop->preview);
-  g_object_unref (pop->op);
-
-  g_free (pop);
-}
-
-static gboolean 
-preview_cb (GtkPrintOperation        *op,
-           GtkPrintOperationPreview *preview,
-           GtkPrintContext          *context,
-           GtkWindow                *parent,
-           gpointer                  data)
-{
-  GtkWidget *window, *close, *page, *hbox, *vbox, *da;
-  gdouble width, height;
-  cairo_t *cr;
-  PreviewOp *pop;
-  PrintData *print_data = data;
-
-  pop = g_new0 (PreviewOp, 1);
-
-  pop->data = print_data;
-
-  width = 200;
-  height = 300;
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_transient_for (GTK_WINDOW (window),
-                               GTK_WINDOW (main_window));
-  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  gtk_container_add (GTK_CONTAINER (window), vbox);
-  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_box_pack_start (GTK_BOX (vbox), hbox,
-                     FALSE, FALSE);
-  page = gtk_spin_button_new_with_range (1, 100, 1);
-  gtk_box_pack_start (GTK_BOX (hbox), page, FALSE, FALSE);
-
-  close = gtk_button_new_with_label ("Close");
-  gtk_box_pack_start (GTK_BOX (hbox), close, FALSE, FALSE);
-
-  da = gtk_drawing_area_new ();
-  gtk_widget_set_size_request (GTK_WIDGET (da), width, height);
-  gtk_box_pack_start (GTK_BOX (vbox), da, TRUE, TRUE);
-
-  gtk_widget_realize (da);
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-  cr = gdk_cairo_create (gtk_widget_get_window (da));
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-  /* TODO: What dpi to use here? This will be used for pagination.. */
-  gtk_print_context_set_cairo_context (context, cr, 72, 72);
-  cairo_destroy (cr);
-  
-  pop->op = g_object_ref (op);
-  pop->preview = preview;
-  pop->context = context;
-  pop->spin = page;
-  pop->area = da;
-  pop->page = 1;
-
-  g_signal_connect (page, "value-changed", 
-                   G_CALLBACK (update_page), pop);
-  g_signal_connect_swapped (close, "clicked", 
-                           G_CALLBACK (gtk_widget_destroy), window);
-
-  g_signal_connect (preview, "ready",
-                   G_CALLBACK (preview_ready), pop);
-  g_signal_connect (preview, "got-page-size",
-                   G_CALLBACK (preview_got_page_size), pop);
-
-  g_signal_connect (window, "destroy", 
-                    G_CALLBACK (preview_destroy), pop);
-                            
-  gtk_widget_show_all (window);
-  
-  return TRUE;
-}
-
 static void
 print_done (GtkPrintOperation *op,
            GtkPrintOperationResult res,
@@ -615,7 +428,6 @@ print_or_preview (GSimpleAction *action, GtkPrintOperationAction print_action)
   g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), print_data);
   g_signal_connect (print, "create_custom_widget", G_CALLBACK (create_custom_widget), print_data);
   g_signal_connect (print, "custom_widget_apply", G_CALLBACK (custom_widget_apply), print_data);
-  g_signal_connect (print, "preview", G_CALLBACK (preview_cb), print_data);
 
   g_signal_connect (print, "done", G_CALLBACK (print_done), print_data);
 


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