gnome-control-center r8479 - in trunk: . capplets/about-me



Author: jensg
Date: Tue Feb 12 22:13:32 2008
New Revision: 8479
URL: http://svn.gnome.org/viewvc/gnome-control-center?rev=8479&view=rev

Log:
2008-02-12  Jens Granseuer  <jensgr gmx net>

	* configure.in: add gio-2.0 to general capplet flags for now; this
	part needs cleaning up in the next cycle

2008-02-12  Jens Granseuer  <jensgr gmx net>

	* e-image-chooser.c: (e_image_chooser_class_init),
	(image_drag_data_received_cb):
	* gnome-about-me.c: (about_me_update_preview): port to gio


Modified:
   trunk/ChangeLog
   trunk/capplets/about-me/ChangeLog
   trunk/capplets/about-me/e-image-chooser.c
   trunk/capplets/about-me/gnome-about-me.c
   trunk/configure.in

Modified: trunk/capplets/about-me/e-image-chooser.c
==============================================================================
--- trunk/capplets/about-me/e-image-chooser.c	(original)
+++ trunk/capplets/about-me/e-image-chooser.c	Tue Feb 12 22:13:32 2008
@@ -24,14 +24,13 @@
 
 #include <glib-object.h>
 #include <glib/gi18n.h>
+#include <gio/gio.h>
 #include <gtk/gtkalignment.h>
 #include <gtk/gtkframe.h>
 #include <gtk/gtkimage.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkdnd.h>
 
-#include <libgnomevfs/gnome-vfs-ops.h>
-
 #include "e-image-chooser.h"
 
 struct _EImageChooserPrivate {
@@ -58,10 +57,6 @@
 
 static void e_image_chooser_init	 (EImageChooser		 *chooser);
 static void e_image_chooser_class_init	 (EImageChooserClass	 *klass);
-#if 0
-static void e_image_chooser_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void e_image_chooser_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
-#endif
 static void e_image_chooser_dispose      (GObject *object);
 
 static gboolean image_drag_motion_cb (GtkWidget *widget,
@@ -139,10 +134,6 @@
 			      g_cclosure_marshal_VOID__VOID,
 			      GTK_TYPE_NONE, 0);
 
-	/*
-	object_class->set_property = e_image_chooser_set_property;
-	object_class->get_property = e_image_chooser_get_property;
-	*/
 	object_class->dispose = e_image_chooser_dispose;
 }
 
@@ -365,50 +356,62 @@
 	target_type = gdk_atom_name (selection_data->target);
 
 	if (!strcmp (target_type, URI_LIST_TYPE)) {
-		GnomeVFSResult result;
-		GnomeVFSHandle *handle;
 		char *uri;
+		GFile *file;
+		GInputStream *istream;
 		char *nl = strstr (selection_data->data, "\r\n");
-		char *buf = NULL;
-		GnomeVFSFileInfo info;
 
 		if (nl)
-			uri = g_strndup (selection_data->data, nl - (char*)selection_data->data);
+			uri = g_strndup (selection_data->data, nl - (char *) selection_data->data);
 		else
 			uri = g_strdup (selection_data->data);
 
-		result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
-		if (result == GNOME_VFS_OK) {
+		file = g_file_new_for_uri (uri);
+		istream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+
+		if (istream != NULL) {
+			GFileInfo *info;
 
-			result = gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_DEFAULT);
-			if (result == GNOME_VFS_OK) {
-				GnomeVFSFileSize num_read;
-
-				buf = g_malloc (info.size);
-
-				result = gnome_vfs_read (handle, buf, info.size, &num_read);
-				if (result == GNOME_VFS_OK) {
-					if (set_image_from_data (chooser, buf, num_read))
-						handled = TRUE;
-					else
-						g_free (buf);
-				} else {
+			info = g_file_query_info (file,
+						  G_FILE_ATTRIBUTE_STANDARD_SIZE,
+						  G_FILE_QUERY_INFO_NONE,
+						  NULL, NULL);
+
+			if (info != NULL) {
+				gsize size;
+				gboolean success;
+				gchar *buf;
+
+				size = g_file_info_get_size (info);
+				g_object_unref (info);
+
+				buf = g_malloc (size);
+
+				success = g_input_stream_read_all (istream,
+								   buf,
+								   size,
+								   &size,
+								   NULL,
+								   NULL);
+				g_input_stream_close (istream, NULL, NULL);
+
+				if (success &&
+						set_image_from_data (chooser, buf, size))
+					handled = TRUE;
+				else
 					g_free (buf);
-				}
 			}
 
-			gnome_vfs_close (handle);
-
+			g_object_unref (istream);
 		}
 
+		g_object_unref (file);
 		g_free (uri);
 	}
 
 	gtk_drag_finish (context, handled, FALSE, time);
 }
 
-
-
 gboolean
 e_image_chooser_set_from_file (EImageChooser *chooser, const char *filename)
 {

Modified: trunk/capplets/about-me/gnome-about-me.c
==============================================================================
--- trunk/capplets/about-me/gnome-about-me.c	(original)
+++ trunk/capplets/about-me/gnome-about-me.c	Tue Feb 12 22:13:32 2008
@@ -26,9 +26,7 @@
 #include <glib/gstdio.h>
 #include <gnome.h>
 #include <pwd.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <gio/gio.h>
 #include <libgnomeui/gnome-thumbnail.h>
 #include <gconf/gconf-client.h>
 #include <glade/glade.h>
@@ -620,20 +618,40 @@
 
 	if (uri) {
 		GtkWidget *image;
-		GdkPixbuf *pixbuf;
-		gchar *mime_type;
+		GdkPixbuf *pixbuf = NULL;
+		GFile *file;
+		GFileInfo *file_info;
 
 		if (!me->thumbs)
 			me->thumbs = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
 
+		file = g_file_new_for_uri (uri);
+		file_info = g_file_query_info (file,
+					       G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+					       G_FILE_QUERY_INFO_NONE,
+					       NULL, NULL);
+		g_object_unref (file);
+
+		if (file_info != NULL) {
+			const gchar *content_type;
+
+			content_type = g_file_info_get_content_type (file_info);
+			if (content_type) {
+				gchar *mime_type;
+
+				mime_type = g_content_type_get_mime_type (content_type);
+
+				pixbuf = gnome_thumbnail_factory_generate_thumbnail (me->thumbs,
+										     uri,
+										     mime_type);
+				g_free (mime_type);
+			}
+			g_object_unref (file_info);
+		}
 
-		mime_type = gnome_vfs_get_mime_type (uri);
-		pixbuf = gnome_thumbnail_factory_generate_thumbnail (me->thumbs,
-								     uri,
-								     mime_type);
 		image = gtk_file_chooser_get_preview_widget (chooser);
 
-		if(pixbuf != NULL) {
+		if (pixbuf != NULL) {
 			gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
 			g_object_unref (pixbuf);
 		} else {
@@ -641,7 +659,6 @@
 						  "gtk-dialog-question",
 						  GTK_ICON_SIZE_DIALOG);
 		}
-		g_free (mime_type);
 	}
 	gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
 }

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Feb 12 22:13:32 2008
@@ -90,6 +90,7 @@
 AM_CONDITIONAL(ENABLE_DYNAMIC_LIBSLAB, test "x$ENABLE_DYNAMIC_LIBSLAB" = "x1")
 
 COMMON_MODULES="gtk+-2.0 >= 2.11.6 dnl
+ gio-2.0 dnl
  gconf-2.0 dnl
  libgnomeui-2.0 >= 2.2.0 dnl
  libglade-2.0 >= 2.0.0 dnl



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]