Commit 9046f9edd96249ef4e84541873db6934de5d18ae
1 parent
2a0b0d58
Exists in
master
and in
5 other branches
Incluindo sinal para mudar o estado das opções de seleção
Showing
7 changed files
with
41 additions
and
5 deletions
Show diff stats
src/gtk/mainwindow.c
| @@ -97,6 +97,12 @@ | @@ -97,6 +97,12 @@ | ||
| 97 | set_integer_to_config("terminal","model",id); | 97 | set_integer_to_config("terminal","model",id); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | + static void selecting(GtkWidget *widget, gboolean on, GtkActionGroup **group) | ||
| 101 | + { | ||
| 102 | + trace("Widget %p selection state changed to %s",widget,on ? "Yes" : "No"); | ||
| 103 | + gtk_action_group_set_sensitive(group[ACTION_GROUP_SELECTION],on); | ||
| 104 | + } | ||
| 105 | + | ||
| 100 | static void setup_input_method(GtkWidget *widget, GtkWidget *obj) | 106 | static void setup_input_method(GtkWidget *widget, GtkWidget *obj) |
| 101 | { | 107 | { |
| 102 | GtkWidget *menu = gtk_menu_new(); | 108 | GtkWidget *menu = gtk_menu_new(); |
| @@ -212,6 +218,7 @@ | @@ -212,6 +218,7 @@ | ||
| 212 | g_signal_connect(terminal,"connected",G_CALLBACK(connected),group); | 218 | g_signal_connect(terminal,"connected",G_CALLBACK(connected),group); |
| 213 | g_signal_connect(terminal,"update_config",G_CALLBACK(update_config),0); | 219 | g_signal_connect(terminal,"update_config",G_CALLBACK(update_config),0); |
| 214 | g_signal_connect(terminal,"model_changed",G_CALLBACK(update_model),0); | 220 | g_signal_connect(terminal,"model_changed",G_CALLBACK(update_model),0); |
| 221 | + g_signal_connect(terminal,"selecting",G_CALLBACK(selecting),group); | ||
| 215 | 222 | ||
| 216 | g_free(path); | 223 | g_free(path); |
| 217 | gtk_widget_grab_focus(terminal); | 224 | gtk_widget_grab_focus(terminal); |
src/gtk/v3270/genmarshal
src/gtk/v3270/private.h
src/gtk/v3270/widget.c
| @@ -236,6 +236,14 @@ static void v3270_class_init(v3270Class *klass) | @@ -236,6 +236,14 @@ static void v3270_class_init(v3270Class *klass) | ||
| 236 | pw3270_VOID__VOID_UINT_POINTER, | 236 | pw3270_VOID__VOID_UINT_POINTER, |
| 237 | G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING); | 237 | G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING); |
| 238 | 238 | ||
| 239 | + v3270_widget_signal[SIGNAL_SELECTING] = | ||
| 240 | + g_signal_new( "selecting", | ||
| 241 | + G_OBJECT_CLASS_TYPE (gobject_class), | ||
| 242 | + G_SIGNAL_RUN_FIRST, | ||
| 243 | + 0, | ||
| 244 | + NULL, NULL, | ||
| 245 | + pw3270_VOID__VOID_BOOL, | ||
| 246 | + G_TYPE_NONE, 1, G_TYPE_BOOLEAN); | ||
| 239 | } | 247 | } |
| 240 | 248 | ||
| 241 | void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) | 249 | void v3270_update_font_metrics(v3270 *terminal, cairo_t *cr, int width, int height) |
| @@ -389,6 +397,11 @@ static void update_model(H3270 *session, const char *name, int model, int rows, | @@ -389,6 +397,11 @@ static void update_model(H3270 *session, const char *name, int model, int rows, | ||
| 389 | g_signal_emit(GTK_WIDGET(session->widget),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); | 397 | g_signal_emit(GTK_WIDGET(session->widget),v3270_widget_signal[SIGNAL_MODEL_CHANGED], 0, (guint) model, name); |
| 390 | } | 398 | } |
| 391 | 399 | ||
| 400 | +static void set_selection(H3270 *session, unsigned char status) | ||
| 401 | +{ | ||
| 402 | + g_signal_emit(GTK_WIDGET(session->widget),v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE); | ||
| 403 | +} | ||
| 404 | + | ||
| 392 | static void v3270_init(v3270 *widget) | 405 | static void v3270_init(v3270 *widget) |
| 393 | { | 406 | { |
| 394 | trace("%s",__FUNCTION__); | 407 | trace("%s",__FUNCTION__); |
| @@ -400,11 +413,12 @@ static void v3270_init(v3270 *widget) | @@ -400,11 +413,12 @@ static void v3270_init(v3270 *widget) | ||
| 400 | return; | 413 | return; |
| 401 | } | 414 | } |
| 402 | 415 | ||
| 403 | - widget->host->widget = widget; | 416 | + widget->host->widget = widget; |
| 404 | 417 | ||
| 405 | widget->host->update = v3270_update_char; | 418 | widget->host->update = v3270_update_char; |
| 406 | widget->host->changed = changed; | 419 | widget->host->changed = changed; |
| 407 | widget->host->set_timer = set_timer; | 420 | widget->host->set_timer = set_timer; |
| 421 | + widget->host->set_selection = set_selection; | ||
| 408 | 422 | ||
| 409 | widget->host->update_luname = update_luname; | 423 | widget->host->update_luname = update_luname; |
| 410 | widget->host->configure = update_screen_size; | 424 | widget->host->configure = update_screen_size; |
src/include/lib3270/session.h
| @@ -132,6 +132,7 @@ | @@ -132,6 +132,7 @@ | ||
| 132 | void (*set_timer)(H3270 *session, unsigned char on); | 132 | void (*set_timer)(H3270 *session, unsigned char on); |
| 133 | void (*erase)(H3270 *session); | 133 | void (*erase)(H3270 *session); |
| 134 | void (*cursor)(H3270 *session, LIB3270_CURSOR id); | 134 | void (*cursor)(H3270 *session, LIB3270_CURSOR id); |
| 135 | + void (*set_selection)(H3270 *session, unsigned char on); | ||
| 135 | 136 | ||
| 136 | }; | 137 | }; |
| 137 | 138 |
src/lib3270/glue.c
| @@ -170,6 +170,11 @@ static void update_char(H3270 *session, int addr, unsigned char chr, unsigned sh | @@ -170,6 +170,11 @@ static void update_char(H3270 *session, int addr, unsigned char chr, unsigned sh | ||
| 170 | 170 | ||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | +static void nop_char(H3270 *session, unsigned char chr) | ||
| 174 | +{ | ||
| 175 | + | ||
| 176 | +} | ||
| 177 | + | ||
| 173 | static void lib3270_session_init(H3270 *hSession, const char *model) | 178 | static void lib3270_session_init(H3270 *hSession, const char *model) |
| 174 | { | 179 | { |
| 175 | int ovc, ovr; | 180 | int ovc, ovr; |
| @@ -180,7 +185,8 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | @@ -180,7 +185,8 @@ static void lib3270_session_init(H3270 *hSession, const char *model) | ||
| 180 | hSession->sz = sizeof(H3270); | 185 | hSession->sz = sizeof(H3270); |
| 181 | 186 | ||
| 182 | // A few dummy calls to avoid "ifs" | 187 | // A few dummy calls to avoid "ifs" |
| 183 | - hSession->update = update_char; | 188 | + hSession->update = update_char; |
| 189 | + hSession->set_selection = nop_char; | ||
| 184 | 190 | ||
| 185 | 191 | ||
| 186 | hSession->sock = -1; | 192 | hSession->sock = -1; |
src/lib3270/selection.c
| @@ -175,6 +175,9 @@ LIB3270_EXPORT void lib3270_clear_selection(H3270 *session) | @@ -175,6 +175,9 @@ LIB3270_EXPORT void lib3270_clear_selection(H3270 *session) | ||
| 175 | session->update(session,a,ea_buf[a].chr,ea_buf[a].attr,a == session->cursor_addr); | 175 | session->update(session,a,ea_buf[a].chr,ea_buf[a].attr,a == session->cursor_addr); |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | + | ||
| 179 | + session->set_selection(session,0); | ||
| 180 | + | ||
| 178 | } | 181 | } |
| 179 | 182 | ||
| 180 | 183 | ||
| @@ -182,11 +185,14 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | @@ -182,11 +185,14 @@ LIB3270_EXPORT void lib3270_select_to(H3270 *session, int baddr) | ||
| 182 | { | 185 | { |
| 183 | CHECK_SESSION_HANDLE(session); | 186 | CHECK_SESSION_HANDLE(session); |
| 184 | 187 | ||
| 185 | - if(session->selected.begin < 0) | ||
| 186 | - session->selected.begin = session->selected.end = session->cursor_addr; | ||
| 187 | - | ||
| 188 | lib3270_set_cursor_address(session,session->selected.end = baddr); | 188 | lib3270_set_cursor_address(session,session->selected.end = baddr); |
| 189 | 189 | ||
| 190 | + if(session->selected.begin < 0) | ||
| 191 | + { | ||
| 192 | + session->selected.begin = session->cursor_addr; | ||
| 193 | + session->set_selection(session,1); | ||
| 194 | + } | ||
| 195 | + | ||
| 190 | update_selection(session); | 196 | update_selection(session); |
| 191 | 197 | ||
| 192 | } | 198 | } |