Re: Gnomified: Options, Paragraph, Font Dialogs


Subject: Re: Gnomified: Options, Paragraph, Font Dialogs
From: Joaquín Cuenca Abela (cuenca@ie2.u-psud.fr)
Date: Wed Apr 05 2000 - 08:26:39 CDT


John Tunison wrote:
>
> Hi Joaquin,
>
> Just wanted to let you know that I have gnomified all of the remaining
> dialogs I could find. I'll hold up on sending patches until we get the
> diffs straightened out. :)
>
> One question: is there a nice way to make runModal reside mostly in
> _UnixDialog_*? The only reason it needs to reappear in _UnixGnomeDialog_*
> is that the line 'GtkWidget * cf = constructWindow();' needs to point to
> the correct version of constructWindow. The niceness of having one
> runModal function becomes very clear in places like
> xap_UnixGnomeDlg_FontChooser.cpp.
>
> One option -- in UnixDialog_*, make runModal look like:
>
> void XAP_UnixGnomeDialog_FontChooser::runModal(XAP_Frame * pFrame)
> {
> _runModal(pFrame, constructWindow);
> }
>
> void XAP_UnixGnomeDialog_FontChooser::_runModal(XAP_Frame * pFrame,
> GtkWidget *(*fnptr)())
> {
> ... old runModal goes here ...
> }
>
> That way we'll only have to overwrite the three line function in
> UnixGnomeDialog_*. Are there other options? Hopefully cleaner? :)

The problem here is that the runModal changes from gtk+ to gnome (or it
has to change). Even if the result will be the same from a user point
of view, when you code for gnome and you want to make a dialog modal,
you have to write:

        gint button;

        // Supose that mainWindow is a dialog with 4 buttons...
        GtkWidget * mainWindow = _constructWindow();

        // Center the dialog, populate window's data items, etc...
        [snip]

        // And here we have how gnome a modal dialog...
        button = gnome_dialog_run_and_close (GNOME_DIALOG (mainWindow));

        switch (button) {
        case 0:
                m_answer = toto;
                break;
        case 1:
                m_answer = titi;
                break;
        case 2:
                m_answer = tata;
                break;
        case 3:
                m_answer = tete;
                break;
        case -1:
                m_answer = tutu; // The user has closed the dialog without click in
any button
                break;
        default:
                UT_ASSERT (0);
        }

Instead, in gtk+ you have to set a callback for each button. Even if
from the user point of view both (the gtk and the gnome version) will
produce the same results, I prefer to use the gnome way in the gnome
version (if you want a point of reference for a gnome version of a
dialog, see WordCount).

P.S.: You can see that except WordCount, there are no dialog boxes that
changes runModal... It's a bug, but the solution is not to share
runModal between gtk and gnome, the solution is to change runModal to
the "gnome style".

> PS. Also, while I'm getting up to speed here, what do underscores signify
> in function names for Abi? For instance, XAP_UnixDialog_FontChooser does
> not use _create_window it uses create_window, while all the AP_UnixDialog
> stuff I've seen uses _constructWindow.

The underscore signify that it's a protected/private function.

--
Joaquín Cuenca Abela
e-mail: cuenca@ie2.u-psud.fr



This archive was generated by hypermail 2b25 : Wed Apr 05 2000 - 08:28:43 CDT