Re: Help on compiling notebook example




Hi,
INMOAP (I'm not much of a programmer), but
Answer 1: Murray is (nearly always) right- don't use testing unless you like broken things.  It's on a website containing the phrase unstable, after all...so the manual is a work in progress.
Answer 2: your bottom line says it all.

The problem with the function is ( sort of ) stated: if you scroll down, you get to
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103: error: return-statement with a value, in function returning 'void'

And when you look again, your call is
  m_Notebook.signal_switch_page().connect(sigc::mem_fun(*this, &ExampleWindow::on_notebook_switch_page) );
But the function you're connecting to is declared as
void ExampleWindow::on_notebook_switch_page(Gtk::Widget* /* page */, guint page_num)

which means that when the function is called, it wants a page widget and a page number passed to it- which isn't happening.

If you want to make it work, you have two options.  Either change the function so it doesn't require anything passed to it, or use sigc::bind to pass the information to it.  The information you're trying to pass is accessible through the notebook itself, so passing it with sigc::bind would seem a good way to introduce unnecessary complexity.  Seeing there's only 2 pages, you could try something like:
void ExampleWindow::on_notebook_switch_page(/*no parameters passed*/)
{   
    int curr = m_Notebook.get_current_page ();
    m_Notebook.next_page();
    if(curr == m_Notebook.get_current_page ()){
        m_Notebook.prev_page ();
    }
}

and see if that compiles ( you'd also have to remove the parameters in the declaration).

Ian
   

From: Chun Yang <achunyang2010 gmail com>
To: gtkmm-list gnome org
Sent: Tue, 19 October, 2010 6:19:30 PM
Subject: Help on compiling notebook example

Hello,

I am not sure this is the correct way to get help on gtkmm GUI program. Please let me know.

I am having a compiling error when compiling the notebook example on the following web-page.
       http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-multi-item-containers.html.en#sec-notebook

This is offendinf code:

  m_Notebook.signal_switch_page().connect(sigc::mem_fun(*this,
              &ExampleWindow::on_notebook_switch_page) );

Here is the compilation errors:
**********************************************************************************************
[chun localhost notebook]$ make
g++ -o obj/Linux/examplewindow.o -c -Iinc `pkg-config gtkmm-2.4 --cflags` src/examplewindow.cpp
In file included from /usr/include/sigc++-2.0/sigc++/functors/slot.h:7,
                 from /usr/include/sigc++-2.0/sigc++/signal_base.h:28,
                 from /usr/include/sigc++-2.0/sigc++/signal.h:8,
                 from /usr/include/sigc++-2.0/sigc++/sigc++.h:23,
                 from /usr/include/glibmm-2.4/glibmm/signalproxy.h:13,
                 from /usr/include/glibmm-2.4/glibmm/objectbase.h:23,
                 from /usr/include/glibmm-2.4/glibmm/wrap.h:26,
                 from /usr/include/glibmm-2.4/glibmm/containerhandle_shared.h:25,
                 from /usr/include/glibmm-2.4/glibmm/arrayhandle.h:23,
                 from /usr/include/glibmm-2.4/glibmm.h:27,
                 from /usr/include/gtkmm-2.4/gtkmm.h:29,
                 from inc/examplewindow.h:4,
                 from src/examplewindow.cpp:2:
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h: In member function ‘typename sigc::adaptor_functor<T_functor>::deduce_result_type<T_arg1, T_arg2, void, void, void, void, void>::type sigc::adaptor_functor<T_functor>::operator()(T_arg1, T_arg2) const [with T_arg1 = GtkNotebookPage* const&, T_arg2 = const unsigned int&, T_functor = sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>]’:
/usr/include/sigc++-2.0/sigc++/functors/slot.h:173:   instantiated from ‘static T_return sigc::internal::slot_call2<T_functor, T_return, T_arg1, T_arg2>::call_it(sigc::internal::slot_rep*, typename sigc::type_trait<T_arg3>::take, typename sigc::type_trait<T_arg4>::take) [with T_functor = sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>, T_return = void, T_arg1 = GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:180:   instantiated from ‘static void* (* sigc::internal::slot_call2<T_functor, T_return, T_arg1, T_arg2>::address())(void*) [with T_functor = sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>, T_return = void, T_arg1 = GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:607:   instantiated from ‘sigc::slot2<T_return, T_arg1, T_arg2>::slot2(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>, T_return = void, T_arg1 = GtkNotebookPage*, T_arg2 = unsigned int]’
/usr/include/sigc++-2.0/sigc++/functors/slot.h:1184:   instantiated from ‘sigc::slot<T_return, T_arg1, T_arg2, sigc::nil, sigc::nil, sigc::nil, sigc::nil, sigc::nil>::slot(const T_functor&) [with T_functor = sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>, T_return = void, T_arg1 = GtkNotebookPage*, T_arg2 = unsigned int]’
src/examplewindow.cpp:30:   instantiated from here
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103: error: no match for call to ‘(sigc::bound_mem_functor2<void, ExampleWindow, Gtk::Widget*, unsigned int>) (GtkNotebookPage* const&, const unsigned int&)’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1916: note: candidates are: T_return sigc::bound_mem_functor2<T_return, T_obj, T_arg1, T_arg2>::operator()(typename sigc::type_trait<T_arg3>::take, typename sigc::type_trait<T_arg4>::take) const [with T_return = void, T_obj = ExampleWindow, T_arg1 = Gtk::Widget*, T_arg2 = unsigned int]
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103: error: return-statement with a value, in function returning 'void'
make: *** [obj/Linux/examplewindow.o] Error 1
[chun localhost notebook]$
---------------------------------------------------------------------------------------------------------------------------------------------

Thanks,
Chun



 

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