Commit 207329f218a8f406ac83ece735deba6c25f1fe82
1 parent
c75488a8
Exists in
master
and in
5 other branches
Melhorando mecanismo que salva a configuração do papel
Showing
1 changed file
with
32 additions
and
22 deletions
Show diff stats
src/pw3270/print.c
@@ -277,9 +277,8 @@ static gchar * enum_to_string(GType type, guint enum_value) | @@ -277,9 +277,8 @@ static gchar * enum_to_string(GType type, guint enum_value) | ||
277 | RegCloseKey(hKey); | 277 | RegCloseKey(hKey); |
278 | } | 278 | } |
279 | 279 | ||
280 | - if(RegCreateKeyEx(registry,"pagesetup",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) | 280 | + if(RegCreateKeyEx(registry,"page",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) |
281 | { | 281 | { |
282 | - HKEY hPaperSize; | ||
283 | gchar * orientation = enum_to_string(GTK_TYPE_PAGE_ORIENTATION,gtk_page_setup_get_orientation(pgsetup)); | 282 | gchar * orientation = enum_to_string(GTK_TYPE_PAGE_ORIENTATION,gtk_page_setup_get_orientation(pgsetup)); |
284 | 283 | ||
285 | // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c | 284 | // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c |
@@ -291,32 +290,43 @@ static gchar * enum_to_string(GType type, guint enum_value) | @@ -291,32 +290,43 @@ static gchar * enum_to_string(GType type, guint enum_value) | ||
291 | 290 | ||
292 | g_free (orientation); | 291 | g_free (orientation); |
293 | 292 | ||
294 | - if(papersize && RegCreateKeyEx(hKey,"papersize",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hPaperSize,&disp) == ERROR_SUCCESS) | ||
295 | - { | ||
296 | - // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpapersize.c | ||
297 | - const gchar *name = gtk_paper_size_get_name(papersize); | ||
298 | - const gchar *display_name = gtk_paper_size_get_display_name(papersize); | ||
299 | - const gchar *ppd_name = gtk_paper_size_get_ppd_name(papersize); | ||
300 | - | ||
301 | - if (ppd_name != NULL) | ||
302 | - save_string(hPaperSize,"PPDName", ppd_name); | ||
303 | - else | ||
304 | - save_string(hPaperSize,"Name", name); | ||
305 | - | ||
306 | - if (display_name) | ||
307 | - save_string(hPaperSize,"DisplayName", display_name); | ||
308 | - | ||
309 | - save_double(hPaperSize, "Width", gtk_paper_size_get_width (size, GTK_UNIT_MM)); | ||
310 | - save_double(hPaperSize, "Height", gtk_paper_size_get_height (size, GTK_UNIT_MM)); | ||
311 | - RegCloseKey(hPaperSize); | ||
312 | - } | ||
313 | RegCloseKey(hKey); | 293 | RegCloseKey(hKey); |
314 | } | 294 | } |
315 | 295 | ||
296 | + if(papersize && RegCreateKeyEx(registry,"paper",0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS) | ||
297 | + { | ||
298 | + // From http://git.gnome.org/browse/gtk+/tree/gtk/gtkpapersize.c | ||
299 | + static const struct _papersettings | ||
300 | + { | ||
301 | + const gchar * name; | ||
302 | + const gchar * (*get)(GtkPaperSize *); | ||
303 | + } papersettings[] = | ||
304 | + { | ||
305 | + { "PPDName", gtk_paper_size_get_ppd_name }, | ||
306 | + { "Name", gtk_paper_size_get_name }, | ||
307 | + { "DisplayName", gtk_paper_size_get_display_name } | ||
308 | + }; | ||
309 | + | ||
310 | + int f; | ||
311 | + | ||
312 | + for(f=0;f<G_N_ELEMENTS(papersettings);f++) | ||
313 | + { | ||
314 | + const gchar *ptr = papersettings[f].get(papersize); | ||
315 | + if(ptr) | ||
316 | + save_string(hKey,papersettings[f].name,ptr); | ||
317 | + } | ||
318 | + | ||
319 | + save_double(hKey, "Width", gtk_paper_size_get_width (papersize, GTK_UNIT_MM)); | ||
320 | + save_double(hKey, "Height", gtk_paper_size_get_height (papersize, GTK_UNIT_MM)); | ||
321 | + | ||
322 | + RegCloseKey(hKey); | ||
323 | + } | ||
324 | + | ||
325 | + | ||
316 | RegCloseKey(registry); | 326 | RegCloseKey(registry); |
317 | } | 327 | } |
318 | #else | 328 | #else |
319 | - GKeyFile * conf = get_application_keyfile(); | 329 | + GKeyFile * conf = get_application_keyfile(); |
320 | gtk_print_settings_to_key_file(settings,conf,"print_settings"); | 330 | gtk_print_settings_to_key_file(settings,conf,"print_settings"); |
321 | gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); | 331 | gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); |
322 | gtk_paper_size_to_key_file(papersize,conf,"paper_size"); | 332 | gtk_paper_size_to_key_file(papersize,conf,"paper_size"); |