Trying out GtkSwitch widget in a form dialog

166 views
Skip to first unread message

Misko

unread,
Apr 12, 2022, 11:27:47 AM4/12/22
to yad-common
I'm trying out switch widget in a form dialog:
yad-form-switch.png
Video demo:
I most likely messed up the translations but here's code anyway

Victor Ananjevsky

unread,
Apr 12, 2022, 11:58:15 AM4/12/22
to yad-c...@googlegroups.com
hi

nice try
two comments - don't use gtk_widget_set_halign() and add description of
this field type to man page
after that please make a pull request and i'll include this feature into main code

Tue, 12 Apr 2022 08:27:47 -0700 (PDT)
Misko <mpsr...@gmail.com> написав:
--
wbr
Victor Ananjevsky <anan...@gmail.com>

Misko

unread,
Apr 12, 2022, 12:40:19 PM4/12/22
to yad-common
Without gtk_widget_set_halign()
yad.png
What happens is when using gtk_grid_attach()
it sets will set the alignment flag to GTK_ALIGN_FILL
That stretches switch widget.
gtk_widget_set_halign() makes sure the widget does not fill the whole space.
Maybe switch will not stretch if it is in another container like box?

Victor Ananjevsky

unread,
Apr 12, 2022, 1:12:38 PM4/12/22
to yad-c...@googlegroups.com

ok
if so, please comment this line with explanation why this code is needed


Tue, 12 Apr 2022 09:40:18 -0700 (PDT)
--
wbr
Victor Ananjevsky <vic...@sanana.kiev.ua>

Misko

unread,
Apr 12, 2022, 1:18:52 PM4/12/22
to yad-common

Oh, I already sent merge request without that line.

Something like this would work too

Victor Ananjevsky

unread,
Apr 12, 2022, 1:31:49 PM4/12/22
to yad-c...@googlegroups.com

well, don't worry, i'll do it by myself

Tue, 12 Apr 2022 10:18:52 -0700 (PDT)

Misko

unread,
Apr 12, 2022, 4:43:36 PM4/12/22
to yad-common
Thank you.
Some lines went down with new code so translations need an update.
I'm not experienced with translations.

For now switch is identical to check button :CHK.
But GtkSwitch emits "state-set" signal when it's activated.
Maybe it would be more useful if it's as a button and packed as a CB.

--field="switch":SW  "TRUE!bash -c 'command %b'"
where %b would be set boolean value
                                     "[initial value] ! command %current_value"

Victor Ananjevsky

unread,
Apr 13, 2022, 1:33:05 AM4/13/22
to yad-c...@googlegroups.com

hi

don't touch translations if you don't change it content. po files are actualizing and compiling
during the build process. don't touch it even if you add a translated strings to code without adding
appropriate translations

and i don't see a reasons to add a separate handler for checking switch state. it can be done by using
more common --changed-action callback

Tue, 12 Apr 2022 13:43:36 -0700 (PDT)

Misko

unread,
Apr 13, 2022, 3:08:39 AM4/13/22
to yad-common
Got it. Thanks
Reply all
Reply to author
Forward
0 new messages