Re: [GnomeMeeting-devel-list] Gnome-vfs support for the static image loading



Here it goes the patch. Please test.

El mié, 07-04-2004 a las 19:04, +0200, Miguel Rodríguez Pérez escribió:

> I have a pseudo-patch written that adds gnome-vfs support for loading
> the static image. 
> With the new gnome file-selector there is support for opening files in
> remote shares (windows shares, sftp shares, whatever they may come). The
> patch makes those shares appear in the file dialog and loads the image
> asynchronously so as not to block the UI is the network connection is
> slow.
> 
> So my question is: Is this feature wanted? If it is a can clean the
> patch and post it here for revision.
> -- 
> Miguel Rodríguez Pérez <migrax terra es>
> 
> _______________________________________________
> Gnomemeeting-devel-list mailing list
> Gnomemeeting-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnomemeeting-devel-list
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 11:07:33 -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 11:07:33 -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 11:07:33 -0000
@@ -416,12 +416,13 @@
 					  GTK_STOCK_OPEN,
 					  GTK_RESPONSE_ACCEPT,
 					  NULL);
+  gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (selector), FALSE);
   
   if (gtk_dialog_run (GTK_DIALOG (selector)) == GTK_RESPONSE_ACCEPT)
   {
     char *filename;
 
-    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (selector));
+    filename = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (selector));
     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 11:07:33 -0000
@@ -34,6 +34,7 @@
  *   description          : This file contains a descendant of a Fake Input 
  *                          Device that display the GM logo when connected to
  *                          a remote party without using a camera.
+ *   Additional code      : Miguel Rodríguez Pérez  <migrax terra es> 
  *
  */
 
@@ -47,26 +48,113 @@
 #include "gm_conf.h"
 
 #include "../pixmaps/text_logo.xpm"
+#include <libgnomevfs/gnome-vfs.h>
 
+const size_t GMH323FakeVideoInputDevice::buffer_size = 4096;
 
 GMH323FakeVideoInputDevice::GMH323FakeVideoInputDevice ()
 {
   orig_pix = NULL;
   cached_pix = NULL;
+  loader_pix = NULL;
+  filehandle = NULL;
 	
   pos = 0;
   increment = 1;
 
   moving = false;
+
+  buffer = new guchar [buffer_size];
 }
 
 
 GMH323FakeVideoInputDevice::~GMH323FakeVideoInputDevice ()
 {
   Close ();
+
+  delete[] buffer;
+}
+
+void GMH323FakeVideoInputDevice::loader_area_updated (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;
+}
 
 BOOL
 GMH323FakeVideoInputDevice::Open (const PString &name,
@@ -89,13 +177,23 @@
   moving = false;
   
   image_name = gm_conf_get_string (VIDEO_DEVICES_KEY "image");
-  orig_pix =  gdk_pixbuf_new_from_file (image_name, NULL);
-  g_free (image_name);
+  loader_pix = gdk_pixbuf_loader_new ();
+  g_signal_connect (G_OBJECT (loader_pix), "area-updated",
+		    G_CALLBACK (loader_area_updated), this);
 
-  if (orig_pix) 
-    return TRUE;
+  if (orig_pix != NULL) {
+    g_object_unref (G_OBJECT (orig_pix));
+    orig_pix = NULL;
+  }
 
-  return FALSE;
+  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;
 }
 
 
@@ -113,15 +211,25 @@
 GMH323FakeVideoInputDevice::Close ()
 {
   gnomemeeting_threads_enter ();
-  if (orig_pix != NULL)
+  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;
+  }
+  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 +316,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 11:07:33 -0000
@@ -34,6 +34,7 @@
  *   description          : This file contains a descendant of a Fake Input 
  *                          Device that display the GM logo when connected to
  *                          a remote party without using a camera.
+ *   Additional code      : Miguel Rodríguez Pérez  <migrax terra es> 
  *
  */
 
@@ -44,12 +45,42 @@
 #define P_FORCE_STATIC_PLUGIN
 
 #include "common.h"
+#include <libgnomevfs/gnome-vfs.h>
 
  
 class GMH323FakeVideoInputDevice : public PVideoInputDevice 
 {
   PCLASSINFO(GMH323FakeVideoInputDevice, PVideoInputDevice);
+  guchar *buffer;
+  static const size_t buffer_size;
+  GdkPixbuf *cached_pix;
+  GdkPixbuf *orig_pix;
+  GdkPixbufLoader *loader_pix;
+  GnomeVFSAsyncHandle *filehandle;
 
+  /**Updates orig_pix and cached_pix with newly arrived data
+  */  
+  static void loader_area_updated (GdkPixbufLoader *loader,
+				   gint x, gint y, gint width,
+				   gint height, gpointer thisclass);
+  /**Called whenever image file has been fully loaded
+  */  
+  static void async_close_cb (GnomeVFSAsyncHandle *fp,
+			      GnomeVFSResult result, gpointer thisclass);
+  /**Called when there is more data read from the file
+  */  
+  static void async_read_cb (GnomeVFSAsyncHandle *fp,
+			     GnomeVFSResult result, 
+			     gpointer buffer,
+			     GnomeVFSFileSize requested,
+			     GnomeVFSFileSize bytes_read,
+			     gpointer thisclass);
+  /**Called when the open call finishes
+  */  
+  static void async_open_cb (GnomeVFSAsyncHandle *fp,
+			     GnomeVFSResult result, gpointer thisclass);
+  /* Needed to call gnome_async_cancel from the main thread */
+  static gboolean async_cancel (gpointer data);
   
  public:
   
@@ -182,8 +213,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]