Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am again at the same position, when I had the question What is the correct way to use g_signal_connect() in C++ for dynamic unity quicklists?

There I was informed that the signature for my static method was incorrect and that I had to add a guint argument in front of the others. Now I have the same problem but for the function called for the "scroll-event" signal that I want to make on to my indicator.

More specifically:

//connecting indicator with the scroll-event and altogether with the function indicator_scrolled
g_signal_connect(G_OBJECT(appindicator), "scroll-event", G_CALLBACK(&indicator_scrolled), (gpointer)this);

This is the function indicator_scrolled:

gboolean indicator_scrolled(GtkStatusIcon  *status_icon, GdkEventScroll *event, gpointer data){
    cout << "The indicator was scrolled\n";
    MainWindow* m = (MainWindow*)data;
    m->action_on_scroll();
}

I can see the "Indicator was scrolled" message but then the program crashed. Adding a guint argument in front of the others didn't solved the problem.

So, what is the correct signature for this function so as to make it work? How can I find what is the correct signature each time so as to avoid this kind of questions? (At the other question user George Edison talked about valgrind but he did not clarify)

Please do not advice that AppIndicators are not the correct way to go with Ubuntu+Qt, please see question Make sniqt recognize all tray abilities (or create a working indicator in Qt)

Edit: After tests I coincidentally found that a guint argument needs to be placed between the GtkStatusIcon and GdkEventScroll arguments. But I would really want to know a way to find out what is the correct function signature.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Have a look at the reference manual: http://developer.ubuntu.com/api/ubuntu-12.04/c/appindicator/libappindicator-app-indicator.html#AppIndicator-scroll-event

arg0 : The AppIndicator object
arg1 : How many steps the scroll wheel has taken
arg2 : (type Gdk.ScrollDirection) Which direction the wheel went in
user_data : user data set when the signal handler was connected.
share|improve this answer
    
I had a look at the source code of another application implementing what I wanted to and its arguments were completely different than the ones specified in the link you provided me with. Thanks for this, it works flawlessly :) –  hakermania Jan 2 '13 at 2:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.