Commit 2f71f60e789c4e95a4c21681724e8b1a162afdd6
1 parent
6abaaa51
Exists in
master
and in
5 other branches
Saving print settings to windows registry.
Removing warnings on win32.
Showing
2 changed files
with
73 additions
and
3 deletions
Show diff stats
src/libpw3270cpp/remote.cc
| ... | ... | @@ -452,7 +452,7 @@ |
| 452 | 452 | |
| 453 | 453 | #if defined(_WIN32) |
| 454 | 454 | |
| 455 | - static string getRegistryKey(const char *name) throw (std::exception) | |
| 455 | + static string getRegistryKey(const char *name) | |
| 456 | 456 | { |
| 457 | 457 | char buffer[4096]; |
| 458 | 458 | HKEY hKey = 0; |
| ... | ... | @@ -1017,7 +1017,7 @@ |
| 1017 | 1017 | { |
| 1018 | 1018 | #if defined(_WIN32) |
| 1019 | 1019 | |
| 1020 | - struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz, lf ? '\n' : 0 }; | |
| 1020 | + struct hllapi_packet_query_at query = { HLLAPI_PACKET_GET_TEXT_AT, (unsigned short) row, (unsigned short) col, (unsigned short) sz, (lf ? '\n' : (char) 0) }; | |
| 1021 | 1021 | |
| 1022 | 1022 | return query_string(&query,sizeof(query),sz); |
| 1023 | 1023 | |
| ... | ... | @@ -1137,7 +1137,7 @@ |
| 1137 | 1137 | { |
| 1138 | 1138 | #if defined(_WIN32) |
| 1139 | 1139 | |
| 1140 | - struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, (unsigned short) baddr, (unsigned short) len, lf ? '\n' : 0 }; | |
| 1140 | + struct hllapi_packet_query_offset query = { HLLAPI_PACKET_GET_TEXT_AT_OFFSET, (unsigned short) baddr, (unsigned short) len, (lf ? '\n' : (char) 0) }; | |
| 1141 | 1141 | return query_string(&query,sizeof(query),len); |
| 1142 | 1142 | |
| 1143 | 1143 | #elif defined(HAVE_DBUS) | ... | ... |
src/pw3270/windows/print.c
| ... | ... | @@ -224,6 +224,76 @@ static gchar * enum_to_string(GType type, guint enum_value) |
| 224 | 224 | |
| 225 | 225 | void save_print_operation_settings(GtkPrintOperation * operation) |
| 226 | 226 | { |
| 227 | + // Save settings | |
| 228 | + GtkPrintSettings * settings = gtk_print_operation_get_print_settings(operation); | |
| 229 | + GtkPageSetup * pgsetup = gtk_print_operation_get_default_page_setup(operation); | |
| 230 | + GtkPaperSize * papersize = gtk_page_setup_get_paper_size(pgsetup); | |
| 231 | + | |
| 232 | + trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup); | |
| 233 | + | |
| 234 | +#ifdef ENABLE_WINDOWS_REGISTRY | |
| 235 | + HKEY registry; | |
| 236 | + | |
| 237 | + if(get_registry_handle("print",®istry,KEY_SET_VALUE)) | |
| 238 | + { | |
| 239 | + HKEY hKey; | |
| 240 | + DWORD disp; | |
| 241 | + | |
| 242 | + if(RegCreateKeyEx(registry,"settings",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) | |
| 243 | + { | |
| 244 | + gtk_print_settings_foreach( settings,(GtkPrintSettingsFunc) save_settings, hKey ); | |
| 245 | + RegCloseKey(hKey); | |
| 246 | + } | |
| 247 | + | |
| 248 | + if(RegCreateKeyEx(registry,"page",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) | |
| 249 | + { | |
| 250 | + gchar * orientation = enum_to_string(GTK_TYPE_PAGE_ORIENTATION,gtk_page_setup_get_orientation(pgsetup)); | |
| 251 | + | |
| 252 | + // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c | |
| 253 | + save_double(hKey, "MarginTop", gtk_page_setup_get_top_margin(pgsetup, GTK_UNIT_MM)); | |
| 254 | + save_double(hKey, "MarginBottom", gtk_page_setup_get_bottom_margin(pgsetup, GTK_UNIT_MM)); | |
| 255 | + save_double(hKey, "MarginLeft", gtk_page_setup_get_left_margin(pgsetup, GTK_UNIT_MM)); | |
| 256 | + save_double(hKey, "MarginRight", gtk_page_setup_get_right_margin(pgsetup, GTK_UNIT_MM)); | |
| 257 | + save_string(hKey, "Orientation", orientation); | |
| 258 | + | |
| 259 | + g_free (orientation); | |
| 260 | + | |
| 261 | + RegCloseKey(hKey); | |
| 262 | + } | |
| 263 | + | |
| 264 | + if(papersize && RegCreateKeyEx(registry,"paper",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) | |
| 265 | + { | |
| 266 | + // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpapersize.c | |
| 267 | + static const struct _papersettings | |
| 268 | + { | |
| 269 | + const gchar * name; | |
| 270 | + const gchar * (*get)(GtkPaperSize *); | |
| 271 | + } papersettings[] = | |
| 272 | + { | |
| 273 | + { "PPDName", gtk_paper_size_get_ppd_name }, | |
| 274 | + { "Name", gtk_paper_size_get_name }, | |
| 275 | + { "DisplayName", gtk_paper_size_get_display_name } | |
| 276 | + }; | |
| 277 | + | |
| 278 | + int f; | |
| 279 | + | |
| 280 | + for(f=0;f<G_N_ELEMENTS(papersettings);f++) | |
| 281 | + { | |
| 282 | + const gchar *ptr = papersettings[f].get(papersize); | |
| 283 | + if(ptr) | |
| 284 | + save_string(hKey,papersettings[f].name,ptr); | |
| 285 | + } | |
| 286 | + | |
| 287 | + save_double(hKey, "Width", gtk_paper_size_get_width (papersize, GTK_UNIT_MM)); | |
| 288 | + save_double(hKey, "Height", gtk_paper_size_get_height (papersize, GTK_UNIT_MM)); | |
| 289 | + | |
| 290 | + RegCloseKey(hKey); | |
| 291 | + } | |
| 292 | + | |
| 293 | + | |
| 294 | + RegCloseKey(registry); | |
| 295 | + } | |
| 296 | +#endif // ENABLE_WINDOWS_REGISTRY | |
| 227 | 297 | |
| 228 | 298 | |
| 229 | 299 | } | ... | ... |