any easy way of having a YES/NO dialog return a 1 or 0?
is there a way of having a YES/NO dialog [that asks a qauestion] return a truth value? i'm looking for something like the macro eprint(...) that James Steward sent in late december. if i eventually figured out a similar marcro that included: GTK_STOCK_YES,1, GTK_STOCK_NO, 0... would the macro pop-up a dialog with [YES] OR [NO] such that clicking the [NO] would return a 0? [YES] would obv'ly return 1. i've run into a function that calls itself recursively and i would like do have this dialog appear before the recursive call or after 10 or 15 times. thanks in advance, gary -- Gary Kline kl...@thought.org http://www.thought.org Public Service Unix Journey Toward the Dawn, E-Book: http://www.thought.org The 8.57a release of Jottings: http://jottings.thought.org Twenty-five years of service to the Unix community. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Sun, Jan 15, 2012 at 01:26:53PM -0800, Gary Kline wrote: > is there a way of having a YES/NO dialog [that asks a qauestion] > return a truth value? i'm looking for something like the macro > eprint(...) that James Steward sent in late december. Use gtk_message_dialog_new() with GTK_BUTTONS_YES_NO buttons type. Your boolean is then equal to gtk_dialog_run(dialog) == GTK_RESPONSE_YES (which also runs the dialog but you can, of course, separate the execution and comparison). > if i eventually figured out a similar marcro that included: > > GTK_STOCK_YES,1, > GTK_STOCK_NO, 0... I don't understand what stock item names have to do with this. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Sun, Jan 15, 2012 at 10:46:21PM +0100, David Ne??as wrote: > Date: Sun, 15 Jan 2012 22:46:21 +0100 > From: David Ne??as > Subject: Re: any easy way of having a YES/NO dialog return a 1 or 0? > To: Gary Kline > Cc: GTK Devel List > > On Sun, Jan 15, 2012 at 01:26:53PM -0800, Gary Kline wrote: > > is there a way of having a YES/NO dialog [that asks a qauestion] > > return a truth value? i'm looking for something like the macro > > eprint(...) that James Steward sent in late december. > > Use gtk_message_dialog_new() with GTK_BUTTONS_YES_NO buttons type. > Your boolean is then equal to > > gtk_dialog_run(dialog) == GTK_RESPONSE_YES > > (which also runs the dialog but you can, of course, separate the > execution and comparison). > > > if i eventually figured out a similar marcro that included: > > > > GTK_STOCK_YES,1, > > GTK_STOCK_NO, 0... > > I don't understand what stock item names have to do with this. > > Yeti this is why i asked the question! thank you, gary > -- Gary Kline kl...@thought.org http://www.thought.org Public Service Unix Journey Toward the Dawn, E-Book: http://www.thought.org The 8.57a release of Jottings: http://jottings.thought.org Twenty-five years of service to the Unix community. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Tue, Jan 17, 2012 at 10:53 AM, Gary Kline wrote: > On Sun, Jan 15, 2012 at 10:46:21PM +0100, David Ne??as wrote: >> Date: Sun, 15 Jan 2012 22:46:21 +0100 >> From: David Ne??as >> Subject: Re: any easy way of having a YES/NO dialog return a 1 or 0? >> To: Gary Kline >> Cc: GTK Devel List >> >> On Sun, Jan 15, 2012 at 01:26:53PM -0800, Gary Kline wrote: >> > is there a way of having a YES/NO dialog [that asks a qauestion] >> > return a truth value? i'm looking for something like the macro >> > eprint(...) that James Steward sent in late december. >> >> Use gtk_message_dialog_new() with GTK_BUTTONS_YES_NO buttons type. >> Your boolean is then equal to >> >> gtk_dialog_run(dialog) == GTK_RESPONSE_YES >> >> (which also runs the dialog but you can, of course, separate the >> execution and comparison). >> >> > if i eventually figured out a similar marcro that included: >> > >> > GTK_STOCK_YES,1, >> > GTK_STOCK_NO, 0... >> >> I don't understand what stock item names have to do with this. >> >> Yeti > > this is why i asked the question! > > thank you, Just because, curiously nobody seems to have said this already in this thread, You do realize that there is a good reason why we try to discourage people from creating "YES/NO" dialogs right ? Even in english, these boolean YES/NO questions can seem ambiguous, to the user, as specially if you start off with a macro in your code and try to form all of your questions in a way that will have a yes or no answer. But the moment you localize your application then this becomes a more serious problem, translators can easily shift the words of your dialog around to sound more natural in another language, in which case the YES/NO answer can be even more ambiguous. For instance: "Are you sure you want to quit without saving" Might come out in another language like: "Don't you want to save before you quit ?" To make things more problematic, some languages don't have words for "YES" and "NO", or they don't make sense in most english contexts. Also, in a language like Korean or Japanese, it's very confusing because very often, the opposite word than the one in english would be used. For instance, if I ask "it's not easy is it", in english one would reply "NO, its not", in Korean one would reply "YES, it's not". In any case, to avoid this ambiguity, what we do is try to always use meaningful answers to the questions we pose in dialogs. "Are you sure you want to quit without saving ?" Should typically have the answers: "Save" "Quit" Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Tue, Jan 17, 2012 at 04:12:51PM +0900, Tristan Van Berkom wrote: > Even in english, these boolean YES/NO questions can seem ambiguous, If you use wordy and convoluted questions such as > "Are you sure you want to quit without saving" then nothing can help the poor users. Of course, they are also susceptible to mistranslation. The fix is brevity and clarity, not banning Yes and No. The question Does 2+2 equal 5? is not improved by buttons labels ‘It is five’ and ‘It is some other number’. Hence >"Are you sure you want to quit without saving ?" > > Should typically have the answers: "Save" "Quit" is nonsense. This question should not occur in a sensible GUI no matter what answers are offered. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
2012/1/17 David Nečas : > On Tue, Jan 17, 2012 at 04:12:51PM +0900, Tristan Van Berkom wrote: >> Even in english, these boolean YES/NO questions can seem ambiguous, > > If you use wordy and convoluted questions such as > >> "Are you sure you want to quit without saving" > > then nothing can help the poor users. Of course, they are also > susceptible to mistranslation. The fix is brevity and clarity, not > banning Yes and No. The question > > Does 2+2 equal 5? > > is not improved by buttons labels ‘It is five’ and ‘It is some other > number’. When is the last time a program asked you that question in a dialog ? > > Hence > >> "Are you sure you want to quit without saving ?" >> >> Should typically have the answers: "Save" "Quit" > > is nonsense. This question should not occur in a sensible GUI no matter > what answers are offered. You are arguing that sensible guis should allow you to quit without warning the user that there is unsaved data ? What do you propose instead ? Are you really suggesting that we revert to unsophisticated error prone yes/no dialogs that plagued the 90s ? I think by 2012 we've learned our lessons about this. Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Tue, 17 Jan 2012, Tristan Van Berkom wrote: 2012/1/17 David Nečas : Hence "Are you sure you want to quit without saving ?" Should typically have the answers: "Save" "Quit" is nonsense. This question should not occur in a sensible GUI no matter what answers are offered. You are arguing that sensible guis should allow you to quit without warning the user that there is unsaved data ? What do you propose instead ? How about: "Do you want to save your data?" Y/N Allin Cottrell___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: any easy way of having a YES/NO dialog return a 1 or 0?
On Tue, Jan 17, 2012 at 10:33 PM, Allin Cottrell wrote: > On Tue, 17 Jan 2012, Tristan Van Berkom wrote: > >> 2012/1/17 David Nečas : >> >>> >>> Hence >>> "Are you sure you want to quit without saving ?" Should typically have the answers: "Save" "Quit" >>> >>> >>> is nonsense. This question should not occur in a sensible GUI no matter >>> what answers are offered. >> >> >> You are arguing that sensible guis should allow you to quit without >> warning the user that there is unsaved data ? >> >> What do you propose instead ? > > > How about: "Do you want to save your data?" Y/N > Yes it makes your life easier as a programmer to imagine that every question can have a simple boolean answer which can be defined as "yes" or "no", it allows you to write dialogs with one-liner macros and such. When your first language is english it almost makes sense to think this way, most of the time. Lets not start to imagine that what is easiest for the programmer is the most friendly to the user. No, not all english yes/no questions can be translated into a question that has a yes/no answer in every language. I wouldn't bet that yes/no is a suitable response to a question in most languages either. Also, consider that the yes/no text in a dialog is generally translated separately from the question, as specially in the case that you use stock responses built into GTK+, the translator then does not have the option to look at the dialog and translate one "yes" differently than another, depending on the context of the question. Anyway, I'm a bit taken aback that after years of steering away from these yes/no dialogs, we're actually arguing this at all. Most modern user interface guidelines have explicit clauses against this already, a quick 5 minutes of grepping the interweb gives me: http://ux.stackexchange.com/questions/9946/should-i-use-yes-no-or-ok-cancel-on-my-message-box http://www.user-interface.org/2005/12/23/dialog-boxes/ I know there was a clause against this in the GNOME HIG, but I've spent enough effort here already... Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list