2013-04-10T11:27:25ZFluxBBhttps://bbs.archlinux.org/viewtopic.php?id=161186You were right Boogie, code is updated ]]>https://bbs.archlinux.org/profile.php?id=354852013-04-10T11:27:25Zhttps://bbs.archlinux.org/viewtopic.php?pid=1257136#p1257136Will see about that! Thanks for your suggestion ]]>https://bbs.archlinux.org/profile.php?id=354852013-04-10T10:27:32Zhttps://bbs.archlinux.org/viewtopic.php?pid=1257117#p1257117Is it really necessary to break; switch statement. you return just before break?

The main point being you have multiple widgets defined so you have to do something to check which one the keypress comes from.

Exactly, I get that now

]]>https://bbs.archlinux.org/profile.php?id=354852013-04-09T19:09:26Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256782#p1256782The main point being you have multiple widgets defined so you have to do something to check which one the keypress comes from.]]>https://bbs.archlinux.org/profile.php?id=432082013-04-09T18:59:16Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256775#p1256775Well, okay. Misinterpreted your code then.]]>https://bbs.archlinux.org/profile.php?id=374602013-04-09T18:46:39Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256766#p1256766SahibBommelig wrote:

One last thing: You don't need this check actually, since you could most likely do:

I cant, since I need to capture CTRL+F in view, and not in searchbar, right?

]]>https://bbs.archlinux.org/profile.php?id=354852013-04-09T18:43:14Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256761#p1256761One last thing: You don't need this check actually, since you could most likely do:

...your callback is registered by g_signal_connect, by passing a function pointer to it.

...your applications enters the gtk_main_loop() at some point.

...when the mainloop notices a key-press-event on the widget you registered the callback on, it will take your registered callback and call it with two parameters: The widget the event happened on, and the event that happened.

...The reason you have to take 2 arguments: Gtk+ demands it. If your function doesn't take 2 arguments the best thing that will happen is a crash.

]]>https://bbs.archlinux.org/profile.php?id=374602013-04-09T18:35:57Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256754#p1256754Looks to me like you need to write your keypress function a little differently, but it's been ages since I've done any gtk programming.Something like:if widget == searchbar do some stuffelse if widget == view do other stuff]]>https://bbs.archlinux.org/profile.php?id=432082013-04-09T18:31:59Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256751#p1256751SahibBommelig wrote:

You seem to have trouble to understand callbacks/gtk's event system it seems.

You don't call keypress in this snippet. You pass it as a function pointer to g_signal_connect. G_CALLBACK is just a macro that casts your function pointer into the GCallback Type, it does not call the function.keypress() gets always called once "key-press-event" happens.

I had that vague idea, yes But I'm still not getting why I need that "unused" variable *widget. My keypress() function does not use it, but it won't work without it.

]]>https://bbs.archlinux.org/profile.php?id=354852013-04-09T18:27:46Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256746#p1256746You seem to have trouble to understand callbacks/gtk's event system it seems.

You don't call keypress in this snippet. You pass it as a function pointer to g_signal_connect. G_CALLBACK is just a macro that casts your function pointer into the GCallback Type, it does not call the function.keypress() gets always called once "key-press-event" happens.

]]>https://bbs.archlinux.org/profile.php?id=374602013-04-09T18:24:54Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256745#p1256745I call keypress() from within the create_window function, like so:

]]>https://bbs.archlinux.org/profile.php?id=354852013-04-09T18:19:59Zhttps://bbs.archlinux.org/viewtopic.php?pid=1256744#p1256744You likely pass keypress() as a callback to a function, do you? Well, this function will call your function with 2 parameters. If your function can take only one bad things happen. If you're lucky your compiler may warn you, but don't rely on that - just look up what the callback is supposed to look like. The Gtk+ Docs will tell you for example.