Commit 44977a0a7ed8735043d905282f77b01c759442dd
1 parent
50fefed4
Exists in
master
and in
5 other branches
Implementando propriedade "model" no widget
Showing
5 changed files
with
33 additions
and
5 deletions
Show diff stats
src/include/lib3270.h
| ... | ... | @@ -979,7 +979,8 @@ |
| 979 | 979 | // LIB3270_EXPORT int lib3270_set_model(H3270 *session, int model); |
| 980 | 980 | LIB3270_EXPORT int lib3270_set_model(H3270 *hSession, const char *name); |
| 981 | 981 | |
| 982 | - LIB3270_EXPORT int lib3270_get_model(H3270 *session); | |
| 982 | + LIB3270_EXPORT const char * lib3270_get_model(H3270 *session); | |
| 983 | + LIB3270_EXPORT int lib3270_get_model_number(H3270 *hSession); | |
| 983 | 984 | |
| 984 | 985 | LIB3270_EXPORT int lib3270_is_protected(H3270 *h, unsigned int baddr); |
| 985 | 986 | ... | ... |
src/lib3270/ctlr.c
| ... | ... | @@ -234,11 +234,18 @@ static int parse_model_number(H3270 *session, const char *m) |
| 234 | 234 | * @param hSession selected 3270 session. |
| 235 | 235 | * @return Current model number. |
| 236 | 236 | */ |
| 237 | -int lib3270_get_model(H3270 *hSession) | |
| 237 | +int lib3270_get_model_number(H3270 *hSession) | |
| 238 | 238 | { |
| 239 | + CHECK_SESSION_HANDLE(hSession); | |
| 239 | 240 | return hSession->model_num; |
| 240 | 241 | } |
| 241 | 242 | |
| 243 | +const char * lib3270_get_model(H3270 *hSession) | |
| 244 | +{ | |
| 245 | + CHECK_SESSION_HANDLE(hSession); | |
| 246 | + return hSession->model_name; | |
| 247 | +} | |
| 248 | + | |
| 242 | 249 | /** |
| 243 | 250 | * Deal with the relationships between model numbers and rows/cols. |
| 244 | 251 | * | ... | ... |
src/pw3270/main.c
| ... | ... | @@ -407,7 +407,7 @@ int main(int argc, char *argv[]) |
| 407 | 407 | { "toggleset", 'S', 0, G_OPTION_ARG_STRING, &toggleset, N_( "Set toggles ON" ), NULL }, |
| 408 | 408 | { "togglereset", 'R', 0, G_OPTION_ARG_STRING, &togglereset, N_( "Set toggles OFF" ), NULL }, |
| 409 | 409 | { "charset", 'C', 0, G_OPTION_ARG_STRING, &charset, N_( "Set host charset" ), NULL }, |
| 410 | - { "model", 'M', 0, G_OPTION_ARG_STRING, &model, N_( "The model of 3270 display to be emulated." ), NULL }, | |
| 410 | + { "model", 'M', 0, G_OPTION_ARG_STRING, &model, N_( "The model of 3270 display to be emulated" ), NULL }, | |
| 411 | 411 | |
| 412 | 412 | #if defined( HAVE_SYSLOG ) |
| 413 | 413 | { "syslog", 'l', 0, G_OPTION_ARG_NONE, &log_to_syslog, N_( "Send messages to syslog" ), NULL }, | ... | ... |
src/pw3270/v3270/widget.c
| ... | ... | @@ -79,6 +79,7 @@ |
| 79 | 79 | /* Widget properties */ |
| 80 | 80 | PROP_ONLINE, |
| 81 | 81 | PROP_SELECTION, |
| 82 | + PROP_MODEL, | |
| 82 | 83 | |
| 83 | 84 | /* Toggles - always the last one, the real values are PROP_TOGGLE+LIB3270_TOGGLE */ |
| 84 | 85 | PROP_TOGGLE |
| ... | ... | @@ -342,6 +343,9 @@ static void v3270_set_property(GObject *object, guint prop_id, const GValue *val |
| 342 | 343 | |
| 343 | 344 | switch (prop_id) |
| 344 | 345 | { |
| 346 | + case PROP_MODEL: | |
| 347 | + lib3270_set_model(window->host,g_value_get_string(value)); | |
| 348 | + break; | |
| 345 | 349 | |
| 346 | 350 | default: |
| 347 | 351 | if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT)) |
| ... | ... | @@ -360,6 +364,10 @@ static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GPa |
| 360 | 364 | |
| 361 | 365 | switch (prop_id) |
| 362 | 366 | { |
| 367 | + case PROP_MODEL: | |
| 368 | + g_value_set_string(value,lib3270_get_model(window->host)); | |
| 369 | + break; | |
| 370 | + | |
| 363 | 371 | case PROP_ONLINE: |
| 364 | 372 | g_value_set_boolean(value,lib3270_is_connected(window->host) ? TRUE : FALSE ); |
| 365 | 373 | break; |
| ... | ... | @@ -662,6 +670,13 @@ static void v3270_class_init(v3270Class *klass) |
| 662 | 670 | FALSE,G_PARAM_READABLE); |
| 663 | 671 | g_object_class_install_property(gobject_class,PROP_SELECTION,v3270_properties[PROP_SELECTION]); |
| 664 | 672 | |
| 673 | + v3270_properties[PROP_MODEL] = g_param_spec_string( | |
| 674 | + "model", | |
| 675 | + "model", | |
| 676 | + "The model of 3270 display to be emulated", | |
| 677 | + FALSE,G_PARAM_READABLE|G_PARAM_WRITABLE); | |
| 678 | + g_object_class_install_property(gobject_class,PROP_MODEL,v3270_properties[PROP_MODEL]); | |
| 679 | + | |
| 665 | 680 | // Toggle properties |
| 666 | 681 | int f; |
| 667 | 682 | |
| ... | ... | @@ -878,6 +893,11 @@ static void update_screen_size(H3270 *session,unsigned short rows, unsigned shor |
| 878 | 893 | |
| 879 | 894 | static void update_model(H3270 *session, const char *name, int model, int rows, int cols) |
| 880 | 895 | { |
| 896 | +#if GTK_CHECK_VERSION(2,26,0) | |
| 897 | + g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_MODEL]); | |
| 898 | +#else | |
| 899 | + g_object_notify(G_OBJECT(session->widget),"model"); | |
| 900 | +#endif // GTK_CHECK_VERSION | |
| 881 | 901 | g_signal_emit(GTK_WIDGET(session->widget),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); |
| 882 | 902 | } |
| 883 | 903 | ... | ... |
src/pw3270/window.c
| ... | ... | @@ -347,7 +347,7 @@ |
| 347 | 347 | char name[2]; |
| 348 | 348 | int model = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item),"mode_3270")); |
| 349 | 349 | |
| 350 | - if(model == lib3270_get_model(v3270_get_session(widget))) | |
| 350 | + if(model == lib3270_get_model_number(v3270_get_session(widget))) | |
| 351 | 351 | return; |
| 352 | 352 | |
| 353 | 353 | trace("screen model on widget %p changes to %d",widget,GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item),"mode_3270"))); |
| ... | ... | @@ -362,7 +362,7 @@ |
| 362 | 362 | { |
| 363 | 363 | static const gchar * text[] = { "80x24", "80x32", "80x43", "132x27" }; |
| 364 | 364 | GtkWidget * menu = gtk_menu_new(); |
| 365 | - int model = lib3270_get_model(v3270_get_session(obj))-2; | |
| 365 | + int model = lib3270_get_model_number(v3270_get_session(obj))-2; | |
| 366 | 366 | GSList * group = NULL; |
| 367 | 367 | GtkWidget * item; |
| 368 | 368 | int f; | ... | ... |