gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog gui/gtk.cpp gui/gtksup.h
Date: Thu, 27 Sep 2007 19:26:04 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     07/09/27 19:26:04

Modified files:
        .              : ChangeLog 
        gui            : gtk.cpp gtksup.h 

Log message:
               * gui/gtk{.cpp,sup.h}: Introduce addFDListener, which will make 
the
                GDK event loop poll the specified file descriptor and execute 
the 
                specified callback if data is to be read from the file 
desciptor.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4449&r2=1.4450
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtk.cpp?cvsroot=gnash&r1=1.118&r2=1.119
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gtksup.h?cvsroot=gnash&r1=1.51&r2=1.52

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4449
retrieving revision 1.4450
diff -u -b -r1.4449 -r1.4450
--- ChangeLog   27 Sep 2007 17:23:17 -0000      1.4449
+++ ChangeLog   27 Sep 2007 19:26:03 -0000      1.4450
@@ -1,3 +1,9 @@
+2007-09-27 Bastiaan Jacques <address@hidden>
+
+       * gui/gtk{.cpp,sup.h}: Introduce addFDListener, which will make the
+       GDK event loop poll the specified file descriptor and execute the
+       specified callback if data is to be read from the file desciptor.
+
 2007-09-27 Sandro Santilli <address@hidden>
 
        * server/as_object.cpp (setPropFlags): properly convert the properties

Index: gui/gtk.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gtk.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- gui/gtk.cpp 27 Sep 2007 13:56:28 -0000      1.118
+++ gui/gtk.cpp 27 Sep 2007 19:26:04 -0000      1.119
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: gtk.cpp,v 1.118 2007/09/27 13:56:28 bwy Exp $ */
+/* $Id: gtk.cpp,v 1.119 2007/09/27 19:26:04 bjacques Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -359,6 +359,29 @@
     g_timeout_add(timeout, (GSourceFunc)gtk_main_quit, NULL);
 }
 
+bool
+GtkGui::addFDListener(int fd, callback_t callback, void* data)
+{
+    // NOTE: "The default encoding for GIOChannel is UTF-8. If your application
+    // is reading output from a command using via pipe, you may need to set the
+    // encoding to the encoding of the current locale (see g_get_charset())
+    // with the g_io_channel_set_encoding() function."
+
+    GIOChannel* gio_read = g_io_channel_unix_new(fd);
+    
+    if (!gio_read) {
+      return false;
+    }
+    
+    if (!g_io_add_watch (gio_read, GIOCondition(G_IO_IN | G_IO_HUP),
+                         GIOFunc (callback), data)) {
+      g_io_channel_unref(gio_read);
+      return false;    
+    }
+    
+    return true;    
+}
+
 void
 GtkGui::quit()
 {

Index: gui/gtksup.h
===================================================================
RCS file: /sources/gnash/gnash/gui/gtksup.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- gui/gtksup.h        26 Sep 2007 08:11:20 -0000      1.51
+++ gui/gtksup.h        27 Sep 2007 19:26:04 -0000      1.52
@@ -36,7 +36,7 @@
 namespace gnash
 {
 
-//typedef void (*callback_t)(int x);
+typedef bool (*callback_t)(void*, int, void *data);
 
 class DSOEXPORT GtkGui : public Gui
 {
@@ -58,6 +58,20 @@
     virtual void setInterval(unsigned int interval);
     virtual void setTimeout(unsigned int timeout);
 
+    /// Add a listener with default priority that listens for IN and HUP
+    /// events on a file descriptor.
+    //
+    /// @param fd The file descriptor to poll.
+    /// @param callback A pointer to a callback function with the following
+    ///                 signature:
+    ///        bool func(void*, int, void* data)
+    ///        The first and second arguments should be ignored.
+    ///        The last argument is a user-specified pointer. The
+    ///        callback should return false if the listener is to be removed.
+    /// @param data A pointer to a user-defined data structure.
+    /// @return true on success, false on failure.
+    bool addFDListener(int fd, callback_t callback, void* data);
+
     /// Create a menu bar for the application, attach to our window. 
     //  This should only appear in the standalone player.
     bool createMenuBar();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]