Commit 2f933768fefd8028c0f5a9e8dd37bfce5d307f75

Authored by Perry Werneck
1 parent 7c328e71

Fixing windows print dialog.

Showing 2 changed files with 12 additions and 114 deletions   Show diff stats
src/pw3270/print.c
... ... @@ -39,120 +39,6 @@
39 39  
40 40 /*--[ Implement ]------------------------------------------------------------------------------------*/
41 41  
42   -/*
43   - static void show_print_error(GtkWidget *widget, GError *err)
44   - {
45   - g_warning("Print operation has failed: %s",err->message);
46   -
47   - GtkWidget *dialog = gtk_message_dialog_new_with_markup( GTK_WINDOW(gtk_widget_get_toplevel(widget)),
48   - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
49   - GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,
50   - "%s",_( "Unable to complete print job" ));
51   -
52   - gtk_window_set_title(GTK_WINDOW(dialog),_("Operation has failed"));
53   -
54   - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),"%s",err->message);
55   -
56   - gtk_dialog_run(GTK_DIALOG(dialog));
57   - gtk_widget_destroy(dialog);
58   -}
59   -*/
60   -
61   - /*
62   - static void done(GtkPrintOperation *prt, GtkPrintOperationResult result, PRINT_INFO *info)
63   - {
64   - if(result == GTK_PRINT_OPERATION_RESULT_ERROR)
65   - {
66   - GError * err = NULL;
67   -
68   - gtk_print_operation_get_error(prt,&err);
69   - show_print_error(info->widget,err);
70   - g_error_free(err);
71   -
72   - }
73   - else
74   - {
75   - // Save settings
76   - GtkPrintSettings * settings = gtk_print_operation_get_print_settings(prt);
77   - GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(prt);
78   - GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup);
79   -
80   - trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup);
81   -
82   -#ifdef ENABLE_WINDOWS_REGISTRY
83   - HKEY registry;
84   -
85   - if(get_registry_handle("print",&registry,KEY_SET_VALUE))
86   - {
87   - HKEY hKey;
88   - DWORD disp;
89   -
90   - if(RegCreateKeyEx(registry,"settings",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
91   - {
92   - gtk_print_settings_foreach( settings,(GtkPrintSettingsFunc) save_settings, hKey );
93   - RegCloseKey(hKey);
94   - }
95   -
96   - if(RegCreateKeyEx(registry,"page",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
97   - {
98   - gchar * orientation = enum_to_string(GTK_TYPE_PAGE_ORIENTATION,gtk_page_setup_get_orientation(pgsetup));
99   -
100   - // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c
101   - save_double(hKey, "MarginTop", gtk_page_setup_get_top_margin(pgsetup, GTK_UNIT_MM));
102   - save_double(hKey, "MarginBottom", gtk_page_setup_get_bottom_margin(pgsetup, GTK_UNIT_MM));
103   - save_double(hKey, "MarginLeft", gtk_page_setup_get_left_margin(pgsetup, GTK_UNIT_MM));
104   - save_double(hKey, "MarginRight", gtk_page_setup_get_right_margin(pgsetup, GTK_UNIT_MM));
105   - save_string(hKey, "Orientation", orientation);
106   -
107   - g_free (orientation);
108   -
109   - RegCloseKey(hKey);
110   - }
111   -
112   - if(papersize && RegCreateKeyEx(registry,"paper",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
113   - {
114   - // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpapersize.c
115   - static const struct _papersettings
116   - {
117   - const gchar * name;
118   - const gchar * (*get)(GtkPaperSize *);
119   - } papersettings[] =
120   - {
121   - { "PPDName", gtk_paper_size_get_ppd_name },
122   - { "Name", gtk_paper_size_get_name },
123   - { "DisplayName", gtk_paper_size_get_display_name }
124   - };
125   -
126   - int f;
127   -
128   - for(f=0;f<G_N_ELEMENTS(papersettings);f++)
129   - {
130   - const gchar *ptr = papersettings[f].get(papersize);
131   - if(ptr)
132   - save_string(hKey,papersettings[f].name,ptr);
133   - }
134   -
135   - save_double(hKey, "Width", gtk_paper_size_get_width (papersize, GTK_UNIT_MM));
136   - save_double(hKey, "Height", gtk_paper_size_get_height (papersize, GTK_UNIT_MM));
137   -
138   - RegCloseKey(hKey);
139   - }
140   -
141   -
142   - RegCloseKey(registry);
143   - }
144   -#else
145   - GKeyFile * conf = get_application_keyfile();
146   - gtk_print_settings_to_key_file(settings,conf,"print_settings");
147   - gtk_page_setup_to_key_file(pgsetup,conf,"page_setup");
148   - gtk_paper_size_to_key_file(papersize,conf,"paper_size");
149   -#endif
150   -
151   - }
152   -
153   - }
154   - */
155   -
156 42 void print_all_action(GtkAction *action, GtkWidget *widget)
157 43 {
158 44 pw3270_print(widget,G_OBJECT(action),GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, LIB3270_CONTENT_ALL);
... ...
src/pw3270/windows/print.c
... ... @@ -106,6 +106,18 @@ static gchar * enum_to_string(GType type, guint enum_value)
106 106 GtkPageSetup * setup = gtk_page_setup_new();
107 107 GtkPaperSize * papersize = NULL;
108 108  
  109 + // Load settings.
  110 + {
  111 + g_autofree gchar * font_family = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT);
  112 + if(font_family && *font_family)
  113 + v3270_print_operation_set_font_family(operation,font_family);
  114 +
  115 + g_autofree gchar * color_scheme = get_string_from_config("print","colors","");
  116 + if(color_scheme && *color_scheme)
  117 + v3270_print_operation_set_color_scheme(operation,color_scheme);
  118 + }
  119 +
  120 +
109 121 #ifdef ENABLE_WINDOWS_REGISTRY
110 122  
111 123 HKEY registry;
... ...