Commit 957aa5c9e902c78298c264ee15e5318e0658e6bc
1 parent
11ac88cd
Exists in
master
and in
1 other branch
Adding signal for customized action fire.
Showing
3 changed files
with
30 additions
and
52 deletions
Show diff stats
src/include/internals.h
... | ... | @@ -118,6 +118,11 @@ |
118 | 118 | V3270_SIGNAL_LOAD_POPUP_RESPONSE, ///< @brief Load popup response (GTK_RESPONSE_NONE to show popup). |
119 | 119 | V3270_SIGNAL_SAVE_POPUP_RESPONSE, ///< @brief Save popup response. |
120 | 120 | |
121 | + // | |
122 | + // Misc signals | |
123 | + // | |
124 | + V3270_SIGNAL_FIRE_ACTION, ///< @brief Fire action by name. | |
125 | + | |
121 | 126 | V3270_SIGNAL_LAST |
122 | 127 | }; |
123 | 128 | ... | ... |
src/terminal/callbacks.c
... | ... | @@ -398,58 +398,6 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title |
398 | 398 | g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,(GSourceFunc) bg_update_oia, data, g_free); |
399 | 399 | } |
400 | 400 | |
401 | - /* | |
402 | - static int popup_ssl_error(H3270 *session, int rc, const char *title, const char *summary, const char *body) | |
403 | - { | |
404 | - GtkWidget *terminal = (GtkWidget *) lib3270_get_user_data(session); | |
405 | - | |
406 | - debug("%s.summary=\"%s\"",__FUNCTION__,summary); | |
407 | - debug("%s.body=\"%s\"",__FUNCTION__,body ? body : "undefined"); | |
408 | - | |
409 | - if(terminal && GTK_IS_V3270(terminal)) | |
410 | - { | |
411 | - GtkWidget * dialog = gtk_message_dialog_new_with_markup( | |
412 | - GTK_WINDOW(gtk_widget_get_toplevel(terminal)), | |
413 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
414 | - GTK_MESSAGE_WARNING, | |
415 | - GTK_BUTTONS_NONE, | |
416 | - "%s", | |
417 | - summary | |
418 | - ); | |
419 | - | |
420 | - gtk_window_set_title(GTK_WINDOW(dialog), title); | |
421 | - | |
422 | - if(body && *body) | |
423 | - { | |
424 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),"%s",body); | |
425 | - } | |
426 | - else if(rc) | |
427 | - { | |
428 | - gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),_( "The error code was %d"),rc); | |
429 | - } | |
430 | - | |
431 | - gtk_dialog_add_buttons( | |
432 | - GTK_DIALOG(dialog), | |
433 | - _("Cancel"), GTK_RESPONSE_CANCEL, | |
434 | - _("Continue"), GTK_RESPONSE_APPLY, | |
435 | - NULL | |
436 | - ); | |
437 | - | |
438 | - gtk_dialog_set_default_response(GTK_DIALOG (dialog),GTK_RESPONSE_CANCEL); | |
439 | - | |
440 | - gtk_widget_show_all(dialog); | |
441 | - int rc = gtk_dialog_run(GTK_DIALOG(dialog)); | |
442 | - gtk_widget_destroy(dialog); | |
443 | - | |
444 | - if(rc == GTK_RESPONSE_APPLY) | |
445 | - return 0; | |
446 | - | |
447 | - } | |
448 | - | |
449 | - return -1; | |
450 | - } | |
451 | - */ | |
452 | - | |
453 | 401 | static int popup(H3270 *hSession, const LIB3270_POPUP *popup, unsigned char wait) { |
454 | 402 | |
455 | 403 | GtkResponseType response = v3270_popup_dialog_show( |
... | ... | @@ -464,6 +412,21 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title |
464 | 412 | |
465 | 413 | } |
466 | 414 | |
415 | + static int action(H3270 *hSession, const char *name) { | |
416 | + | |
417 | + guint response = ENOENT; | |
418 | + | |
419 | + v3270_signal_emit( | |
420 | + GTK_WIDGET(lib3270_get_user_data(hSession)), | |
421 | + V3270_SIGNAL_FIRE_ACTION, | |
422 | + name, | |
423 | + &response | |
424 | + ); | |
425 | + | |
426 | + return response; | |
427 | + } | |
428 | + | |
429 | + | |
467 | 430 | void v3270_install_callbacks(v3270 *widget) |
468 | 431 | { |
469 | 432 | struct lib3270_session_callbacks *cbk; |
... | ... | @@ -517,6 +480,7 @@ static void popup_handler(H3270 *session, LIB3270_NOTIFY type, const char *title |
517 | 480 | cbk->save = save; |
518 | 481 | cbk->load = load; |
519 | 482 | cbk->popup = popup; |
483 | + cbk->action = action; | |
520 | 484 | |
521 | 485 | } |
522 | 486 | ... | ... |
src/terminal/widget.c
... | ... | @@ -498,6 +498,15 @@ static void finalize(GObject *object) { |
498 | 498 | v3270_UINT__POINTER, |
499 | 499 | G_TYPE_UINT, 1, G_TYPE_POINTER); |
500 | 500 | |
501 | + v3270_widget_signal[V3270_SIGNAL_FIRE_ACTION] = | |
502 | + g_signal_new( I_("fire-action"), | |
503 | + G_OBJECT_CLASS_TYPE (gobject_class), | |
504 | + G_SIGNAL_RUN_LAST, | |
505 | + 0, | |
506 | + NULL, NULL, | |
507 | + v3270_UINT__POINTER, | |
508 | + G_TYPE_UINT, 1, G_TYPE_POINTER); | |
509 | + | |
501 | 510 | v3270_widget_signal[V3270_SIGNAL_SAVE_POPUP_RESPONSE] = |
502 | 511 | g_signal_new( I_("save-popup-response"), |
503 | 512 | G_OBJECT_CLASS_TYPE (gobject_class), | ... | ... |