Friday, May 3, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1135  / 1 Year ago, fri, november 18, 2022, 3:36:42

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
";
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.


More From » application-development

 Answers
0

Have a look at the reference manual: https://web.archive.org/web/20130604060558/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.

[#33422] Friday, November 18, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
errettas

Total Points: 160
Total Questions: 118
Total Answers: 91

Location: Laos
Member since Fri, Sep 11, 2020
4 Years ago
;