diff --git a/mouse.c b/mouse.c index 102849f..0b192b2 100644 --- a/mouse.c +++ b/mouse.c @@ -36,6 +36,10 @@ #include #include +/*--[ Globals ]--------------------------------------------------------------------------------------*/ + + static GtkAction *action_scroll[] = { NULL, NULL, NULL, NULL }; + /*--[ Implement ]------------------------------------------------------------------------------------*/ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) @@ -262,3 +266,24 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) return FALSE; } + +void v3270_set_scroll_action(GtkWidget *widget, GdkScrollDirection direction, GtkAction *action) +{ + g_return_if_fail(GTK_IS_V3270(widget)); + action_scroll[((int) direction) & 0x03] = action; +} + +gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) +{ + v3270 * terminal = GTK_V3270(widget); + + if(lib3270_get_program_message(terminal->host) != LIB3270_MESSAGE_NONE || event->direction < 0 || event->direction > G_N_ELEMENTS(action_scroll)) + return FALSE; + + trace("Scroll: %d Action: %p",event->direction,action_scroll[event->direction]); + + if(action_scroll[event->direction]) + gtk_action_activate(action_scroll[event->direction]); + + return TRUE; + } diff --git a/private.h b/private.h index 1839f7c..0925123 100644 --- a/private.h +++ b/private.h @@ -254,5 +254,6 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event); gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event); void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event); gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y); +gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data); G_END_DECLS diff --git a/widget.c b/widget.c index e1c300f..7997340 100644 --- a/widget.c +++ b/widget.c @@ -294,6 +294,7 @@ static void v3270_class_init(v3270Class *klass) widget_class->button_release_event = v3270_button_release_event; widget_class->motion_notify_event = v3270_motion_notify_event; widget_class->popup_menu = v3270_popup_menu; + widget_class->scroll_event = v3270_scroll_event; /* Accessibility support */ widget_class->get_accessible = v3270_get_accessible; -- libgit2 0.21.2