From: Ben Pfaff Date: Thu, 13 May 2010 04:54:10 +0000 (-0700) Subject: gui: Factor out creation of Cairo output driver in printing code. X-Git-Tag: v0.7.5~27 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4f431743aa0207244f5a56cc2d6e2ba057e79c6;p=pspp-builds.git gui: Factor out creation of Cairo output driver in printing code. The following commit will add a lot more code here, so it's best to avoid duplication. --- diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index b079cf1d..b78ef8d3 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -617,7 +617,17 @@ psppire_output_window_new (void) +static void +create_xr_print_driver (GtkPrintContext *context, PsppireOutputWindow *window) +{ + struct string_map options; + + string_map_init (&options); + window->print_xrd = + xr_driver_create (gtk_print_context_get_cairo_context (context), &options); + string_map_destroy (&options); +} static gboolean paginate (GtkPrintOperation *operation, @@ -641,23 +651,16 @@ paginate (GtkPrintOperation *operation, } else { - struct string_map options = STRING_MAP_INITIALIZER (options); g_print ("Number of pages is %d\n", window->print_n_pages); gtk_print_operation_set_n_pages (operation, window->print_n_pages); window->print_item = 0; - // xr_driver_destroy (window->print_xrd); - - window->print_xrd = - xr_driver_create (gtk_print_context_get_cairo_context (context), &options); - - string_map_destroy (&options); + create_xr_print_driver (context, window); return TRUE; } } - static void begin_print (GtkPrintOperation *operation, GtkPrintContext *context, @@ -665,12 +668,8 @@ begin_print (GtkPrintOperation *operation, { g_print ("%s\n", __FUNCTION__); - struct string_map options = STRING_MAP_INITIALIZER (options); + create_xr_print_driver (context, window); - window->print_xrd = - xr_driver_create (gtk_print_context_get_cairo_context (context), &options); - - string_map_destroy (&options); window->print_item = 0; window->print_n_pages = 1; }