Re: gtk_key_snooper_install() example
- From: Olexiy Avramchenko <olexiy ctech cn ua>
- To: Greg Breland <gbreland mozillanews org>
- Cc: gtk-app-devel <gtk-app-devel-list gnome org>
- Subject: Re: gtk_key_snooper_install() example
- Date: Mon, 29 Aug 2005 09:42:16 +0300
Greg Breland wrote:
I've seen this asked before a while back with no response, so I thought
I'd give it a try. Google hasn't been any help at all.
I'm trying to install a snooper and it's working just fine, but I get a
compiler type warning on the first arg of gtk_key_snooper_install() and
I'm sure I don't have it quite right. An example of how to use this
function would help a lot. Below is what I'm trying. Thanks for
any/all help.
static gint snooper_event(GtkWidget*,GdkEventKey*,AE_APPLICATION*);
gtk_key_snooper_install(&snooper_event, form->parent);
static gint snooper_event (GtkWidget *widget, GdkEventKey *event,
AE_APPLICATION *app){
printf("Event: %i\n", event->keyval);
}
1. Use typecast (GtkKeySnoopFunc) to get rid of compiler warning.
2. Place 'return' with value to snooper_event - without it key events
will disappear randomly.
-- C
#include <gtk/gtk.h>
static gboolean
snooper (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
g_print ("0x%x\n", event->keyval);
return FALSE; /* pass event further */
}
int
main (int argc, char **argv)
{
GtkWidget *window;
gtk_init (&argc, &argv);
gtk_key_snooper_install ((GtkKeySnoopFunc)snooper, 0);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), 0);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
-- C
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]