GNC error/warning dialogs

Derek Atkins warlord@MIT.EDU
19 Apr 2002 16:41:52 -0400


Sounds good to me.  Centralizing duplicated code is, IMHO, a good
thing.  Also, you can probably test whether a message is invariant by
checking if there are any arguments.  If there are no arguments, then
you wouldn't need to do anything special.

As far as changing the argument order, I have no problem with that,
personally, provided you do a global search-and-replace and fix all
occurances ;)

-derek

David Hampton <hampton@employees.org> writes:

> Any objection to my pushing the formatting of error/warning dialog
> message strings into the gnc_xxx_dialog() routines?  These library
> functions would grow a bit, but most of the callers of these routines
> would simplify.  This also has the benefit of consolidating all the
> logic about creating/freeing temporary strings and results into one
> location.
> 
> Here's a typical diff:
> 
> @@ -687,15 +685,9 @@
>    {
>      const char *format = _("The file \n    %s\n already exists.\n"
>                             "Are you sure you want to overwrite it?");
> -    char *tmpmsg;
> -    gboolean result;
> -
> -    tmpmsg = g_strdup_printf (format, newfile);
> -    result = gnc_verify_dialog (tmpmsg, FALSE);
> -    g_free (tmpmsg);
>  
>      /* if user says cancel, we should break out */
> -    if (!result)
> +    if (!gnc_verify_dialog (FALSE, format, newfile))
>      {
>        g_free (newfile);
>        return;
> 
> There are two drawbacks.  First, invariant messages will also be
> duplicated by the library function before the dialog is created. 
> Second, the order of the arguments to these dialog creation routines
> changes as the format string gets pushed to the end of the function call
> as the last required argument to the function.  (This last isn't a
> requirement of the compiler, but its conceptually simpler to group the
> format string and its variable number of arguments together.)  All of
> these routines would still perform compile time checking of the
> arguments to the format string.
> 
> Comments? 
> 
> David
> 

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord@MIT.EDU                        PGP key available