After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 335763 - Dialogs should be able to use custom button label text
Dialogs should be able to use custom button label text
Status: RESOLVED FIXED
Product: zenity
Classification: Core
Component: general
2.14.x
Other Linux
: Normal normal
: ---
Assigned To: Zenity Maintainers
Zenity Maintainers
: 118015 430807 553493 (view as bug list)
Depends on:
Blocks: 521914
 
 
Reported: 2006-03-23 23:00 UTC by Jim
Modified: 2009-08-10 03:22 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
proposed implementation (10.03 KB, patch)
2007-08-09 09:58 UTC, Cosimo Cecchi
none Details | Review
includes icons on buttons (10.39 KB, patch)
2007-08-09 12:58 UTC, Cosimo Cecchi
needs-work Details | Review
proposed implementation v2 (9.79 KB, patch)
2007-11-13 10:36 UTC, Cosimo Cecchi
needs-work Details | Review
Modified version of Cosimo's patch (6.23 KB, patch)
2008-03-27 16:50 UTC, Thomas Thurman
committed Details | Review

Description Jim 2006-03-23 23:00:01 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"
Comment 1 Frederik Elwert 2006-03-26 10:39:51 UTC
I support this request. "Cancel" is in many cases not the same as "No".
Comment 2 Wouter Bolsterlee (uws) 2006-09-07 14:38:26 UTC
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]
Comment 3 Frederik Elwert 2006-09-07 15:19:32 UTC
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.
Comment 4 Jim 2006-09-07 21:55:56 UTC
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. 
Comment 5 Frederik Elwert 2006-09-07 22:08:02 UTC
"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.
Comment 6 Jim 2006-09-07 23:33:44 UTC
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 
Comment 7 Jim 2006-09-08 09:04:08 UTC
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. 
Comment 8 Jim 2007-01-04 19:39:20 UTC
Any movement on this request? 
Comment 9 Wouter Bolsterlee (uws) 2007-01-07 13:32:09 UTC
The correct fix would be to allow custom button labels. Retitling.
Comment 10 Jani Monoses 2007-01-10 10:43:58 UTC
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.
Comment 11 Lucas Rocha 2007-05-14 21:51:48 UTC
*** Bug 430807 has been marked as a duplicate of this bug. ***
Comment 12 Lucas Rocha 2007-05-14 21:53:18 UTC
*** Bug 118015 has been marked as a duplicate of this bug. ***
Comment 13 Cosimo Cecchi 2007-08-09 09:58:54 UTC
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.
Comment 14 Cosimo Cecchi 2007-08-09 12:58:41 UTC
Created attachment 93358 [details] [review]
includes icons on buttons

A small update that adds corresponding cancel and ok icons on buttons.
Comment 15 Cosimo Cecchi 2007-09-11 22:56:30 UTC
Lucas: any opinion on this?
Comment 16 Lucas Rocha 2007-11-09 23:35:58 UTC
(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.  

Comment 17 Cosimo Cecchi 2007-11-13 10:36:24 UTC
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.
Comment 18 Lucas Rocha 2008-03-17 19:06:11 UTC
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.
Comment 19 Thomas Thurman 2008-03-18 11:54:04 UTC
It would be very useful for Metacity if the patch was working and included.  (See bug 521914.)
Comment 20 Thomas Thurman 2008-03-27 16:50:51 UTC
Created attachment 108120 [details] [review]
Modified version of Cosimo's patch

Here's a version which addresses your concerns.
Comment 21 Lucas Rocha 2008-03-29 22:14:31 UTC
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.
Comment 22 Lucas Rocha 2009-08-10 03:22:29 UTC
*** Bug 553493 has been marked as a duplicate of this bug. ***