diff --git a/src/pw3270/linux/print.c b/src/pw3270/linux/print.c index 8e3b92b..5e365e5 100644 --- a/src/pw3270/linux/print.c +++ b/src/pw3270/linux/print.c @@ -37,6 +37,7 @@ /*--[ Implement ]------------------------------------------------------------------------------------*/ +/* static GtkWidget * create_custom_widget(GtkPrintOperation *prt, gpointer G_GNUC_UNUSED(dunno)) { GtkWidget * widget = gtk_frame_new(""); @@ -70,31 +71,24 @@ return widget; } +*/ +/* static void custom_widget_apply(GtkPrintOperation *prt, GtkWidget *widget, gpointer G_GNUC_UNUSED(dunno)) { GtkWidget * settings = gtk_bin_get_child(GTK_BIN(widget)); - v3270_print_operation_apply_settings(prt,settings); - - // Store font family - g_autofree gchar * font_family = v3270_print_settings_get_font_family(settings); - set_string_to_config("print",FONT_CONFIG,font_family); - - // Store save color settings - g_autofree gchar * colors = v3270_print_settings_get_color_scheme(settings); - set_string_to_config("print","colors","%s",colors); - } +*/ - void setup_print_dialog(GtkPrintOperation * operation) + void load_print_operation_settings(GtkPrintOperation * operation) { GtkPrintSettings * settings = gtk_print_settings_new(); GtkPageSetup * setup = gtk_page_setup_new(); GtkPaperSize * papersize = NULL; - g_signal_connect(operation,"create-custom-widget",G_CALLBACK(create_custom_widget),NULL); - g_signal_connect(operation,"custom-widget-apply",G_CALLBACK(custom_widget_apply), NULL); +// g_signal_connect(operation,"create-custom-widget",G_CALLBACK(create_custom_widget),NULL); +// g_signal_connect(operation,"custom-widget-apply",G_CALLBACK(custom_widget_apply), NULL); // Load page and print settings GKeyFile * conf = get_application_keyfile(); @@ -138,5 +132,36 @@ gtk_page_setup_set_paper_size_and_default_margins(setup,papersize); gtk_print_operation_set_default_page_setup(operation,setup); + // Load font and colors + g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); + if(font_family && *font_family) + v3270_print_operation_set_font_family(operation,font_family); + + g_autofree gchar * color_scheme = get_string_from_config("print","colors",""); + if(color_scheme && *color_scheme) + v3270_print_operation_set_color_scheme(operation,color_scheme); + } + void save_print_operation_settings(GtkPrintOperation * operation) + { + GtkPrintSettings * settings = gtk_print_operation_get_print_settings(operation); + GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); + GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); + + g_message("Saving print settings"); + + GKeyFile * conf = get_application_keyfile(); + gtk_print_settings_to_key_file(settings,conf,"print_settings"); + gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); + gtk_paper_size_to_key_file(papersize,conf,"paper_size"); + + // Store font family + g_autofree gchar * font_family = v3270_print_operation_get_font_family(operation); + set_string_to_config("print",FONT_CONFIG,font_family); + + // Store save color settings + g_autofree gchar * colors = v3270_print_operation_get_color_scheme(operation); + set_string_to_config("print","colors","%s",colors); + + } diff --git a/src/pw3270/print.c b/src/pw3270/print.c index bce17bc..259d80d 100644 --- a/src/pw3270/print.c +++ b/src/pw3270/print.c @@ -24,8 +24,6 @@ * * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) * */ @@ -183,18 +181,19 @@ gtk_print_operation_set_allow_async(operation,get_boolean_from_config("print","allow_async",TRUE)); - setup_print_dialog(operation); + load_print_operation_settings(operation); // // Run print dialog // GError *err = NULL; - gtk_print_operation_run( + GtkPrintOperationResult result = + gtk_print_operation_run( operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(gtk_widget_get_toplevel(widget)), &err - ); + ); if(err) { @@ -216,6 +215,33 @@ rc = -1; } + else + { + switch(result) + { + case GTK_PRINT_OPERATION_RESULT_ERROR: // An error has occurred. + g_message("Print operation has failed"); + break; + + case GTK_PRINT_OPERATION_RESULT_APPLY: // The print settings should be stored. + save_print_operation_settings(operation); + break; + + case GTK_PRINT_OPERATION_RESULT_CANCEL: // The print operation has been canceled, the print settings should not be stored. + g_message("Print operation was cancelled"); + break; + + case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS: // The print operation is not complete yet. This value will only be returned when running asynchronously. + g_message("Print operation is in progress"); + break; + + default: + g_warning("Unexpected print operation result: %d",(int) result); + + } + } + + g_object_unref(operation); return rc; diff --git a/src/pw3270/private.h b/src/pw3270/private.h index cf9c319..301ae91 100644 --- a/src/pw3270/private.h +++ b/src/pw3270/private.h @@ -77,7 +77,8 @@ G_GNUC_INTERNAL void run_security_dialog(GtkWidget *widget); // Tools - G_GNUC_INTERNAL void setup_print_dialog(GtkPrintOperation * operation); + G_GNUC_INTERNAL void load_print_operation_settings(GtkPrintOperation * operation); + G_GNUC_INTERNAL void save_print_operation_settings(GtkPrintOperation * operation); // actions G_GNUC_INTERNAL void paste_file_action(GtkAction *action, GtkWidget *widget); diff --git a/src/pw3270/windows/print.c b/src/pw3270/windows/print.c index ad3bdad..7534226 100644 --- a/src/pw3270/windows/print.c +++ b/src/pw3270/windows/print.c @@ -100,7 +100,7 @@ static gchar * enum_to_string(GType type, guint enum_value) } } - void setup_print_dialog(GtkPrintOperation * operation) + void load_print_operation_settings(GtkPrintOperation * operation) { GtkPrintSettings * settings = gtk_print_settings_new(); GtkPageSetup * setup = gtk_page_setup_new(); @@ -222,3 +222,8 @@ static gchar * enum_to_string(GType type, guint enum_value) } + void save_print_operation_settings(GtkPrintOperation * operation) + { + + + } -- libgit2 0.21.2