Re: [gtkmm] Design Question



Craig Slusher <ouslush columbus rr com> writes:

> Yes, this definitely makes things a bit clearer.  The problem I am running
> across is how to let each class access the _same_ backend class and the _same_
> RefPtr object which holds the .glade info.

Although both can be achieved with references, out of curiosity, why
are you doing the latter? Grabbing only one window from the Glade file
at a time helps prevent name clashes, and libglade is caching the
widget hierarchy anyway so you shouldn't gain anything in performance.

I have a wrapper which I use for all my projects:

  // helper for loading a Glade XML file
  inline Glib::RefPtr<Gnome::Glade::Xml> get_glade_xml(Glib::ustring root)
  {
    try {
      return Gnome::Glade::Xml::create(MY_PROJECT_GLADEDIR
                                       "my-project.glade", root);
    }
    catch (Gnome::Glade::XmlError &error) {
      fatal_error(error.what());
      return Glib::RefPtr<Gnome::Glade::Xml>(); // kill warning
    }
  }

Then MY_PROJECT_GLADEDIR is defined from Makefile.am. Instantiating a
window is as simple as calling get_glade_xml("some_window") and
grabbing the widget pointers from the Gnome::Glade::Xml object it
returns.


> As to the question you raised at the end of the gnomemm email, I
> think that many people would benefit from a "Programming with
> libglademm2/gtkmm2" tutorial. I for one have been looking all over
> for at least examples as to how things are done using the two, but
> have been unsuccessful.

Hm, something else grabbed my attention. I will think about this
again. If you want a practical example, there is PrefixSuffix by
Murray Cumming (very small), on Source Forge IIRC, or perhaps even my
Hardware Monitor applet:

  http://www.cs.auc.dk/~olau/hardware-monitor/

It is actually not terribly difficult since all of the voodoo stuff is
hidden in libglade, but still it takes some time to get productive
with.

-- 
Ole Laursen
http://www.cs.auc.dk/~olau/



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