[glade--]OptionMenu doesn't work with gtkmm 1.3.17 (patch)

"Marcelo E. Magallon" <[email protected]>
Newsgroups gmane.comp.gnome.glademm
Message-ID <[email protected]>
Hi,

 I hope this list let's me post without being subscribed to it.

 The option menu writer in current CVS does something like this:

 Gtk::Menu *menu1 = manage(new class Gtk::Menu());
 Gtk::OptionMenu *optionmenu1 = manage(new class Gtk::OptionMenu());
 Gtk::MenuItem *all1 = NULL;
 menu1->items().push_back(Gtk::Menu_Helpers::MenuElem("All"));
 all1 = (Gtk::MenuItem *)&menu1->items().back();
 optionmenu1->set_flags(Gtk::CAN_FOCUS);
 optionmenu1->add(*menu1);

 that last line is the problem.  GTK+ complains loudly about reparenting
 that menu1 and the end result doesn't work.  The correct call would be:

 optionmenu1->set_menu(*menu1);

 I have patched writers/optionmenu.cc to do this.  I'm not sure how to
 handle the gtkmm 1 case.  I suppose the current code works for that
 case, so it'd be something like:

 GTKMM2 ? "set_menu(" : "add("

 HTH,

 Marcelo
glademm.diff (text/plain, 1.4 KB)
Index: src/writers/optionmenu.cc
===================================================================
RCS file: /cvs/gnome/glade--/src/writers/optionmenu.cc,v
retrieving revision 1.39
diff -u -r1.39 optionmenu.cc
--- src/writers/optionmenu.cc	15 Jun 2002 13:22:14 -0000	1.39
+++ src/writers/optionmenu.cc	10 Jul 2002 20:42:10 -0000
@@ -35,6 +35,7 @@
 	virtual void GCInclude(const Widget &w, CxxFile &f) const;
 	virtual void AdditionalMemberVars(const Widget &w,CxxFile &f,bool container=false) const;
 	virtual void Configure(const Widget &w, CxxFile &f,const std::string &instance) const;
+	virtual void AddChild(const Widget &w,CxxFile &f,const std::string &instance) const;
 	virtual bool NeedExplicitCtor(const Widget &w) const
 	{  return false; }
 	virtual void ConstructionArgs(Widget const &w, CxxFile &f) const
@@ -126,5 +127,15 @@
       f.Statement() << name << "->set_history("<<initial_choice <<')';
       f.EndBlock();
    }
+}
+
+void Gtk_OptionMenu::AddChild(const Widget &w,CxxFile &f,const std::string &instance) const
+{  const std::string cn=w.ChildName();
+   if (!cn.empty())
+   {  std::cerr << "Warning: Gtk_Container::AddChild(" << w.Name() << ",,"
+           << instance << ") with child name " << cn
+           << ",\n\t" << TypeName(w) << "::IsSubwidget() might need fixing\n";
+   }
+   f.Statement() << instance << "set_menu(" << Reference(w) << ')';
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.