Added glib iteration inside ecore main loop, fixed wrong function definition.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:11:15 +0000 (20:11 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:09 +0000 (17:11 -0400)
FIXES:
 - Added glib iteration inside ecore main loop.
 - Fixed warning about assignment from incompatible pointer type.

Signed-off-by: Bruno Abinader <bruno.abinader@indt.org.br>
Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1279 596f6dd7-e928-0410-a184-9e12fd12cf7e

glib.pxd
purple.pyx

index d0cf22f..014a177 100644 (file)
--- a/glib.pxd
+++ b/glib.pxd
@@ -25,10 +25,12 @@ cdef extern from "glib.h":
     ctypedef gint gboolean
     ctypedef gboolean (*GSourceFunc) (gpointer data)
 
     ctypedef gint gboolean
     ctypedef gboolean (*GSourceFunc) (gpointer data)
 
-    # GHashTable is an opaque data structure
     ctypedef struct GHashTable:
         pass
 
     ctypedef struct GHashTable:
         pass
 
+    ctypedef struct GMainContext:
+        pass
+
     struct _GSList:
         gpointer data
         _GSList *next
     struct _GSList:
         gpointer data
         _GSList *next
@@ -52,4 +54,6 @@ cdef extern from "glib.h":
     guint g_timeout_add(guint interval, GSourceFunc function, gpointer data)
     guint g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
 
     guint g_timeout_add(guint interval, GSourceFunc function, gpointer data)
     guint g_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
 
+    gboolean g_main_context_iteration (GMainContext *context, gboolean may_block)
+
     gboolean g_source_remove(guint tag)
     gboolean g_source_remove(guint tag)
index 94613f2..cde5123 100644 (file)
@@ -19,6 +19,8 @@
 
 include "glib.pxd"
 
 
 include "glib.pxd"
 
+import ecore
+
 cdef extern from *:
     ctypedef char* const_char_ptr "const char *"
 
 cdef extern from *:
     ctypedef char* const_char_ptr "const char *"
 
@@ -39,7 +41,7 @@ cdef extern from "libpurple/core.h":
         void (*debug_ui_init) ()
         void (*ui_init) ()
         void (*quit) ()
         void (*debug_ui_init) ()
         void (*ui_init) ()
         void (*quit) ()
-        GHashTable (*get_ui_info) ()
+        GHashTable* (*get_ui_info) ()
 
     gboolean c_purple_core_init "purple_core_init" (const_char_ptr ui_name)
     void c_purple_core_quit "purple_core_quit" ()
 
     gboolean c_purple_core_init "purple_core_init" (const_char_ptr ui_name)
     void c_purple_core_quit "purple_core_quit" ()
@@ -119,6 +121,9 @@ cdef class Purple:
         c_purple_debug_set_enabled(debug_enabled)
         c_purple_util_set_user_dir(default_path)
         c_purple_plugins_add_search_path(default_path)
         c_purple_debug_set_enabled(debug_enabled)
         c_purple_util_set_user_dir(default_path)
         c_purple_plugins_add_search_path(default_path)
+
+        # adds glib iteration inside ecore main loop
+        ecore.idler_add(self.__glib_iteration_when_idle)
      # __cinit__
 
     def __del__(self):
      # __cinit__
 
     def __del__(self):
@@ -146,7 +151,6 @@ cdef class Purple:
     # __core_ui_ops_quit
 
     cdef GHashTable *__core_ui_ops_get_ui_info(self):
     # __core_ui_ops_quit
 
     cdef GHashTable *__core_ui_ops_get_ui_info(self):
-        # FIXME: warning: assignment from incompatible pointer type
         if self.c_ui_info == NULL:
             self.c_ui_info = g_hash_table_new(g_str_hash, g_str_equal)
 
         if self.c_ui_info == NULL:
             self.c_ui_info = g_hash_table_new(g_str_hash, g_str_equal)
 
@@ -155,6 +159,11 @@ cdef class Purple:
         return self.c_ui_info
     # __core_ui_ops_get_ui_info
 
         return self.c_ui_info
     # __core_ui_ops_get_ui_info
 
+    def __glib_iteration_when_idle(self):
+        g_main_context_iteration(NULL, False)
+        return True
+    # __glib_iteration_when_idle
+
     def purple_init(self):
         """ Initializes libpurple """
         # initialize c_core_ui_ops structure
     def purple_init(self):
         """ Initializes libpurple """
         # initialize c_core_ui_ops structure
@@ -162,7 +171,7 @@ cdef class Purple:
         self.c_core_ui_ops.debug_ui_init = <void (*)()> self.__core_ui_ops_debug_init
         self.c_core_ui_ops.ui_init = <void (*)()> self.__core_ui_ops_ui_init
         self.c_core_ui_ops.quit = <void (*)()> self.__core_ui_ops_quit
         self.c_core_ui_ops.debug_ui_init = <void (*)()> self.__core_ui_ops_debug_init
         self.c_core_ui_ops.ui_init = <void (*)()> self.__core_ui_ops_ui_init
         self.c_core_ui_ops.quit = <void (*)()> self.__core_ui_ops_quit
-        self.c_core_ui_ops.get_ui_info = <GHashTable (*)()> self.__core_ui_ops_get_ui_info
+        self.c_core_ui_ops.get_ui_info = <GHashTable* (*)()> self.__core_ui_ops_get_ui_info
 
         c_purple_core_set_ui_ops(&self.c_core_ui_ops)
 
 
         c_purple_core_set_ui_ops(&self.c_core_ui_ops)
 
@@ -194,6 +203,7 @@ cdef class Purple:
 
         # load pounces
         c_purple_pounces_load()
 
         # load pounces
         c_purple_pounces_load()
+
         return ret
     # core_init
 
         return ret
     # core_init