diff --git a/modules/view/backends/gtk3/events.reds b/modules/view/backends/gtk3/events.reds index aeb9d94b86..85554ffcf6 100644 --- a/modules/view/backends/gtk3/events.reds +++ b/modules/view/backends/gtk3/events.reds @@ -23,9 +23,11 @@ Red/System [ gui-evt: declare red-event! ;-- low-level event value slot gui-evt/header: TYPE_EVENT -modal-loop-type: 0 ;-- remanence of last EVT_MOVE or EVT_SIZE +check-handler: 0 ;-- for blocking signal propagation during check's state update + +modal-loop-type: 0 ;-- remanence of last EVT_MOVE or EVT_SIZE zoom-distance: 0 -special-key: -1 ;-- <> -1 if a non-displayable key is pressed +special-key: -1 ;-- <> -1 if a non-displayable key is pressed flags-blk: declare red-block! ;-- static block value for event/flags flags-blk/header: TYPE_BLOCK @@ -1024,7 +1026,7 @@ connect-widget-events: func [ case [ sym = check [ - gobj_signal_connect(widget "toggled" :button-toggled widget) + check-handler: gobj_signal_connect(widget "toggled" :button-toggled widget) ;-- used to block signal ] sym = radio [ 0 diff --git a/modules/view/backends/gtk3/handlers.reds b/modules/view/backends/gtk3/handlers.reds index b3f87f7709..cb0a0e4644 100644 --- a/modules/view/backends/gtk3/handlers.reds +++ b/modules/view/backends/gtk3/handlers.reds @@ -111,22 +111,43 @@ vbar-value-changed: func [ button-toggled: func [ [cdecl] - evbox [handle!] - button [handle!] + evbox [handle!] + button [handle!] /local - bool [red-logic!] - type [integer!] - undetermined? [logic!] + values [red-value!] + bool [red-logic!] + type [red-word!] + flags [integer!] + sym [integer!] + tri? [logic!] + toggled? [logic!] + mixed? [logic!] ][ - bool: (as red-logic! get-face-values button) + FACE_OBJ_DATA - undetermined?: gtk_toggle_button_get_inconsistent button - - either undetermined? [ - type: TYPE_OF(bool) - bool/header: TYPE_NONE ;-- NONE indicates undeterminate + values: get-face-values button + bool: as red-logic! values + FACE_OBJ_DATA + type: as red-word! values + FACE_OBJ_TYPE + flags: get-flags as red-block! values + FACE_OBJ_FLAGS + + sym: symbol/resolve type/symbol + tri?: flags and FACET_FLAGS_TRISTATE <> 0 + toggled?: gtk_toggle_button_get_active button + + either all [sym = check tri?][ + mixed?: gtk_toggle_button_get_inconsistent button + if toggled? [ + gtk_toggle_button_set_inconsistent button not mixed? ;-- flip on each toggle + unless mixed? [ ;-- N Y + g_signal_handler_block button check-handler ;-- [ ] <-> [v] <-> [-] + gtk_toggle_button_set_active button no ;-- |--- emulate ---^ + g_signal_handler_unblock button check-handler + bool/header: TYPE_NONE + ] + ] ][ - bool/value: gtk_toggle_button_get_active button + bool/header: TYPE_LOGIC + bool/value: toggled? ] + make-event button 0 EVT_CHANGE ]