Commit c853e9b43c642b0cba5abb5635ba15181925046d
1 parent
6282c734
Exists in
master
and in
5 other branches
Melhorando alerta no caso de systype errado.
Showing
2 changed files
with
41 additions
and
2 deletions
Show diff stats
src/lib3270/options.c
| ... | ... | @@ -153,7 +153,7 @@ LIB3270_EXPORT LIB3270_OPTION lib3270_parse_host_type(const char *name) |
| 153 | 153 | |
| 154 | 154 | int f; |
| 155 | 155 | |
| 156 | - for(f=0;f<(sizeof(host_type)/sizeof(host_type[0]));f++) | |
| 156 | + for(f=0;host_type[f].name;f++) | |
| 157 | 157 | { |
| 158 | 158 | if(!strcasecmp(host_type[f].name,name)) |
| 159 | 159 | return host_type[f].option; | ... | ... |
src/pw3270/window.c
| ... | ... | @@ -294,8 +294,47 @@ |
| 294 | 294 | |
| 295 | 295 | LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name) |
| 296 | 296 | { |
| 297 | + size_t f; | |
| 298 | + size_t sz; | |
| 299 | + | |
| 297 | 300 | g_return_if_fail(GTK_IS_PW3270(widget)); |
| 298 | - v3270_set_host_type(GTK_PW3270(widget)->terminal,name); | |
| 301 | + | |
| 302 | + int rc = v3270_set_host_type(GTK_PW3270(widget)->terminal,name); | |
| 303 | + | |
| 304 | + if(!rc) { | |
| 305 | + return; | |
| 306 | + } | |
| 307 | + | |
| 308 | + GtkWidget *popup = gtk_message_dialog_new_with_markup( | |
| 309 | + GTK_WINDOW(widget), | |
| 310 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 311 | + GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE, | |
| 312 | + _( "Can't recognize \"%s\" as a valid host type" ), name); | |
| 313 | + | |
| 314 | + gtk_window_set_title(GTK_WINDOW(popup),strerror(rc)); | |
| 315 | + | |
| 316 | + // Obtenho as opções válidas. | |
| 317 | + char text[4096]; | |
| 318 | + const LIB3270_OPTION_ENTRY *host_type = lib3270_get_option_list(); | |
| 319 | + | |
| 320 | + *text = 0; | |
| 321 | + for(f=1;host_type[f].name;f++) | |
| 322 | + { | |
| 323 | + sz = strlen(text); | |
| 324 | + snprintf(text+sz,4095-sz,_( "%s<b>%s</b> for %s"), *text ? ", " : "",host_type[f].name,gettext(host_type[f].description)); | |
| 325 | + | |
| 326 | + } | |
| 327 | + | |
| 328 | + sz = strlen(text); | |
| 329 | + snprintf(text+sz,4095-sz,_( " and <b>%s</b> for %s."),host_type[0].name,gettext(host_type[0].description)); | |
| 330 | + | |
| 331 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),_( "The known types are %s" ),text); | |
| 332 | + | |
| 333 | + gtk_dialog_run(GTK_DIALOG(popup)); | |
| 334 | + | |
| 335 | + gtk_widget_destroy(popup); | |
| 336 | + | |
| 337 | + | |
| 299 | 338 | } |
| 300 | 339 | |
| 301 | 340 | LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) | ... | ... |