set.c
5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
* (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
* aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob
* o nome G3270.
*
* Copyright (C) <2008> <Banco do Brasil S.A.>
*
* Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
* os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
* Free Software Foundation.
*
* Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
* GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
* A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
* obter mais detalhes.
*
* Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
* programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
* St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Este programa está nomeado como set.c e possui - linhas de código.
*
* Contatos:
*
* perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
* erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
*
*/
#include "private.h"
/*--[ Implement ]------------------------------------------------------------------------------------*/
void v3270ft_set_active(v3270ft *dialog, GList * active) {
int f;
gboolean sensitive = (active != NULL);
dialog->active = active;
// Habilita/Desabilita widgets
gtk_widget_set_sensitive(GTK_WIDGET(dialog->type),sensitive);
gtk_widget_set_sensitive(GTK_WIDGET(dialog->local),sensitive);
gtk_widget_set_sensitive(GTK_WIDGET(dialog->remote),sensitive);
for(f=0;f<NUM_OPTIONS_WIDGETS;f++) {
gtk_widget_set_sensitive(dialog->opt[f],sensitive);
}
for(f=0;f<FT_BUTTON_COUNT;f++) {
gtk_widget_set_sensitive(dialog->button[f],sensitive);
}
for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
gtk_widget_set_sensitive(dialog->value[f],sensitive);
}
// Preenche dialogo
if(sensitive) {
struct v3270ft_entry * info = (struct v3270ft_entry *) active->data;
gtk_combo_box_set_active(dialog->type,info->type);
gtk_entry_set_text(dialog->local,info->local);
gtk_entry_set_text(dialog->remote,info->remote);
v3270ft_set_options(GTK_WIDGET(dialog),info->options);
for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->value[f]),info->value[f]);
}
} else {
gtk_entry_set_text(dialog->local,"");
gtk_entry_set_text(dialog->remote,"");
v3270ft_set_options(GTK_WIDGET(dialog),0);
for(f = 0; f < LIB3270_FT_VALUE_COUNT; f++) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->value[f]),0);
}
}
}
/**
* v3270ft_set_options:
* @widget: a #v3270ft
* @options: The lib3270 file transfer options.
*
* Since: 5.1
**/
void v3270ft_set_options(GtkWidget *widget, LIB3270_FT_OPTION opt) {
int id;
v3270ft * ft = GTK_V3270FT(widget);
if(opt & LIB3270_FT_OPTION_RECEIVE) {
// Receber arquivo, reseto flags específicas do envio
opt &= ~(LIB3270_FT_RECORD_FORMAT_DEFAULT|LIB3270_FT_RECORD_FORMAT_FIXED|LIB3270_FT_RECORD_FORMAT_VARIABLE|LIB3270_FT_RECORD_FORMAT_UNDEFINED|LIB3270_FT_ALLOCATION_UNITS_DEFAULT|LIB3270_FT_ALLOCATION_UNITS_TRACKS|LIB3270_FT_ALLOCATION_UNITS_CYLINDERS|LIB3270_FT_ALLOCATION_UNITS_AVBLOCK);
gtk_widget_set_sensitive(ft->radio[0],FALSE);
gtk_widget_set_sensitive(ft->radio[1],FALSE);
for(id = 0; id < 4; id++) {
gtk_widget_set_sensitive(ft->value[id],FALSE);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(ft->value[id]),0);
}
} else {
gtk_widget_set_sensitive(ft->radio[0],TRUE);
gtk_widget_set_sensitive(ft->radio[1],TRUE);
for(id = 0; id < 4; id++) {
gtk_widget_set_sensitive(ft->value[id],TRUE);
}
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[4]),TRUE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[8]),TRUE);
for(id=0;id<NUM_OPTIONS_WIDGETS;id++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ft->opt[id]),(opt & ft_option[id].opt) == ft_option[id].opt);
}
struct v3270ft_entry *entry = v3270ft_get_selected(ft);
if(entry) {
entry->options = opt;
v3270ft_update_actions(ft);
}
}
void v3270ftprogress_set_header(GtkWidget *widget, const gchar *status) {
#ifdef HAVE_GTK_HEADER_BAR
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(gtk_dialog_get_header_bar(GTK_DIALOG(widget))),status);
#endif
}
void v3270ftprogress_set_transfer(GtkWidget *widget, struct v3270ft_entry *entry) {
v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
/*
if(dialog->session) {
lib3270_ft_set_user_data(dialog->session,NULL);
lib3270_ft_destroy(dialog->session);
}
*/
dialog->active = entry;
debug("%s\n%s <-> %s",__FUNCTION__,entry->local,entry->remote);
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_LOCAL],entry->local);
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_REMOTE],entry->remote);
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_TOTAL],"");
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_CURRENT],"");
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_SPEED],"");
gtk_entry_set_text(dialog->info[PROGRESS_FIELD_ETA],"");
gtk_progress_bar_set_fraction(dialog->progress,0);
v3270ftprogress_set_header(widget,_("Preparing"));
}
void v3270ftprogress_set_session(GtkWidget *widget, H3270 *session) {
v3270ftprogress * dialog = GTK_V3270FTPROGRESS(widget);
if(dialog->session) {
lib3270_ft_destroy(dialog->session,NULL);
}
dialog->session = session;
}
guint v3270ft_append_selection(GtkWidget *widget, GtkSelectionData *data) {
gchar **uri = g_strsplit((const gchar *) gtk_selection_data_get_text(data),"\n",-1);
size_t f;
guint qtd = 0;
for(f=0;uri[f];f++) {
if(!g_ascii_strncasecmp("file:///",uri[f],8)) {
const gchar *filename = uri[f]+7;
if(g_file_test(filename,G_FILE_TEST_IS_REGULAR)) {
v3270ft_append_file(widget,filename,TRUE);
qtd++;
}
}
}
g_strfreev(uri);
return qtd;
}