Commit a63a0c5d1e6c3204788bc00ae8e48d6a3e215d3a

Authored by perry.werneck@gmail.com
1 parent e9ccd4ae

Ajustando diálogo de transferência de arquivos

src/include/lib3270.h
@@ -1021,6 +1021,16 @@ @@ -1021,6 +1021,16 @@
1021 1021
1022 LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void); 1022 LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void);
1023 1023
  1024 + /**
  1025 + * The host is TSO?
  1026 + *
  1027 + * @param hSession Session Handle
  1028 + *
  1029 + * @return Non zero if the host is TSO.
  1030 + *
  1031 + */
  1032 + LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession);
  1033 +
1024 1034
1025 #ifdef __cplusplus 1035 #ifdef __cplusplus
1026 } 1036 }
src/lib3270/options.c
@@ -118,3 +118,9 @@ LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void) @@ -118,3 +118,9 @@ LIB3270_EXPORT const LIB3270_OPTION_ENTRY * lib3270_get_option_list(void)
118 { 118 {
119 return options; 119 return options;
120 } 120 }
  121 +
  122 +LIB3270_EXPORT int lib3270_is_tso(H3270 *hSession)
  123 +{
  124 + CHECK_SESSION_HANDLE(hSession);
  125 + return (hSession->options & LIB3270_OPTION_TSO) != 0;
  126 +}
src/pw3270/filetransfer.c
@@ -209,7 +209,7 @@ static void ft_dialog_save(GtkWidget *widget, const gchar *name) @@ -209,7 +209,7 @@ static void ft_dialog_save(GtkWidget *widget, const gchar *name)
209 209
210 static void ft_complete(H3270FT *ft, unsigned long length,double kbytes_sec) 210 static void ft_complete(H3270FT *ft, unsigned long length,double kbytes_sec)
211 { 211 {
212 - v3270_ft_progress_update(GTK_WIDGET(ft->widget),length,length,kbytes_sec); 212 + v3270_ft_progress_complete(GTK_WIDGET(ft->widget),length,kbytes_sec);
213 } 213 }
214 214
215 static void ft_message(struct _h3270ft *ft, const char *text) 215 static void ft_message(struct _h3270ft *ft, const char *text)
@@ -247,7 +247,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch @@ -247,7 +247,7 @@ gint v3270_transfer_file(GtkWidget *widget, LIB3270_FT_OPTION options, const gch
247 (options & LIB3270_FT_OPTION_RECEIVE) ? _( "Receiving file" ) : _( "Sending file" ), 247 (options & LIB3270_FT_OPTION_RECEIVE) ? _( "Receiving file" ) : _( "Sending file" ),
248 GTK_WINDOW(gtk_widget_get_toplevel(widget)), 248 GTK_WINDOW(gtk_widget_get_toplevel(widget)),
249 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, 249 GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
250 - GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,NULL ); 250 + _( "_Cancel" ), GTK_RESPONSE_CANCEL,NULL );
251 251
252 252
253 // Create FT progress dialog 253 // Create FT progress dialog
@@ -300,6 +300,8 @@ void download_action(GtkAction *action, GtkWidget *widget) @@ -300,6 +300,8 @@ void download_action(GtkAction *action, GtkWidget *widget)
300 300
301 GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_RECEIVE|get_options_from_config(name)); 301 GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_RECEIVE|get_options_from_config(name));
302 302
  303 + v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
  304 +
303 ft_dialog_load(dialog,name); 305 ft_dialog_load(dialog,name);
304 306
305 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) 307 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
@@ -343,6 +345,7 @@ void upload_action(GtkAction *action, GtkWidget *widget) @@ -343,6 +345,7 @@ void upload_action(GtkAction *action, GtkWidget *widget)
343 345
344 GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_SEND|get_options_from_config(name)); 346 GtkWidget *dialog = v3270_ft_dialog_new(widget,LIB3270_FT_OPTION_SEND|get_options_from_config(name));
345 347
  348 + v3270_ft_dialog_set_tso(dialog,lib3270_is_tso(v3270_get_session(widget)));
346 ft_dialog_load(dialog,name); 349 ft_dialog_load(dialog,name);
347 350
348 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) 351 if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
src/pw3270/ft/ftprogress.c
@@ -207,9 +207,53 @@ void v3270_ft_progress_update(GtkWidget *widget, unsigned long current, unsigned @@ -207,9 +207,53 @@ void v3270_ft_progress_update(GtkWidget *widget, unsigned long current, unsigned
207 } 207 }
208 208
209 if(total && current) 209 if(total && current)
  210 + {
  211 + double remaining = ((double) (total - current))/1024.0;
  212 +
  213 + if(remaining > 0 && kbytes_sec > 0)
  214 + {
  215 + char buffer[40];
  216 + double seconds = ((double) remaining) / kbytes_sec;
  217 + time_t eta = time(0) + ((time_t) seconds);
  218 + strftime(buffer, 39, "%H:%M:%S", localtime(&eta));
  219 + gtk_label_set_text(obj->value[VALUE_ETA],buffer);
  220 + }
  221 + else
  222 + {
  223 + gtk_label_set_text(obj->value[VALUE_ETA],"");
  224 + }
  225 +
210 gtk_progress_bar_set_fraction(obj->progress,((gdouble) current) / ((gdouble) total)); 226 gtk_progress_bar_set_fraction(obj->progress,((gdouble) current) / ((gdouble) total));
  227 + }
211 else 228 else
  229 + {
212 gtk_progress_bar_pulse(obj->progress); 230 gtk_progress_bar_pulse(obj->progress);
  231 + gtk_label_set_text(obj->value[VALUE_ETA],"");
  232 + }
  233 +
  234 +}
  235 +
  236 +void v3270_ft_progress_complete(GtkWidget *widget,unsigned long length, double kbytes_sec)
  237 +{
  238 + g_return_if_fail(GTK_IS_V3270FTProgress(widget));
  239 +
  240 + v3270FTProgress *obj = GTK_V3270FTProcess(widget);
  241 +
  242 + if(length)
  243 + {
  244 + gchar *str = g_strdup_printf("%ld",length);
  245 + gtk_label_set_text(obj->value[VALUE_CURRENT],str);
  246 + g_free(str);
  247 + }
  248 +
  249 + if(kbytes_sec)
  250 + {
  251 + gchar *str = g_strdup_printf("%ld KB/s",(unsigned long) kbytes_sec);
  252 + gtk_label_set_text(obj->value[VALUE_SPEED],str);
  253 + g_free(str);
  254 + }
  255 +
  256 + gtk_label_set_text(obj->value[VALUE_ETA],"");
213 257
214 } 258 }
215 259
src/pw3270/ft/v3270ft.h
@@ -96,6 +96,7 @@ @@ -96,6 +96,7 @@
96 LIB3270_EXPORT void v3270_ft_progress_set_message(GtkWidget *widget, const gchar *msg); 96 LIB3270_EXPORT void v3270_ft_progress_set_message(GtkWidget *widget, const gchar *msg);
97 LIB3270_EXPORT void v3270_ft_progress_set_host_filename(GtkWidget *widget, const gchar *name); 97 LIB3270_EXPORT void v3270_ft_progress_set_host_filename(GtkWidget *widget, const gchar *name);
98 LIB3270_EXPORT void v3270_ft_progress_set_local_filename(GtkWidget *widget, const gchar *name); 98 LIB3270_EXPORT void v3270_ft_progress_set_local_filename(GtkWidget *widget, const gchar *name);
  99 + LIB3270_EXPORT void v3270_ft_progress_complete(GtkWidget *widget,unsigned long length,double kbytes_sec);
99 100
100 101
101 102