Commit dd87907c760c3b362a7f9c9acb52d2e7dd98e61e
1 parent
f9c12c35
Exists in
master
and in
5 other branches
Trabalhando no suporte atk
Showing
13 changed files
with
358 additions
and
128 deletions
Show diff stats
src/gtk/actions.c
... | ... | @@ -45,7 +45,7 @@ static void lib3270_action(GtkAction *action, GtkWidget *widget) |
45 | 45 | { |
46 | 46 | int (*call)(H3270 *h) = (int (*)(H3270 *h)) g_object_get_data(G_OBJECT(action),"lib3270_call"); |
47 | 47 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
48 | - call(GTK_V3270(widget)->host); | |
48 | + call(v3270_get_session(widget)); | |
49 | 49 | } |
50 | 50 | |
51 | 51 | static void connect_action(GtkAction *action, GtkWidget *widget) |
... | ... | @@ -116,7 +116,7 @@ static void paste_clipboard_action(GtkAction *action, GtkWidget *widget) |
116 | 116 | static void paste_next_action(GtkAction *action, GtkWidget *widget) |
117 | 117 | { |
118 | 118 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
119 | - lib3270_pastenext(GTK_V3270(widget)->host); | |
119 | + lib3270_pastenext(v3270_get_session(widget)); | |
120 | 120 | } |
121 | 121 | |
122 | 122 | static void connect_standard_action(GtkAction *action, GtkWidget *widget, const gchar *name) |
... | ... | @@ -197,20 +197,20 @@ static void lib3270_toggle_action(GtkToggleAction *action,GtkWidget *widget) |
197 | 197 | if(toggle == TOGGLE_GDKDEBUG) |
198 | 198 | gdk_window_set_debug_updates(gtk_toggle_action_get_active(action)); |
199 | 199 | else if(toggle < LIB3270_TOGGLE_COUNT) |
200 | - lib3270_set_toggle(GTK_V3270(widget)->host,toggle,gtk_toggle_action_get_active(action)); | |
200 | + lib3270_set_toggle(v3270_get_session(widget),toggle,gtk_toggle_action_get_active(action)); | |
201 | 201 | } |
202 | 202 | |
203 | 203 | static void selection_move_action(GtkAction *action, GtkWidget *widget) |
204 | 204 | { |
205 | 205 | trace("Action %s activated on widget %p",gtk_action_get_name(action),widget); |
206 | - lib3270_move_selection(GTK_V3270(widget)->host,(LIB3270_DIRECTION) g_object_get_data(G_OBJECT(action),"direction")); | |
206 | + lib3270_move_selection(v3270_get_session(widget),(LIB3270_DIRECTION) g_object_get_data(G_OBJECT(action),"direction")); | |
207 | 207 | } |
208 | 208 | |
209 | 209 | static void cursor_move_action(GtkAction *action, GtkWidget *widget) |
210 | 210 | { |
211 | 211 | int flags = (int) g_object_get_data(G_OBJECT(action),"move_flags"); |
212 | 212 | trace("Action %s activated on widget %p flags=%04x",gtk_action_get_name(action),widget,(unsigned short) g_object_get_data(G_OBJECT(action),"move_flags")); |
213 | - lib3270_move_cursor(GTK_V3270(widget)->host,(LIB3270_DIRECTION) (flags & 0x03), (flags & 0x80) ); | |
213 | + lib3270_move_cursor(v3270_get_session(widget),(LIB3270_DIRECTION) (flags & 0x03), (flags & 0x80) ); | |
214 | 214 | } |
215 | 215 | |
216 | 216 | static void connect_move_action(GtkAction *action, GtkWidget *widget, const gchar *target, unsigned short flags, GError **error) |
... | ... | @@ -244,47 +244,47 @@ static void connect_move_action(GtkAction *action, GtkWidget *widget, const gcha |
244 | 244 | static void action_pfkey(GtkAction *action, GtkWidget *widget) |
245 | 245 | { |
246 | 246 | trace("Action %s activated on widget %p key=%p",gtk_action_get_name(action),widget,g_object_get_data(G_OBJECT(action),"pfkey")); |
247 | - lib3270_pfkey(GTK_V3270(widget)->host,(int) g_object_get_data(G_OBJECT(action),"pfkey")); | |
247 | + lib3270_pfkey(v3270_get_session(widget),(int) g_object_get_data(G_OBJECT(action),"pfkey")); | |
248 | 248 | } |
249 | 249 | |
250 | 250 | static void action_pakey(GtkAction *action, GtkWidget *widget) |
251 | 251 | { |
252 | 252 | trace("Action %s activated on widget %p key=%p",gtk_action_get_name(action),widget,g_object_get_data(G_OBJECT(action),"pakey")); |
253 | - lib3270_pakey(GTK_V3270(widget)->host,(int) g_object_get_data(G_OBJECT(action),"pakey")); | |
253 | + lib3270_pakey(v3270_get_session(widget),(int) g_object_get_data(G_OBJECT(action),"pakey")); | |
254 | 254 | } |
255 | 255 | |
256 | 256 | static void action_set_toggle(GtkAction *action, GtkWidget *widget) |
257 | 257 | { |
258 | 258 | LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); |
259 | 259 | trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); |
260 | - lib3270_set_toggle(GTK_V3270(widget)->host,id,1); | |
260 | + lib3270_set_toggle(v3270_get_session(widget),id,1); | |
261 | 261 | } |
262 | 262 | |
263 | 263 | static void action_reset_toggle(GtkAction *action, GtkWidget *widget) |
264 | 264 | { |
265 | 265 | LIB3270_TOGGLE id = (LIB3270_TOGGLE) g_object_get_data(G_OBJECT(action),"toggle_id"); |
266 | 266 | trace("Action %s activated on widget %p toggle=%d",gtk_action_get_name(action),widget,id); |
267 | - lib3270_set_toggle(GTK_V3270(widget)->host,id,0); | |
267 | + lib3270_set_toggle(v3270_get_session(widget),id,0); | |
268 | 268 | } |
269 | 269 | |
270 | 270 | static void action_select_all(GtkAction *action, GtkWidget *widget) |
271 | 271 | { |
272 | - lib3270_selectall(GTK_V3270(widget)->host); | |
272 | + lib3270_selectall(v3270_get_session(widget)); | |
273 | 273 | } |
274 | 274 | |
275 | 275 | static void action_select_field(GtkAction *action, GtkWidget *widget) |
276 | 276 | { |
277 | - lib3270_selectfield(GTK_V3270(widget)->host); | |
277 | + lib3270_selectfield(v3270_get_session(widget)); | |
278 | 278 | } |
279 | 279 | |
280 | 280 | static void action_select_none(GtkAction *action, GtkWidget *widget) |
281 | 281 | { |
282 | - lib3270_unselect(GTK_V3270(widget)->host); | |
282 | + lib3270_unselect(v3270_get_session(widget)); | |
283 | 283 | } |
284 | 284 | |
285 | 285 | static void action_select_last(GtkAction *action, GtkWidget *widget) |
286 | 286 | { |
287 | - lib3270_reselect(GTK_V3270(widget)->host); | |
287 | + lib3270_reselect(v3270_get_session(widget)); | |
288 | 288 | } |
289 | 289 | |
290 | 290 | static int id_from_array(const gchar *key, const gchar **array, GError **error) |
... | ... | @@ -598,7 +598,7 @@ GtkAction * ui_get_action(GtkWidget *widget, const gchar *name, GHashTable *hash |
598 | 598 | if(id < LIB3270_TOGGLE_COUNT) |
599 | 599 | toggle_action[id] = action; |
600 | 600 | g_object_set_data(G_OBJECT(action),"toggle_id",(gpointer) id); |
601 | - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),(lib3270_get_toggle(GTK_V3270(widget)->host,id) != 0)); | |
601 | + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),(lib3270_get_toggle(v3270_get_session(widget),id) != 0)); | |
602 | 602 | g_signal_connect(action,"toggled",G_CALLBACK(lib3270_toggle_action),widget); |
603 | 603 | break; |
604 | 604 | ... | ... |
src/gtk/dialog.c
... | ... | @@ -388,7 +388,7 @@ |
388 | 388 | |
389 | 389 | void save_all_action(GtkAction *action, GtkWidget *widget) |
390 | 390 | { |
391 | - gchar *text = v3270_get_text(widget); | |
391 | + gchar *text = v3270_get_text(widget,0,-1); | |
392 | 392 | |
393 | 393 | trace("Action %s activated on widget %p text=%p",gtk_action_get_name(action),widget,text); |
394 | 394 | ... | ... |
src/gtk/mainwindow.c
... | ... | @@ -201,7 +201,7 @@ |
201 | 201 | static void setup_input_method(GtkWidget *widget, GtkWidget *obj) |
202 | 202 | { |
203 | 203 | GtkWidget *menu = gtk_menu_new(); |
204 | - gtk_im_multicontext_append_menuitems((GtkIMMulticontext *) GTK_V3270(obj)->input_method,GTK_MENU_SHELL(menu)); | |
204 | + gtk_im_multicontext_append_menuitems((GtkIMMulticontext *) v3270_get_im_context(obj) ,GTK_MENU_SHELL(menu)); | |
205 | 205 | gtk_widget_show_all(menu); |
206 | 206 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget),menu); |
207 | 207 | } |
... | ... | @@ -281,6 +281,8 @@ |
281 | 281 | GtkWidget **popup; |
282 | 282 | int f; |
283 | 283 | |
284 | + gtk_widget_set_tooltip_text(terminal,_( "3270 screen")); | |
285 | + | |
284 | 286 | if(uri) |
285 | 287 | { |
286 | 288 | lib3270_set_host(host,uri); | ... | ... |
src/gtk/v3270/accessible.c
... | ... | @@ -27,9 +27,18 @@ |
27 | 27 | * |
28 | 28 | */ |
29 | 29 | |
30 | + #include <lib3270/config.h> | |
31 | + | |
32 | + #define ENABLE_NLS | |
33 | + #define GETTEXT_PACKAGE PACKAGE_NAME | |
34 | + | |
30 | 35 | #include <gtk/gtk.h> |
36 | + #include <libintl.h> | |
37 | + #include <glib/gi18n.h> | |
38 | + | |
31 | 39 | #include <pw3270.h> |
32 | 40 | #include "v3270.h" |
41 | + #include "private.h" | |
33 | 42 | #include "accessible.h" |
34 | 43 | |
35 | 44 | // References: |
... | ... | @@ -41,44 +50,55 @@ |
41 | 50 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
42 | 51 | |
43 | 52 | static void atk_component_interface_init (AtkComponentIface *iface); |
44 | -static void atk_editable_text_interface_init (AtkEditableTextIface *iface); | |
45 | 53 | |
46 | 54 | static void v3270_accessible_class_init (v3270AccessibleClass *klass); |
47 | 55 | static void v3270_accessible_init (v3270Accessible *widget); |
48 | 56 | |
57 | +static void atk_text_interface_init (AtkTextIface *iface); | |
58 | + | |
49 | 59 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
50 | 60 | |
51 | 61 | G_DEFINE_TYPE_WITH_CODE (v3270Accessible, v3270_accessible, GTK_TYPE_ACCESSIBLE, |
52 | 62 | G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init) |
53 | - G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init) ) | |
63 | + G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init) ) | |
54 | 64 | |
65 | +// G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init) ) | |
55 | 66 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init) |
56 | 67 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_EDITABLE_TEXT, atk_editable_text_interface_init) |
57 | 68 | // G_IMPLEMENT_INTERFACE (ATK_TYPE_TEXT, atk_text_interface_init) |
58 | 69 | |
59 | 70 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
60 | 71 | |
72 | +/* | |
73 | +static const gchar * v3270_accessible_get_description(AtkObject *accessible) | |
74 | +{ | |
75 | + return _( "3270 screen" ); | |
76 | +} | |
77 | +*/ | |
78 | + | |
61 | 79 | static void v3270_accessible_class_init(v3270AccessibleClass *klass) |
62 | 80 | { |
81 | + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); | |
82 | + | |
63 | 83 | trace("******************************* %s",__FUNCTION__); |
84 | + | |
64 | 85 | /* |
65 | - AtkObjectClass *class = ATK_OBJECT_CLASS (klass); | |
66 | - | |
67 | - klass->notify_gtk = gtk_widget_accessible_notify_gtk; | |
68 | - | |
69 | - class->get_description = gtk_widget_accessible_get_description; | |
70 | - class->get_parent = gtk_widget_accessible_get_parent; | |
71 | - class->ref_relation_set = gtk_widget_accessible_ref_relation_set; | |
72 | - class->ref_state_set = gtk_widget_accessible_ref_state_set; | |
73 | - class->get_index_in_parent = gtk_widget_accessible_get_index_in_parent; | |
74 | - class->initialize = gtk_widget_accessible_initialize; | |
75 | - class->get_attributes = gtk_widget_accessible_get_attributes; | |
76 | - class->focus_event = gtk_widget_accessible_focus_event; | |
86 | + class->get_description = v3270_accessible_get_description; | |
87 | + | |
88 | + | |
89 | + klass->notify_gtk = gtk_widget_accessible_notify_gtk; | |
90 | + | |
91 | + class->get_parent = gtk_widget_accessible_get_parent; | |
92 | + class->ref_relation_set = gtk_widget_accessible_ref_relation_set; | |
93 | + class->ref_state_set = gtk_widget_accessible_ref_state_set; | |
94 | + class->get_index_in_parent = gtk_widget_accessible_get_index_in_parent; | |
95 | + class->initialize = gtk_widget_accessible_initialize; | |
96 | + class->get_attributes = gtk_widget_accessible_get_attributes; | |
97 | + class->focus_event = gtk_widget_accessible_focus_event; | |
77 | 98 | */ |
78 | 99 | } |
79 | 100 | |
80 | -static void | |
81 | -atk_component_interface_init(AtkComponentIface *iface) | |
101 | +static void atk_component_interface_init(AtkComponentIface *iface) | |
82 | 102 | { |
83 | 103 | /* |
84 | 104 | iface->get_extents = gtk_widget_accessible_get_extents; |
... | ... | @@ -91,23 +111,164 @@ atk_component_interface_init(AtkComponentIface *iface) |
91 | 111 | */ |
92 | 112 | } |
93 | 113 | |
94 | -static void v3270_accessible_init(v3270Accessible *widget) | |
114 | +static gunichar v3270_accessible_get_character_at_offset(AtkText *atk_text, gint offset) | |
115 | +{ | |
116 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (atk_text)); | |
117 | + | |
118 | + trace("*********** %s %p",__FUNCTION__,widget); | |
119 | + | |
120 | + if (widget == NULL) | |
121 | + return '\0'; | |
122 | + | |
123 | + return 'X'; | |
124 | +} | |
125 | + | |
126 | +static gint v3270_accessible_get_caret_offset(AtkText *text) | |
127 | +{ | |
128 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE(text)); | |
129 | + | |
130 | + if (widget == NULL) | |
131 | + return 0; | |
132 | + | |
133 | + return lib3270_get_cursor_address(GTK_V3270(widget)->host); | |
134 | +} | |
135 | + | |
136 | +static gint v3270_accessible_get_character_count(AtkText *text) | |
137 | +{ | |
138 | + int rows,cols; | |
139 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE(text)); | |
140 | + | |
141 | + trace("*********** %s %p len=%d",__FUNCTION__,widget,lib3270_get_length(GTK_V3270(widget)->host)); | |
142 | + | |
143 | + if(!widget) | |
144 | + return 0; | |
145 | + | |
146 | + return lib3270_get_length(GTK_V3270(widget)->host); | |
147 | +} | |
148 | + | |
149 | +static gint v3270_accessible_get_offset_at_point(AtkText *atk_text, gint x, gint y, AtkCoordType coords) | |
95 | 150 | { |
96 | - trace("*********************************** %s",__FUNCTION__); | |
151 | + GtkWidget *widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (atk_text)); | |
152 | + | |
153 | + trace("*********** %s %p",__FUNCTION__,widget); | |
154 | + | |
155 | + if(!widget) | |
156 | + return -1; | |
157 | + | |
97 | 158 | |
159 | + return 1; | |
98 | 160 | } |
99 | 161 | |
100 | -static void atk_editable_text_interface_init(AtkEditableTextIface *iface) | |
162 | +static gchar * v3270_accessible_get_text_at_offset(AtkText *atk_text, gint offset, AtkTextBoundary boundary_type, gint *start_offset, gint *end_offset) | |
101 | 163 | { |
102 | - trace("********************************** %s",__FUNCTION__); | |
164 | + GtkWidget * widget = gtk_accessible_get_widget(GTK_ACCESSIBLE (atk_text)); | |
165 | + H3270 * host; | |
166 | + char * text; | |
167 | + int rows,cols,first; | |
168 | + | |
169 | + trace("*********** %s %p offset=%d",__FUNCTION__,widget,offset); | |
170 | + | |
171 | + if(!widget) | |
172 | + return NULL; | |
173 | + | |
174 | + host = GTK_V3270(widget)->host; | |
175 | + lib3270_get_screen_size(host,&rows,&cols); | |
176 | + | |
177 | + switch(boundary_type) | |
178 | + { | |
179 | + case ATK_TEXT_BOUNDARY_CHAR: // Boundary is the boundary between characters | |
180 | + // (including non-printing characters) | |
181 | + | |
182 | + text = lib3270_get_text(host,offset,1); | |
183 | + break; | |
184 | + | |
185 | + case ATK_TEXT_BOUNDARY_WORD_START: // Boundary is the start (i.e. first character) of a word. | |
186 | + return g_strdup("ATK_TEXT_BOUNDARY_WORD_START"); | |
187 | + break; | |
188 | + | |
189 | + case ATK_TEXT_BOUNDARY_WORD_END: // Boundary is the end (i.e. last character) of a word. | |
190 | + return g_strdup("ATK_TEXT_BOUNDARY_WORD_END"); | |
191 | + break; | |
192 | + | |
193 | + case ATK_TEXT_BOUNDARY_SENTENCE_START: // Boundary is the first character in a sentence. | |
194 | + return g_strdup("ATK_TEXT_BOUNDARY_SENTENCE_START"); | |
195 | + break; | |
196 | + | |
197 | + case ATK_TEXT_BOUNDARY_SENTENCE_END: // Boundary is the last (terminal) character in | |
198 | + // a sentence; in languages which use "sentence stop" punctuation such as English, the boundary is thus the '.', '?', or | |
199 | + // similar terminal punctuation character. | |
200 | + return g_strdup("ATK_TEXT_BOUNDARY_SENTENCE_END"); | |
201 | + break; | |
202 | + | |
203 | + | |
204 | + case ATK_TEXT_BOUNDARY_LINE_START: // Boundary is the initial character of the content or a character immediately following a newline, | |
205 | + // linefeed, or return character. | |
206 | + first = (offset/cols)*cols; | |
207 | + if(first == offset) | |
208 | + offset++; | |
209 | + text = lib3270_get_text(host,first,(offset-first)); | |
210 | + break; | |
211 | + | |
212 | + | |
213 | + case ATK_TEXT_BOUNDARY_LINE_END: // Boundary is the linefeed, or return character. | |
214 | + return g_strdup("ATK_TEXT_BOUNDARY_LINE_END"); | |
215 | + break; | |
216 | + | |
217 | + } | |
218 | + | |
219 | + if(text) | |
220 | + { | |
221 | + gsize bytes_written; | |
222 | + GError * error = NULL; | |
223 | + gchar * utfchar = g_convert_with_fallback( text, | |
224 | + -1, | |
225 | + "UTF-8", | |
226 | + lib3270_get_charset(host), | |
227 | + " ", | |
228 | + NULL, | |
229 | + &bytes_written, | |
230 | + &error ); | |
231 | + | |
232 | + if(error) | |
233 | + { | |
234 | + g_warning("%s failed: %s",__FUNCTION__,error->message); | |
235 | + g_error_free(error); | |
236 | + } | |
237 | + return utfchar; | |
238 | + } | |
239 | + | |
240 | + return NULL; | |
241 | +} | |
242 | + | |
243 | +static void atk_text_interface_init(AtkTextIface *iface) | |
244 | +{ | |
245 | + iface->get_character_at_offset = v3270_accessible_get_character_at_offset; | |
246 | + iface->get_caret_offset = v3270_accessible_get_caret_offset; | |
247 | + iface->get_character_count = v3270_accessible_get_character_count; | |
248 | + iface->get_offset_at_point = v3270_accessible_get_offset_at_point; | |
249 | + iface->get_text_at_offset = v3270_accessible_get_text_at_offset; | |
103 | 250 | /* |
104 | - iface->set_text_contents = gtk_entry_accessible_set_text_contents; | |
105 | - iface->insert_text = gtk_entry_accessible_insert_text; | |
106 | - iface->copy_text = gtk_entry_accessible_copy_text; | |
107 | - iface->cut_text = gtk_entry_accessible_cut_text; | |
108 | - iface->delete_text = gtk_entry_accessible_delete_text; | |
109 | - iface->paste_text = gtk_entry_accessible_paste_text; | |
110 | - iface->set_run_attributes = NULL; | |
251 | + iface->get_text = gtk_entry_accessible_get_text; | |
252 | + iface->get_text_before_offset = gtk_entry_accessible_get_text_before_offset; | |
253 | + iface->get_text_at_offset = gtk_entry_accessible_get_text_at_offset; | |
254 | + iface->get_text_after_offset = gtk_entry_accessible_get_text_after_offset; | |
255 | + iface->get_caret_offset = gtk_entry_accessible_get_caret_offset; | |
256 | + iface->set_caret_offset = gtk_entry_accessible_set_caret_offset; | |
257 | + iface->get_n_selections = gtk_entry_accessible_get_n_selections; | |
258 | + iface->get_selection = gtk_entry_accessible_get_selection; | |
259 | + iface->add_selection = gtk_entry_accessible_add_selection; | |
260 | + iface->remove_selection = gtk_entry_accessible_remove_selection; | |
261 | + iface->set_selection = gtk_entry_accessible_set_selection; | |
262 | + iface->get_run_attributes = gtk_entry_accessible_get_run_attributes; | |
263 | + iface->get_default_attributes = gtk_entry_accessible_get_default_attributes; | |
264 | + iface->get_character_extents = gtk_entry_accessible_get_character_extents; | |
111 | 265 | */ |
112 | 266 | } |
113 | 267 | |
268 | + | |
269 | +static void v3270_accessible_init(v3270Accessible *widget) | |
270 | +{ | |
271 | +} | |
272 | + | |
273 | + | |
274 | + | ... | ... |
src/gtk/v3270/clipboard.c
... | ... | @@ -75,7 +75,7 @@ static void clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection, |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | -gchar * v3270_get_text(GtkWidget *widget) | |
78 | +gchar * v3270_get_text(GtkWidget *widget, int offset, int len) | |
79 | 79 | { |
80 | 80 | v3270 * terminal; |
81 | 81 | gchar * text; |
... | ... | @@ -85,7 +85,7 @@ gchar * v3270_get_text(GtkWidget *widget) |
85 | 85 | |
86 | 86 | terminal = GTK_V3270(widget); |
87 | 87 | |
88 | - str = lib3270_get_text(terminal->host); | |
88 | + str = lib3270_get_text(terminal->host, offset, len); | |
89 | 89 | |
90 | 90 | if(!str) |
91 | 91 | return NULL; | ... | ... |
src/gtk/v3270/mouse.c
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | |
38 | 38 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
39 | 39 | |
40 | -static int decode_position(v3270 *widget, gdouble x, gdouble y) | |
40 | +gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) | |
41 | 41 | { |
42 | 42 | GdkPoint point; |
43 | 43 | int r,c; |
... | ... | @@ -120,7 +120,7 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event) |
120 | 120 | |
121 | 121 | gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) |
122 | 122 | { |
123 | - int baddr = decode_position(GTK_V3270(widget),event->x,event->y); | |
123 | + int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y); | |
124 | 124 | |
125 | 125 | if(baddr < 0) |
126 | 126 | return FALSE; |
... | ... | @@ -167,7 +167,7 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) |
167 | 167 | gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) |
168 | 168 | { |
169 | 169 | v3270 * terminal = GTK_V3270(widget); |
170 | - int baddr = decode_position(terminal,event->x,event->y); | |
170 | + int baddr = v3270_get_offset_at_point(terminal,event->x,event->y); | |
171 | 171 | |
172 | 172 | if(baddr < 0) |
173 | 173 | return FALSE; | ... | ... |
src/gtk/v3270/oia.c
... | ... | @@ -726,6 +726,10 @@ void v3270_update_cursor(H3270 *session, unsigned short row, unsigned short col, |
726 | 726 | |
727 | 727 | gtk_widget_queue_draw_area(GTK_WIDGET(terminal),rect->x,rect->y,rect->width,rect->height); |
728 | 728 | } |
729 | + | |
730 | + if(terminal->accessible) | |
731 | + g_signal_emit_by_name(ATK_TEXT(terminal->accessible),"text-caret-moved",lib3270_get_cursor_address(session)); | |
732 | + | |
729 | 733 | } |
730 | 734 | |
731 | 735 | struct timer_info | ... | ... |
src/gtk/v3270/private.h
... | ... | @@ -37,7 +37,9 @@ |
37 | 37 | #include <libintl.h> |
38 | 38 | #include <glib/gi18n.h> |
39 | 39 | |
40 | -#include <lib3270.h> | |
40 | +#ifndef V3270_H_INCLUDED | |
41 | + #include "v3270.h" | |
42 | +#endif | |
41 | 43 | |
42 | 44 | G_BEGIN_DECLS |
43 | 45 | |
... | ... | @@ -98,6 +100,84 @@ G_BEGIN_DECLS |
98 | 100 | |
99 | 101 | #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+9 |
100 | 102 | |
103 | + | |
104 | + struct v3270_metrics | |
105 | + { | |
106 | + guint width; | |
107 | + guint height; | |
108 | + guint ascent; | |
109 | + guint descent; | |
110 | + | |
111 | + guint spacing; | |
112 | + | |
113 | + guint left; | |
114 | + guint top; | |
115 | + }; | |
116 | + | |
117 | +/*--[ Widget data ]----------------------------------------------------------------------------------*/ | |
118 | + | |
119 | + struct _v3270 | |
120 | + { | |
121 | + GtkWidget parent; | |
122 | + | |
123 | + // private | |
124 | + int selecting : 1; /**< Selecting region */ | |
125 | + int moving : 1; /**< Moving selected region */ | |
126 | + int resizing : 1; /**< Resizing selected region */ | |
127 | + | |
128 | +#if GTK_CHECK_VERSION(3,0,0) | |
129 | + | |
130 | +#else | |
131 | + gint width; | |
132 | + gint height; | |
133 | +#endif // GTK_CHECK_VERSION(3,0,0) | |
134 | + | |
135 | + GSource * timer; | |
136 | + GtkIMContext * input_method; | |
137 | + unsigned short keyflags; | |
138 | + gchar * clipboard; /**< Clipboard contents (text only) */ | |
139 | + | |
140 | + LIB3270_CURSOR pointer_id; | |
141 | + unsigned char pointer; /** Mouse pointer ID */ | |
142 | + int selection_addr; /** Selection addr */ | |
143 | + | |
144 | + // Font info | |
145 | + gchar * font_family; | |
146 | + cairo_font_weight_t font_weight; | |
147 | + cairo_scaled_font_t * font_scaled; | |
148 | + cairo_surface_t * surface; | |
149 | + | |
150 | + struct v3270_metrics metrics; | |
151 | + | |
152 | + gint minimum_width; | |
153 | + gint minimum_height; | |
154 | + | |
155 | + // Colors | |
156 | + GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | |
157 | + | |
158 | + // Regions | |
159 | + GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; | |
160 | + | |
161 | + struct | |
162 | + { | |
163 | + unsigned char show; /**< Cursor flag */ | |
164 | + unsigned char chr; /**< Char at cursor position */ | |
165 | + unsigned short attr; /**< Attribute at cursor position */ | |
166 | + GdkRectangle rect; /**< Cursor rectangle */ | |
167 | + GSource * timer; /**< Cursor blinking timer */ | |
168 | + cairo_surface_t * surface; /**< Cursor image */ | |
169 | + } cursor; | |
170 | + | |
171 | + // Acessibility | |
172 | + GtkAccessible * accessible; | |
173 | + | |
174 | + // lib3270 stuff | |
175 | + H3270 * host; /**< Related 3270 session */ | |
176 | + | |
177 | + }; | |
178 | + | |
179 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
180 | + | |
101 | 181 | G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; |
102 | 182 | G_GNUC_INTERNAL GdkCursor * v3270_cursor[V3270_CURSOR_COUNT]; |
103 | 183 | |
... | ... | @@ -147,5 +227,6 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event); |
147 | 227 | gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event); |
148 | 228 | gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event); |
149 | 229 | void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event); |
230 | +gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y); | |
150 | 231 | |
151 | 232 | G_END_DECLS | ... | ... |
src/gtk/v3270/v3270.h
... | ... | @@ -128,79 +128,6 @@ |
128 | 128 | #define v3270char void |
129 | 129 | #endif // v3270_char |
130 | 130 | |
131 | - struct v3270_metrics | |
132 | - { | |
133 | - guint width; | |
134 | - guint height; | |
135 | - guint ascent; | |
136 | - guint descent; | |
137 | - | |
138 | - guint spacing; | |
139 | - | |
140 | - guint left; | |
141 | - guint top; | |
142 | - }; | |
143 | - | |
144 | - struct _v3270 | |
145 | - { | |
146 | - GtkWidget parent; | |
147 | - | |
148 | - // private | |
149 | - int selecting : 1; /**< Selecting region */ | |
150 | - int moving : 1; /**< Moving selected region */ | |
151 | - int resizing : 1; /**< Resizing selected region */ | |
152 | - | |
153 | -#if GTK_CHECK_VERSION(3,0,0) | |
154 | - | |
155 | -#else | |
156 | - gint width; | |
157 | - gint height; | |
158 | -#endif // GTK_CHECK_VERSION(3,0,0) | |
159 | - | |
160 | - GSource * timer; | |
161 | - GtkIMContext * input_method; | |
162 | - unsigned short keyflags; | |
163 | - gchar * clipboard; /**< Clipboard contents (text only) */ | |
164 | - | |
165 | - LIB3270_CURSOR pointer_id; | |
166 | - unsigned char pointer; /** Mouse pointer ID */ | |
167 | - int selection_addr; /** Selection addr */ | |
168 | - | |
169 | - // Font info | |
170 | - gchar * font_family; | |
171 | - cairo_font_weight_t font_weight; | |
172 | - cairo_scaled_font_t * font_scaled; | |
173 | - cairo_surface_t * surface; | |
174 | - | |
175 | - struct v3270_metrics metrics; | |
176 | - | |
177 | - gint minimum_width; | |
178 | - gint minimum_height; | |
179 | - | |
180 | - // Colors | |
181 | - GdkColor color[V3270_COLOR_COUNT]; /**< Terminal widget colors */ | |
182 | - | |
183 | - // Regions | |
184 | - GdkRectangle oia_rect[V3270_OIA_FIELD_COUNT]; | |
185 | - | |
186 | - struct | |
187 | - { | |
188 | - unsigned char show; /**< Cursor flag */ | |
189 | - unsigned char chr; /**< Char at cursor position */ | |
190 | - unsigned short attr; /**< Attribute at cursor position */ | |
191 | - GdkRectangle rect; /**< Cursor rectangle */ | |
192 | - GSource * timer; /**< Cursor blinking timer */ | |
193 | - cairo_surface_t * surface; /**< Cursor image */ | |
194 | - } cursor; | |
195 | - | |
196 | - // Acessibility | |
197 | - GtkAccessible * accessible; | |
198 | - | |
199 | - // lib3270 stuff | |
200 | - H3270 * host; /**< Related 3270 session */ | |
201 | - | |
202 | - }; | |
203 | - | |
204 | 131 | GtkWidget * v3270_new(void); |
205 | 132 | GType v3270_get_type(void); |
206 | 133 | |
... | ... | @@ -217,7 +144,7 @@ |
217 | 144 | // Clipboard |
218 | 145 | const gchar * v3270_get_selected_text(GtkWidget *widget); |
219 | 146 | const gchar * v3270_get_copy(GtkWidget *widget); |
220 | - gchar * v3270_get_text(GtkWidget *widget); | |
147 | + gchar * v3270_get_text(GtkWidget *widget,int offset, int len); | |
221 | 148 | const gchar * v3270_copy(GtkWidget *widget); |
222 | 149 | const gchar * v3270_copy_append(GtkWidget *widget); |
223 | 150 | |
... | ... | @@ -233,6 +160,10 @@ |
233 | 160 | void v3270_set_color(GtkWidget *widget, enum V3270_COLOR id, GdkColor *color); |
234 | 161 | GdkColor * v3270_get_color(GtkWidget *widget, enum V3270_COLOR id); |
235 | 162 | |
163 | + // Misc | |
164 | + GtkIMContext * v3270_get_im_context(GtkWidget *widget); | |
165 | + | |
166 | + | |
236 | 167 | G_END_DECLS |
237 | 168 | |
238 | 169 | #endif // V3270_H_INCLUDED | ... | ... |
src/gtk/v3270/widget.c
... | ... | @@ -1107,8 +1107,15 @@ static AtkObject * v3270_get_accessible(GtkWidget * widget) |
1107 | 1107 | { |
1108 | 1108 | terminal->accessible = g_object_new(GTK_TYPE_V3270_ACCESSIBLE,NULL); |
1109 | 1109 | atk_object_initialize(ATK_OBJECT(terminal->accessible), widget); |
1110 | + gtk_accessible_set_widget(GTK_ACCESSIBLE(terminal->accessible),widget); | |
1111 | + g_object_ref(terminal->accessible); | |
1110 | 1112 | } |
1111 | 1113 | |
1112 | 1114 | return ATK_OBJECT(terminal->accessible); |
1113 | 1115 | } |
1114 | 1116 | |
1117 | +GtkIMContext * v3270_get_im_context(GtkWidget *widget) | |
1118 | +{ | |
1119 | + return GTK_V3270(widget)->input_method; | |
1120 | +} | |
1121 | + | ... | ... |
src/include/lib3270.h
... | ... | @@ -267,6 +267,8 @@ |
267 | 267 | */ |
268 | 268 | LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c); |
269 | 269 | |
270 | + LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h); | |
271 | + | |
270 | 272 | /** |
271 | 273 | * Start a new session (INCOMPLETE). |
272 | 274 | * |
... | ... | @@ -660,12 +662,14 @@ |
660 | 662 | /** |
661 | 663 | * Get all text inside the terminal. |
662 | 664 | * |
663 | - * @param h Session Handle. | |
665 | + * @param h Session Handle. | |
666 | + * @param offset Start position. | |
667 | + * @param len Text length or -1 to all text. | |
664 | 668 | * |
665 | - * @return All text if available, or NULL. Release it with free() | |
669 | + * @return Contents at position if available, or NULL. Release it with free() | |
666 | 670 | * |
667 | 671 | */ |
668 | - LIB3270_EXPORT char * lib3270_get_text(H3270 *h); | |
672 | + LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len); | |
669 | 673 | |
670 | 674 | /** |
671 | 675 | * Get a terminal character and attribute. | ... | ... |
src/lib3270/screen.c
... | ... | @@ -223,8 +223,15 @@ static unsigned short calc_attrs(H3270 *session, int baddr, int fa_addr, int fa) |
223 | 223 | return a; |
224 | 224 | } |
225 | 225 | |
226 | +LIB3270_EXPORT unsigned int lib3270_get_length(H3270 *h) | |
227 | +{ | |
228 | + CHECK_SESSION_HANDLE(h); | |
229 | + return h->rows * h->cols; | |
230 | +} | |
231 | + | |
226 | 232 | LIB3270_EXPORT void lib3270_get_screen_size(H3270 *h, int *r, int *c) |
227 | 233 | { |
234 | + CHECK_SESSION_HANDLE(h); | |
228 | 235 | *r = h->rows; |
229 | 236 | *c = h->cols; |
230 | 237 | } | ... | ... |
src/lib3270/selection.c
... | ... | @@ -407,9 +407,38 @@ static char * get_text(H3270 *hSession,unsigned char all) |
407 | 407 | return ret; |
408 | 408 | } |
409 | 409 | |
410 | -LIB3270_EXPORT char * lib3270_get_text(H3270 *hSession) | |
410 | +LIB3270_EXPORT char * lib3270_get_text(H3270 *h, int offset, int len) | |
411 | 411 | { |
412 | - return get_text(hSession,1); | |
412 | + char *buffer; | |
413 | + int col, maxlen; | |
414 | + char *ptr; | |
415 | + | |
416 | + CHECK_SESSION_HANDLE(h); | |
417 | + | |
418 | + maxlen = h->rows * (h->cols+1); | |
419 | + | |
420 | + if(len < 0) | |
421 | + len = (maxlen - offset); | |
422 | + else if(len > maxlen) | |
423 | + len = maxlen; | |
424 | + | |
425 | + buffer = malloc(len+1); | |
426 | + col = offset%h->cols; | |
427 | + ptr = buffer; | |
428 | + | |
429 | + while(len-- > 0) | |
430 | + { | |
431 | + *(ptr++) = h->text[offset++].chr; | |
432 | + if(col++ >= h->cols && len > 0) | |
433 | + { | |
434 | + col = 0; | |
435 | + *(ptr++) = '\n'; | |
436 | + len--; | |
437 | + } | |
438 | + } | |
439 | + *ptr = 0; | |
440 | + | |
441 | + return buffer; | |
413 | 442 | } |
414 | 443 | |
415 | 444 | LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) |
... | ... | @@ -417,6 +446,10 @@ LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession) |
417 | 446 | if(!hSession->selected || hSession->select.begin == hSession->select.end) |
418 | 447 | return NULL; |
419 | 448 | |
449 | + if(!lib3270_connected(hSession)) | |
450 | + return NULL; | |
451 | + | |
452 | + | |
420 | 453 | return get_text(hSession,0); |
421 | 454 | } |
422 | 455 | ... | ... |