Re: [Vala] [Genie] emulate a mouse click to trigger widget changes




On Wed, March 10, 2010 01:36, James Parkinson wrote:

How do you signal another Widget, such as changing a NoteBook Tab when you
select a menu item, especially when the widgets are defined in a glade xml
file ?

In the example code, when you click the menu item, it calls
on_menu_change_tab() as the action for that menu item.
How can this do the equivalent of  nbMain.set_current_page(4)  without
causing a Segment fault on windoze ?
[...]
      builder.connect_signals (null)
[...]
  [CCode (cname="G_MODULE_EXPORT on_menu_change_tab")]
  def on_menu_change_tab ()

There are two problems with your handler:

1) It needs to have 'instance_pos = -1' added to the CCode clause, so it
   will look like:

   [CCode (name="G_MODULE_EXPORT on_menu_change_tab", instance_pos = -1)]
   def on_menu_change_tab ()

   That will change the signature of the method to what Gtk.Builer expects.

2) You need to pass 'this' as argument to builder.connect_signals, so it
   can get passed to the handler.

3) Than just call nbMain.set_current_page(4) in the handler.

-- 
                                        - Jan Hudec <bulb ucw cz>




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