Commit f2b6a5344c1ed6974de8934295d843d4943e4c07

Authored by Perry Werneck
1 parent b93f900f
Exists in master and in 1 other branch develop

Adding signal for OIA clicks.

src/include/internals.h
@@ -81,7 +81,6 @@ @@ -81,7 +81,6 @@
81 V3270_SIGNAL_MESSAGE_CHANGED, 81 V3270_SIGNAL_MESSAGE_CHANGED,
82 V3270_SIGNAL_KEYPRESS, 82 V3270_SIGNAL_KEYPRESS,
83 V3270_SIGNAL_MODEL_CHANGED, 83 V3270_SIGNAL_MODEL_CHANGED,
84 - V3270_SIGNAL_POPUP,  
85 V3270_SIGNAL_CHANGED, 84 V3270_SIGNAL_CHANGED,
86 V3270_SIGNAL_MESSAGE, 85 V3270_SIGNAL_MESSAGE,
87 V3270_SIGNAL_FIELD, 86 V3270_SIGNAL_FIELD,
@@ -107,6 +106,12 @@ @@ -107,6 +106,12 @@
107 V3270_SIGNAL_PRINT_SETUP, 106 V3270_SIGNAL_PRINT_SETUP,
108 107
109 // 108 //
  109 + // Popup signals
  110 + //
  111 + V3270_SIGNAL_POPUP,
  112 + V3270_SIGNAL_OIA_POPUP,
  113 +
  114 + //
110 // Settings signals (Mostly fired by V3270Settings dialogs). 115 // Settings signals (Mostly fired by V3270Settings dialogs).
111 // 116 //
112 V3270_SIGNAL_SAVE_SETTINGS, ///< @brief Notify main application to save all widget settings. 117 V3270_SIGNAL_SAVE_SETTINGS, ///< @brief Notify main application to save all widget settings.
src/terminal/marshal
@@ -11,4 +11,5 @@ BOOLEAN:VOID,BOOLEAN,BOOLEAN,POINTER @@ -11,4 +11,5 @@ BOOLEAN:VOID,BOOLEAN,BOOLEAN,POINTER
11 VOID:VOID,UINT,UINT 11 VOID:VOID,UINT,UINT
12 VOID:VOID,UINT,POINTER,POINTER,POINTER 12 VOID:VOID,UINT,POINTER,POINTER,POINTER
13 BOOLEAN:VOID,BOOLEAN,UINT,POINTER 13 BOOLEAN:VOID,BOOLEAN,UINT,POINTER
  14 +BOOLEAN:VOID,UINT,POINTER
14 VOID:VOID,POINTER,UINT 15 VOID:VOID,POINTER,UINT
src/terminal/mouse.c
@@ -40,21 +40,17 @@ @@ -40,21 +40,17 @@
40 40
41 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 41 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
42 42
43 -/*--[ Globals ]--------------------------------------------------------------------------------------*/  
44 -  
45 -// static GtkAction *action_scroll[] = { NULL, NULL, NULL, NULL };  
46 -  
47 /*--[ Implement ]------------------------------------------------------------------------------------*/ 43 /*--[ Implement ]------------------------------------------------------------------------------------*/
48 44
49 -gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y)  
50 -{ 45 +gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) {
  46 +
51 GdkPoint point; 47 GdkPoint point;
52 unsigned int r,c; 48 unsigned int r,c;
53 49
54 g_return_val_if_fail(widget->font.width > 0,-1); 50 g_return_val_if_fail(widget->font.width > 0,-1);
55 51
56 - if(x > 0 && y > 0)  
57 - { 52 + if(x > 0 && y > 0) {
  53 +
58 point.x = ((x-widget->font.margin.left)/widget->font.width); 54 point.x = ((x-widget->font.margin.left)/widget->font.width);
59 point.y = ((y-widget->font.margin.top)/widget->font.spacing.value); 55 point.y = ((y-widget->font.margin.top)/widget->font.spacing.value);
60 56
@@ -67,10 +63,9 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y) @@ -67,10 +63,9 @@ gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y)
67 return -1; 63 return -1;
68 } 64 }
69 65
70 -static void single_click(v3270 *widget, int baddr)  
71 -{  
72 - switch(lib3270_get_selection_flags(widget->host,baddr))  
73 - { 66 +static void single_click(v3270 *widget, int baddr) {
  67 +
  68 + switch(lib3270_get_selection_flags(widget->host,baddr)) {
74 case 0x00: 69 case 0x00:
75 // Unselected area, move cursor and remove selection 70 // Unselected area, move cursor and remove selection
76 v3270_disable_updates(GTK_WIDGET(widget)); 71 v3270_disable_updates(GTK_WIDGET(widget));
@@ -87,7 +82,6 @@ static void single_click(v3270 *widget, int baddr) @@ -87,7 +82,6 @@ static void single_click(v3270 *widget, int baddr)
87 widget->moving = 1; 82 widget->moving = 1;
88 } 83 }
89 84
90 -  
91 } 85 }
92 86
93 static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) 87 static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr)
@@ -95,8 +89,7 @@ static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) @@ -95,8 +89,7 @@ static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr)
95 #pragma GCC diagnostic push 89 #pragma GCC diagnostic push
96 #pragma GCC diagnostic ignored "-Wswitch" 90 #pragma GCC diagnostic ignored "-Wswitch"
97 91
98 - switch(type)  
99 - { 92 + switch(type) {
100 case GDK_BUTTON_PRESS: // Single click - set mode 93 case GDK_BUTTON_PRESS: // Single click - set mode
101 single_click(GTK_V3270(widget),baddr); 94 single_click(GTK_V3270(widget),baddr);
102 break; 95 break;
@@ -117,8 +110,7 @@ static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr) @@ -117,8 +110,7 @@ static void button_1_press(GtkWidget *widget, GdkEventType type, int baddr)
117 110
118 } 111 }
119 112
120 -void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event)  
121 -{ 113 +void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event) {
122 unsigned char chr = 0; 114 unsigned char chr = 0;
123 unsigned short attr; 115 unsigned short attr;
124 gboolean handled = FALSE; 116 gboolean handled = FALSE;
@@ -137,14 +129,13 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event) @@ -137,14 +129,13 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event)
137 gdk_display_beep(gtk_widget_get_display(GTK_WIDGET(widget))); 129 gdk_display_beep(gtk_widget_get_display(GTK_WIDGET(widget)));
138 } 130 }
139 131
140 -static V3270_OIA_FIELD get_field_from_event(v3270 *widget, GdkEventButton *event)  
141 -{ 132 +static V3270_OIA_FIELD get_field_from_event(v3270 *widget, GdkEventButton *event) {
  133 +
142 if(event->y >= widget->oia.rect->y) 134 if(event->y >= widget->oia.rect->y)
143 { 135 {
144 V3270_OIA_FIELD f; 136 V3270_OIA_FIELD f;
145 137
146 - for(f=0;f<V3270_OIA_FIELD_COUNT;f++)  
147 - { 138 + for(f=0;f<V3270_OIA_FIELD_COUNT;f++) {
148 if(event->x >= widget->oia.rect[f].x && event->x <= (widget->oia.rect[f].x+widget->oia.rect[f].width)) 139 if(event->x >= widget->oia.rect[f].x && event->x <= (widget->oia.rect[f].x+widget->oia.rect[f].width))
149 return f; 140 return f;
150 } 141 }
@@ -157,12 +148,13 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) @@ -157,12 +148,13 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event)
157 { 148 {
158 int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y); 149 int baddr = v3270_get_offset_at_point(GTK_V3270(widget),event->x,event->y);
159 150
160 - if(baddr >= 0)  
161 - { 151 + if(baddr >= 0) {
  152 +
  153 + // Click inside the terminal contents.
  154 +
162 GTK_V3270(widget)->oia.selected = V3270_OIA_FIELD_INVALID; 155 GTK_V3270(widget)->oia.selected = V3270_OIA_FIELD_INVALID;
163 156
164 - switch(event->button)  
165 - { 157 + switch(event->button) {
166 case 1: // Left button 158 case 1: // Left button
167 button_1_press(widget,event->type,baddr); 159 button_1_press(widget,event->type,baddr);
168 break; 160 break;
@@ -173,10 +165,40 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) @@ -173,10 +165,40 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event)
173 break; 165 break;
174 166
175 } 167 }
176 - }  
177 - else if(event->button == 1 && event->type == GDK_BUTTON_PRESS)  
178 - {  
179 - GTK_V3270(widget)->oia.selected = get_field_from_event(GTK_V3270(widget),event); 168 +
  169 + } else if(event->type == GDK_BUTTON_PRESS) {
  170 +
  171 + V3270_OIA_FIELD field = get_field_from_event(GTK_V3270(widget),event);
  172 +
  173 + if(field != V3270_OIA_FIELD_INVALID) {
  174 +
  175 + debug("Button %d pressed on OIA %d",(int) event->button, (int) field);
  176 +
  177 + switch(event->button) {
  178 + case 1: // Left button
  179 + GTK_V3270(widget)->oia.selected = field;
  180 + break;
  181 +
  182 + case 3: // Right button
  183 + {
  184 + gboolean handled = FALSE;
  185 +
  186 + g_signal_emit(widget, v3270_widget_signal[V3270_SIGNAL_OIA_POPUP],
  187 + 0,
  188 + (guint) field,
  189 + event,
  190 + &handled);
  191 +
  192 + if(!handled)
  193 + gdk_display_beep(gtk_widget_get_display(widget));
  194 +
  195 + }
  196 + break;
  197 + }
  198 +
  199 +
  200 + }
  201 +
180 } 202 }
181 203
182 return FALSE; 204 return FALSE;
@@ -184,9 +206,8 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event) @@ -184,9 +206,8 @@ gboolean v3270_button_press_event(GtkWidget *widget, GdkEventButton *event)
184 206
185 gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event) 207 gboolean v3270_button_release_event(GtkWidget *widget, GdkEventButton*event)
186 { 208 {
187 - switch(event->button)  
188 - {  
189 - case 1: 209 + switch(event->button) {
  210 + case 1: // Left button
190 GTK_V3270(widget)->selecting = 0; 211 GTK_V3270(widget)->selecting = 0;
191 GTK_V3270(widget)->moving = 0; 212 GTK_V3270(widget)->moving = 0;
192 GTK_V3270(widget)->resizing = 0; 213 GTK_V3270(widget)->resizing = 0;
src/terminal/widget.c
@@ -380,6 +380,15 @@ static void v3270_class_init(v3270Class *klass) @@ -380,6 +380,15 @@ static void v3270_class_init(v3270Class *klass)
380 v3270_BOOLEAN__VOID_BOOLEAN_BOOLEAN_POINTER, 380 v3270_BOOLEAN__VOID_BOOLEAN_BOOLEAN_POINTER,
381 G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER); 381 G_TYPE_BOOLEAN, 3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER);
382 382
  383 + v3270_widget_signal[V3270_SIGNAL_OIA_POPUP] =
  384 + g_signal_new( I_("oia-popup"),
  385 + G_OBJECT_CLASS_TYPE (gobject_class),
  386 + G_SIGNAL_RUN_LAST,
  387 + 0,
  388 + NULL, NULL,
  389 + v3270_BOOLEAN__VOID_UINT_POINTER,
  390 + G_TYPE_BOOLEAN, 2, G_TYPE_UINT, G_TYPE_POINTER);
  391 +
383 v3270_widget_signal[V3270_SIGNAL_PASTENEXT] = 392 v3270_widget_signal[V3270_SIGNAL_PASTENEXT] =
384 g_signal_new( I_("pastenext"), 393 g_signal_new( I_("pastenext"),
385 G_OBJECT_CLASS_TYPE (gobject_class), 394 G_OBJECT_CLASS_TYPE (gobject_class),