Author: ArcRiley
Date: 2009-01-07 00:04:56 -0500 (Wed, 07 Jan 2009)
New Revision: 1430

Modified:
   trunk/concordance/src/utils.c
   trunk/concordance/src/utils.h
Log:
split conAddWatch() from conAddSocket() so new IO watches can be added
conAddSocket() functions the same as it did


Modified: trunk/concordance/src/utils.c
===================================================================
--- trunk/concordance/src/utils.c       2009-01-06 19:01:34 UTC (rev 1429)
+++ trunk/concordance/src/utils.c       2009-01-07 05:04:56 UTC (rev 1430)
@@ -25,8 +25,7 @@
 conAddSocket(gint fd, GIOCondition condition, GSourceFunc callback,
              gpointer data, GMainContext* context) {                      /*\
   cdef :                                                                  \*/
-    GIOChannel* newChannel;
-    GSource*    newSource;
+    GIOChannel* channel;
 
   /* create a new channel using an OS-dependent function
 
@@ -34,14 +33,28 @@
      GIOChannel*       g_io_channel_unix_new         (gint fd);
   */
   #ifdef MS_WINDOWS
-    newChannel = g_io_channel_win32_new_socket(fd);
+    channel = g_io_channel_win32_new_socket(fd);
   #else
-    newChannel = g_io_channel_unix_new(fd);
+    channel = g_io_channel_unix_new(fd);
   #endif
 
-  /* add this channel to our context watch
+  /* See below */
+  conAddWatch(channel, condition, callback, data, context);  
 
-     Note that this block is a replacement for g_io_add_watch() which
+  return channel;
+}
+
+
+gint
+conAddWatch(GIOChannel* channel, GIOCondition condition, GSourceFunc callback,
+            gpointer data, GMainContext* context) {                       /*\
+  cdef :                                                                  \*/
+    GSource* source;
+    guint    id;
+
+  /* add a channel to our context watch
+
+     Note that this function is a replacement for g_io_add_watch() which
      uses our own context rather than the default context.
 
      GSource *    g_io_create_watch        (GIOChannel *channel,
@@ -53,8 +66,9 @@
      guint        g_source_attach          (GSource *source,
                                             GMainContext *context);
   */
-  newSource = g_io_create_watch(newChannel, condition);
-  g_source_set_callback(newSource, callback, data, NULL);
-  g_source_attach(newSource, context);
-  return newChannel;
+  source = g_io_create_watch(channel, condition);
+  g_source_set_callback(source, callback, data, NULL);
+  id = g_source_attach(source, context);
+  g_source_unref(source);
+  return id;
 }

Modified: trunk/concordance/src/utils.h
===================================================================
--- trunk/concordance/src/utils.h       2009-01-06 19:01:34 UTC (rev 1429)
+++ trunk/concordance/src/utils.h       2009-01-07 05:04:56 UTC (rev 1430)
@@ -21,3 +21,5 @@
 
 GIOChannel* conAddSocket(gint fd, GIOCondition condition, GSourceFunc callback,
                          gpointer data, GMainContext* context);
+gint conAddWatch(GIOChannel* channel, GIOCondition condition, 
+                 GSourceFunc callback, gpointer data, GMainContext* context);

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to