GNOME Bugzilla – Bug 335763
Dialogs should be able to use custom button label text
Last modified: 2009-08-10 03:22:29 UTC
Many times an answer should be yes or no The only option I have to date is zenity --question --text "Question to be answered" results in a Cancel or Ok buttons. Can a Yes No buttons be added to Zenity's quetion? or mabe a option flage such as zenity --questionYN --text "Question to be answered" or zenity --questionOC --text "Question to be answered"
I support this request. "Cancel" is in many cases not the same as "No".
Yes/No questions are generally no good from a usability perspective. Gnome policy dictates that the text on dialog buttons should reflect the action that will be taken if the button is pressed. Research shows people don't read dialogs very well. Wrong: Do you want to delete this file? [No] [Yes] Wrong: Do you want to keep this file? [No] [Yes] Correct: Do you want to delete this file? [Cancel] [Delete]
OK, I agree. But then it should be possible to change the button text. E.g.: zenity --question --text "Do you want to delete this file? " --ok-text "Delete" Accordingly, an "--cancel-text" option or something would make sense.
I would agfree that Windows users do not read dialogs well. There are many many situations that a yes/no option would be a better choice then Ok/Cancel Consider the following script #!/bin/bash title="Aiglx Service" #Date: 3-19-2006 # Wriiten By: fedorajim@gmail.com zenity --question --text "Do you want to turn On or Off the AIGLX Service? --title="$title" if [ "$(echo $?)" == "1" ] #They clicked "no" then # Turn off the AIGLX Service gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false else # turn on the AIGLX Service gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true fi Does it make sense to click "Cancel" for this particular question? I also run FC6 Test2 and this option is obviously not available in Gnome 2.15 as now.
"Cancel" does not make sense. But neither does "No". It should be "Turn On" and "Turn Off" as button text. And if there was an Option to change the button text, one could still decide to use "Yes" and "No", if they really (!) make sense.
I agree that the ability to change the button text would be better but the above case without the ability to change the button text makes more sense than "cancel". After viewing the source files, the glade dialogs are set in stone. The only thing you can change is the title & text. SO is the option to either change the button text or create a alternate dialog a viable solution? The latter would be alot easier
since the zenity interface is created with glade and glade has a buch of options as buttons go, ( including Yes/No) anyway of calling that chunk of gtk for zenity? Or is it that zenity is not going to be refined and better to use python? which defeatsa the purpose of calling zenity in bash scripts.
Any movement on this request?
The correct fix would be to allow custom button labels. Retitling.
Another example where a --yesno dialog would make more sense is pppoeconf in debian It asks whether a list of detected interfaces is the one the user expects to have, and if No is answered it goes on to further detect things. This works with whiptail/xdialog but with gdialog/zenity it is awkward as there's no No button and the situation does not fit the Cancel/Ok scenario. I am not sure what the best way to provide compat with xdialog's --yesno option is: handle the option and have it affect the --question code by changing the glade widgets once loaded from XML, or write a completely new dialog widget.
*** Bug 430807 has been marked as a duplicate of this bug. ***
*** Bug 118015 has been marked as a duplicate of this bug. ***
Created attachment 93345 [details] [review] proposed implementation The attached patch implements what is requested here. I made question.c a separate file, so it is easier to read or modify. Also, this way it is much simpler to pass the data to the constructor called by main.c.
Created attachment 93358 [details] [review] includes icons on buttons A small update that adds corresponding cancel and ok icons on buttons.
Lucas: any opinion on this?
(In reply to comment #14) > Created an attachment (id=93358) [edit] > includes icons on buttons > > A small update that adds corresponding cancel and ok icons on buttons. Cosimo, thanks for the patch! One major issue: why creating a "question.c" when the question dialog is already defined in msg.c? You can just add the question-specific code there.
Created attachment 99018 [details] [review] proposed implementation v2 Thanks for the review, Lucas. I updated the patch to put the code directly in msg.c and fixed ugly indentation problems that my previous patch had.
Cosimo, thanks for the new patch! You don't need to create a new struct for question data (ZenityQuestionData). You just add those attributes to ZenityMsgData, no problem. This way you don't need to change zenity_msg(...) for example. Except for that, the patch is ok.
It would be very useful for Metacity if the patch was working and included. (See bug 521914.)
Created attachment 108120 [details] [review] Modified version of Cosimo's patch Here's a version which addresses your concerns.
Commited in trunk, thanks guys! It will be available on 2.23.1. 2008-03-30 Lucas Rocha <lucasr@gnome.org> Allow question dialogs to use custom button label text (Fixes bug #335763). Patch from Cosimo Cecchi <anarki@lilik.it> and Thomas Thurman <tthurman@gnome.org>. * src/msg.c (zenity_msg_construct_question_dialog), (zenity_msg): dynamically add dialog buttons with provided labels. * src/option.c (zenity_option_free): free input labels. (zenity_question_post_callback): set button labels provided by the respective command line options. * src/zenity.glade: remove pre-defined dialog button from question dialog. * src/zenity.h: added ok_label and cancel_label to ZenityMsgData.
*** Bug 553493 has been marked as a duplicate of this bug. ***