On 12/11/2012 01:45 PM, Jakub Filak wrote:
- related to trac#916
+/* Reserve 7 bits for configuration of dialog version */
I didn't understand the above comment...
+typedef enum {
- ASK_YES_NO_SAVE_RESULT = 0x001,
It looks like you don't check this bit anywhere, you only set it sometimes. Did I miss something?
- ASK_YES_NO_YESFOREVER = 0x100,
What ASK_YES_NO_YESFOREVER means?
+} ask_yes_no_dialog_flags;
+static int run_ask_yes_no_save_generic_result_dialog(ask_yes_no_dialog_flags flags,
const char *key,
const char *message,
GtkWindow *parent)
{ const char *ask_result = get_user_setting(key);
- if (ask_result && string_to_bool(ask_result) == false)
/* Do you want to be asked? -> No, I don't. Do whatever you want */
return true;
- if (ask_result)
- {
const bool ret = string_to_bool(ask_result);
if (flags & ASK_YES_NO_YESFOREVER && ret == false)
I would use ()s: ((flags & ASK_YES_NO_YESFOREVER) && ret == false) there is a subtlety in C's precedence rules in these operators somewhere... I only remember that < > <= >= == != are safe, but &, <<, ? : etc - can't memorize those :)
/* Do you want to be asked? -> No, I don't. Do whatever you want */
return true;
return ret;
- }
+/*
- Function shows a dialog with 'Yes/No' buttons and a check box allowing to
- remember the answer. The "Don't ask me again" response is stored in
- configuration file under 'key'.
- */
The comment needs to be in *.h file. I would imagine users read _that_ file. For one, they may _miss_ *.c file on their system.
Yes, like you did it here:
--- a/src/gtk-helpers/internal_libreport_gtk.h +++ b/src/gtk-helpers/internal_libreport_gtk.h @@ -115,6 +115,24 @@ GList *find_url_tokens(const char *line); #define run_ask_yes_no_yesforever_dialog libreport_run_ask_yes_no_yesforever_dialog int run_ask_yes_no_yesforever_dialog(const char *key, const char *message, GtkWindow *parent);
+/*
- Runs a dialog with 'Yes'/'No' buttons and 'Don't ask me again' check box and
- waits until the dialog is closed. This variant of dialog allows user to
- click both of buttons if the check box is checked and stores a string which
- corresponds to an answer.
Is the answer stored always, or only if checkbox is 'checked'?
- Uses libreport's user settings. Don't forget to call load_user_settings()
- before the first call of this funcion and call save_user_settings() after
- the last call of this function.
- @param key Key under which the response is stored. Not NULL
- @param message Displayed message. Not NULL
- @param parent Transient parent or NULL
- @returns Non 0 if the answer is "Yes"; otherwise 0
- */
+#define run_ask_yes_no_save_result_dialog libreport_run_ask_yes_no_save_result_dialog +int run_ask_yes_no_save_result_dialog(const char *key, const char *message, GtkWindow *parent);
#ifdef __cplusplus } #endif