Commit 8a71cc37e3f4b8e9f624268b2bc33a4ed1e17910

Authored by perry.werneck@gmail.com
1 parent 7dcee0b9

Windows - Incluindo save/restore do estado da janela no registry

src/include/lib3270/config.h.in
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
61 61
62 #define X3270_TRACE 62 #define X3270_TRACE
63 63
64 - /* #define X3270_PRINTER */ 64 + #undef HAVE_PRINTER
65 65
66 #undef HAVE_IGEMAC 66 #undef HAVE_IGEMAC
67 #undef HAVE_MACUI 67 #undef HAVE_MACUI
src/include/v3270.h
@@ -112,9 +112,9 @@ @@ -112,9 +112,9 @@
112 112
113 // V3270_OIA_CAPS, /**< Caps indication ("A" or blank) */ 113 // V3270_OIA_CAPS, /**< Caps indication ("A" or blank) */
114 114
115 -#ifdef X3270_PRINTER 115 +#ifdef HAVE_PRINTER
116 V3270_OIA_PRINTER, /**< Printer indication ("P" or blank) */ 116 V3270_OIA_PRINTER, /**< Printer indication ("P" or blank) */
117 -#endif // X3270_PRINTER 117 +#endif // HAVE_PRINTER
118 118
119 V3270_OIA_FIELD_COUNT 119 V3270_OIA_FIELD_COUNT
120 120
src/lib3270/ansi.c
@@ -124,7 +124,7 @@ @@ -124,7 +124,7 @@
124 #define CSDES LIB3270_ANSI_STATE_CSDES 124 #define CSDES LIB3270_ANSI_STATE_CSDES
125 #define N1 LIB3270_ANSI_STATE_N1 125 #define N1 LIB3270_ANSI_STATE_N1
126 #define DECP LIB3270_ANSI_STATE_DECP 126 #define DECP LIB3270_ANSI_STATE_DECP
127 -#define TEXT LIB3270_ANSI_STATE_TEXT 127 +// #define TEXT LIB3270_ANSI_STATE_TEXT
128 #define TEXT2 LIB3270_ANSI_STATE_TEXT2 128 #define TEXT2 LIB3270_ANSI_STATE_TEXT2
129 #define MBPEND LIB3270_ANSI_STATE_MBPEND 129 #define MBPEND LIB3270_ANSI_STATE_MBPEND
130 130
@@ -1597,14 +1597,14 @@ xterm_text_mode(H3270 *hSession, int ig1 unused, int ig2 unused) @@ -1597,14 +1597,14 @@ xterm_text_mode(H3270 *hSession, int ig1 unused, int ig2 unused)
1597 { 1597 {
1598 nx = 0; 1598 nx = 0;
1599 n[0] = 0; 1599 n[0] = 0;
1600 - return TEXT; 1600 + return LIB3270_ANSI_STATE_TEXT;
1601 } 1601 }
1602 1602
1603 static enum lib3270_ansi_state 1603 static enum lib3270_ansi_state
1604 xterm_text_semicolon(H3270 *hSession, int ig1 unused, int ig2 unused) 1604 xterm_text_semicolon(H3270 *hSession, int ig1 unused, int ig2 unused)
1605 { 1605 {
1606 tx = 0; 1606 tx = 0;
1607 - return TEXT2; 1607 + return LIB3270_ANSI_STATE_TEXT2;
1608 } 1608 }
1609 1609
1610 static enum lib3270_ansi_state 1610 static enum lib3270_ansi_state
src/lib3270/session.c
@@ -337,11 +337,6 @@ H3270 * lib3270_session_new(const char *model) @@ -337,11 +337,6 @@ H3270 * lib3270_session_new(const char *model)
337 ft_init(hSession); 337 ft_init(hSession);
338 #endif 338 #endif
339 339
340 -/*  
341 -#if defined(X3270_PRINTER)  
342 - printer_init();  
343 -#endif  
344 -*/  
345 trace("%s finished",__FUNCTION__); 340 trace("%s finished",__FUNCTION__);
346 341
347 errno = 0; 342 errno = 0;
src/pw3270/common/config.c
@@ -688,7 +688,29 @@ void save_window_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd @@ -688,7 +688,29 @@ void save_window_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd
688 { 688 {
689 #if defined( WIN_REGISTRY_ENABLED ) 689 #if defined( WIN_REGISTRY_ENABLED )
690 690
691 - #warning save window state to registry 691 + gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key);
  692 +
  693 + HKEY hKey;
  694 + DWORD disp;
  695 +
  696 + if(RegCreateKeyEx(HKEY_CURRENT_USER,path,0,NULL,REG_OPTION_NON_VOLATILE,KEY_SET_VALUE,NULL,&hKey,&disp) == ERROR_SUCCESS)
  697 + {
  698 + int f;
  699 + int pos[2];
  700 +
  701 + for(f=0;f<G_N_ELEMENTS(WindowState);f++)
  702 + {
  703 + DWORD value = (CurrentState & WindowState[f].flag) ? 1 : 0;
  704 + RegSetValueEx(hKey, WindowState[f].name, 0, REG_DWORD,(const BYTE *) &value,sizeof(value));
  705 + }
  706 +
  707 + gtk_window_get_size(GTK_WINDOW(hwnd),&pos[0],&pos[1]);
  708 + RegSetValueEx(hKey, "Size", 0, REG_BINARY,(const BYTE *) pos,sizeof(pos));
  709 +
  710 + RegCloseKey(hKey);
  711 + }
  712 +
  713 + g_free(path);
692 714
693 #else 715 #else
694 int f; 716 int f;
@@ -712,7 +734,57 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget @@ -712,7 +734,57 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget
712 { 734 {
713 #if defined( WIN_REGISTRY_ENABLED ) 735 #if defined( WIN_REGISTRY_ENABLED )
714 736
715 - #warning Implement window state saving on window 737 + gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key);
  738 + HKEY hKey;
  739 +
  740 + if(RegOpenKeyEx(HKEY_CURRENT_USER,path,0,KEY_READ,&hKey) == ERROR_SUCCESS)
  741 + {
  742 + int f;
  743 + int pos[2];
  744 + unsigned long datalen;
  745 + unsigned long datatype;
  746 +
  747 +
  748 + datalen = sizeof(pos);
  749 + if(RegQueryValueExA(hKey,"Size",NULL,&datatype,(BYTE *) pos,&datalen) == ERROR_SUCCESS)
  750 + {
  751 + if(datatype == REG_BINARY && datalen == sizeof(pos))
  752 + {
  753 + gtk_window_resize(GTK_WINDOW(hwnd),pos[0],pos[1]);
  754 + }
  755 + else
  756 + {
  757 + g_warning("Unexpected registry data in %s\\Size",path);
  758 + }
  759 + }
  760 +
  761 +
  762 + for(f=0;f<G_N_ELEMENTS(WindowState);f++)
  763 + {
  764 + DWORD data;
  765 +
  766 + datalen = sizeof(data);
  767 +
  768 + if(RegQueryValueExA(hKey,WindowState[f].name,NULL,&datatype,(BYTE *) &data,&datalen) == ERROR_SUCCESS)
  769 + {
  770 + if(datatype == REG_DWORD)
  771 + {
  772 + if(data)
  773 + WindowState[f].activate(GTK_WINDOW(hwnd));
  774 +
  775 + }
  776 + else
  777 + {
  778 + g_warning("Unexpected registry data type in %s\\%s",path,WindowState[f].name);
  779 + }
  780 + }
  781 + }
  782 +
  783 +
  784 + RegCloseKey(hKey);
  785 + }
  786 +
  787 + g_free(path);
716 788
717 #else 789 #else
718 gchar * id = g_strconcat(group,".",key,NULL); 790 gchar * id = g_strconcat(group,".",key,NULL);
src/pw3270/v3270/oia.c
@@ -502,9 +502,9 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me @@ -502,9 +502,9 @@ void v3270_draw_oia(cairo_t *cr, H3270 *host, int row, int cols, struct v3270_me
502 { V3270_OIA_TIMER, setup_timer_position }, 502 { V3270_OIA_TIMER, setup_timer_position },
503 { V3270_OIA_SPINNER, setup_spinner_position }, 503 { V3270_OIA_SPINNER, setup_spinner_position },
504 { V3270_OIA_LUNAME, setup_luname_position }, 504 { V3270_OIA_LUNAME, setup_luname_position },
505 -#ifdef X3270_PRINTER 505 +#ifdef HAVE_PRINTER
506 { V3270_OIA_PRINTER, setup_single_char_right }, 506 { V3270_OIA_PRINTER, setup_single_char_right },
507 -#endif // X3270_PRINTER 507 +#endif // HAVE_PRINTER
508 { V3270_OIA_SCRIPT, setup_single_char_right }, 508 { V3270_OIA_SCRIPT, setup_single_char_right },
509 { V3270_OIA_INSERT, setup_insert_position }, 509 { V3270_OIA_INSERT, setup_insert_position },
510 { V3270_OIA_TYPEAHEAD, setup_single_char_right }, 510 { V3270_OIA_TYPEAHEAD, setup_single_char_right },
@@ -1047,27 +1047,10 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on) @@ -1047,27 +1047,10 @@ void v3270_update_oia(H3270 *session, LIB3270_FLAG id, unsigned char on)
1047 cairo_destroy(cr); 1047 cairo_destroy(cr);
1048 break; 1048 break;
1049 1049
1050 -/*  
1051 - case LIB3270_FLAG_SECURE:  
1052 - cr = set_update_region(terminal,&r,V3270_OIA_SSL);  
1053 - v3270_draw_ssl_status(cr,terminal->host,&terminal->metrics,terminal->color,r);  
1054 - gtk_widget_queue_draw_area(GTK_WIDGET(terminal),r->x,r->y,r->width,r->height);  
1055 - cairo_destroy(cr);  
1056 - break;  
1057 -*/  
1058 -  
1059 case LIB3270_FLAG_TYPEAHEAD: 1050 case LIB3270_FLAG_TYPEAHEAD:
1060 update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,"T"); 1051 update_text_field(terminal,on,V3270_OIA_TYPEAHEAD,"T");
1061 break; 1052 break;
1062 1053
1063 -/*  
1064 -#if defined(LIB3270_FLAG_PRINTER) && defined(X3270_PRINTER)  
1065 - case LIB3270_FLAG_PRINTER:  
1066 - update_text_field(terminal,on,V3270_OIA_PRINTER,"P");  
1067 - break;  
1068 -#endif // LIB3270_FLAG_PRINTER  
1069 -*/  
1070 -  
1071 default: 1054 default:
1072 return; 1055 return;
1073 } 1056 }