[gok] Remove deprecated GTK+ symbols - bgo#572686
- From: Gerd Kohlberger <gerdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gok] Remove deprecated GTK+ symbols - bgo#572686
- Date: Sun, 3 May 2009 15:02:33 -0400 (EDT)
commit c87e07919e8b80add321fda5029361cd4ea6393a
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Mon Apr 27 12:45:02 2009 +0200
Remove deprecated GTK+ symbols - bgo#572686
Replace gdk_input_add and gdk_input_remove with GIOChannel.
---
gok/gtkjoyswitch.h | 8 ++++----
gok/switchapi.c | 33 +++++++++++++++++++++------------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/gok/gtkjoyswitch.h b/gok/gtkjoyswitch.h
index 85132a1..85cd019 100644
--- a/gok/gtkjoyswitch.h
+++ b/gok/gtkjoyswitch.h
@@ -1,7 +1,7 @@
-/* switchapi.h
+/* gtkjoyswitch.h
*
-* Copyright 2002 Sun Microsystems, Inc.,
-* Copyright 2002 University Of Toronto
+* Copyright 2002-2009 Sun Microsystems, Inc.,
+* Copyright 2002-2009 University Of Toronto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -36,7 +36,7 @@ typedef struct _JoySwitchData {
joystick_callback callback_up[JOYSTICK_MAXB];
joystick_callback callback_down[JOYSTICK_MAXB];
gpointer callback_data;
- gint gdktag;
+ guint source_id;
int buttons[JOYSTICK_MAXB];
} JoySwitchData;
diff --git a/gok/switchapi.c b/gok/switchapi.c
index e58aa05..c960231 100644
--- a/gok/switchapi.c
+++ b/gok/switchapi.c
@@ -1,7 +1,7 @@
/* switchapi.c
*
-* Copyright 2002 Sun Microsystems, Inc.,
-* Copyright 2002 University Of Toronto
+* Copyright 2002-2009 Sun Microsystems, Inc.,
+* Copyright 2002-2009 University Of Toronto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -41,10 +41,12 @@
#include "switchapi.h"
#include "gok-scanner.h"
#include "gok-log.h"
-
+
+#define READ_CONDITION (G_IO_IN | G_IO_HUP | G_IO_ERR)
+
#ifdef __linux__
/* static */
-static void joystick_event(gpointer data, gint fdsource, GdkInputCondition cond);
+static gboolean joystick_event (GIOChannel *channel, GIOCondition condition, gpointer data);
static JoySwitchData * joydata;
#endif
@@ -59,6 +61,7 @@ static JoySwitchData * joydata;
gint initSwitchApi()
{
#ifdef __linux__
+ GIOChannel *channel;
static gboolean bInitialized = FALSE;
gchar devname[]="/dev/js0";
gchar name[128] = "Unknown";
@@ -96,8 +99,12 @@ gint initSwitchApi()
ioctl(joydata->joystickfd, JSIOCGBUTTONS, &joydata->num_buttons);
ioctl(joydata->joystickfd, JSIOCGNAME(128), name);
joydata->device_name = g_strdup(name);
- joydata->gdktag = gdk_input_add(joydata->joystickfd, GDK_INPUT_READ, joystick_event, joydata);
-
+
+ channel = g_io_channel_unix_new (joydata->joystickfd);
+ joydata->source_id = g_io_add_watch (channel, READ_CONDITION,
+ joystick_event, joydata);
+ g_io_channel_unref (channel);
+
/* connect the switch events to the gok scanner */
if (joydata->num_buttons >= 1)
{
@@ -199,9 +206,9 @@ gint deregisterSwitchUpListener (gint switch_num) {
gint closeSwitchApi()
{
#ifdef __linux__
- if (joydata->gdktag)
+ if (joydata->source_id)
{
- gdk_input_remove(joydata->gdktag);
+ g_source_remove (joydata->source_id);
}
if (joydata->joystickfd != -1)
{
@@ -222,10 +229,11 @@ gint closeSwitchApi()
*
*
*
-* returns: Always zero.
+* returns: Always TRUE to continue watching
**/
#ifdef __linux__
-static void joystick_event(gpointer data, gint fdsource, GdkInputCondition cond)
+static gboolean
+joystick_event (GIOChannel *channel, GIOCondition condition, gpointer data)
{
struct js_event js;
int readrc;
@@ -238,7 +246,7 @@ static void joystick_event(gpointer data, gint fdsource, GdkInputCondition cond)
return;
}
- readrc = read(fdsource, &js, sizeof(struct js_event));
+ readrc = read (joydata->joystickfd, &js, sizeof(struct js_event));
if (readrc == sizeof(struct js_event))
{
if ((js.type&3) == JS_EVENT_BUTTON)
@@ -264,8 +272,9 @@ static void joystick_event(gpointer data, gint fdsource, GdkInputCondition cond)
}
else
{
- gok_log_x ("source(%d), %d bytes read\n", fdsource, readrc);
+ gok_log_x ("source(%d), %d bytes read\n", joydata->joystickfd, readrc);
}
+ return TRUE;
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]