Date: Thursday, April 22, 2010 @ 10:44:36
  Author: jgc
Revision: 78365

Add GIO port patch for genius. This should get rid of GnomeVFS.

Added:
  genius/trunk/genius-gio.patch

------------------+
 genius-gio.patch |  374 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 374 insertions(+)

Added: genius-gio.patch
===================================================================
--- genius-gio.patch                            (rev 0)
+++ genius-gio.patch    2010-04-22 14:44:36 UTC (rev 78365)
@@ -0,0 +1,374 @@
+diff -ru genius-1.0.9/configure.in genius.gio/configure.in
+--- genius-1.0.9/configure.in  2009-12-23 22:18:48.000000000 +0100
++++ genius.gio/configure.in    2010-04-22 12:04:04.000000000 +0200
+@@ -13,11 +13,11 @@
+ dnl ================= Requirements 
================================================
+ 
+ VTE_REQUIRED=0.8.19
+-LIBGNOMEVFS_REQUIRED=2.0.0
+ GTK_REQUIRED=2.12.0
+ GLIB_REQUIRED=2.12.0
+ GTKSOURCEVIEW_REQUIRED=0.3.0
+ GTKSOURCEVIEW2_REQUIRED=2.0.2
++GIO_REQUIRED=2.22.0
+ 
+ dnl 
===============================================================================
+ 
+@@ -117,11 +117,11 @@
+ AC_SUBST(GLIB_CFLAGS)
+ AC_SUBST(GLIB_LIBS)
+ 
+-GENIUS_MODULES="gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0 >= 
$LIBGNOMEVFS_REQUIRED vte >= $VTE_REQUIRED"
++GENIUS_MODULES="gtk+-2.0 >= $GTK_REQUIRED gio-2.0 >= $GIO_REQUIRED vte >= 
$VTE_REQUIRED"
+ 
+ if test "x$use_gnome" = "xyes" ; then
+   echo " 
+-Testing for presence of GNOME (GTK and gnome-vfs is enough) and GtkSourceView:
++Testing for presence of GNOME (GTK and GIO is enough) and GtkSourceView:
+ Note:
+       You can compile without GNOME by using the --disable-gnome option
+ "
+diff -ru genius-1.0.9/src/gnome-genius.c genius.gio/src/gnome-genius.c
+--- genius-1.0.9/src/gnome-genius.c    2009-11-10 07:10:57.000000000 +0100
++++ genius.gio/src/gnome-genius.c      2010-04-22 16:31:46.000000000 +0200
+@@ -25,7 +25,6 @@
+ #include <gdk/gdkkeysyms.h>
+ #include <gtk/gtk.h>
+ #include <vte/vte.h>
+-#include <libgnomevfs/gnome-vfs.h>
+ 
+ #include <string.h>
+ #include <unistd.h>
+@@ -68,9 +67,7 @@
+ #endif
+ #endif
+ 
+-#include <libgnomevfs/gnome-vfs-uri.h>
+-#include <libgnomevfs/gnome-vfs-ops.h>
+-#include <libgnomevfs/gnome-vfs-utils.h>
++#include <gio/gio.h>
+ 
+ #include "gnome-genius.h"
+ 
+@@ -697,17 +694,17 @@
+ static gboolean
+ uri_exists (const gchar* text_uri)
+ {
+-      GnomeVFSURI *uri;
++      GFile *uri;
+       gboolean res;
+               
+       g_return_val_if_fail (text_uri != NULL, FALSE);
+       
+-      uri = gnome_vfs_uri_new (text_uri);
++      uri = g_file_new_for_uri (text_uri);
+       g_return_val_if_fail (uri != NULL, FALSE);
+ 
+-      res = gnome_vfs_uri_exists (uri);
++      res = g_file_query_exists (uri, NULL);
+ 
+-      gnome_vfs_uri_unref (uri);
++      g_object_unref (uri);
+ 
+       return res;
+ }
+@@ -3088,77 +3085,70 @@
+ }
+ 
+ static gboolean
+-save_contents_vfs (const char *file, const char *str, int size)
++save_contents_vfs (const char *filename, const char *str, int size)
+ {
+-      GnomeVFSHandle *handle;
+-      GnomeVFSFileSize bytes;
+-      GnomeVFSResult result;
+-
+-      /* FIXME: we should handle errors better by perhaps moving
+-         to a different name first and erasing only when saving
+-         was all fine */
+-
+-      /* Be safe about saving files, unlink and create in
+-       * exclusive mode */
+-      result = gnome_vfs_unlink (file);
+-      /* FIXME: error handling, but not if it's
+-       * the file-doesn't-exist kind of error which is fine */
+-      result = gnome_vfs_create (&handle, file,
+-                                 GNOME_VFS_OPEN_WRITE,
+-                                 TRUE /* exclusive */,
+-                                 0644);
+-      if (result != GNOME_VFS_OK) {
+-              /* FIXME: error handling */
++      GFile* file;
++      GFileOutputStream* stream;
++      gssize bytes;
++
++      file = g_file_new_for_uri (filename);
++      stream = g_file_replace (file, NULL, TRUE, G_FILE_CREATE_NONE, NULL, 
NULL);
++      
++      if (stream == NULL)
++      {
++              g_object_unref (file);
+               return FALSE;
+       }
+ 
+-      result = gnome_vfs_write (handle, str, size, &bytes);
+-      if (result != GNOME_VFS_OK || bytes != size) {
+-              gnome_vfs_close (handle);
+-              /* FIXME: error handling */
++      g_output_stream_write_all (G_OUTPUT_STREAM (stream), str, size, &bytes, 
NULL, NULL);
++
++      if (bytes != size)
++      {
++              g_object_unref(stream);
++              g_object_unref(file);
+               return FALSE;
+       }
+ 
+-      /* add traling \n if needed */
+       if (size > 0 && str[size-1] != '\n')
+-              gnome_vfs_write (handle, "\n", 1, &bytes);
+-      /* FIXME: error handling? */
++              g_output_stream_write (G_OUTPUT_STREAM (stream), "\n", 1, NULL, 
NULL);
+ 
+-      gnome_vfs_close (handle);
++      g_output_stream_close (G_OUTPUT_STREAM (stream), NULL, NULL);
++      g_object_unref (stream);
++      g_object_unref (file);
+ 
+       return TRUE;
+ }
+ 
+ static char *
+-get_contents_vfs (const char *file)
++get_contents_vfs (const char *filename)
+ {
+-      GnomeVFSHandle *handle;
+-      GnomeVFSFileSize bytes;
++      GFile* file;
++      GFileInputStream* stream;
++      gssize bytes;
+       char buffer[4096];
+-      GnomeVFSResult result;
+       GString *str;
+ 
+-      /* FIXME: add limit to avoid reading until never */
++      file = g_file_new_for_uri (filename);
++      stream = g_file_read (file, NULL, NULL);
+ 
+-      result = gnome_vfs_open (&handle, file,
+-                               GNOME_VFS_OPEN_READ);
+-      if (result != GNOME_VFS_OK) {
+-              /* FIXME: error handling */
+-              return NULL;
++      if (stream == NULL)
++      {
++              g_object_unref (file);
++              return FALSE;
+       }
+ 
+       str = g_string_new (NULL);
+ 
+-      while (gnome_vfs_read (handle,
+-                             buffer,
+-                             sizeof (buffer)-1,
+-                             &bytes) == GNOME_VFS_OK) {
++      while ((bytes = g_input_stream_read (G_INPUT_STREAM (stream), buffer, 
sizeof (buffer) -1, NULL, NULL)) > 0)
++      {
+               buffer[bytes] = '\0';
+               g_string_append (str, buffer);
+       }
+-
+-      gnome_vfs_close (handle);
+-
++      
++      g_input_stream_close (G_INPUT_STREAM (stream), NULL, NULL);
++      g_object_unref (stream);
++      g_object_unref (file);
++      
+       return g_string_free (str, FALSE);
+ }
+ 
+@@ -3270,15 +3260,15 @@
+ static gboolean
+ file_exists (const char *fname)
+ {
+-      GnomeVFSURI *uri;
++      GFile* uri;
+       gboolean ret;
+ 
+       if (ve_string_empty (fname))
+               return FALSE; 
+ 
+-      uri = gnome_vfs_uri_new (fname);
+-      ret = gnome_vfs_uri_exists (uri);
+-      gnome_vfs_uri_unref (uri);
++      uri = g_file_new_for_uri (fname);
++      ret = g_file_query_exists (uri, NULL);
++      g_object_unref (uri);
+ 
+       return ret;
+ }
+@@ -3286,26 +3276,26 @@
+ static gboolean
+ file_is_writable (const char *fname)
+ {
+-      GnomeVFSFileInfo *info;
+-      GnomeVFSResult result;
++      GFile* file;
++      GFileInfo* info;
+       gboolean ret;
+-
++      
+       if (ve_string_empty (fname))
+               return FALSE; 
+ 
+-      info = gnome_vfs_file_info_new ();
+-      result = gnome_vfs_get_file_info (fname, 
+-                                        info, 
+-                                        (GNOME_VFS_FILE_INFO_DEFAULT 
+-                                         | GNOME_VFS_FILE_INFO_FOLLOW_LINKS
+-                                         | 
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS));
+-      ret = (info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE);
+-      gnome_vfs_file_info_unref (info);
++      file = g_file_new_for_uri (fname);
++      info = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, 
G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ 
+-      if (result == GNOME_VFS_OK)
+-              return ret;
+-      else
++      if (info == NULL)
++      {
++              g_object_unref (file);
+               return FALSE;
++      }
++      ret = g_file_info_get_attribute_boolean (info, 
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
++      g_object_unref (info);
++      g_object_unref (file);
++
++      return ret;
+ }
+ 
+ 
+@@ -3414,13 +3404,18 @@
+                               p);
+ 
+       if (filename == NULL) {
++              GFile* file;
+               char *d = g_get_current_dir ();
+               char *n = g_strdup_printf (_("Program_%d.gel"), cnt);
+               /* the file name will have an underscore */
+               char *fn = g_build_filename (d, n, NULL);
+               g_free (d);
+               g_free (n);
+-              p->name = gnome_vfs_get_uri_from_local_path (fn);
++
++              file = g_file_new_for_path (fn);
++              p->name = g_file_get_uri (file);
++
++              g_object_unref (file);
+               g_free (fn);
+               p->vname = g_strdup_printf (_("Program %d"), cnt);
+               cnt++;
+@@ -4684,51 +4679,23 @@
+       return str->str;
+ }
+ 
+-static gboolean
+-is_uri (const char *s)
+-{
+-      const char *p;
+-      if ( ! s)
+-              return FALSE;
+-
+-      for (p = s; (*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z'); p++)
+-              ;
+-      if (p == s)
+-              return FALSE;
+-      if (*p == ':') {
+-              GnomeVFSURI *uri =
+-                      gnome_vfs_uri_new (s);
+-
+-              if (uri != NULL) {
+-                      gnome_vfs_uri_unref (uri);
+-                      return TRUE;
+-              } else {
+-                      return FALSE;
+-              }
+-      }
+-      return FALSE;
+-}
+-
+ static void
+ loadup_files_from_cmdline (int argc, char *argv[])
+ {
+       int i;
+ 
+       for (i = 1; i < argc && argv[i] != NULL; i++) {
+-              char *fn;
+-              if (is_uri (argv[i])) {
+-                      fn = g_strdup (argv[i]);
+-              } else if (g_path_is_absolute (argv[i])) {
+-                      fn = gnome_vfs_get_uri_from_local_path (argv[i]);
+-              } else {
+-                      char *d = g_get_current_dir ();
+-                      char *n = g_build_filename (d, argv[i], NULL);
+-                      fn = gnome_vfs_get_uri_from_local_path (n);
+-                      g_free (d);
+-                      g_free (n);
+-              }
+-              new_program (fn);
+-              g_free (fn);
++              GFile *file;
++              char *uri;
++              
++              file = g_file_new_for_commandline_arg (argv[i]);
++              uri = g_file_get_uri (file);
++
++              g_object_unref (file);
++
++              new_program (uri);
++              
++              g_free (uri);
+       }
+ }
+ 
+@@ -4737,22 +4704,20 @@
+                   gint x, gint y, GtkSelectionData *selection_data, 
+                   guint info, guint time)
+ {
+-      GList *list;
+-      GList *li;
+-      
++      char *uri;
++      char **uris;
++      int i = 0;
++
+       if (info != TARGET_URI_LIST)
+               return;
+                       
+-      list = gnome_vfs_uri_list_parse ((gpointer)selection_data->data);
++      uris = g_uri_list_extract_uris (selection_data->data);
+ 
+-      for (li = list; li != NULL; li = li->next) {
+-              const GnomeVFSURI *uri = li->data;
+-              char *s = gnome_vfs_uri_to_string (uri,
+-                                                 GNOME_VFS_URI_HIDE_NONE);
+-              new_program (s);
++      for (uri = uris[i]; uri != NULL; i++, uri = uris[i])
++      {
++              new_program (uri);
+       }
+-      
+-      gnome_vfs_uri_list_free (list);
++      g_strfreev (uris);
+ }
+ 
+ static void
+@@ -4848,7 +4813,6 @@
+                                                     NULL);
+ 
+       gtk_init (&argc, &argv);
+-      gnome_vfs_init ();
+       /* FIXME: handle errors */
+ 
+       if (give_no_lib_error_after_init) {

Reply via email to