Re: [gtkmm] Preferred method to access glade objects within gtkmm

Chris Haidinyak wrote:
> Hi,
>    I know this must have come up before but I cannot seem to find an
> answer. I have several dialog objects built in glade-2 and I want to tie
> them into the main window menu handling system. The trouble seems to be
> that the glade-- program puts the definition of these objects in the
> project scope instead of the main window scope.

I looked at glade-- and had similar questions. I chose to use glade to create my user interface, and use glademm to read in the interface.

In my system the main window has the menu, and when the user selects a menu item, I create the window at that time:

void winMain::on_menuPOReview_activate()
    if (!poReview)
        poReview = new winPOReview();

The winPOReview object reads its own glade file to define its window.

class winPOReview : public Gtk::Window

        winPOReview ();

        virtual void on_show();

        Glib::RefPtr<Gnome::Glade::Xml> m_refGlade;

        // Widgets
        Gtk::Entry *txtStartDate;
        Gtk::Entry *txtEndDate;
        Gtk::TreeView *tvPOList;

    m_refGlade = Gnome::Glade::Xml::create(
        config.gladePath + "order/");

    m_refGlade->reparent_widget("vbox1", *this);

    // When the original glade window is reparented to this window
    // object, we loose the old window settings. So, we just copy
    // the settings from the old window to this window.
    Gtk::Window *original;
    m_refGlade->get_widget ("winPOReview", original);

    this->set_title        (original->property_title());
    this->set_modal        (original->property_modal());
    this->set_position     (original->property_window_position());
    this->set_size_request (original->property_default_width(),
    this->set_icon         (original->property_icon());
    this->set_resizable    (original->property_resizable());

    m_refGlade->get_widget ("tvPOList", tvPOList);
    if (tvPOList)
        poList = new ucPOList(tvPOList);

    btnPrint = 0;
    m_refGlade->get_widget ("btnPrint", btnPrint);
    if (btnPrint)
          connect(SigC::slot(*this, &winPOReview::on_btnPrint_clicked

> Is there a preferred
> method of accessing this data from within the main window class?
> Surprisingly, I cannot find a single application out there which
> utilizes gtkmm (c++)  AND glade-2 AND multiple dialog objects. I
> definitely want to learn how it is done if there is a suggested
> methodology. Please advise; thanks.

I searched HARD for a methodology too and did not find one. However, we ended up copying and expanding the methodology that we used when developing in VB and it has worked very well for us.

> Also, if there is a class of example programs which tie together
> multiple objects across source files, please point me in the right
> direction.

If you have developed GUI applications before, you should consider adapting your previous methodology. I have worked on a few large and several small software projects and a common lesson learned in ALL of these projects is this:

   The TOOL does not write software, a PERSON writes software!

Don't get caught up in writing software around some code from the latest fancy code generator. Code generators are fine for getting started, but when you need to write the meat of the project, the generated code starts to get in the way.

> Best Regards,
>  Chris Haidinyak

Good luck!  Let us know what you learn!

Jeffrey S. Gavin

> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org

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