Re: [GnomeMeeting-devel-list] Gnome-vfs support for the static image loading
- From: Miguel Rodríguez Pérez <migrax terra es>
- To: gnomemeeting-devel-list gnome org
- Subject: Re: [GnomeMeeting-devel-list] Gnome-vfs support for the static image loading
- Date: Thu, 08 Apr 2004 18:35:03 +0200
Cannot reply to damien's answer, bacuse i have not received it yet
(looks like mx.terra.es is down atm :()
This patch doesn't duplicate vfakeio... I really don't know what I do
prefer, so it is your call...
El jue, 08-04-2004 a las 17:32, +0200, Miguel RodrÃguez Pérez escribió:
> Here it goes the latest version of the patch. I have corrected some
> minor coding style issues (loader_area_updated should be called
> loader_area_updated_cb) and tried to follow GM's doc style (hope I did
> get it right this time).
> I have also made the compilation optional depending on the macro
> DISABLE_GNOME. For this I created two new files vfakeio-vfs.cpp and
> vfakeio-vfs.h that replace vfakeio.cpp and vfakeio.h when DISABLE_GNOME
> is undefined.
>
> Do I commit?
>
> PS: Damien, I'm missing some mails from the list (mails I sent and the
> last mail from Craig). Can you check everything is ok? Thanks.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnomemeeting/ChangeLog,v
retrieving revision 1.1223
diff -d -u -r1.1223 ChangeLog
--- ChangeLog 7 Apr 2004 08:25:04 -0000 1.1223
+++ ChangeLog 8 Apr 2004 16:31:55 -0000
@@ -1,3 +1,12 @@
+2004-04-08 Miguel Rodríguez Pérez <migrax terra es>
+
+ * configure.in: Add explicit detection of gnome-vfs.
+
+ * src/pref_window.cpp (browse_button_clicked_cb): Accept non local files.
+
+ * src/vfakeio.cpp:
+ * src/vfakeio.h: Implement async loading of gnome-vfs uris.
+
2004-04-07 Kilian Krause <kk verfaction de>
* configure.in, lib/about/gnome-about.c, lib/about/gnome-about.h,
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gnomemeeting/configure.in,v
retrieving revision 1.266
diff -d -u -r1.266 configure.in
--- configure.in 7 Apr 2004 08:25:04 -0000 1.266
+++ configure.in 8 Apr 2004 16:31:55 -0000
@@ -79,7 +79,7 @@
PKG_CHECK_MODULES(GNOMEMEETING, gtk+-2.0 >= 2.0.6 gthread-2.0 >= 2.0.6 esound >= 0.2.28 libxml-2.0 >= 2.5.0)
GNOMEMEETING_CFLAGS="$GNOMEMEETING_CFLAGS -DDISABLE_GNOME"
else
-PKG_CHECK_MODULES(GNOMEMEETING, gtk+-2.0 >= 2.0.6 gthread-2.0 >= 2.0.6 esound >= 0.2.28 gconf-2.0 >= 1.2.1 libxml-2.0 >= 2.5.0 libgnome-2.0 >= 2.0.0 libgnomeui-2.0 >= 2.0.0)
+PKG_CHECK_MODULES(GNOMEMEETING, gtk+-2.0 >= 2.0.6 gthread-2.0 >= 2.0.6 esound >= 0.2.28 gconf-2.0 >= 1.2.1 libxml-2.0 >= 2.5.0 libgnome-2.0 >= 2.0.0 libgnomeui-2.0 >= 2.0.0 gnome-vfs-2.0 >= 2.2.0)
fi
OPENH323_REC_VERSION="1.13.4"
Index: src/pref_window.cpp
===================================================================
RCS file: /cvs/gnome/gnomemeeting/src/pref_window.cpp,v
retrieving revision 1.216
diff -d -u -r1.216 pref_window.cpp
--- src/pref_window.cpp 29 Mar 2004 18:41:40 -0000 1.216
+++ src/pref_window.cpp 8 Apr 2004 16:31:57 -0000
@@ -416,12 +416,19 @@
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
+#ifndef DISABLE_GNOME
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (selector), FALSE);
+#endif
if (gtk_dialog_run (GTK_DIALOG (selector)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
+#ifdef DISABLE_GNOME
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
+#else
+ filename = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (selector));
+#endif
gtk_entry_set_text (GTK_ENTRY (data), filename);
g_free (filename);
Index: src/vfakeio.cpp
===================================================================
RCS file: /cvs/gnome/gnomemeeting/src/vfakeio.cpp,v
retrieving revision 1.15
diff -d -u -r1.15 vfakeio.cpp
--- src/vfakeio.cpp 27 Mar 2004 18:34:52 -0000 1.15
+++ src/vfakeio.cpp 8 Apr 2004 16:31:57 -0000
@@ -48,6 +48,11 @@
#include "../pixmaps/text_logo.xpm"
+#ifndef DISABLE_GNOME
+#include <libgnomevfs/gnome-vfs.h>
+
+const size_t GMH323FakeVideoInputDevice::buffer_size = 4096;
+#endif
GMH323FakeVideoInputDevice::GMH323FakeVideoInputDevice ()
{
@@ -58,15 +63,107 @@
increment = 1;
moving = false;
+
+#ifndef DISABLE_GNOME
+ loader_pix = NULL;
+ filehandle = NULL;
+
+ buffer = new guchar [buffer_size];
+#endif
}
GMH323FakeVideoInputDevice::~GMH323FakeVideoInputDevice ()
{
Close ();
+
+#ifndef DISABLE_GNOME
+ delete[] buffer;
+#endif
}
+#ifndef DISABLE_GNOME
+void GMH323FakeVideoInputDevice::loader_area_updated_cb (GdkPixbufLoader *loader,
+ gint x, gint y, gint width,
+ gint height,
+ gpointer thisclass)
+{
+ GMH323FakeVideoInputDevice *thisc = static_cast<GMH323FakeVideoInputDevice *> (thisclass);
+
+ if (thisc->orig_pix)
+ g_object_unref (G_OBJECT (thisc->orig_pix));
+ if (thisc->cached_pix != NULL) {
+ g_object_unref (G_OBJECT (thisc->cached_pix));
+ thisc->cached_pix = NULL;
+ }
+ thisc->orig_pix = gdk_pixbuf_loader_get_pixbuf (loader);
+ g_object_ref (G_OBJECT (thisc->orig_pix));
+}
+
+void GMH323FakeVideoInputDevice::async_close_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result,
+ gpointer thisclass)
+{
+ GMH323FakeVideoInputDevice *thisc = static_cast<GMH323FakeVideoInputDevice *> (thisclass);
+
+ if (thisc->loader_pix != NULL) {
+ gdk_pixbuf_loader_close (thisc->loader_pix, NULL);
+ g_object_unref (G_OBJECT (thisc->loader_pix));
+ thisc->loader_pix = NULL;
+ }
+}
+
+void GMH323FakeVideoInputDevice::async_read_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result,
+ gpointer buffer,
+ GnomeVFSFileSize requested,
+ GnomeVFSFileSize bytes_read,
+ gpointer thisclass)
+{
+ GMH323FakeVideoInputDevice *thisc = static_cast<GMH323FakeVideoInputDevice *> (thisclass);
+
+
+ if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
+ gnome_vfs_async_close (fp, async_close_cb, thisclass);
+ return;
+ }
+
+ if (thisc->loader_pix != NULL)
+ gdk_pixbuf_loader_write (thisc->loader_pix,
+ thisc->buffer, thisc->buffer_size, NULL);
+
+ if (result == GNOME_VFS_ERROR_EOF) {
+ gnome_vfs_async_close (fp, async_close_cb, thisclass);
+ } else {
+ gnome_vfs_async_read (fp, thisc->buffer, thisc->buffer_size,
+ async_read_cb, thisclass);
+ }
+}
+
+void GMH323FakeVideoInputDevice::async_open_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result,
+ gpointer thisclass)
+{
+ GMH323FakeVideoInputDevice *thisc = static_cast<GMH323FakeVideoInputDevice *> (thisclass);
+
+
+ if (result != GNOME_VFS_OK) {
+ gnome_vfs_async_close (fp, async_close_cb, thisclass);
+ return;
+ }
+
+ gnome_vfs_async_read (fp, thisc->buffer, 4096,
+ async_read_cb, thisclass);
+}
+
+gboolean GMH323FakeVideoInputDevice::async_cancel (gpointer data)
+{
+ gnome_vfs_async_cancel ((GnomeVFSAsyncHandle *)data);
+
+ return FALSE;
+}
+#endif
BOOL
GMH323FakeVideoInputDevice::Open (const PString &name,
@@ -89,6 +186,7 @@
moving = false;
image_name = gm_conf_get_string (VIDEO_DEVICES_KEY "image");
+#ifdef DISABLE_GNOME
orig_pix = gdk_pixbuf_new_from_file (image_name, NULL);
g_free (image_name);
@@ -96,6 +194,25 @@
return TRUE;
return FALSE;
+#else
+ loader_pix = gdk_pixbuf_loader_new ();
+ g_signal_connect (G_OBJECT (loader_pix), "area-updated",
+ G_CALLBACK (loader_area_updated_cb), this);
+
+ if (orig_pix != NULL) {
+ g_object_unref (G_OBJECT (orig_pix));
+ orig_pix = NULL;
+ }
+
+ gnome_vfs_async_open (&filehandle, image_name, GNOME_VFS_OPEN_READ,
+ GNOME_VFS_PRIORITY_DEFAULT,
+ async_open_cb,
+ this);
+
+ g_free (image_name);
+
+ return TRUE;
+#endif
}
@@ -113,14 +230,27 @@
GMH323FakeVideoInputDevice::Close ()
{
gnomemeeting_threads_enter ();
- if (orig_pix != NULL)
+#ifndef DISABLE_GNOME
+ if (filehandle != NULL) {
+ g_idle_add (async_cancel, filehandle);
+ filehandle = NULL;
+ }
+ if (loader_pix != NULL) {
+ gdk_pixbuf_loader_close (loader_pix, NULL);
+ g_object_unref (G_OBJECT (loader_pix));
+ loader_pix = NULL;
+ }
+#endif
+ if (orig_pix != NULL) {
g_object_unref (G_OBJECT (orig_pix));
- if (cached_pix != NULL)
+ orig_pix = NULL;
+ }
+ if (cached_pix != NULL) {
g_object_unref (G_OBJECT (cached_pix));
+ cached_pix = NULL;
+ }
gnomemeeting_threads_leave ();
- orig_pix = NULL;
- cached_pix = NULL;
return TRUE;
}
@@ -208,6 +338,9 @@
int orig_height = 0;
GetFrameSize (width, height);
+
+ if (orig_pix == NULL)
+ return FALSE;
gnomemeeting_threads_enter ();
Index: src/vfakeio.h
===================================================================
RCS file: /cvs/gnome/gnomemeeting/src/vfakeio.h,v
retrieving revision 1.12
diff -d -u -r1.12 vfakeio.h
--- src/vfakeio.h 8 Feb 2004 21:33:38 -0000 1.12
+++ src/vfakeio.h 8 Apr 2004 16:31:57 -0000
@@ -44,12 +44,64 @@
#define P_FORCE_STATIC_PLUGIN
#include "common.h"
-
+#ifndef DISABLE_GNOME
+#include <libgnomevfs/gnome-vfs.h>
+#endif
class GMH323FakeVideoInputDevice : public PVideoInputDevice
{
PCLASSINFO(GMH323FakeVideoInputDevice, PVideoInputDevice);
+ GdkPixbuf *cached_pix;
+ GdkPixbuf *orig_pix;
+
+#ifndef DISABLE_GNOME
+ guchar *buffer;
+ static const size_t buffer_size;
+ GdkPixbufLoader *loader_pix;
+ GnomeVFSAsyncHandle *filehandle;
+
+ /* DESCRIPTION : Callback called when the loading pixbuf is updated.
+ * BEHAVIOR : Recreates orig_pix and cached_pix
+ * PRE : thisclass is a pointer to the pointer class/
+ */
+ static void loader_area_updated_cb (GdkPixbufLoader *loader,
+ gint x, gint y, gint width,
+ gint height, gpointer thisclass);
+
+ /* DESCRIPTION : Callback called to confirm close of the async operation
+ * BEHAVIOR : Frees all resouurces associated with pixbuf loading
+ * PRE : thisclass is a pointer to the pointer class/
+ */
+ static void async_close_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result, gpointer thisclass);
+
+ /* DESCRIPTION : Callback called when there is data ready to be used
+ * BEHAVIOR : Passes the read data to the pixbuf loader
+ * PRE : thisclass is a pointer to the pointer class/
+ */
+ static void async_read_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result,
+ gpointer buffer,
+ GnomeVFSFileSize requested,
+ GnomeVFSFileSize bytes_read,
+ gpointer thisclass);
+
+ /* DESCRIPTION : Callback called to confirm uri opening
+ * BEHAVIOR : Prepares the reading of data from the uri
+ * PRE : thisclass is a pointer to the pointer class/
+ */
+ static void async_open_cb (GnomeVFSAsyncHandle *fp,
+ GnomeVFSResult result, gpointer thisclass);
+
+ /* DESCRIPTION : Called from the main loop to cancel a pending gnome-async request.
+ * It seems gnome-vfs doesn't support this operation being
+ * done from a thread.
+ * BEHAVIOR : Calls gnome_vfs_async_cancel
+ * PRE : Data is the handler of the gnome-vfs operation/
+ */
+ static gboolean async_cancel (gpointer data);
+#endif
public:
@@ -182,8 +234,6 @@
PBYTEArray data;
- GdkPixbuf *orig_pix;
- GdkPixbuf *cached_pix;
bool moving;
int rgb_increment;
int pos;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]