GNC error/warning dialogs

David Hampton hampton@employees.org
19 Apr 2002 13:16:47 -0700


--=-xUp7bb2UIGccv0vl6SHy
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

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 =3D _("The file \n    %s\n already exists.\n"
                            "Are you sure you want to overwrite it?");
-    char *tmpmsg;
-    gboolean result;
-
-    tmpmsg =3D g_strdup_printf (format, newfile);
-    result =3D gnc_verify_dialog (tmpmsg, FALSE);
-    g_free (tmpmsg);
=20
     /* 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.=20
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?=20

David


--=-xUp7bb2UIGccv0vl6SHy
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA8wHsvlSwHWMdNRQQRAsHjAJ44r4UWdYwjcH768SC7jLoG8aPTUACbBJlO
dh+tYxHMbiN4svc0btibZZE=
=aE3L
-----END PGP SIGNATURE-----

--=-xUp7bb2UIGccv0vl6SHy--