]> Pileus Git - ~andy/gtk/commitdiff
New function to cancel a running print operation.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 19 May 2006 19:25:51 +0000 (19:25 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 19 May 2006 19:25:51 +0000 (19:25 +0000)
2006-05-19  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtk.symbols:
* gtk/gtkprintoperation.h:
* gtk/gtkprintoperation.c (gtk_print_operation_cancel): New function
to cancel a running print operation.

* gtk/gtkprintoperation-private.h (struct _GtkPrintOperationPrivate):
Add a cancelled flag, use g types, use bitfields.

* gtk/gtkprintoperation.c (print_pages): Clean up after the idle
in the synchronous case.

ChangeLog
ChangeLog.pre-2-10
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkprintoperation-private.h
gtk/gtkprintoperation.c
gtk/gtkprintoperation.h

index e5a4786936d9781e6d97165d40da254287769605..9b35a6993610fff38b492d6b4bfc554f00b234fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2006-05-19  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols: 
+       * gtk/gtkprintoperation.h: 
+       * gtk/gtkprintoperation.c (gtk_print_operation_cancel): New function
+       to cancel a running print operation.
+
+       * gtk/gtkprintoperation-private.h (struct _GtkPrintOperationPrivate): 
+       Add a cancelled flag, use g types, use bitfields.
+
+       * gtk/gtkprintoperation.c (print_pages): Clean up after the idle
+       in the synchronous case.
+
        * gtk/gtknotebook.c (gtk_notebook_pages_allocate): Fix a 
        boundary case in scrolling where a tab was not shown.  (#168105,
        Hiroyuki Ikezoe, patch by Kouhei Sutou)
index e5a4786936d9781e6d97165d40da254287769605..9b35a6993610fff38b492d6b4bfc554f00b234fc 100644 (file)
@@ -1,5 +1,16 @@
 2006-05-19  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols: 
+       * gtk/gtkprintoperation.h: 
+       * gtk/gtkprintoperation.c (gtk_print_operation_cancel): New function
+       to cancel a running print operation.
+
+       * gtk/gtkprintoperation-private.h (struct _GtkPrintOperationPrivate): 
+       Add a cancelled flag, use g types, use bitfields.
+
+       * gtk/gtkprintoperation.c (print_pages): Clean up after the idle
+       in the synchronous case.
+
        * gtk/gtknotebook.c (gtk_notebook_pages_allocate): Fix a 
        boundary case in scrolling where a tab was not shown.  (#168105,
        Hiroyuki Ikezoe, patch by Kouhei Sutou)
index 0b280bdf0c489fc7baafd3904ca8c3e236495c9a..1db7b2b165102f1f6275b8f6d3511ffbc09d68bd 100644 (file)
@@ -1,3 +1,7 @@
+2006-05-19  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtk-sections.txt: Additions
+
 2006-05-18  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/tmpl/gtkenums.sgml: Updates
index 32cc6e9611001da7c9ea0418bbfa495626f7c4bf..23bd08786065e11feee9e62d05742aafb071c6ea 100644 (file)
@@ -6084,8 +6084,8 @@ gtk_print_operation_set_use_full_page
 gtk_print_operation_set_unit
 gtk_print_operation_set_show_dialog
 gtk_print_operation_set_pdf_target 
-gtk_print_operation_run
 gtk_print_operation_run_async
+gtk_print_operation_cancel
 gtk_print_operation_get_status
 gtk_print_operation_get_status_string
 gtk_print_operation_is_finished
index c6da83ee2e3587e82865a17a1eb40a8015495f65..b2da5fb50c231c078d5ea04c35afa8ac538c8dcd 100644 (file)
@@ -2701,6 +2701,7 @@ gtk_print_operation_run_async
 gtk_print_operation_get_status
 gtk_print_operation_get_status_string
 gtk_print_operation_is_finished
+gtk_print_operation_cancel
 #endif
 #endif
 
index 392ede65626b486e5cf486dc21007ef2abf0ca53..333bcfcc3d7b76b2abe657c3e7956696a7d9ee2a 100644 (file)
@@ -28,45 +28,46 @@ G_BEGIN_DECLS
 struct _GtkPrintOperationPrivate
 {
   GtkPrintStatus status;
-  char *status_string;
+  gchar *status_string;
   GtkPageSetup *default_page_setup;
   GtkPrintSettings *print_settings;
-  char *job_name;
-  int nr_of_pages;
-  int current_page;
-  gboolean use_full_page;
+  gchar *job_name;
+  gint nr_of_pages;
+  gint current_page;
   GtkUnit unit;
-  gboolean show_dialog;
-  gboolean track_print_status;
-  char *pdf_target;
+  gchar *pdf_target;
+  guint use_full_page      : 1;
+  guint show_dialog        : 1;
+  guint track_print_status : 1;
+  guint cancelled          : 1;
 
   guint print_pages_idle_id;
 
   /* Data for the print job: */
   cairo_surface_t *surface;
-  double dpi_x, dpi_y;
+  gdouble dpi_x, dpi_y;
 
   GtkPrintPages print_pages;
   GtkPageRange *page_ranges;
-  int num_page_ranges;
+  gint num_page_ranges;
   
-  int manual_num_copies;
-  gboolean manual_collation;
-  gboolean manual_reverse;
-  gboolean manual_orientation;
+  gint manual_num_copies;
+  guint manual_collation   : 1;
+  guint manual_reverse     : 1;
+  guint manual_orientation : 1;
   double manual_scale;
   GtkPageSet manual_page_set;
  
-  void *platform_data;
+  gpointer platform_data;
+  GDestroyNotify free_platform_data;
 
   void (*start_page) (GtkPrintOperation *operation,
-                     GtkPrintContext *print_context,
-                     GtkPageSetup *page_setup);
-  void (*end_page) (GtkPrintOperation *operation,
-                   GtkPrintContext *print_context);
-  void (*end_run) (GtkPrintOperation *operation,
-                  gboolean wait);
-  GDestroyNotify free_platform_data;
+                     GtkPrintContext   *print_context,
+                     GtkPageSetup      *page_setup);
+  void (*end_page)   (GtkPrintOperation *operation,
+                     GtkPrintContext   *print_context);
+  void (*end_run)    (GtkPrintOperation *operation,
+                     gboolean           wait);
 };
 
 GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
@@ -75,15 +76,15 @@ GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPri
                                                                          GError           **error);
 
 typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op,
-                                            gboolean wait);
+                                            gboolean           wait);
 
 void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation          *op,
                                                             GtkWindow                  *parent,
                                                             GtkPrintOperationPrintFunc  print_cb);
 
 void _gtk_print_operation_set_status (GtkPrintOperation *op,
-                                     GtkPrintStatus status,
-                                     const char *string);
+                                     GtkPrintStatus     status,
+                                     const gchar       *string);
 
 /* GtkPrintContext private functions: */
 
index 963aea026117cd448bab24784403d3b7e4a4586a..977a72d5449c3b1f87fd8fde858187eb0c5d21a3 100644 (file)
@@ -1347,18 +1347,15 @@ static void
 print_pages_idle_done (gpointer user_data)
 {
   PrintPagesData *data;
-  GtkPrintOperationPrivate *priv;
 
   data = (PrintPagesData*)user_data;
-  priv = data->op->priv;
+  data->op->priv->print_pages_idle_id = 0;
 
   g_object_unref (data->print_context);
   g_object_unref (data->initial_page_setup);
 
   g_object_unref (data->op);
   g_free (data);
-
-  priv->print_pages_idle_id = 0;
 }
 
 static gboolean
@@ -1484,6 +1481,17 @@ print_pages_idle (gpointer user_data)
 
  out:
 
+  if (priv->cancelled)
+    {
+      g_signal_emit (data->op, signals[END_PRINT], 0, data->print_context);
+      
+      cairo_surface_finish (data->op->priv->surface);
+      
+      _gtk_print_operation_set_status (data->op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL);
+      
+      done = TRUE;
+    }
+
   GDK_THREADS_LEAVE ();
 
   return !done;
@@ -1535,13 +1543,13 @@ print_pages (GtkPrintOperation *op,
          while (gtk_events_pending ())
            gtk_main_iteration ();
        }
+      print_pages_idle_done (data);
     }
   else
     priv->print_pages_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
                                                 print_pages_idle, 
                                                 data, 
-                                                print_pages_idle_done);
-}
+                                                print_pages_idle_done);}
 
 /**
  * gtk_print_operation_run:
@@ -1645,5 +1653,26 @@ gtk_print_operation_run_async (GtkPrintOperation *op,
 }
 
 
+/**
+ * gtk_print_operation_cancel:
+ * @op: a #GtkPrintOperation
+ *
+ * Cancels a running print operation. This function may
+ * be called from a begin-print, paginate or draw-page
+ * signal handler to stop the currently running print 
+ * operation.
+ *
+ * Since: 2.10
+ */
+void
+gtk_print_operation_cancel (GtkPrintOperation *op)
+{
+  g_return_if_fail (GTK_IS_PRINT_OPERATION (op));
+  
+  op->priv->cancelled = TRUE;
+}
+
+
+
 #define __GTK_PRINT_OPERATION_C__
 #include "gtkaliasdef.c"
index adcb9a17ac1ef14e15cb006aceb99932328112ac..e60ec5bc92cb8c410899dc011e7f8e98604d649a 100644 (file)
@@ -138,6 +138,7 @@ GtkPrintOperationResult gtk_print_operation_run                    (GtkPrintOper
 GtkPrintStatus          gtk_print_operation_get_status             (GtkPrintOperation  *op);
 G_CONST_RETURN gchar *  gtk_print_operation_get_status_string      (GtkPrintOperation  *op);
 gboolean                gtk_print_operation_is_finished            (GtkPrintOperation  *op);
+void                    gtk_print_operation_cancel                 (GtkPrintOperation  *op);
 
 GtkPageSetup           *gtk_print_run_page_setup_dialog            (GtkWindow          *parent,
                                                                    GtkPageSetup       *page_setup,