nautilus-image-converter r37 - in trunk: . src
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-image-converter r37 - in trunk: . src
- Date: Sat, 26 Jan 2008 23:00:17 +0000 (GMT)
Author: juergbi
Date: Sat Jan 26 23:00:17 2008
New Revision: 37
URL: http://svn.gnome.org/viewvc/nautilus-image-converter?rev=37&view=rev
Log:
2008-01-26 Juerg Billeter <j bitron ch>
* configure.ac, src/nautilus-image-resizer.c,
src/nautilus-image-rotator.c: port to GIO, requires glib 2.15 and
nautilus 2.21, based on patch by Andrew Walton
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/src/nautilus-image-resizer.c
trunk/src/nautilus-image-rotator.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sat Jan 26 23:00:17 2008
@@ -22,12 +22,12 @@
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
-NAUTILUS_REQUIRED=2.12.0
-GTK_REQUIRED=2.4.0
+NAUTILUS_REQUIRED=2.21.0
+GLIB_REQUIRED=2.15.0
+GTK_REQUIRED=2.12.0
LIBGLADE_REQUIRED=2.4.0
-GNOMEVFS_REQUIRED=2.6.0
-PKG_CHECK_MODULES(NAUTILUS, libnautilus-extension >= $NAUTILUS_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED gnome-vfs-2.0 >= $GNOMEVFS_REQUIRED)
+PKG_CHECK_MODULES(NAUTILUS, libnautilus-extension >= $NAUTILUS_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED)
AC_SUBST(NAUTILUS_CFLAGS)
AC_SUBST(NAUTILUS_LIBS)
Modified: trunk/src/nautilus-image-resizer.c
==============================================================================
--- trunk/src/nautilus-image-resizer.c (original)
+++ trunk/src/nautilus-image-resizer.c Sat Jan 26 23:00:17 2008
@@ -1,7 +1,7 @@
/*
- * nautilus-image-resize-dialog.c
+ * nautilus-image-resizer.c
*
- * Copyright (C) 2004-2005 JÃrg Billeter
+ * Copyright (C) 2004-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -30,11 +30,10 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs.h>
-
#include <libnautilus-extension/nautilus-file-info.h>
#define PKGDATADIR DATADIR "/" PACKAGE
@@ -159,45 +158,36 @@
static void run_op (NautilusImageResizer *resizer);
-static char *
-nautilus_image_resizer_transform_uri (NautilusImageResizer *resizer, char *text_uri)
+static GFile *
+nautilus_image_resizer_transform_filename (NautilusImageResizer *resizer, GFile *orig_file)
{
NautilusImageResizerPrivate *priv = NAUTILUS_IMAGE_RESIZER_GET_PRIVATE (resizer);
- GnomeVFSURI *uri;
- GnomeVFSURI *parent;
- GnomeVFSURI *new_uri;
- char *escaped_basename;
- char *basename;
- char *extension;
- char *new_basename;
- char *new_text_uri;
-
- uri = gnome_vfs_uri_new (text_uri);
-
- parent = gnome_vfs_uri_get_parent (uri);
-
- escaped_basename = gnome_vfs_uri_extract_short_path_name (uri);
- basename = gnome_vfs_unescape_string (escaped_basename, "/");
- g_free (escaped_basename);
- gnome_vfs_uri_unref (uri);
+ GFile *parent_file, *new_file;
+ char *basename, *extension, *new_path, *new_basename;
+
+ g_return_val_if_fail (G_IS_FILE (orig_file), NULL);
+
+ parent_file = g_file_get_parent (orig_file);
+
+ basename = g_strdup (g_file_get_basename (orig_file));
+
extension = g_strdup (strrchr (basename, '.'));
if (extension != NULL)
basename[strlen (basename) - strlen (extension)] = '\0';
+
new_basename = g_strdup_printf ("%s%s%s", basename,
priv->suffix == NULL ? ".tmp" : priv->suffix,
extension == NULL ? "" : extension);
g_free (basename);
g_free (extension);
-
- new_uri = gnome_vfs_uri_append_file_name (parent, new_basename);
- gnome_vfs_uri_unref (parent);
+
+ new_file = g_file_get_child (parent_file, new_basename);
+
+ g_object_unref (parent_file);
g_free (new_basename);
-
- new_text_uri = gnome_vfs_uri_to_string (new_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (new_uri);
-
- return new_text_uri;
+
+ return new_file;
}
static void
@@ -238,9 +228,11 @@
} else if (priv->suffix == NULL) {
/* resize image in place */
- char *uri = nautilus_file_info_get_uri (file);
- char *new_uri = nautilus_image_resizer_transform_uri (resizer, uri);
- gnome_vfs_move (new_uri, uri, TRUE);
+ GFile *orig_location = nautilus_file_info_get_location (file);
+ GFile *new_location = nautilus_image_resizer_transform_filename (resizer, orig_location);
+ g_file_move (new_location, orig_location, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
+ g_object_unref (orig_location);
+ g_object_unref (new_location);
}
if (status == 0 || !retry) {
@@ -308,13 +300,13 @@
NautilusFileInfo *file = NAUTILUS_FILE_INFO (priv->files->data);
- char *uri = nautilus_file_info_get_uri (file);
- char *filename = gnome_vfs_get_local_path_from_uri (uri);
- char *new_uri = nautilus_image_resizer_transform_uri (resizer, uri);
- g_free (uri);
- char *new_filename = gnome_vfs_get_local_path_from_uri (new_uri);
- g_free (new_uri);
-
+ GFile *orig_location = nautilus_file_info_get_location (file);
+ char *filename = g_file_get_path (orig_location);
+ GFile *new_location = nautilus_image_resizer_transform_filename (resizer, orig_location);
+ char *new_filename = g_file_get_path (new_location);
+ g_object_unref (orig_location);
+ g_object_unref (new_location);
+
/* FIXME: check whether new_uri already exists and provide "Replace _All", "_Skip", and "_Replace" options */
gchar *argv[6];
Modified: trunk/src/nautilus-image-rotator.c
==============================================================================
--- trunk/src/nautilus-image-rotator.c (original)
+++ trunk/src/nautilus-image-rotator.c Sat Jan 26 23:00:17 2008
@@ -1,7 +1,7 @@
/*
* nautilus-image-rotator.c
*
- * Copyright (C) 2004-2006 JÃrg Billeter
+ * Copyright (C) 2004-2008 JÃrg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
@@ -30,11 +30,10 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs.h>
-
#include <libnautilus-extension/nautilus-file-info.h>
#define PKGDATADIR DATADIR "/" PACKAGE
@@ -156,45 +155,36 @@
static void run_op (NautilusImageRotator *rotator);
-static char *
-nautilus_image_rotator_transform_uri (NautilusImageRotator *rotator, char *text_uri)
+static GFile *
+nautilus_image_rotator_transform_filename (NautilusImageRotator *rotator, GFile *orig_file)
{
NautilusImageRotatorPrivate *priv = NAUTILUS_IMAGE_ROTATOR_GET_PRIVATE (rotator);
- GnomeVFSURI *uri;
- GnomeVFSURI *parent;
- GnomeVFSURI *new_uri;
- char *escaped_basename;
- char *basename;
- char *extension;
- char *new_basename;
- char *new_text_uri;
-
- uri = gnome_vfs_uri_new (text_uri);
-
- parent = gnome_vfs_uri_get_parent (uri);
-
- escaped_basename = gnome_vfs_uri_extract_short_path_name (uri);
- basename = gnome_vfs_unescape_string (escaped_basename, "/");
- g_free (escaped_basename);
- gnome_vfs_uri_unref (uri);
+ GFile *parent_file, *new_file;
+ char *basename, *extension, *new_path, *new_basename;
+
+ g_return_val_if_fail (G_IS_FILE (orig_file), NULL);
+
+ parent_file = g_file_get_parent (orig_file);
+
+ basename = g_strdup (g_file_get_basename (orig_file));
+
extension = g_strdup (strrchr (basename, '.'));
if (extension != NULL)
basename[strlen (basename) - strlen (extension)] = '\0';
+
new_basename = g_strdup_printf ("%s%s%s", basename,
priv->suffix == NULL ? ".tmp" : priv->suffix,
extension == NULL ? "" : extension);
g_free (basename);
g_free (extension);
-
- new_uri = gnome_vfs_uri_append_file_name (parent, new_basename);
- gnome_vfs_uri_unref (parent);
+
+ new_file = g_file_get_child (parent_file, new_basename);
+
+ g_object_unref (parent_file);
g_free (new_basename);
-
- new_text_uri = gnome_vfs_uri_to_string (new_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (new_uri);
-
- return new_text_uri;
+
+ return new_file;
}
static void
@@ -235,9 +225,11 @@
} else if (priv->suffix == NULL) {
/* rotate image in place */
- char *uri = nautilus_file_info_get_uri (file);
- char *new_uri = nautilus_image_rotator_transform_uri (rotator, uri);
- gnome_vfs_move (new_uri, uri, TRUE);
+ GFile *orig_location = nautilus_file_info_get_location (file);
+ GFile *new_location = nautilus_image_rotator_transform_filename (rotator, orig_location);
+ g_file_move (new_location, orig_location, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL);
+ g_object_unref (orig_location);
+ g_object_unref (new_location);
}
if (status == 0 || !retry) {
@@ -305,13 +297,13 @@
NautilusFileInfo *file = NAUTILUS_FILE_INFO (priv->files->data);
- char *uri = nautilus_file_info_get_uri (file);
- char *filename = gnome_vfs_get_local_path_from_uri (uri);
- char *new_uri = nautilus_image_rotator_transform_uri (rotator, uri);
- g_free (uri);
- char *new_filename = gnome_vfs_get_local_path_from_uri (new_uri);
- g_free (new_uri);
-
+ GFile *orig_location = nautilus_file_info_get_location (file);
+ char *filename = g_file_get_path (orig_location);
+ GFile *new_location = nautilus_image_rotator_transform_filename (rotator, orig_location);
+ char *new_filename = g_file_get_path (new_location);
+ g_object_unref (orig_location);
+ g_object_unref (new_location);
+
/* FIXME: check whether new_uri already exists and provide "Replace _All", "_Skip", and "_Replace" options */
gchar *argv[8];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]