Commit 27fce99fdea8c19f7efa71ed9ddd5def90483b7a
1 parent
421deaec
Exists in
master
and in
1 other branch
Adding v3270 test program.
Showing
1 changed file
with
132 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,132 @@ |
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. Registro no INPI sob | |
5 | + * o nome G3270. | |
6 | + * | |
7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
8 | + * | |
9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
11 | + * Free Software Foundation. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
16 | + * obter mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
21 | + * | |
22 | + * Este programa está nomeado como testprogram.c e possui - linhas de código. | |
23 | + * | |
24 | + * Contatos: | |
25 | + * | |
26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
28 | + * | |
29 | + */ | |
30 | + | |
31 | + #include <v3270.h> | |
32 | + #include <v3270/filetransfer.h> | |
33 | + #include <v3270/ftprogress.h> | |
34 | + #include <stdlib.h> | |
35 | + | |
36 | + /*---[ Implement ]----------------------------------------------------------------------------------*/ | |
37 | + | |
38 | +static gboolean popup_menu(GtkWidget *widget, gboolean selected, gboolean online, GdkEventButton *event, gpointer user_data) { | |
39 | + | |
40 | + if(!online) | |
41 | + return FALSE; | |
42 | + | |
43 | + GtkWidget * dialog = v3270ft_new(); | |
44 | + | |
45 | + v3270ft_load(dialog,"transfer.xml"); | |
46 | + | |
47 | + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(widget))); | |
48 | + | |
49 | + do { | |
50 | + | |
51 | + gtk_widget_show_all(dialog); | |
52 | + | |
53 | + switch(gtk_dialog_run(GTK_DIALOG(dialog))) { | |
54 | + case GTK_RESPONSE_APPLY: | |
55 | + case GTK_RESPONSE_OK: | |
56 | + case GTK_RESPONSE_YES: | |
57 | + gtk_widget_hide(dialog); | |
58 | + v3270ft_transfer(dialog,v3270_get_session(widget)); | |
59 | + break; | |
60 | + | |
61 | + case GTK_RESPONSE_CANCEL: | |
62 | + case GTK_RESPONSE_NO: | |
63 | + case GTK_RESPONSE_DELETE_EVENT: | |
64 | + v3270ft_remove_all(dialog); | |
65 | + break; | |
66 | + | |
67 | + default: | |
68 | + g_warning("Unexpected response from v3270ft"); | |
69 | + } | |
70 | + | |
71 | + } while(v3270ft_get_length(dialog) > 0); | |
72 | + | |
73 | + gtk_widget_destroy(dialog); | |
74 | + | |
75 | + return TRUE; | |
76 | + | |
77 | +} | |
78 | + | |
79 | +static void activate(GtkApplication* app, gpointer user_data) { | |
80 | + | |
81 | + const gchar * search[] = { | |
82 | + | |
83 | + g_get_user_config_dir(), | |
84 | + g_get_user_data_dir(), | |
85 | + g_get_home_dir(), | |
86 | + NULL | |
87 | + | |
88 | + }; | |
89 | + | |
90 | + GtkWidget * window = gtk_application_window_new(app); | |
91 | + GtkWidget * terminal = v3270_new(); | |
92 | + gchar * filename = NULL; | |
93 | + | |
94 | + // Setup terminal | |
95 | + GKeyFile * conf = g_key_file_new(); | |
96 | + | |
97 | + g_key_file_load_from_dirs(conf,"pw3270.conf",(const gchar **) search, &filename,G_KEY_FILE_NONE,NULL); | |
98 | + g_message("Configuration from %s",filename); | |
99 | + | |
100 | + // v3270_set_from_keyfile(terminal,conf); | |
101 | + | |
102 | + g_key_file_unref(conf); | |
103 | + | |
104 | + v3270_connect(terminal); | |
105 | + | |
106 | + g_signal_connect(terminal,"popup",G_CALLBACK(popup_menu),NULL); | |
107 | + | |
108 | + // Setup and show window | |
109 | + gtk_window_set_title(GTK_WINDOW(window), "Window"); | |
110 | + gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER); | |
111 | + gtk_window_set_default_size (GTK_WINDOW (window), 800, 500); | |
112 | + gtk_container_add(GTK_CONTAINER(window),terminal); | |
113 | + gtk_widget_show_all (window); | |
114 | + | |
115 | +} | |
116 | + | |
117 | +int main (int argc, char **argv) { | |
118 | + | |
119 | + GtkApplication *app; | |
120 | + int status; | |
121 | + | |
122 | + app = gtk_application_new ("br.com.bb.pw3270",G_APPLICATION_FLAGS_NONE); | |
123 | + | |
124 | + g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); | |
125 | + | |
126 | + status = g_application_run (G_APPLICATION (app), argc, argv); | |
127 | + g_object_unref (app); | |
128 | + | |
129 | + g_message("rc=%d",status); | |
130 | + return status; | |
131 | +} | |
132 | + | ... | ... |