Commit c5b4e64a2bf717ff97a2da04fd63b303604a34ce
1 parent
3c70bc72
Exists in
master
and in
5 other branches
Implementando save/restore das configurações de impressao no linux
Showing
3 changed files
with
80 additions
and
5 deletions
Show diff stats
src/gtk/common/common.h.in
| ... | ... | @@ -35,6 +35,21 @@ |
| 35 | 35 | #include <gtk/gtk.h> |
| 36 | 36 | #include <errno.h> |
| 37 | 37 | |
| 38 | + #ifdef WIN32 | |
| 39 | + | |
| 40 | + #include <windows.h> | |
| 41 | + #define WIN_REGISTRY_ENABLED 1 | |
| 42 | + | |
| 43 | + #ifndef KEY_WOW64_64KEY | |
| 44 | + #define KEY_WOW64_64KEY 0x0100 | |
| 45 | + #endif // KEY_WOW64_64KEY | |
| 46 | + | |
| 47 | + #ifndef KEY_WOW64_32KEY | |
| 48 | + #define KEY_WOW64_32KEY 0x0200 | |
| 49 | + #endif // KEY_WOW64_64KEY | |
| 50 | + | |
| 51 | + #endif // WIN32 | |
| 52 | + | |
| 38 | 53 | #ifndef PACKAGE_NAME |
| 39 | 54 | #define PACKAGE_NAME "@PACKAGE_NAME@" |
| 40 | 55 | #endif |
| ... | ... | @@ -68,4 +83,10 @@ |
| 68 | 83 | |
| 69 | 84 | gchar * build_data_filename(const gchar *first_element, ...); |
| 70 | 85 | |
| 86 | +#ifdef WIN_REGISTRY_ENABLED | |
| 87 | + HKEY get_registry_handle(const gchar *first_element,REGSAM samDesired); | |
| 88 | +#else | |
| 89 | + GKeyFile * get_application_keyfile(void); | |
| 90 | +#endif // WIN_REGISTRY_ENABLED | |
| 91 | + | |
| 71 | 92 | #endif | ... | ... |
src/gtk/common/config.c
| ... | ... | @@ -564,3 +564,19 @@ gchar * build_data_filename(const gchar *first_element, ...) |
| 564 | 564 | |
| 565 | 565 | return g_string_free(result, FALSE); |
| 566 | 566 | } |
| 567 | + | |
| 568 | +#ifdef WIN_REGISTRY_ENABLED | |
| 569 | +HKEY get_registry_handle(const gchar *first_element,REGSAM samDesired) | |
| 570 | +{ | |
| 571 | + #warning Implementar | |
| 572 | + | |
| 573 | + return 0; | |
| 574 | +} | |
| 575 | +#else | |
| 576 | +GKeyFile * get_application_keyfile(void) | |
| 577 | +{ | |
| 578 | + if(!program_config) | |
| 579 | + configuration_init(); | |
| 580 | + return program_config; | |
| 581 | +} | |
| 582 | +#endif // WIN_REGISTRY_ENABLED | ... | ... |
src/gtk/print.c
| ... | ... | @@ -133,7 +133,17 @@ |
| 133 | 133 | |
| 134 | 134 | static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, PRINT_INFO *info) |
| 135 | 135 | { |
| 136 | - trace("%s",__FUNCTION__); | |
| 136 | +#ifdef WIN32 | |
| 137 | + | |
| 138 | + #warning Implementar | |
| 139 | + | |
| 140 | +#else | |
| 141 | + GKeyFile * conf = get_application_keyfile(); | |
| 142 | + | |
| 143 | + gtk_print_settings_to_key_file(gtk_print_operation_get_print_settings(prt),conf,"print_settings"); | |
| 144 | + gtk_page_setup_to_key_file(gtk_print_operation_get_default_page_setup(prt),conf,"page_setup"); | |
| 145 | + | |
| 146 | +#endif | |
| 137 | 147 | |
| 138 | 148 | if(info->font_scaled) |
| 139 | 149 | cairo_scaled_font_destroy(info->font_scaled); |
| ... | ... | @@ -269,8 +279,8 @@ |
| 269 | 279 | static GtkPrintOperation * begin_print_operation(GtkAction *action, GtkWidget *widget, PRINT_INFO **info) |
| 270 | 280 | { |
| 271 | 281 | GtkPrintOperation * print = gtk_print_operation_new(); |
| 272 | -// GtkPrintSettings * settings = gtk_print_settings_new(); | |
| 273 | -// GtkPageSetup * setup = gtk_page_setup_new(); | |
| 282 | + GtkPrintSettings * settings = gtk_print_settings_new(); | |
| 283 | + GtkPageSetup * setup = gtk_page_setup_new(); | |
| 274 | 284 | const gchar * attr; |
| 275 | 285 | |
| 276 | 286 | *info = g_new0(PRINT_INFO,1); |
| ... | ... | @@ -300,9 +310,37 @@ |
| 300 | 310 | g_signal_connect(print,"create-custom-widget",G_CALLBACK(create_custom_widget), *info); |
| 301 | 311 | g_signal_connect(print,"custom-widget-apply",G_CALLBACK(custom_widget_apply), *info); |
| 302 | 312 | |
| 313 | + // Load page and print settings | |
| 314 | + { | |
| 315 | +#ifdef WIN32 | |
| 316 | + | |
| 317 | + #warning Implementar | |
| 318 | + | |
| 319 | +#else | |
| 320 | + GKeyFile * conf = get_application_keyfile(); | |
| 321 | + GError * err = NULL; | |
| 322 | + | |
| 323 | + | |
| 324 | + if(!gtk_print_settings_load_key_file(settings,conf,"print_settings",&err)) | |
| 325 | + { | |
| 326 | + g_warning("Error getting print settings: %s",err->message); | |
| 327 | + g_error_free(err); | |
| 328 | + err = NULL; | |
| 329 | + } | |
| 330 | + | |
| 331 | + if(!gtk_page_setup_load_key_file(setup,conf,"page_setup",&err)) | |
| 332 | + { | |
| 333 | + g_warning("Error getting page setup: %s",err->message); | |
| 334 | + g_error_free(err); | |
| 335 | + err = NULL; | |
| 336 | + } | |
| 337 | + | |
| 338 | +#endif | |
| 339 | + } | |
| 340 | + | |
| 303 | 341 | // Finish settings |
| 304 | - // gtk_print_operation_set_print_settings(print,settings); | |
| 305 | - // gtk_print_operation_set_default_page_setup(print,setup); | |
| 342 | + gtk_print_operation_set_print_settings(print,settings); | |
| 343 | + gtk_print_operation_set_default_page_setup(print,setup); | |
| 306 | 344 | |
| 307 | 345 | return print; |
| 308 | 346 | } | ... | ... |