Re: gtk_key_snooper_install() example

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,
   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 */

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


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