Commit 32a1451c4139a9d050e385181884c96c37d64890
1 parent
c00d8694
Exists in
master
and in
1 other branch
Implementando novo widget para seleção de servidor
Showing
4 changed files
with
487 additions
and
1 deletions
Show diff stats
@@ -0,0 +1,417 @@ | @@ -0,0 +1,417 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como hostdialog.c e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | + #include "hostselect.h" | ||
31 | + #include <pw3270/v3270.h> | ||
32 | + | ||
33 | +/*--[ Widget definition ]----------------------------------------------------------------------------*/ | ||
34 | + | ||
35 | + static const struct _host_type | ||
36 | + { | ||
37 | + const gchar * name; | ||
38 | + const gchar * description; | ||
39 | + LIB3270_OPTION option; | ||
40 | + } host_type[] = | ||
41 | + { | ||
42 | + { "S390", N_( "IBM S/390" ), LIB3270_OPTION_S390 }, | ||
43 | + { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_AS400 }, | ||
44 | + { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, | ||
45 | + { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } | ||
46 | + }; | ||
47 | + | ||
48 | + static const struct _colortable | ||
49 | + { | ||
50 | + unsigned short colors; | ||
51 | + const gchar * description; | ||
52 | + } colortable[] = | ||
53 | + { | ||
54 | + { 16, N_( "16 colors" ) }, | ||
55 | + { 8, N_( "8 colors" ) }, | ||
56 | + { 2, N_( "Monochrome" ) }, | ||
57 | + }; | ||
58 | + | ||
59 | + enum _entry | ||
60 | + { | ||
61 | + ENTRY_HOSTNAME, | ||
62 | + ENTRY_SRVCNAME, | ||
63 | + | ||
64 | + ENTRY_COUNT | ||
65 | + }; | ||
66 | + | ||
67 | + static const gchar *comboLabel[] = { N_("System _type:"), N_("_Color table:") }; | ||
68 | + | ||
69 | + struct _V3270HostSelectWidget | ||
70 | + { | ||
71 | +#if GTK_CHECK_VERSION(3,0,0) | ||
72 | + GtkBin parent; | ||
73 | +#else | ||
74 | + GtkVBox parent; | ||
75 | +#endif // GTK_CHECK_VERSION | ||
76 | + | ||
77 | + LIB3270_OPTION options; /**< Connect option */ | ||
78 | + | ||
79 | + GtkEntry * entry[ENTRY_COUNT]; /**< Entry fields for host & service name */ | ||
80 | + GtkToggleButton * ssl; /**< SSL Connection? */ | ||
81 | + GtkComboBox * combo[G_N_ELEMENTS(comboLabel)]; /**< Model & Color combobox */ | ||
82 | + unsigned short colors; /**< Number of colors */ | ||
83 | + H3270 * hSession; /**< lib3270's session handle */ | ||
84 | + | ||
85 | + }; | ||
86 | + | ||
87 | + struct _V3270HostSelectWidgetClass | ||
88 | + { | ||
89 | +#if GTK_CHECK_VERSION(3,0,0) | ||
90 | + GtkBinClass parent_class; | ||
91 | +#else | ||
92 | + GtkVBoxClass parent_class; | ||
93 | +#endif // GTK_CHECK_VERSION | ||
94 | + }; | ||
95 | + | ||
96 | + | ||
97 | +#if GTK_CHECK_VERSION(3,0,0) | ||
98 | + G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_BIN); | ||
99 | +#else | ||
100 | + G_DEFINE_TYPE(V3270HostSelectWidget, V3270HostSelectWidget, GTK_TYPE_VBOX); | ||
101 | +#endif // GTK_CHECK_VERSION | ||
102 | + | ||
103 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | ||
104 | + | ||
105 | +static void V3270HostSelectWidget_class_init(V3270HostSelectWidgetClass *klass) | ||
106 | +{ | ||
107 | +#if GTK_CHECK_VERSION(3,0,0) | ||
108 | +#else | ||
109 | +#endif // GTK_CHECK_VERSION | ||
110 | +} | ||
111 | + | ||
112 | +static void toggle_ssl(GtkToggleButton *button, V3270HostSelectWidget *dialog) | ||
113 | +{ | ||
114 | + if(gtk_toggle_button_get_active(button)) | ||
115 | + dialog->options |= LIB3270_OPTION_SSL; | ||
116 | + else | ||
117 | + dialog->options &= ~LIB3270_OPTION_SSL; | ||
118 | +} | ||
119 | + | ||
120 | +static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) | ||
121 | +{ | ||
122 | + GValue value = { 0, }; | ||
123 | + GtkTreeIter iter; | ||
124 | + | ||
125 | + if(!gtk_combo_box_get_active_iter(widget,&iter)) | ||
126 | + return; | ||
127 | + | ||
128 | + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | ||
129 | + | ||
130 | + dialog->options &= ~(LIB3270_OPTION_HOST_TYPE); | ||
131 | + dialog->options |= g_value_get_int(&value); | ||
132 | + | ||
133 | +} | ||
134 | + | ||
135 | +static void colortable_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) | ||
136 | +{ | ||
137 | + GValue value = { 0, }; | ||
138 | + GtkTreeIter iter; | ||
139 | + | ||
140 | + if(!gtk_combo_box_get_active_iter(widget,&iter)) | ||
141 | + return; | ||
142 | + | ||
143 | + gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | ||
144 | + | ||
145 | + dialog->colors = g_value_get_int(&value); | ||
146 | + | ||
147 | +} | ||
148 | + | ||
149 | +static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) | ||
150 | +{ | ||
151 | +#if GTK_CHECK_VERSION(3,0,0) | ||
152 | + GtkGrid * grid = GTK_GRID(gtk_grid_new()); | ||
153 | +#else | ||
154 | + GtkTable * grid = gtk_table_new(?,?,FALSE); | ||
155 | +#endif // GTK_CHECK_VERSION | ||
156 | + | ||
157 | + GtkWidget * label[ENTRY_COUNT] = | ||
158 | + { | ||
159 | + gtk_label_new_with_mnemonic( _( "_Host:" ) ), | ||
160 | + gtk_label_new_with_mnemonic( _( "_Service:" ) ) | ||
161 | + }; | ||
162 | + | ||
163 | + int f; | ||
164 | + | ||
165 | + gtk_container_set_border_width(GTK_CONTAINER(grid),3); | ||
166 | + | ||
167 | + for(f=0;f<ENTRY_COUNT;f++) | ||
168 | + { | ||
169 | + widget->entry[f] = GTK_ENTRY(gtk_entry_new()); | ||
170 | + gtk_misc_set_alignment(GTK_MISC(label[f]),0,0.5); | ||
171 | + gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),GTK_WIDGET(widget->entry[f])); | ||
172 | + } | ||
173 | + | ||
174 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),_("Address or name of the host to connect.") ); | ||
175 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),_("Port or service name (empty for \"telnet\").") ); | ||
176 | + | ||
177 | + // SSL checkbox | ||
178 | + widget->ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." ))); | ||
179 | + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->ssl),_( "Check for SSL secure connection." )); | ||
180 | + g_signal_connect(G_OBJECT(widget->ssl),"toggled",G_CALLBACK(toggle_ssl),widget); | ||
181 | + | ||
182 | + // Extended options | ||
183 | + GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); | ||
184 | + | ||
185 | + // Host type | ||
186 | + { | ||
187 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | ||
188 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | ||
189 | + | ||
190 | + widget->combo[0] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); | ||
191 | + | ||
192 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[0]), renderer, TRUE); | ||
193 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[0]), renderer, "text", 0, NULL); | ||
194 | + | ||
195 | + for(f=0;f<G_N_ELEMENTS(host_type);f++) | ||
196 | + { | ||
197 | + GtkTreeIter iter; | ||
198 | + gtk_list_store_append((GtkListStore *) model,&iter); | ||
199 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, host_type[f].option, -1); | ||
200 | + } | ||
201 | + | ||
202 | + g_signal_connect(G_OBJECT(widget->combo[0]),"changed",G_CALLBACK(systype_changed),widget); | ||
203 | + | ||
204 | + } | ||
205 | + | ||
206 | + // Color table | ||
207 | + { | ||
208 | + GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | ||
209 | + GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | ||
210 | + | ||
211 | + widget->combo[1] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); | ||
212 | + | ||
213 | + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[1]), renderer, TRUE); | ||
214 | + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[1]), renderer, "text", 0, NULL); | ||
215 | + | ||
216 | + for(f=0;f<G_N_ELEMENTS(colortable);f++) | ||
217 | + { | ||
218 | + GtkTreeIter iter; | ||
219 | + gtk_list_store_append((GtkListStore *) model,&iter); | ||
220 | + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, colortable[f].colors, -1); | ||
221 | + } | ||
222 | + | ||
223 | + g_signal_connect(G_OBJECT(widget->combo[1]),"changed",G_CALLBACK(colortable_changed),widget); | ||
224 | + | ||
225 | + } | ||
226 | + | ||
227 | + gtk_entry_set_max_length(widget->entry[ENTRY_HOSTNAME],0xFF); | ||
228 | + gtk_entry_set_width_chars(widget->entry[ENTRY_HOSTNAME],50); | ||
229 | + | ||
230 | + gtk_entry_set_max_length(widget->entry[ENTRY_SRVCNAME],6); | ||
231 | + gtk_entry_set_width_chars(widget->entry[ENTRY_SRVCNAME],7); | ||
232 | + | ||
233 | + gtk_entry_set_placeholder_text(widget->entry[ENTRY_SRVCNAME],"telnet"); | ||
234 | + | ||
235 | +#if GTK_CHECK_VERSION(3,0,0) | ||
236 | + | ||
237 | + gtk_widget_set_hexpand(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),TRUE); | ||
238 | + gtk_widget_set_hexpand(GTK_WIDGET(widget->ssl),TRUE); | ||
239 | + gtk_widget_set_hexpand(GTK_WIDGET(expander),TRUE); | ||
240 | + | ||
241 | + gtk_grid_set_row_homogeneous(grid,FALSE); | ||
242 | + gtk_grid_set_column_homogeneous(grid,FALSE); | ||
243 | + gtk_grid_set_column_spacing(grid,5); | ||
244 | + gtk_grid_set_row_spacing(grid,5); | ||
245 | + | ||
246 | + gtk_grid_attach(grid,label[ENTRY_HOSTNAME],0,0,1,1); | ||
247 | + gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),1,0,3,1); | ||
248 | + | ||
249 | + gtk_grid_attach(grid,label[ENTRY_SRVCNAME],4,0,1,1); | ||
250 | + gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),5,0,1,1); | ||
251 | + | ||
252 | + gtk_grid_attach(grid,GTK_WIDGET(widget->ssl),1,1,3,1); | ||
253 | + | ||
254 | + | ||
255 | + // Host options | ||
256 | + { | ||
257 | + GtkGrid *opt = GTK_GRID(gtk_grid_new()); | ||
258 | + gtk_grid_set_column_spacing(opt,5); | ||
259 | + gtk_grid_set_row_spacing(opt,5); | ||
260 | + | ||
261 | + for(f=0;f<G_N_ELEMENTS(comboLabel);f++) | ||
262 | + { | ||
263 | + GtkWidget *label = gtk_label_new_with_mnemonic(gettext(comboLabel[f])); | ||
264 | + gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | ||
265 | + gtk_grid_attach(opt,label,0,f+1,1,1); | ||
266 | + gtk_grid_attach(opt,GTK_WIDGET(widget->combo[f]),1,f+1,2,1); | ||
267 | + } | ||
268 | + | ||
269 | + gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(opt)); | ||
270 | + } | ||
271 | + gtk_grid_attach(grid,GTK_WIDGET(expander),1,2,5,2); | ||
272 | + | ||
273 | + | ||
274 | +#else | ||
275 | + | ||
276 | + gtk_table_set_row_spacings(grid,5); | ||
277 | + gtk_table_set_col_spacings(grid,5); | ||
278 | + | ||
279 | + #error Implementar | ||
280 | + | ||
281 | +#endif // GTK_CHECK_VERSION | ||
282 | + | ||
283 | + | ||
284 | + gtk_widget_show_all(GTK_WIDGET(grid)); | ||
285 | + gtk_container_add(GTK_CONTAINER(widget),GTK_WIDGET(grid)); | ||
286 | +} | ||
287 | + | ||
288 | +GtkWidget * v3270_host_select_new(GtkWidget *widget) | ||
289 | +{ | ||
290 | + g_return_val_if_fail(GTK_IS_V3270(widget),NULL); | ||
291 | + | ||
292 | + V3270HostSelectWidget * selector = GTK_V3270HostSelectWidget(g_object_new(GTK_TYPE_V3270HostSelectWidget, NULL)); | ||
293 | + | ||
294 | + v3270_host_select_set_session(selector,widget); | ||
295 | + | ||
296 | + return GTK_WIDGET(selector); | ||
297 | +} | ||
298 | + | ||
299 | +void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session) | ||
300 | +{ | ||
301 | + g_return_if_fail(GTK_IS_V3270(session)); | ||
302 | + g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget)); | ||
303 | + | ||
304 | + widget->hSession = v3270_get_session(session); | ||
305 | + | ||
306 | + gtk_entry_set_text(widget->entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession)); | ||
307 | + gtk_entry_set_text(widget->entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession)); | ||
308 | + | ||
309 | + LIB3270_OPTION opt = lib3270_get_options(widget->hSession); | ||
310 | + | ||
311 | + gtk_toggle_button_set_active(widget->ssl,(opt & LIB3270_OPTION_SSL) != 0); | ||
312 | + | ||
313 | + // Set host type | ||
314 | + { | ||
315 | + GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[0]); | ||
316 | + GtkTreeIter iter; | ||
317 | + | ||
318 | + if(gtk_tree_model_get_iter_first(model,&iter)) | ||
319 | + { | ||
320 | + do | ||
321 | + { | ||
322 | + GValue value = { 0, }; | ||
323 | + | ||
324 | + gtk_tree_model_get_value(model,&iter,1,&value); | ||
325 | + | ||
326 | + if(g_value_get_int(&value) == (opt&LIB3270_OPTION_HOST_TYPE)) | ||
327 | + { | ||
328 | + gtk_combo_box_set_active_iter(widget->combo[0],&iter); | ||
329 | + break; | ||
330 | + } | ||
331 | + | ||
332 | + } while(gtk_tree_model_iter_next(model,&iter)); | ||
333 | + } | ||
334 | + } | ||
335 | + | ||
336 | + // Set color type | ||
337 | + { | ||
338 | + GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[1]); | ||
339 | + GtkTreeIter iter; | ||
340 | + int colors = (int) lib3270_get_color_type(widget->hSession); | ||
341 | + | ||
342 | + if(gtk_tree_model_get_iter_first(model,&iter)) | ||
343 | + { | ||
344 | + do | ||
345 | + { | ||
346 | + GValue value = { 0, }; | ||
347 | + | ||
348 | + gtk_tree_model_get_value(model,&iter,1,&value); | ||
349 | + | ||
350 | + g_message("%d - %d",g_value_get_int(&value),colors); | ||
351 | + | ||
352 | + if(g_value_get_int(&value) == colors) | ||
353 | + { | ||
354 | + gtk_combo_box_set_active_iter(widget->combo[1],&iter); | ||
355 | + break; | ||
356 | + } | ||
357 | + | ||
358 | + } while(gtk_tree_model_iter_next(model,&iter)); | ||
359 | + } | ||
360 | + } | ||
361 | + | ||
362 | + // Just in case | ||
363 | + widget->options = opt; | ||
364 | +} | ||
365 | + | ||
366 | +LIB3270_EXPORT void v3270_select_host(GtkWidget *widget) | ||
367 | +{ | ||
368 | + g_return_if_fail(GTK_IS_V3270(widget)); | ||
369 | + | ||
370 | + GtkWidget * dialog = v3270_host_select_new(widget); | ||
371 | + GtkWidget * win = gtk_dialog_new_with_buttons( | ||
372 | + _( "Select hostname" ), | ||
373 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | ||
374 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | ||
375 | + _( "C_onnect" ), GTK_RESPONSE_ACCEPT, | ||
376 | + _( "_Cancel" ), GTK_RESPONSE_REJECT, | ||
377 | + NULL ); | ||
378 | + | ||
379 | + | ||
380 | + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(win))),dialog,FALSE,FALSE,2); | ||
381 | + gtk_widget_show_all(dialog); | ||
382 | + | ||
383 | + gboolean again = TRUE; | ||
384 | + while(again) | ||
385 | + { | ||
386 | + gtk_widget_set_sensitive(win,TRUE); | ||
387 | + gtk_widget_set_visible(win,TRUE); | ||
388 | + | ||
389 | + switch(gtk_dialog_run(GTK_DIALOG(win))) | ||
390 | + { | ||
391 | + case GTK_RESPONSE_ACCEPT: | ||
392 | + gtk_widget_set_visible(win,FALSE); | ||
393 | + gtk_widget_set_sensitive(win,FALSE); | ||
394 | + again = v3270_host_select_apply(GTK_V3270HostSelectWidget(dialog)) != 0; | ||
395 | + break; | ||
396 | + | ||
397 | + case GTK_RESPONSE_REJECT: | ||
398 | + again = FALSE; | ||
399 | + break; | ||
400 | + } | ||
401 | + } | ||
402 | + | ||
403 | + gtk_widget_destroy(win); | ||
404 | + | ||
405 | +} | ||
406 | + | ||
407 | +LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget) | ||
408 | +{ | ||
409 | + g_return_if_fail(GTK_IS_V3270HostSelectWidget(widget)); | ||
410 | + | ||
411 | + lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_HOSTNAME])); | ||
412 | + lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_SRVCNAME])); | ||
413 | + lib3270_set_options(widget->hSession,widget->options); | ||
414 | + | ||
415 | + return lib3270_connect(widget->hSession,0); | ||
416 | +} | ||
417 | + |
@@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como hostdialog.h e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | +#ifndef V3270HOST_H_INCLUDED | ||
31 | + | ||
32 | + #include <lib3270/config.h> | ||
33 | + #define ENABLE_NLS | ||
34 | + | ||
35 | + #ifndef GETTEXT_PACKAGE | ||
36 | + #define GETTEXT_PACKAGE PACKAGE_NAME | ||
37 | + #endif | ||
38 | + | ||
39 | + #include <libintl.h> | ||
40 | + #include <glib/gi18n.h> | ||
41 | + #include <gtk/gtk.h> | ||
42 | + #include <lib3270.h> | ||
43 | + | ||
44 | + #define V3270FT_H_INCLUDED 1 | ||
45 | + | ||
46 | + G_BEGIN_DECLS | ||
47 | + | ||
48 | +/*--[ Progress widget ]------------------------------------------------------------------------------*/ | ||
49 | + | ||
50 | + #define GTK_TYPE_V3270HostSelectWidget (V3270HostSelectWidget_get_type ()) | ||
51 | + #define GTK_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidget)) | ||
52 | + #define GTK_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass)) | ||
53 | + #define GTK_IS_V3270HostSelectWidget(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_V3270HostSelectWidget)) | ||
54 | + #define GTK_IS_V3270HostSelectWidget_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_V3270HostSelectWidget)) | ||
55 | + #define GTK_V3270HostSelectWidget_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_V3270HostSelectWidget, V3270HostSelectWidgetClass)) | ||
56 | + | ||
57 | + typedef struct _V3270HostSelectWidget V3270HostSelectWidget; | ||
58 | + typedef struct _V3270HostSelectWidgetClass V3270HostSelectWidgetClass; | ||
59 | + | ||
60 | +/*--[ Prototipes ]-----------------------------------------------------------------------------------*/ | ||
61 | + | ||
62 | + LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, GtkWidget *session); | ||
63 | + LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget); | ||
64 | + | ||
65 | + G_END_DECLS | ||
66 | + | ||
67 | +#endif // V3270HOST_H_INCLUDED |
mouse.c
@@ -49,6 +49,8 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) | @@ -49,6 +49,8 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) | ||
49 | GdkPoint point; | 49 | GdkPoint point; |
50 | int r,c; | 50 | int r,c; |
51 | 51 | ||
52 | + g_return_val_if_fail(widget->metrics.width > 0,-1); | ||
53 | + | ||
52 | if(x > 0 && y > 0) | 54 | if(x > 0 && y > 0) |
53 | { | 55 | { |
54 | point.x = ((x-widget->metrics.left)/widget->metrics.width); | 56 | point.x = ((x-widget->metrics.left)/widget->metrics.width); |
sources.mak
@@ -27,5 +27,5 @@ | @@ -27,5 +27,5 @@ | ||
27 | # | 27 | # |
28 | 28 | ||
29 | V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c selection.c \ | 29 | V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c selection.c \ |
30 | - accessible.c security.c macros.c | 30 | + accessible.c security.c macros.c hostselect.c |
31 | 31 |