[gtkmm] Reducing duplication in bakery_gnomeui



Murray and I were working on Bakery and Bakery_gnomeui the other day,
when we ran into a snag: App_Gtk and App_GnomeUI both use the same code
for their menus, but when you virtually derive App_GnomeUI from App_Gtk,
we get a bunch of compile errors.  Here they are:

In file included from App_GnomeUI.cc:19:
../../bakery_gnomeui/App/App_GnomeUI.h:47: no unique final overrider for
`
   virtual void Glib::ObjectBase::destroy_notify_()' in
`Bakery::App_GnomeUI'
../../bakery_gnomeui/App/App_GnomeUI.h:47: no unique final overrider for
`
   virtual void Glib::ObjectBase::set_manage()' in `Bakery::App_GnomeUI'
App_GnomeUI.cc: In constructor `Bakery::App_GnomeUI::App_GnomeUI(const
   Glib::ustring&, const Glib::ustring&)':
App_GnomeUI.cc:33: no matching function for call to
`Bakery::App_Gtk::App_Gtk()
   '
/opt/gnome26/include/bakery-2.4/bakery/App/App_Gtk.h:43: candidates are:
   Bakery::App_Gtk::App_Gtk(const Bakery::App_Gtk&)
/opt/gnome26/include/bakery-2.4/bakery/App/App_Gtk.h:48:
   Bakery::App_Gtk::App_Gtk(const Glib::ustring&)
App_GnomeUI.cc:38: request for member `set_resizable' is ambiguous in
multiple
   inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:605: candidates are: void
   Gtk::Window::set_resizable(bool = true)
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:605:                 void
   Gtk::Window::set_resizable(bool = true)
App_GnomeUI.cc:39: request for member `set_default_size' is ambiguous in
   multiple inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:1145: candidates are: void
   Gtk::Window::set_default_size(int, int)
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:1145:                 void
   Gtk::Window::set_default_size(int, int)
App_GnomeUI.cc: In member function `virtual void
Bakery::App_GnomeUI::init()':
App_GnomeUI.cc:77: request for member `show_all' is ambiguous in
multiple
   inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:439: candidates are: void
   Gtk::Widget::show_all()
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:439:                 void
   Gtk::Widget::show_all()
App_GnomeUI.cc: In member function `virtual void
   Bakery::App_GnomeUI::init_menus()':
App_GnomeUI.cc:110: request for member `add_accel_group' is ambiguous in
   multiple inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:434: candidates are: void
   Gtk::Window::add_accel_group(const Glib::RefPtr<Gtk::AccelGroup>&)
/opt/gnome26/include/gtkmm-2.3/gtkmm/window.h:434:                 void
   Gtk::Window::add_accel_group(const Glib::RefPtr<Gtk::AccelGroup>&)
App_GnomeUI.cc: In member function `virtual void
   Bakery::App_GnomeUI::on_menu_help_about()':
App_GnomeUI.cc:250: `Gtk::Window' is an ambiguous base of
`Bakery::App_GnomeUI'
App_GnomeUI.cc:273: `Gtk::Window' is an ambiguous base of
`Bakery::App_GnomeUI'
App_GnomeUI.cc: In member function `virtual void
   Bakery::App_GnomeUI::ui_hide()':
App_GnomeUI.cc:336: request for member `hide' is ambiguous in multiple
   inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:433: candidates are: void
   Gtk::Widget::hide()
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:433:                 void
   Gtk::Widget::hide()
App_GnomeUI.cc: In member function `virtual void
   Bakery::App_GnomeUI::ui_bring_to_front()':
App_GnomeUI.cc:341: request for member `get_window' is ambiguous in
multiple
   inheritance lattice
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:1920: candidates are:
   Glib::RefPtr<const Gdk::Window> Gtk::Widget::get_window() const
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:1919: candidates are:
   Glib::RefPtr<Gdk::Window> Gtk::Widget::get_window()
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:1920:
   Glib::RefPtr<const Gdk::Window> Gtk::Widget::get_window() const
/opt/gnome26/include/gtkmm-2.3/gtkmm/widget.h:1919:
   Glib::RefPtr<Gdk::Window> Gtk::Widget::get_window()

I'm thinking this is because of virtual inheritance.  Here is the
inheritance chart for App_Gtk and App_GnomeUI (I put v for not virtual
and v for virtual):

    Bakery::App_GnomeUI                Bakery::App_Gtk
        v       n                          v    v
        /        \                        /      \
Bakery::App   Gnome::UI::App     Bakery::App    Gtk::Window
                 n
                 |
              Gtk::Window

App_GnomeUI and App_Gtk use the same code except for in a few places, so
we would like to reduce the code duplication.  If I change
Gnome::UI::App to virtually inherit from Gtk::Window and App_GnomeUI to
virtually inherit from App_Gtk:

                   Bakery::App_GnomeUI
                       v         n
                      /           \
            Bakery::App_Gtk   Gnome::UI::App
                      v          v
                       \        /
                       Gtk::Window

I get this error:
In file included from App_GnomeUI.cc:19:
../../bakery_gnomeui/App/App_GnomeUI.h:47: no unique final overrider for
`
   virtual void Gtk::Container::add(Gtk::Widget&)' in
`Bakery::App_GnomeUI'
make: *** [App_GnomeUI.lo] Error 1

I'm not sure what that means (since I'm still getting the idea of
virtual inheritance down).  Any help would be great!

-- 
======================================================================
Bryan Forbes
bryan reigndropsfall net
http://www.reigndropsfall.net

"It does not take a majority to prevail, but rather an irate, tireless
minority keen to set brush fires in people's minds."
        - Samuel Adams, an architect of the Constitution

Key fingerprint = 3D7D B728 713A BB7B B8B1  5B61 3888 17E0 70CA 0F3D

Attachment: signature.asc
Description: This is a digitally signed message part



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