Commit fa936e43aa2e51d843c10271d68b3fc5be6c0623

Authored by perry.werneck@gmail.com
1 parent 985b0a60

Incluindo notificação do estado do bloco selecionado

src/include/lib3270.h
... ... @@ -844,6 +844,8 @@
844 844  
845 845 LIB3270_EXPORT char * lib3270_cut_selected(H3270 *hSession);
846 846  
  847 + LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession);
  848 +
847 849 /**
848 850 * Get all text inside the terminal.
849 851 *
... ...
src/lib3270/selection.c
... ... @@ -572,8 +572,16 @@ LIB3270_EXPORT char * lib3270_get_field_at(H3270 *session, int baddr)
572 572 return lib3270_get_text(session,first,lib3270_field_length(session,first)+1);
573 573 }
574 574  
  575 +LIB3270_EXPORT int lib3270_has_selection(H3270 *hSession)
  576 +{
  577 + CHECK_SESSION_HANDLE(hSession);
  578 + return hSession->selected != 0;
  579 +}
  580 +
575 581 LIB3270_EXPORT char * lib3270_get_selected(H3270 *hSession)
576 582 {
  583 + CHECK_SESSION_HANDLE(hSession);
  584 +
577 585 if(!hSession->selected || hSession->select.start == hSession->select.end)
578 586 return NULL;
579 587  
... ...
src/pw3270/v3270/widget.c
... ... @@ -77,7 +77,8 @@
77 77  
78 78  
79 79 /* Widget properties */
80   - PROP_CONNECTED,
  80 + PROP_ONLINE,
  81 + PROP_SELECTION,
81 82  
82 83 /* Toggles - always the last one, the real values are PROP_TOGGLE+LIB3270_TOGGLE */
83 84 PROP_TOGGLE
... ... @@ -359,10 +360,14 @@ static void v3270_get_property(GObject *object,guint prop_id, GValue *value, GPa
359 360  
360 361 switch (prop_id)
361 362 {
362   - case PROP_CONNECTED:
  363 + case PROP_ONLINE:
363 364 g_value_set_boolean(value,lib3270_is_connected(window->host) ? TRUE : FALSE );
364 365 break;
365 366  
  367 + case PROP_SELECTION:
  368 + g_value_set_boolean(value,lib3270_has_selection(window->host) ? TRUE : FALSE );
  369 + break;
  370 +
366 371 default:
367 372 if(prop_id < (PROP_TOGGLE + LIB3270_TOGGLE_COUNT))
368 373 {
... ... @@ -643,12 +648,19 @@ static void v3270_class_init(v3270Class *klass)
643 648 gobject_class->set_property = v3270_set_property;
644 649 gobject_class->get_property = v3270_get_property;
645 650  
646   - v3270_properties[PROP_CONNECTED] = g_param_spec_boolean(
647   - "connected",
648   - "connected",
649   - "Indicates the connection state",
  651 + v3270_properties[PROP_ONLINE] = g_param_spec_boolean(
  652 + "online",
  653 + "online",
  654 + "True if is online",
650 655 FALSE,G_PARAM_READABLE);
651   - g_object_class_install_property(gobject_class,PROP_CONNECTED,v3270_properties[PROP_CONNECTED]);
  656 + g_object_class_install_property(gobject_class,PROP_ONLINE,v3270_properties[PROP_ONLINE]);
  657 +
  658 + v3270_properties[PROP_SELECTION] = g_param_spec_boolean(
  659 + "selection",
  660 + "selection",
  661 + "True on selected area",
  662 + FALSE,G_PARAM_READABLE);
  663 + g_object_class_install_property(gobject_class,PROP_SELECTION,v3270_properties[PROP_SELECTION]);
652 664  
653 665 // Toggle properties
654 666 int f;
... ... @@ -844,7 +856,7 @@ static void update_connect(H3270 *session, unsigned char connected)
844 856 g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_DISCONNECTED], 0);
845 857 }
846 858  
847   - g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_CONNECTED]);
  859 + g_object_notify_by_pspec(G_OBJECT(session->widget), v3270_properties[PROP_ONLINE]);
848 860  
849 861 gtk_widget_queue_draw(GTK_WIDGET(widget));
850 862 }
... ... @@ -922,7 +934,9 @@ static void changed(H3270 *session, int offset, int len)
922 934  
923 935 static void set_selection(H3270 *session, unsigned char status)
924 936 {
925   - GtkWidget * widget = GTK_WIDGET(session->widget);
  937 + GtkWidget * widget = GTK_WIDGET(session->widget);
  938 +
  939 + g_object_notify_by_pspec(G_OBJECT(widget), v3270_properties[PROP_SELECTION]);
926 940 g_signal_emit(widget,v3270_widget_signal[SIGNAL_SELECTING], 0, status ? TRUE : FALSE);
927 941 }
928 942  
... ...