Modules and Name space



Hello!

I know I should probably be talking to the module-authors perl org but
due to the Gtk2/Gnome2 aspects I'm coming here first...

Open Door Software Inc is currently developing a Gnome2-Perl based
application for audio and data CD burning. This application will be
released under the terms of the GPL and will be included with the ODS
GNU/Linux GNOME Desktop distribution in response to general community
demands. The application is almost finished and will probably be
released before the distribution is complete. (end-of-shameless-plug
that is at least on topic as it's Perl and Gnome2 based)

The application uses Gtk2::Dialog's for giving the user feedback outside
the main UI. I've written some simple wrappers for creating and showing
these dialogs. Being that I'm the author of UI::Dialog and that one of
the TODO's on that project is to add a Gtk2 backend for displaying
extremely similar dialogs, I've opted to not implement the UI::Dialog
backend (at least for now) and instead come to this list and query
everyone's thoughts.

Before we get to my real questions, here's a quick tut on how to use
these wrappers. There are currently three dialogs implemented.
"Message"  which is a straight forward message box, ok button and
optional stock-icon placed nicely to the left of the content. "ErrorMsg"
which is just a "Message" with the default title of "Error" and
stock-icon "gtk-dialog-error". The last is "Question" which is the same
a "Message" with the exception of having "Yes" and "No" buttons.

<example>

#
# Message:
#

# Get a prepped prefab Gtk2::Dialog window with content
$message = new Message ( title => "a title",
                         icon => "gtk-dialog-info",
                         text => "Hello world" );

# display the widget and run a main loop for it
$message->show_all();
$response = $message->run();

# here's the good stuff... same as above in one line
$response = new_run Message ( %options );

# but we don't want to the window to block with a main loop so
# what want is to just show_all and continue on
new_show Message ( %options );

# however this is an error so let's make things simple:
new_show ErrorMsg ( text => "Yup, you ate the wrong burrito!" );

#
#  Question:
#

# Note: Questions always block with a call to run()
$answer = new_run Question ( title => "And?",
                             text => "So what's it going to be?" );
if ( $answer eq 'yes' ) {
    ...
} else {
    ...
}

</example>

In addition to these prefab Dialogs, there are two other modules that
may be of interest to the community.

The first is a module of constants. Nothing is exported by default and
you have the choice of individual constants or related groups of
constants. These are simple things that I've found to be creating over
and over again with GUI apps.

<from the POD>

:truth
       TRUE = 1
       FALSE = 0

:pad
       PAD_EDGE = 12
       PAD_WIDGET = 8
       PAD_ZERO = 0

:pack
       PACK_EXPAND = ( 1, 0 )
       PACK_FILL = ( 0, 1 )
       PACK_ZERO = ( 0, 0 )
       PACK_GROW = ( 1, 1 )

:align
       A_LEFT = 0.00
       A_CENTRE = 0.50
       A_RIGHT = 1.00
       A_TOP = 0.00
       A_MIDDLE = 0.50
       A_BOTTOM = 1.00

:justify
       J_LEFT = 'left'
       J_CENTRE = 'center'
       J_RIGHT = 'right'
       J_FILL = 'fill'

:policy
       P_ALWAYS = 'always'
       P_AUTO = 'automatic'
       P_NEVER = 'never'

</from the POD>

The final module has two very simple utility functions:

<code>

sub Gtk2_Main_Iteration {
    while ( events_pending Gtk2 ) {
        main_iteration Gtk2;
    }
}

sub Gtk2_Main_Quit {
    while ( events_pending Gtk2 ) {
        main_iteration Gtk2;
    }
    main_quit Gtk2;
}

</code>



So what this all boils down to is the following questions:

A) Do I tuck these things into UI::Dialog::PurePerl::Gtk2?
   (my original plan).

B) Make a separate module under a different name space, ie: Gtk2::UI::*

C) either A or B but omit the Constants and/or Utils

D) Get suggestions and implement a best fit solution


All feedback on this topic is greatly appreciated.

Thank you for your time.

-- 
Kevin C. Krinke <kckrinke opendoorsoftware com>
Open Door Software Inc.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]