Skip to content

Commit

Permalink
FIX: [GTK] issues red#4244 ([View] incorrect treatment of logical val…
Browse files Browse the repository at this point in the history
…ues in RADIO and CHECK), red#4245 ([View] CHECK treats NONE as truthy)
  • Loading branch information
9214 authored and qtxie committed May 5, 2020
1 parent 391b57a commit 5f42b0b
Showing 1 changed file with 37 additions and 14 deletions.
51 changes: 37 additions & 14 deletions modules/view/backends/gtk3/gui.reds
Original file line number Diff line number Diff line change
Expand Up @@ -1204,21 +1204,39 @@ set-selected-focus: func [
]

set-logic-state: func [
widget [handle!]
state [red-logic!]
check? [logic!]
widget [handle!]
state [red-logic!]
check? [logic!]
/local
value [integer!]
][
value: either TYPE_OF(state) <> TYPE_LOGIC [
state/header: TYPE_LOGIC
state/value: check?
either check? [-1][0]
flags [integer!]
type [integer!]
tri? [logic!]
value [logic!]
][
if check? [
flags: get-flags as red-block! (get-face-values widget) + FACE_OBJ_FLAGS
tri?: flags and FACET_FLAGS_TRISTATE <> 0
g_signal_handler_block widget check-handler ;-- suppress signal handler
]

type: TYPE_OF(state)
either all [check? tri? type = TYPE_NONE][
gtk_toggle_button_set_inconsistent widget yes
gtk_toggle_button_set_active widget no
][
as-integer state/value ;-- returns 0/1, matches the messages
value: switch type [
TYPE_NONE [false]
TYPE_LOGIC [state/value] ;-- returns 0/1, matches the messages
default [true]
]

gtk_toggle_button_set_inconsistent widget no
gtk_toggle_button_set_active widget value
]

if check? [
g_signal_handler_unblock widget check-handler ;-- resume signal handling
]
gtk_toggle_button_set_active widget as logic! value
if value = -1 [gtk_toggle_button_set_inconsistent widget true]
]

get-flags: func [
Expand Down Expand Up @@ -1256,6 +1274,7 @@ get-flags: func [
sym = no-buttons [flags: flags or FACET_FLAGS_NO_BTNS]
sym = modal [flags: flags or FACET_FLAGS_MODAL]
sym = popup [flags: flags or FACET_FLAGS_POPUP]
sym = tri-state [flags: flags or FACET_FLAGS_TRISTATE]
sym = scrollable [flags: flags or FACET_FLAGS_SCROLLABLE]
sym = password [flags: flags or FACET_FLAGS_PASSWORD]
true [fire [TO_ERROR(script invalid-arg) word]]
Expand Down Expand Up @@ -1670,7 +1689,6 @@ OS-make-view: func [
case [
sym = check [
widget: gtk_check_button_new_with_label caption
set-logic-state widget as red-logic! data no
]
sym = radio [
handle: as handle! parent
Expand Down Expand Up @@ -1898,14 +1916,19 @@ OS-make-view: func [
]

unless any [sym = window sym = area][build-context-menu widget menu]

; Deal with actors
connect-widget-events widget values sym

if sym = radio [
if last-face-type? face as handle! parent sym [
connect-radio-toggled-events face widget as handle! parent
]
]

if sym = check [
set-logic-state widget as red-logic! data yes
]

change-selection widget selected sym
change-color widget color sym
Expand Down

0 comments on commit 5f42b0b

Please sign in to comment.