marlin r1303 - in trunk: . src
- From: iain svn gnome org
- To: svn-commits-list gnome org
- Subject: marlin r1303 - in trunk: . src
- Date: Fri, 10 Oct 2008 01:10:16 +0000 (UTC)
Author: iain
Date: Fri Oct 10 01:10:16 2008
New Revision: 1303
URL: http://svn.gnome.org/viewvc/marlin?rev=1303&view=rev
Log:
Start replacing gnome-vfs with GIO
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/src/ChangeLog
trunk/src/main.c
trunk/src/marlin-window.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Fri Oct 10 01:10:16 2008
@@ -75,6 +75,7 @@
GSTREAMER_REQUIRED=0.10.0
PKG_CHECK_MODULES(MARLIN, glib-2.0 >= 2.10.0 gmodule-2.0 >= 2.10.0 \
gthread-2.0 >= 2.8.0 \
+ gio-2.0 >= 2.18.0 \
libgnome-2.0 >= 2.6.0 \
gconf-2.0 \
gnome-vfs-2.0 >= 2.6.0 \
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Fri Oct 10 01:10:16 2008
@@ -28,12 +28,11 @@
#include <signal.h>
#include <execinfo.h>
+#include <gio/gio.h>
#include <gnome.h>
#include <gconf/gconf-client.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
#include <gst/gst.h>
#ifdef HAVE_MEDIA_PROFILES
@@ -283,7 +282,7 @@
}
g_object_unref (sample);
-
+
g_signal_connect (G_OBJECT (window), "delete-event",
G_CALLBACK (window_deleted), NULL);
g_signal_connect (G_OBJECT (window), "destroy",
@@ -292,6 +291,7 @@
if (filename != NULL) {
GtkRecentManager *manager;
GtkRecentData data;
+ gboolean uncertain;
char *uri;
marlin_window_load_file (window, filename);
@@ -300,7 +300,9 @@
data.display_name = NULL;
data.description = NULL;
- data.mime_type = (char *) gnome_vfs_mime_type_from_name (filename);
+ data.mime_type = (char *) g_content_type_guess (filename,
+ NULL, 0,
+ &uncertain);
data.app_name = "Marlin";
/* This should be filled with argv[0]? */
data.app_exec = "marlin %u";
@@ -313,9 +315,11 @@
uri = g_strdup_printf ("file://%s", filename);
}
gtk_recent_manager_add_full (manager, uri, &data);
+
+ g_free (data.mime_type);
g_free (uri);
}
-
+
marlin_windows = g_list_prepend (marlin_windows, window);
/* FIXME: Not sure what this should be */
@@ -378,20 +382,19 @@
return tb_model;
}
-/* From Totem */
static char *
make_full_path (const char *path)
{
- char *retval, *curdir, *curdir_withslash, *escaped;
-
+ char *retval, *curdir, *escaped;
+
g_return_val_if_fail (path != NULL, NULL);
if (strstr (path, "://") != NULL) {
return g_strdup (path);
}
-
+
if (path[0] == '/') {
- escaped = gnome_vfs_escape_path_string (path);
+ escaped = g_uri_escape_string (path, NULL, TRUE);
retval = g_strdup_printf ("%s", path);
g_free (escaped);
@@ -399,21 +402,10 @@
}
curdir = g_get_current_dir ();
-#if 0
- escaped = gnome_vfs_escape_path_string (curdir);
- curdir_withslash = g_strdup_printf ("%s%s",
- escaped, G_DIR_SEPARATOR_S);
- g_free (escaped);
-#endif
- curdir_withslash = g_strdup_printf ("%s%s", curdir,
- G_DIR_SEPARATOR_S);
+ retval = g_strdup_printf ("file://%s%s%s", curdir,
+ G_DIR_SEPARATOR_S, path);
g_free (curdir);
-/* escaped = gnome_vfs_escape_path_string (path); */
- retval = gnome_vfs_uri_make_full_from_relative (curdir_withslash, path);
- g_free (curdir_withslash);
-/* g_free (escaped); */
-
return retval;
}
Modified: trunk/src/marlin-window.c
==============================================================================
--- trunk/src/marlin-window.c (original)
+++ trunk/src/marlin-window.c Fri Oct 10 01:10:16 2008
@@ -34,13 +34,12 @@
#include <glib/gi18n.h>
+#include <gio/gio.h>
+
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
-
#include <gconf/gconf-client.h>
#ifdef HAVE_MEDIA_PROFILES
@@ -3076,21 +3075,22 @@
struct _save_op_data *sod;
MarlinOperation *operation;
MarlinSavePipeline *pipeline;
- const char *mimetype;
+ gboolean uncertain;
+ char *mimetype;
char *path, *name;
int i;
sod = g_new (struct _save_op_data, 1);
- mimetype = gnome_vfs_mime_type_from_name (filename);
+ mimetype = g_content_type_guess (filename, NULL, 0, &uncertain);
if (strcmp (mimetype, "application/octet-stream") == 0) {
int i;
for (i = 0; extension_to_mime[i].extension; i++) {
char *ext = strrchr (filename, '.');
-
+
if (strcmp (ext, extension_to_mime[i].extension) == 0) {
- mimetype = extension_to_mime[i].mimetype;
+ mimetype = g_strdup (extension_to_mime[i].mimetype);
break;
} else {
mimetype = NULL;
@@ -3116,7 +3116,7 @@
g_signal_connect (G_OBJECT (operation), "paused",
G_CALLBACK (save_op_paused), sod);
/* FIXME: Should handle errors too */
-
+
sod->filename = g_strdup (filename);
path = g_path_get_dirname (filename);
name = g_path_get_basename (filename);
@@ -3152,51 +3152,58 @@
sod->pipeline = (MarlinPipeline *) pipeline;
g_signal_connect (G_OBJECT (pipeline), "shutdown",
G_CALLBACK (save_shutdown), sod);
-
+
if (encoder != NULL) {
/* Caller has supplied an encoder, so the parameters have
already been set */
- marlin_default_save (GTK_WINDOW (window),
+ marlin_default_save (GTK_WINDOW (window),
MARLIN_PIPELINE (pipeline));
g_object_set (G_OBJECT (window->priv->sample),
"encoder", encoder,
NULL);
+
+ g_free (mimetype);
return;
}
for (i = 0; mimetypemap[i].function; i++) {
if (mimetypemap[i].mimetype == NULL) {
- marlin_default_save (GTK_WINDOW (window),
+ marlin_default_save (GTK_WINDOW (window),
MARLIN_PIPELINE (pipeline));
+
+ g_free (mimetype);
return;
}
-
+
if (strcmp (mimetype, mimetypemap[i].mimetype) == 0) {
- mimetypemap[i].function (GTK_WINDOW (window),
+ mimetypemap[i].function (GTK_WINDOW (window),
MARLIN_PIPELINE (pipeline));
+
+ g_free (mimetype);
return;
}
}
-}
+}
void
marlin_window_save_sample (MarlinWindow *window)
{
char *filename;
GstElement *encoder;
-
+
g_object_get (G_OBJECT (window->priv->sample),
"filename", &filename,
"encoder", &encoder,
NULL);
if (encoder == NULL) {
- const char *mimetype;
+ gboolean uncertain;
+ char *mimetype;
- /* If there was no encoder then we need to check that we
+ /* If there was no encoder then we need to check that we
can save to this format */
- mimetype = gnome_vfs_mime_type_from_name (filename);
+ mimetype = g_content_type_guess (filename, NULL, 0, &uncertain);
if (marlin_gst_can_encode (mimetype) == FALSE) {
GtkWidget *dialog;
char *text;
@@ -3212,7 +3219,7 @@
text,
filename, mimetype);
g_free (text);
-
+
/* Naughty */
gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), FALSE);
@@ -3232,16 +3239,19 @@
gtk_widget_destroy (dialog);
marlin_window_save_sample_as (window);
break;
-
+
default:
break;
}
-
+
+ g_free (mimetype);
g_free (filename);
return;
}
+
+ g_free (mimetype);
}
-
+
save_sample_as (window, filename, encoder);
g_free (filename);
}
@@ -3399,34 +3409,48 @@
}
if (g_file_test (name, G_FILE_TEST_EXISTS)) {
- GnomeVFSFileSize size;
- GnomeVFSResult result;
- GnomeVFSURI *uri;
- char *text_uri;
- struct stat statbuf;
-
- text_uri = g_strdup_printf ("file://%s", name);
- uri = gnome_vfs_uri_new (text_uri);
- g_free (text_uri);
-
- result = gnome_vfs_get_volume_free_space (uri, &size);
- gnome_vfs_uri_unref (uri);
+ GFile *file;
+ GFileInfo *file_info, *fs_info;
+ guint64 free_size;
+ goffset file_size;
+ GError *error = NULL;
+
+ file = g_file_new_for_path (name);
+ file_info = g_file_query_info (file, NULL,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, &error);
+ if (error != NULL) {
+ g_warning ("Error querying file info: %s",
+ error->message);
+ g_object_unref (file);
+ g_error_free (error);
+ return ask_overwrite_dialog (window, name);
+ }
- if (result != GNOME_VFS_OK) {
+ fs_info = g_file_query_filesystem_info
+ (file, G_FILE_ATTRIBUTE_FILESYSTEM_FREE, NULL, &error);
+ if (error != NULL) {
+ g_warning ("Error querying filesystem info: %s",
+ error->message);
+ g_error_free (error);
+ g_object_unref (file_info);
+ g_object_unref (file);
return ask_overwrite_dialog (window, name);
+ }
+
+ /* Check the there's enough space */
+ free_size = g_file_info_get_attribute_uint64
+ (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+ file_size = g_file_info_get_size (file_info);
+
+ g_object_unref (file_info);
+ g_object_unref (fs_info);
+ g_object_unref (file);
+
+ if (file_size >= free_size) {
+ return ask_nospace_write_dialog (window, name);
} else {
- /* Check the there's enough space */
- if (stat (name, &statbuf) != 0) {
- g_warning ("stat on %s failed: %s", name,
- g_strerror (errno));
- return FALSE;
- }
-
- if (statbuf.st_size >= size) {
- return ask_nospace_write_dialog (window, name);
- } else {
- return ask_overwrite_dialog (window, name);
- }
+ return ask_overwrite_dialog (window, name);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]