diff --git a/genmarshal b/genmarshal index 1360dca..3e90214 100644 --- a/genmarshal +++ b/genmarshal @@ -10,3 +10,4 @@ VOID:VOID,BOOL BOOL:VOID,BOOL,BOOL,POINTER VOID:VOID,UINT,UINT VOID:VOID,UINT,POINTER,POINTER,POINTER +BOOL:VOID,BOOL,UINT,POINTER diff --git a/mouse.c b/mouse.c index aba09af..4376f99 100644 --- a/mouse.c +++ b/mouse.c @@ -128,28 +128,49 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event) gdk_beep(); } -gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) +static V3270_OIA_FIELD get_field_from_event(v3270 *widget, GdkEventButton *event) { - int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y); + if(event->y >= widget->oia_rect->y) + { + V3270_OIA_FIELD f; - if(baddr < 0) - return FALSE; + for(f=0;fx >= widget->oia_rect[f].x && event->x <= (widget->oia_rect[f].x+widget->oia_rect[f].width)) + return f; + } + } -// trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); + return V3270_OIA_FIELD_INVALID; +} - switch(event->button) +gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) +{ + int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y); + + if(baddr >= 0) { - case 1: // Left button - button_1_press(widget,event->type,baddr); - break; + GTK_V3270(widget)->selected_field = V3270_OIA_FIELD_INVALID; - case 3: // Right button - if(event->type == GDK_BUTTON_PRESS) - v3270_emit_popup(GTK_V3270(widget),baddr,event); - break; + switch(event->button) + { + case 1: // Left button + button_1_press(widget,event->type,baddr); + break; - default: - trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); + case 3: // Right button + if(event->type == GDK_BUTTON_PRESS) + v3270_emit_popup(GTK_V3270(widget),baddr,event); + break; + + default: + trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); + } + } + else if(event->button == 1 && event->type == GDK_BUTTON_PRESS) + { + GTK_V3270(widget)->selected_field = get_field_from_event(GTK_V3270(widget),event); + trace("%s field=%d",__FUNCTION__,GTK_V3270(widget)->selected_field); } return FALSE; @@ -163,24 +184,44 @@ gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) GTK_V3270(widget)->selecting = 0; GTK_V3270(widget)->moving = 0; GTK_V3270(widget)->resizing = 0; + + if(GTK_V3270(widget)->selected_field != V3270_OIA_FIELD_INVALID && GTK_V3270(widget)->selected_field == get_field_from_event(GTK_V3270(widget),event)) + { + gboolean handled = FALSE; + + trace("%s field %d was clicked event=%p",__FUNCTION__,GTK_V3270(widget)->selected_field,event); + + g_signal_emit(widget, v3270_widget_signal[SIGNAL_FIELD], 0, + lib3270_connected(GTK_V3270(widget)->host) ? TRUE : FALSE, + GTK_V3270(widget)->selected_field, + event, + &handled); + + trace("Handled: %s",handled ? "Yes": "No"); + + if(!handled) + gdk_beep(); + + } + + GTK_V3270(widget)->selected_field = V3270_OIA_FIELD_INVALID; + break; default: trace("%s button=%d type=%d",__FUNCTION__,event->button,event->type); } - return FALSE; } - static void update_mouse_pointer(GtkWidget *widget, int baddr) { - v3270 *terminal = GTK_V3270(widget); + v3270 * terminal = GTK_V3270(widget); + int id = terminal->pointer; if(baddr >= 0 && terminal->pointer_id == LIB3270_CURSOR_EDITABLE) { - int id = terminal->pointer; switch(lib3270_get_selection_flags(terminal->host,baddr) & 0x8f) { @@ -225,9 +266,10 @@ static void update_mouse_pointer(GtkWidget *widget, int baddr) } - gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); } + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); + } void v3270_update_mouse_pointer(GtkWidget *widget) @@ -244,11 +286,20 @@ void v3270_update_mouse_pointer(GtkWidget *widget) gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) { - v3270 * terminal = GTK_V3270(widget); - int baddr = v3270_get_offset_at_point(terminal,event->x,event->y); + v3270 * terminal = GTK_V3270(widget); + int baddr; + + if(!lib3270_connected(terminal->host)) + { + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[V3270_CURSOR_PROTECTED]); + return FALSE; + } + + baddr = v3270_get_offset_at_point(terminal,event->x,event->y); if(baddr >= 0) { + if(terminal->selecting) // Select region { lib3270_select_to(terminal->host,baddr); @@ -263,6 +314,37 @@ gboolean v3270_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) update_mouse_pointer(widget,baddr); } } + else if(event->y >= terminal->oia_rect->y) + { + int id = V3270_CURSOR_PROTECTED; + + if(event->x >= terminal->oia_rect[V3270_OIA_SSL].x && event->x <= (terminal->oia_rect[V3270_OIA_SSL].x + terminal->oia_rect[V3270_OIA_SSL].width)) + { + switch(lib3270_get_secure(terminal->host)) + { + case LIB3270_SSL_UNSECURE: /**< No secure connection */ + id = V3270_CURSOR_QUESTION; + break; + + case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ + id = V3270_CURSOR_WAITING; + break; + + case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ + id = V3270_CURSOR_QUESTION; + break; + + case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ + id = V3270_CURSOR_QUESTION; + break; + + default: + id = V3270_CURSOR_LOCKED; + } + } + + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[id]); + } return FALSE; } diff --git a/oia.c b/oia.c index 23e3cf3..79d6b21 100644 --- a/oia.c +++ b/oia.c @@ -335,6 +335,13 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri bits = (unsigned char *) unlocked_bits; break; + case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ + gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); + width = unlocked_width; + height = unlocked_height; + bits = (unsigned char *) unlocked_bits; + break; + case LIB3270_SSL_NEGOTIATED: /**< Connection secure, no CA or self-signed */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); width = negotiated_width; @@ -342,7 +349,6 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri bits = (unsigned char *) negotiated_bits; break; - case LIB3270_SSL_SECURE: /**< Connection secure with CA check */ gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_OK); width = locked_width; @@ -350,19 +356,11 @@ void v3270_draw_ssl_status(cairo_t *cr, H3270 *host, struct v3270_metrics *metri bits = (unsigned char *) locked_bits; break; - case LIB3270_SSL_NEGOTIATING: /**< Negotiating SSL */ - gdk_cairo_set_source_color(cr,color+V3270_COLOR_OIA_STATUS_WARNING); - width = unlocked_width; - height = unlocked_height; - bits = (unsigned char *) unlocked_bits; - break; - default: return; } - icon = cairo_image_surface_create_for_data( bits, CAIRO_FORMAT_A1, width,height, diff --git a/private.h b/private.h index 5909eaa..35db64d 100644 --- a/private.h +++ b/private.h @@ -81,10 +81,12 @@ G_BEGIN_DECLS SIGNAL_CLIPBOARD, SIGNAL_CHANGED, SIGNAL_MESSAGE, + SIGNAL_FIELD, LAST_SIGNAL }; + /*--[ Globals ]--------------------------------------------------------------------------------------*/ #define V3270_CURSOR_UNPROTECTED LIB3270_CURSOR_EDITABLE @@ -101,8 +103,9 @@ G_BEGIN_DECLS #define V3270_CURSOR_SELECTION_BOTTOM LIB3270_CURSOR_USER+7 #define V3270_CURSOR_SELECTION_LEFT LIB3270_CURSOR_USER+8 #define V3270_CURSOR_SELECTION_RIGHT LIB3270_CURSOR_USER+9 + #define V3270_CURSOR_QUESTION LIB3270_CURSOR_USER+10 - #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+10 + #define V3270_CURSOR_COUNT LIB3270_CURSOR_USER+11 struct v3270_metrics @@ -144,8 +147,10 @@ G_BEGIN_DECLS gchar * clipboard; /**< Clipboard contents (text only) */ LIB3270_CURSOR pointer_id; - unsigned char pointer; /** Mouse pointer ID */ - int selection_addr; /** Selection addr */ + unsigned char pointer; /**< Mouse pointer ID */ + int selection_addr; /**< Selection addr */ + + V3270_OIA_FIELD selected_field; /**< Clicked OIA field */ // Font info gchar * font_family; diff --git a/widget.c b/widget.c index 41f81f8..0d6861c 100644 --- a/widget.c +++ b/widget.c @@ -333,6 +333,8 @@ static void v3270_class_init(v3270Class *klass) // Cursors { #ifdef WIN32 + // http://git.gnome.org/browse/gtk+/tree/gdk/win32/gdkcursor-win32.c + // http://www.functionx.com/win32/Lesson02b.htm static const gchar * cr[V3270_CURSOR_COUNT] = { "ibeam", // V3270_CURSOR_UNPROTECTED @@ -348,6 +350,7 @@ static void v3270_class_init(v3270Class *klass) "sizens", // V3270_CURSOR_SELECTION_BOTTOM "sizewe", // V3270_CURSOR_SELECTION_LEFT "sizewe", // V3270_CURSOR_SELECTION_RIGHT + "help", // V3270_CURSOR_QUESTION }; #else static const int cr[V3270_CURSOR_COUNT] = @@ -365,6 +368,7 @@ static void v3270_class_init(v3270Class *klass) GDK_BOTTOM_SIDE, // V3270_CURSOR_SELECTION_BOTTOM GDK_LEFT_SIDE, // V3270_CURSOR_SELECTION_LEFT GDK_RIGHT_SIDE, // V3270_CURSOR_SELECTION_RIGHT + GDK_QUESTION_ARROW, // V3270_CURSOR_QUESTION }; #endif // WIN32 @@ -516,6 +520,15 @@ static void v3270_class_init(v3270Class *klass) pw3270_VOID__VOID_UINT_POINTER_POINTER_POINTER, G_TYPE_NONE, 4, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); + v3270_widget_signal[SIGNAL_FIELD] = + g_signal_new( "field_clicked", + G_OBJECT_CLASS_TYPE (gobject_class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + pw3270_BOOL__VOID_BOOL_UINT_POINTER, + G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_POINTER); + } void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) -- libgit2 0.21.2