Commit 80555b01 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl

Mon Aug 30 14:43:41 2010 Jiri (George) Lebl <jirka@5z.com>

	* src/gnome-genius.c, configure.in: Apply patch from
	  Jan de Groot jan at jgc.homeip.net to port the GnomeVFS stuff
	  to GIO.  This raises the glib requirement to 2.16 for the gnome
	  version.  When built without gnome then 2.12 is all that is needed
	  still.
parent 688f497c
Mon Aug 30 14:43:41 2010 Jiri (George) Lebl <jirka@5z.com>
* src/gnome-genius.c, configure.in: Apply patch from
Jan de Groot jan at jgc.homeip.net to port the GnomeVFS stuff
to GIO. This raises the glib requirement to 2.16 for the gnome
version. When built without gnome then 2.12 is all that is needed
still.
Mon Aug 30 13:41:49 2010 Jiri (George) Lebl <jirka@5z.com>
* src/funclib.c: ExpandMatrix,SetMatrixSize,ColumnsOf,RowsOf,
......
......@@ -13,11 +13,11 @@ AC_PROG_INTLTOOL([0.21])
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.16.0
dnl ===============================================================================
......@@ -117,11 +117,11 @@ PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED)
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
"
......
......@@ -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"
......@@ -699,17 +696,17 @@ count_char (const char *s, char c)
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;
}
......@@ -3135,77 +3132,70 @@ changed_cb (GtkTextBuffer *buffer, GtkWidget *tab_widget)
}
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);
}
......@@ -3317,15 +3307,15 @@ get_source_language_manager ()
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;
}
......@@ -3333,26 +3323,26 @@ file_exists (const char *fname)
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;
}
......@@ -3461,13 +3451,18 @@ new_program (const char *filename)
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++;
......@@ -4734,51 +4729,23 @@ get_version_details (void)
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);
}
}
......@@ -4787,22 +4754,20 @@ drag_data_received (GtkWidget *widget, GdkDragContext *context,
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
......@@ -4898,7 +4863,6 @@ main (int argc, char *argv[])
NULL);
gtk_init (&argc, &argv);
gnome_vfs_init ();
/* FIXME: handle errors */
if (give_no_lib_error_after_init) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment