[glade--]Fix for set_size_request

Mark Jones <[email protected]>
Newsgroups gmane.comp.gnome.glademm
Message-ID <20021023052630.WKDN4740.out005.verizon.net@[127.0.0.1]>
I looked into this tonight.  There are two things missing related to size and positioning (that I see):

1.  Set size request not written.  The source of this is in: writers/widget.cc (line 85)

void Gtk_Widget::Configure(const Widget &w, CxxFile &f,const std::string &instance) const
{ 

....some lines of code here
// then:
  WriteIntIntProperty(w,f,instance, "width", "height", 
  	GTKMM2?"size_request":"usize");
// Should be:
  WriteIntIntProperty(w,f,instance, GTKMM2?"width_request":"width", GTKMM2?"height_request":"height", 
  	GTKMM2?"size_request":"usize");

With this change it works for Gtkmm2.

But, it needs to have the call to Fixed::put give the right values of x and y for a widget on a fixed container.  Right now it prints 0 and 0.  However, if you change the .glade file around a little, it then works.  So perhaps it is not reading the .glade file correctly?

Old glade section (glade-- prints 0's):
	      <child>
		<widget class="GtkSpinButton" id="spinbutton1">
		  <property name="width_request">112</property>
		  <property name="height_request">32</property>
		  <property name="visible">True</property>
		  <property name="can_focus">True</property>
		  <property name="climb_rate">1</property>
		  <property name="digits">0</property>
		  <property name="numeric">False</property>
		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
		  <property name="snap_to_ticks">False</property>
		  <property name="wrap">False</property>
		  <property name="adjustment">1 0 100 1 10 10</property>
		</widget>
		<packing>
		  <property name="x">8</property>
		  <property name="y">80</property>
		</packing>
	      </child>


Alternate glade section (glade-- prints the correct values for x and y):
	      <child>
		<widget class="GtkSpinButton" id="spinbutton1">
		  <property name="width_request">112</property>
		  <property name="height_request">32</property>
		  <property name="visible">True</property>
		  <property name="can_focus">True</property>
		  <property name="climb_rate">1</property>
		  <property name="digits">0</property>
		  <property name="numeric">False</property>
		  <property name="update_policy">GTK_UPDATE_ALWAYS</property>
		  <property name="snap_to_ticks">False</property>
		  <property name="wrap">False</property>
		  <property name="adjustment">1 0 100 1 10 10</property>
		  <property name="x">8</property>
		  <property name="y">80</property>
		</widget>
		<packing>
		  <property name="x">8</property>
		  <property name="y">80</property>
		</packing>
	      </child>


You'll notice I just copied the properties out of the packing section to the section above.  Then it finds them as properties when it looks for them in writers/fixed.cc:
void Gtk_Fixed::AddChild(const Widget &w,CxxFile &f,const std::string &instance) const
{  int x=w.getIntProperty("x",0);
   int y=w.getIntProperty("y",0);

I am not sure what is wrong here, whether glade is writing the xml wrong, or whether glade-- is not parsing it right, or if the code above should call something other than getIntProperty().

The line of code it produces in the whatever_glade.cc file is (in case that was not clear):
   fixed1->put(*spinbutton1, 8, 80);

Mark
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.