Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] (PR#13395) add_idle_callback for gui_xaw
Home

[Freeciv-Dev] (PR#13395) add_idle_callback for gui_xaw

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13395) add_idle_callback for gui_xaw
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 2 Jul 2005 10:31:36 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13395 >

This patch implements add_idle_callback for gui-xaw.  Hopefully it is
correct...

-jason

Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.131
diff -u -r1.131 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       30 Jun 2005 20:29:23 -0000      1.131
+++ client/gui-gtk-2.0/gui_main.c       2 Jul 2005 17:30:38 -0000
@@ -1670,7 +1670,7 @@
 /****************************************************************************
   A wrapper for the callback called through add_idle_callback.
 ****************************************************************************/
-static gint idle_callback_wrapper(gpointer data)
+static gint idle_callback_wrapper(XtPointer closure, XtIntervalId *id)
 {
   struct callback *cb = data;
 
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.117
diff -u -r1.117 gui_main.c
--- client/gui-xaw/gui_main.c   21 Jun 2005 16:21:00 -0000      1.117
+++ client/gui-xaw/gui_main.c   2 Jul 2005 17:30:38 -0000
@@ -905,6 +905,24 @@
   }
 }
 
+struct callback {
+  void (*callback)(void *data);
+  void *data;
+};
+
+/****************************************************************************
+  A wrapper for the callback called through add_idle_callback.
+****************************************************************************/
+static void idle_callback_wrapper(XtPointer data, XtIntervalId *id)
+{
+  struct callback *cb = data;
+
+  freelog(LOG_NORMAL, "Idle callback callback.");
+  (cb->callback)(cb->data);
+  free(cb);
+  XtRemoveTimeOut(*id);
+}
+
 /****************************************************************************
   Enqueue a callback to be called during an idle moment.  The 'callback'
   function should be called sometimes soon, and passed the 'data' pointer
@@ -912,9 +930,10 @@
 ****************************************************************************/
 void add_idle_callback(void (callback)(void *), void *data)
 {
-  /* PORTME */
+  struct callback *cb = fc_malloc(sizeof(*cb));
 
-  /* This is a reasonable fallback if it's not ported. */
-  freelog(LOG_ERROR, "Unimplemented add_idle_callback.");
-  (callback)(data);
+  freelog(LOG_NORMAL, "Idle callback.");
+  cb->callback = callback;
+  cb->data = data;
+  XtAppAddTimeOut(app_context, 0, idle_callback_wrapper, cb);
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13395) add_idle_callback for gui_xaw, Jason Short <=