]> Pileus Git - ~andy/gtk/blobdiff - tests/testnouiprint.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testnouiprint.c
index c640063b20da09ae70f9bfecdca91fdd9a2a3b96..885fa243ba2ad45d55a50181268b144cf3a711dc 100644 (file)
@@ -3,24 +3,23 @@
  *
  * Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public Lesser
+ * License along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <config.h>
-#include "gtk/gtkprintoperation.h"
+#include "config.h"
 #include <math.h>
+#include "gtk/gtk.h"
 
 static void
 draw_page (GtkPrintOperation *operation,
@@ -31,7 +30,7 @@ draw_page (GtkPrintOperation *operation,
   PangoLayout *layout;
   PangoFontDescription *desc;
   
-  cr = gtk_print_context_get_cairo (context);
+  cr = gtk_print_context_get_cairo_context (context);
 
   /* Draw a red rectangle, as wide as the paper (inside the margins) */
   cairo_set_source_rgb (cr, 1.0, 0, 0);
@@ -42,7 +41,7 @@ draw_page (GtkPrintOperation *operation,
   /* Draw some lines */
   cairo_move_to (cr, 20, 10);
   cairo_line_to (cr, 40, 20);
-  cairo_arc (cr, 60, 60, 20, 0, M_PI);
+  cairo_arc (cr, 60, 60, 20, 0, G_PI);
   cairo_line_to (cr, 80, 20);
   
   cairo_set_source_rgb (cr, 0, 0, 0);
@@ -54,7 +53,7 @@ draw_page (GtkPrintOperation *operation,
 
   /* Draw some text */
   
-  layout = gtk_print_context_create_layout (context);
+  layout = gtk_print_context_create_pango_layout (context);
   pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
   desc = pango_font_description_from_string ("sans 28");
   pango_layout_set_font_description (layout, desc);
@@ -71,7 +70,7 @@ draw_page (GtkPrintOperation *operation,
   /* Font Fill */
   cairo_set_source_rgb (cr, 0, 0.0, 1.0);
   cairo_fill (cr);
-  
+
   g_object_unref (layout);
 }
 
@@ -79,29 +78,18 @@ draw_page (GtkPrintOperation *operation,
 int
 main (int argc, char **argv)
 {
-  GMainLoop *loop;
   GtkPrintOperation *print;
-  GtkPrintOperationResult res;
   GtkPrintSettings *settings;
 
-  
-  /* Unfortunately we need a display for the XSettings to get the
-     list of backends... */
-  /* gtk_parse_args (&argc, &argv); */
-  gtk_init (&argc, &argv);
-
-  loop = g_main_loop_new (NULL, TRUE);
-
   settings = gtk_print_settings_new ();
   /* gtk_print_settings_set_printer (settings, "printer"); */
-  
+
   print = gtk_print_operation_new ();
   gtk_print_operation_set_print_settings (print, settings);
   gtk_print_operation_set_n_pages (print, 1);
   gtk_print_operation_set_unit (print, GTK_UNIT_MM);
-  gtk_print_operation_set_show_dialog (print, FALSE);
   g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
-  res = gtk_print_operation_run (print, NULL, NULL);
+  gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT, NULL, NULL);
 
   return 0;
 }