Re: Your opinion about "how to get data from dialog box"

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

 



Harobed <mailing@xxxxxxxxxxx> writes:

> Hello,
>
> I would like know your opinion about one choice whose for me is
> without response.
>
> For you, what is the best code design to use when you make a dialog
> box. More specify about how get the data ?

This might be OT, but I would inherit from Gtk::Dialog, and provide
get_foo() methods to get at my data.  That is:

class MyDialog : public Gtk::Dialog
{
public:
   Glib::ustring get_username() {
      return m_entry->get_text();
   }
  [...]
private:
   Gtk::Entry *m_entry;
};

and use it like so:

Glib::ustring username;
MyDialog dialog(parent_window);
int status = dialog.run();
if (status == Gtk::RESPONSE_OK)
   username = dialog.get_username();


Using plain GTK and C, you could still (potentially) inherit from
GtkDialog using GObject, and provide your own accessors to get the
data.  I've not yet tried this myself.  It looks a little more tedious
that doing it in C++, but perfectly possible.

I'd be interested to know if this is recommended, or if using signals
is preferred.  I can't see a cleaner way of doing it than using
inheritance.


-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848.  Please sign and encrypt your mail.
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux