[glade--]Bug fix for stock buttons


I ran into another bug of it not properly handling stock buttons, and
instead of creating them, it would give them the label of their stockID
(like "gtk-apply").

Below is the code that fixed it for me in my copy from CVS (pulled out


void Gtk_Button::ConstructionArgs(const Widget &w, CxxFile &f) const
{  assert(!w.hasProperty("stock_button"));

   if ((w.hasProperty("label"))&& GTKMM2 && w.hasProperty("use_stock") )
// maybe should be:
//   if ((w.hasProperty("label"))&& GTKMM2 &&
(w.getProperty("use_stock")=="True") )
// that is, if == is overloaded for the return type of getProperty()
// but it works as above because glade-2 seems to leave out that
property completely
// if it is not a stock button, but theoretically as far as XML goes,
glade-2 could write:
//	      <property name="use_stock">False</property>
// and unless, hasProperty() returned false, which would contradict the
word, "has"
// then it would improperly set it up to use a stock button, unless
written as the 2nd
// way with =="True"
      // Now I do not know if this is the preferred/correct way to
handle a stockid, but
      // it compiles, links and runs just fine (button is correct when
app is run)
      //Ex:   Gtk::Button *buttonInstance = manage(new class
      std::string label=w.getProperty("label");
      f << "Gtk::StockID(" << Configuration.Translatable(label) << ")";
   else if (w.hasProperty("label"))
   {  f.FunctionArg();
      std::string label=w.getProperty("label");
      if (GTKMM1 && label.find('_')!=std::string::npos)
         f << "\"\"";
//Ex:   Gtk::Button *buttonInstance = manage(new class
         f << Configuration.Translatable(label);
      if (GTKMM1)
#if 0 // why don't we support this?
         gfloat xalign=0.5;
         gfloat yalign=0.5; // w.getFloatProperty("xalign");
         f.FunctionArg() << xalign;
         f.FunctionArg() << yalign;
      if (GTKMM2 && label.find('_')!=std::string::npos)
//Ex:   Gtk::Button *buttonInstance = manage(new class
         f.FunctionArg() << "true";

Ximian Evolution is wrapping the lines though (at least as I write
this), so it may be hard to tell what is comments and what is not
depending on whether it is really breaking them or not.

Also, I did not test this for cases other than GTKMM2, but I think this
should work looking at the order of the if else clauses.  Hopefully this
is either the full fix, or gets you close to it.  It worked for me
though.  :)


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