Re: Attaching a signal handler to menus created by hand - Not using UI Manager or Menu Helper methods



instead of :
file_new.signal_activate().connect(*this,
sigc::mem_fun(&Edm_Main_Menu::OnFileNew));

try:
file_new.signal_activate().connect(
    sigc::mem_fun(*this, &Edm_Main_Menu::OnFileNew));

Hope that helps.
Rob.

On 6/28/05, Jason Alan Smith <jsmith435 cox net> wrote:
> Hello, I have an application I'm writing trying to create the menus by
> hand, not using the UIManager or the menuhelpers, mainly cause I want to
> be able to do it first the "hard" way and then use the easy ways.
> 
> I've attached some of the code I'm having problems with below along with
> the errors I get.
> 
> My Question is how do I attach a signal handler by hand to a menu
> activate signal?  I've searched the archives and did a little searching
> but could not find anything.  I've also checked the sample apps in the
> gtkmm source but they all seem to use the "easy" methods.
> 
> A pitcher of virtual beer to anyone who can help!  Thanks much in
> advance!
> 
> Jason
> 
> 
> **********************************************************
> Source Code Follows:
> **********************************************************
> 
> Edm_Main_Menu::Edm_Main_Menu()
> {
>         file_menu("File"),
>         file_new("New"),
>         file_open("Open"),
>         file_save("Save"),
>         file_save_as("Save As"),
>         file_close("Close"),
>         file_exit("Exit")
> 
>         menu.append(file_new);
>         menu.append(file_open);
>         menu.append(file_save);
>         menu.append(file_save_as);
>         menu.append(file_close);
>         menu.append(file_exit);
> 
>         file_menu.set_submenu(menu);
>         append(file_menu);
> 
>         file_new.signal_activate().connect(*this,
> sigc::mem_fun(&Edm_Main_Menu::OnFileNew));
> 
>     show_all_children();
> }
> 
> gives:
> 
> Edm_Main_Menu.cxx: In constructor 'Edm_Main_Menu::Edm_Main_Menu()':
> Edm_Main_Menu.cxx:32: error: no matching function for call to
> 'Glib::SignalProxy0<void>::connect(Edm_Main_Menu&,
> sigc::mem_functor0<void, Edm_Main_Menu>)'
> /usr/include/glibmm-2.4/glibmm/signalproxy.h:145: note: candidates are:
> sigc::connection Glib::SignalProxy0<R>::connect(const
> sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil, sigc::nil>&, bool) [with R = void]
> 
> **********************************************************
> also tried without the *this in the file_new.signal... line and got
> this:
> **********************************************************
> 
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member
> function 'typename sigc::adaptor_functor<T_functor>::result_type
> sigc::adaptor_functor<T_functor>::operator()() const [with T_functor =
> sigc::mem_functor0<void, Edm_Main_Menu>]':
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:103:   instantiated from
> 'static T_return sigc::internal::slot_call0<T_functor,
> T_return>::call_it(sigc::internal::slot_rep*) [with T_functor =
> sigc::mem_functor0<void, Edm_Main_Menu>, T_return = void]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:110:   instantiated from
> 'static void* (* sigc::internal::slot_call0<T_functor,
> T_return>::address())(void*) [with T_functor = sigc::mem_functor0<void,
> Edm_Main_Menu>, T_return = void]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:454:   instantiated from
> 'sigc::slot0<T_return>::slot0(const T_functor&) [with T_functor =
> sigc::mem_functor0<void, Edm_Main_Menu>, T_return = void]'
> /usr/include/sigc++-2.0/sigc++/functors/slot.h:1130:   instantiated from
> 'sigc::slot<T_return, sigc::nil, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor
> = sigc::mem_functor0<void, Edm_Main_Menu>, T_return = void]'
> Edm_Main_Menu.cxx:32:   instantiated from here
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251: error: no
> match for call to '(sigc::mem_functor0<void, Edm_Main_Menu>) ()'
> /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:94: note: candidates
> are: T_return sigc::mem_functor0<T_return, T_obj>::operator()(T_obj*)
> const [with T_return = void, T_obj = Edm_Main_Menu]
> /usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:101: note:
> T_return sigc::mem_functor0<T_return, T_obj>::operator()(T_obj&) const
> [with T_return = void, T_obj = Edm_Main_Menu]
> /usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:251: error:
> return-statement with a value, in function returning 'void'
> 
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>



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