Re: GtkMessageDialog convenience method

	Hi, Volodya !

> It looks like GtkMessageDialog does not provide a convenience method to create 
> a message both with both primary and secondary text and run it, something 
> like:
>    GtkMessageDialog::error(
> 	window, "Something bad happened", "Check your karma");
> Instead, I need to use:
>    GtkMessageDialog d(..............);
>    d.set_secondary_text(....);
> Is the lack of such convenience method by design, or nobody ever asked for it, 
> or nobody has the right yet to implement it?

	I indeed suggested some time ago the creation of convenience functions
being in charge of creating the dialog, running it and returning. Some
of them are shown below:

/** Shows an error or information message
  @param w The window this dialog depends on
  @param msg The message to be shown
  @param msg_sec the secondary message (explanation) to be shown.
void show_ok_message(
        Gtk::Window &w,
        const Glib::ustring &msg,
        const Glib::ustring &sec_msg,
        Gtk::MessageType message_type = Gtk::MESSAGE_INFO);

/** Asks for information: prompts a dialog wth an entry box in order
  for the user to introduce the info required.
  @param title The title of the dialog
  @param requirement The main question (will appear in bold face)
  @param explanation Small help to assist the user on the info to enter
  @return an String containing the info introduced by the user. It will
          empty if the user pressed the cancel button.
Glib::ustring ask_info(
                Gtk::Window &w,
        const Glib::ustring &title,
        const Glib::ustring &requirement,
        const Glib::ustring &explanation);

	Their implementation is quite straightforward, though I've found these
functions very useful (I don't have to dive into the documentation just
for showing a message). This is, of course, not the same as overloading
constructors in order to be able to get access to all features at the
time of creation. But it's similar. If you want more complex behaviours,
then you'll have to create the dialog and deal with it as usual.

	Another possibility would be to create these functions as static
methods of Gtk::MessageDialog, this way they would be encapsulated.
Anyway, if you are interested in the source code (a .h file), don't
hesitate to contact me.

	Salud !



PBC -- J. Baltasar García Perez-Schofield
jbgarcia en uvigo de es
Dep. Informática, Universidad de Vigo, España (Spain)

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