Commit 2027f7ff92b7adf719b87c8357b220c6e555ff9d

Authored by perry
1 parent 638ee277
Exists in master

Incluindo opções para salvar/restaurar conteúdo do buffer 3270.

v3.3.7/src/g3270/actions.c
... ... @@ -64,6 +64,7 @@
64 64 static void action_SaveSelected(void);
65 65 static void action_SaveClipboard(void);
66 66 static void action_DumpScreen(void);
  67 + static void action_LoadScreenDump(void);
67 68  
68 69 /*---[ Callback tables ]----------------------------------------------------------------------------------------*/
69 70  
... ... @@ -113,69 +114,70 @@
113 114 static const GtkActionEntry internal_action_entries[] =
114 115 {
115 116 /* Top menus */
116   - { "FileMenu", NULL, N_( "_File" ), NULL, NULL, NULL },
117   - { "NetworkMenu", NULL, N_( "_Network" ), NULL, NULL, NULL },
118   - { "HelpMenu", NULL, N_( "Help" ), NULL, NULL, NULL },
119   - { "EditMenu", NULL, N_( "_Edit" ), NULL, NULL, NULL },
120   - { "OptionsMenu", NULL, N_( "_Options" ), NULL, NULL, NULL },
121   - { "SettingsMenu", NULL, N_( "Settings" ), NULL, NULL, NULL },
122   - { "FontSettings", GTK_STOCK_SELECT_FONT, N_( "Select font" ), NULL, NULL, NULL },
  117 + { "FileMenu", NULL, N_( "_File" ), NULL, NULL, NULL },
  118 + { "NetworkMenu", NULL, N_( "_Network" ), NULL, NULL, NULL },
  119 + { "HelpMenu", NULL, N_( "Help" ), NULL, NULL, NULL },
  120 + { "EditMenu", NULL, N_( "_Edit" ), NULL, NULL, NULL },
  121 + { "OptionsMenu", NULL, N_( "_Options" ), NULL, NULL, NULL },
  122 + { "SettingsMenu", NULL, N_( "Settings" ), NULL, NULL, NULL },
  123 + { "FontSettings", GTK_STOCK_SELECT_FONT, N_( "Select font" ), NULL, NULL, NULL },
123 124  
124 125 /* Stock menus */
125   - { "Preferences", GTK_STOCK_PREFERENCES, N_( "Preferences" ), NULL, NULL, NULL },
126   - { "Network", GTK_STOCK_NETWORK, N_( "Network" ), NULL, NULL, NULL },
127   - { "Properties", GTK_STOCK_PROPERTIES, N_( "Properties" ), NULL, NULL, NULL },
  126 + { "Preferences", GTK_STOCK_PREFERENCES, N_( "Preferences" ), NULL, NULL, NULL },
  127 + { "Network", GTK_STOCK_NETWORK, N_( "Network" ), NULL, NULL, NULL },
  128 + { "Properties", GTK_STOCK_PROPERTIES, N_( "Properties" ), NULL, NULL, NULL },
128 129  
129 130 /* Misc actions */
130   - { "About", GTK_STOCK_ABOUT, N_( "About" ), NULL, NULL, G_CALLBACK(action_About) },
131   - { "Connect", GTK_STOCK_CONNECT, N_( "_Connect" ), NULL, NULL, G_CALLBACK(action_Connect) },
132   - { "Disconnect", GTK_STOCK_DISCONNECT, N_( "_Disconnect" ), NULL, NULL, G_CALLBACK(action_Disconnect) },
133   - { "Quit", GTK_STOCK_QUIT, N_( "_Quit" ), NULL, NULL, G_CALLBACK(action_Quit) },
134   - { "SelectColors", GTK_STOCK_SELECT_COLOR, N_( "Colors" ), NULL, NULL, G_CALLBACK(action_SelectColors) },
135   - { "DumpScreen", NULL, N_( "Dump screen" ), "<Alt>D", NULL, G_CALLBACK(action_DumpScreen) },
  131 + { "About", GTK_STOCK_ABOUT, N_( "About" ), NULL, NULL, G_CALLBACK(action_About) },
  132 + { "Connect", GTK_STOCK_CONNECT, N_( "_Connect" ), NULL, NULL, G_CALLBACK(action_Connect) },
  133 + { "Disconnect", GTK_STOCK_DISCONNECT, N_( "_Disconnect" ), NULL, NULL, G_CALLBACK(action_Disconnect) },
  134 + { "Quit", GTK_STOCK_QUIT, N_( "_Quit" ), NULL, NULL, G_CALLBACK(action_Quit) },
  135 + { "SelectColors", GTK_STOCK_SELECT_COLOR, N_( "Colors" ), NULL, NULL, G_CALLBACK(action_SelectColors) },
  136 + { "DumpScreen", NULL, N_( "Dump screen" ), "<Alt>D", NULL, G_CALLBACK(action_DumpScreen) },
  137 + { "LoadScreenDump", NULL, N_( "Load screen dump" ), "<Alt>R", NULL, G_CALLBACK(action_LoadScreenDump) },
136 138  
137 139 /* Edit actions */
138   - { "Copy", GTK_STOCK_COPY, N_( "Copy" ), NULL, NULL, G_CALLBACK(action_Copy) },
139   - { "Append", GTK_STOCK_ADD, N_( "Add to copy" ), NULL, NULL, G_CALLBACK(action_Append) },
140   - { "Paste", GTK_STOCK_PASTE, N_( "Paste" ), NULL, NULL, G_CALLBACK(action_Paste) },
141   - { "PasteNext", NULL, N_( "Paste _next" ), NULL, NULL, G_CALLBACK(action_PasteNext) },
142   - { "Unselect", NULL, N_( "_Unselect" ), NULL, NULL, G_CALLBACK(action_ClearSelection) },
143   - { "Reselect", NULL, N_( "_Reselect" ), NULL, NULL, G_CALLBACK(Reselect) },
144   - { "SelectAll", GTK_STOCK_SELECT_ALL, N_( "Select all" ), "<Alt>A", NULL, G_CALLBACK(action_SelectAll) },
145   - { "Clear", GTK_STOCK_CLEAR, N_( "Clear fields" ), "Clear", NULL, G_CALLBACK(action_Clear) },
  140 + { "Copy", GTK_STOCK_COPY, N_( "Copy" ), NULL, NULL, G_CALLBACK(action_Copy) },
  141 + { "Append", GTK_STOCK_ADD, N_( "Add to copy" ), NULL, NULL, G_CALLBACK(action_Append) },
  142 + { "Paste", GTK_STOCK_PASTE, N_( "Paste" ), NULL, NULL, G_CALLBACK(action_Paste) },
  143 + { "PasteNext", NULL, N_( "Paste _next" ), NULL, NULL, G_CALLBACK(action_PasteNext) },
  144 + { "Unselect", NULL, N_( "_Unselect" ), NULL, NULL, G_CALLBACK(action_ClearSelection) },
  145 + { "Reselect", NULL, N_( "_Reselect" ), NULL, NULL, G_CALLBACK(Reselect) },
  146 + { "SelectAll", GTK_STOCK_SELECT_ALL, N_( "Select all" ), "<Alt>A", NULL, G_CALLBACK(action_SelectAll) },
  147 + { "Clear", GTK_STOCK_CLEAR, N_( "Clear fields" ), "Clear", NULL, G_CALLBACK(action_Clear) },
146 148  
147 149 /* Printer actions */
148   - { "PrintScreen", GTK_STOCK_PRINT, N_( "Print" ), "Print", NULL, G_CALLBACK(action_PrintScreen) },
149   - { "PrintSelected", NULL, N_( "Print selected" ), NULL, NULL, G_CALLBACK(action_PrintSelected) },
150   - { "PrintClipboard", NULL, N_( "Print copy" ), NULL, NULL, G_CALLBACK(action_PrintClipboard) },
  150 + { "PrintScreen", GTK_STOCK_PRINT, N_( "Print" ), "Print", NULL, G_CALLBACK(action_PrintScreen) },
  151 + { "PrintSelected", NULL, N_( "Print selected" ), NULL, NULL, G_CALLBACK(action_PrintSelected) },
  152 + { "PrintClipboard", NULL, N_( "Print copy" ), NULL, NULL, G_CALLBACK(action_PrintClipboard) },
151 153  
152 154 /* Save actions */
153   - { "Save", GTK_STOCK_SAVE, N_( "Save" ), NULL, NULL, NULL },
154   - { "SaveScreen", NULL, N_( "Save screen" ), NULL, NULL, G_CALLBACK(action_SaveScreen) },
155   - { "SaveSelected", NULL, N_( "Save selected" ), NULL, NULL, G_CALLBACK(action_SaveSelected) },
156   - { "SaveClipboard", NULL, N_( "Save copy" ), NULL, NULL, G_CALLBACK(action_SaveClipboard) },
  155 + { "Save", GTK_STOCK_SAVE, N_( "Save" ), NULL, NULL, NULL },
  156 + { "SaveScreen", NULL, N_( "Save screen" ), NULL, NULL, G_CALLBACK(action_SaveScreen) },
  157 + { "SaveSelected", NULL, N_( "Save selected" ), NULL, NULL, G_CALLBACK(action_SaveSelected) },
  158 + { "SaveClipboard", NULL, N_( "Save copy" ), NULL, NULL, G_CALLBACK(action_SaveClipboard) },
157 159  
158 160 /* Select actions */
159   - { "SelectRight", NULL, N_( "Select Right" ), "<Shift>Right", NULL, G_CALLBACK(action_SelectRight) },
160   - { "SelectLeft", NULL, N_( "Select Left" ), "<Shift>Left", NULL, G_CALLBACK(action_SelectLeft) },
161   - { "SelectUp", NULL, N_( "Select Up" ), "<Shift>Up", NULL, G_CALLBACK(action_SelectUp) },
162   - { "SelectDown", NULL, N_( "Select Down" ), "<Shift>Down", NULL, G_CALLBACK(action_SelectDown) },
163   - { "SelectField", NULL, N_( "Select Field" ), "<Ctrl>f", NULL, G_CALLBACK(action_SelectField) },
  161 + { "SelectRight", NULL, N_( "Select Right" ), "<Shift>Right", NULL, G_CALLBACK(action_SelectRight) },
  162 + { "SelectLeft", NULL, N_( "Select Left" ), "<Shift>Left", NULL, G_CALLBACK(action_SelectLeft) },
  163 + { "SelectUp", NULL, N_( "Select Up" ), "<Shift>Up", NULL, G_CALLBACK(action_SelectUp) },
  164 + { "SelectDown", NULL, N_( "Select Down" ), "<Shift>Down", NULL, G_CALLBACK(action_SelectDown) },
  165 + { "SelectField", NULL, N_( "Select Field" ), "<Ctrl>f", NULL, G_CALLBACK(action_SelectField) },
164 166  
165 167 /* Cursor Movement */
166   - { "CursorRight", GTK_STOCK_GO_FORWARD, N_( "Right" ), "Right", NULL, G_CALLBACK(action_Right) },
167   - { "CursorLeft", GTK_STOCK_GO_BACK, N_( "Left" ), "Left", NULL, G_CALLBACK(action_Left) },
168   - { "CursorUp", GTK_STOCK_GO_UP, N_( "Up" ), "Up", NULL, G_CALLBACK(action_Up) },
169   - { "CursorDown", GTK_STOCK_GO_DOWN, N_( "Down" ), "Down", NULL, G_CALLBACK(action_Down) },
170   - { "Enter", NULL, N_( "Enter" ), "Return", NULL, G_CALLBACK(action_Enter) },
  168 + { "CursorRight", GTK_STOCK_GO_FORWARD, N_( "Right" ), "Right", NULL, G_CALLBACK(action_Right) },
  169 + { "CursorLeft", GTK_STOCK_GO_BACK, N_( "Left" ), "Left", NULL, G_CALLBACK(action_Left) },
  170 + { "CursorUp", GTK_STOCK_GO_UP, N_( "Up" ), "Up", NULL, G_CALLBACK(action_Up) },
  171 + { "CursorDown", GTK_STOCK_GO_DOWN, N_( "Down" ), "Down", NULL, G_CALLBACK(action_Down) },
  172 + { "Enter", NULL, N_( "Enter" ), "Return", NULL, G_CALLBACK(action_Enter) },
171 173  
172 174 /* Terminal Actions */
173   - { "Reset", NULL, N_( "Reset" ), "<Ctrl>r", NULL, G_CALLBACK(action_Reset) },
174   - { "Escape", NULL, N_( "Escape" ), "Escape", NULL, G_CALLBACK(action_Reset) },
175   - { "Return", GTK_STOCK_APPLY, N_( "Return" ), "Return", NULL, G_CALLBACK(action_Enter) },
176   - { "PageUP", NULL, N_( "Page-Up" ), "Page_Up", NULL, G_CALLBACK(action_PageUP) },
177   - { "PageDown", NULL, N_( "Page-Down" ), "Page_Down", NULL, G_CALLBACK(action_PageDown) },
178   - { "Redraw", NULL, N_( "Redraw screen" ), NULL, NULL, G_CALLBACK(action_Redraw) },
  175 + { "Reset", NULL, N_( "Reset" ), "<Ctrl>r", NULL, G_CALLBACK(action_Reset) },
  176 + { "Escape", NULL, N_( "Escape" ), "Escape", NULL, G_CALLBACK(action_Reset) },
  177 + { "Return", GTK_STOCK_APPLY, N_( "Return" ), "Return", NULL, G_CALLBACK(action_Enter) },
  178 + { "PageUP", NULL, N_( "Page-Up" ), "Page_Up", NULL, G_CALLBACK(action_PageUP) },
  179 + { "PageDown", NULL, N_( "Page-Down" ), "Page_Down", NULL, G_CALLBACK(action_PageDown) },
  180 + { "Redraw", NULL, N_( "Redraw screen" ), NULL, NULL, G_CALLBACK(action_Redraw) },
179 181 };
180 182  
181 183 GtkActionGroup *main_actions = NULL;
... ... @@ -862,6 +864,41 @@
862 864 return 0;
863 865 }
864 866  
  867 + static void action_LoadScreenDump(void)
  868 + {
  869 + GtkWidget *dialog = gtk_file_chooser_dialog_new( _( "Load screen dump" ),
  870 + GTK_WINDOW(topwindow),
  871 + GTK_FILE_CHOOSER_ACTION_OPEN,
  872 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
  873 + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
  874 + NULL );
  875 +
  876 +
  877 + if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
  878 + {
  879 + GError *error = NULL;
  880 + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
  881 + gsize sz;
  882 + struct ea *buffer = NULL;
  883 +
  884 + if(!g_file_get_contents(filename, (gchar **) &buffer, &sz, &error))
  885 + {
  886 + popup_an_error( N_( "Error loading %s\n%s" ), filename, error->message ? error->message : N_( "Unexpected error" ));
  887 + g_error_free(error);
  888 + }
  889 + else
  890 + {
  891 + sz /= sizeof(struct ea);
  892 + if(set_device_buffer(buffer,sz))
  893 + popup_an_error( N_( "Can't set device buffer contents" ) );
  894 + }
  895 +
  896 + g_free(buffer);
  897 + }
  898 +
  899 + gtk_widget_destroy(dialog);
  900 + }
  901 +
865 902 static void action_DumpScreen(void)
866 903 {
867 904 GtkWidget *dialog = gtk_file_chooser_dialog_new( _( "Dump screen contents" ),
... ...
v3.3.7/src/g3270/ui.xml
... ... @@ -113,5 +113,6 @@
113 113 <accelerator action='PageDown' />
114 114 <accelerator action='NextField' />
115 115 <accelerator action='DumpScreen' />
  116 + <accelerator action='LoadScreenDump' />
116 117  
117 118 </ui>
... ...
v3.3.7/src/include/globals.h
... ... @@ -250,6 +250,7 @@ struct ea {
250 250 #define CS_GE 0x04 /* cs flag for Graphic Escape */
251 251  
252 252 struct ea * copy_device_buffer(int *el); /* Return a "malloced" copy of the device buffer, set number of elements */
  253 +int set_device_buffer(struct ea *src, int el); /* Set the contents of the device buffer for debugging purposes */
253 254  
254 255 /* translation lists */
255 256 struct trans_list {
... ...
v3.3.7/src/lib/screen.c
... ... @@ -1044,6 +1044,18 @@ extern void popup_an_error(const char *fmt, ...)
1044 1044  
1045 1045 }
1046 1046  
  1047 +int set_device_buffer(struct ea *src, int el)
  1048 +{
  1049 + if(el > (maxROWS * maxCOLS))
  1050 + return EINVAL;
  1051 +
  1052 + memcpy(ea_buf,src,sizeof(struct ea) * el);
  1053 +
  1054 + screen_disp();
  1055 +
  1056 + return 0;
  1057 +}
  1058 +
1047 1059 struct ea * copy_device_buffer(int *el)
1048 1060 {
1049 1061 int sz = sizeof(struct ea) * (maxROWS * maxCOLS);
... ...