xchat-gnome r2650 - in trunk: . src/fe-gnome



Author: cosimoc
Date: Thu Sep  4 23:29:18 2008
New Revision: 2650
URL: http://svn.gnome.org/viewvc/xchat-gnome?rev=2650&view=rev

Log:
2008-09-05  Cosimo Cecchi  <cosimoc gnome org>

	* configure.ac:
	Require Glib 2.16.0 and GTK+ 2.13.7.
	* src/fe-gnome/conversation-panel.c: (drop_paste), (uri_is_text),
	(check_file_size):
	* src/fe-gnome/dcc-window.c: (dcc_window_update):
	* src/fe-gnome/fe-gnome.c:
	Drop gnome-vfs dependency; port to the GIO api.
	Part of bug #550985.


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/fe-gnome/conversation-panel.c
   trunk/src/fe-gnome/dcc-window.c
   trunk/src/fe-gnome/fe-gnome.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Sep  4 23:29:18 2008
@@ -16,10 +16,9 @@
 
 IT_PROG_INTLTOOL([0.35.0])
 
-GLIB_REQUIRED=2.12.0
-GTK_REQUIRED=2.11.6
+GLIB_REQUIRED=2.16.0
+GTK_REQUIRED=2.13.7
 LIBGLADE_REQUIRED=2.3.2
-LIBGNOMEVFS_REQUIRED=2.9.2
 LIBGNOME_REQUIRED=2.16.0
 LIBGNOMEUI_REQUIRED=2.16.0
 GCONF_REQUIRED=2.8.0
@@ -58,9 +57,9 @@
 # Hard dependencies
 PKG_CHECK_MODULES([DEPENDENCIES], [\
                   glib-2.0 >= $GLIB_REQUIRED \
+		  gio-2.0 >= $GLIB_REQUIRED \
                   gtk+-2.0 >= $GTK_REQUIRED \
                   libglade-2.0 >= $LIBGLADE_REQUIRED \
-                  gnome-vfs-2.0 >= $LIBGNOMEVFS_REQUIRED \
 		  libgnome-2.0 >= $LIBGNOME_REQUIRED \
                   libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \
                   gconf-2.0 >= $GCONF_REQUIRED \

Modified: trunk/src/fe-gnome/conversation-panel.c
==============================================================================
--- trunk/src/fe-gnome/conversation-panel.c	(original)
+++ trunk/src/fe-gnome/conversation-panel.c	Thu Sep  4 23:29:18 2008
@@ -24,7 +24,6 @@
 #include <gconf/gconf.h>
 #include <gconf/gconf-client.h>
 #include <libgnomeui/gnome-stock-icons.h>
-#include <libgnomevfs/gnome-vfs.h>
 
 #include "conversation-panel.h"
 #include "gui.h"
@@ -863,20 +862,24 @@
 static void
 drop_paste (ConversationPanel *panel)
 {
-	GnomeVFSResult result;
-	gchar *contents, *uri;
+	GFile *file;
+	gboolean res;
+	char *contents;
+	const char *uri = panel->priv->dropped_files->data;
+	GError *error = NULL;
 
 	g_return_if_fail (g_slist_length (panel->priv->dropped_files) == 1);
 
-	uri = panel->priv->dropped_files->data;
-	result = gnome_vfs_read_entire_file (uri, NULL, &contents);
-	if (result == GNOME_VFS_OK) {
+	res = g_file_get_contents (uri, &contents, NULL, NULL);
+
+	if (res) {
 		if (panel->priv->current != NULL) {
-			handle_multiline (panel->priv->current, (char *) contents, TRUE, FALSE);
+			handle_multiline (panel->priv->current, contents, TRUE, FALSE);
 		}
 		g_free (contents);
 	} else {
-		g_printerr (_("Error reading file \"%s\": %s\n"), uri, gnome_vfs_result_to_string (result));
+		g_printerr (_("Error reading file \"%s\": %s\n"), uri, error->message);
+		g_error_free (error);
 	}
 
 	free_dropped_files (panel);
@@ -909,12 +912,21 @@
 uri_is_text (gchar *uri)
 {
 	gchar *mime;
+	GFile *file;
+	GFileInfo *info;
 	gboolean is_text = FALSE;
 
-	mime = gnome_vfs_get_mime_type (uri);
-	if (mime) {
-		is_text = g_str_has_prefix (mime, "text/");
-		g_free (mime);
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+				  0, NULL, NULL);
+	g_object_unref (file);
+	
+	if (info) {
+		const char *type;
+		type = g_file_info_get_content_type (info);
+		is_text = g_content_type_is_a (type, "text");
+
+		g_object_unref (info);
 	}
 
 	return is_text;
@@ -923,21 +935,29 @@
 static gboolean
 check_file_size (gchar *uri)
 {
-	GnomeVFSResult result;
-	GnomeVFSFileInfo *info;
+	GFile *file;
+	GFileInfo *info;
+	GError *error = NULL;
 	gboolean file_size_ok = FALSE;
 
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT);
+	file = g_file_new_for_uri (uri);
+	info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_SIZE,
+				  0, NULL, &error);
+	g_object_unref (file);
+
+	if (!info) {
+		g_printerr (_("Error retrieving file information for \"%s\": %s\n"),
+			      uri, error->message);
+		g_error_free (error);
+	} else {
+		goffset size = g_file_info_get_size (info);
 
-	if (result == GNOME_VFS_OK) {
-		if (info->size <= DROP_FILE_PASTE_MAX_SIZE)
+		if (size <= DROP_FILE_PASTE_MAX_SIZE)
 			file_size_ok = TRUE;
-	} else {
-		g_printerr (_("Error retrieving file information for \"%s\": %s\n"), uri, gnome_vfs_result_to_string (result));
+
+		g_object_unref (info);
 	}
 
-	gnome_vfs_file_info_unref (info);
 	return file_size_ok;
 }
 

Modified: trunk/src/fe-gnome/dcc-window.c
==============================================================================
--- trunk/src/fe-gnome/dcc-window.c	(original)
+++ trunk/src/fe-gnome/dcc-window.c	Thu Sep  4 23:29:18 2008
@@ -22,9 +22,8 @@
 #include <config.h>
 #include <glib/gi18n.h>
 #include <glib.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomeui/gnome-icon-lookup.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
 #include "gui.h"
 #include "dcc-window.h"
 #include "util.h"
@@ -331,12 +330,13 @@
 				g_free (remaining_text);
 
 				/* We put off rendering the icon until we get at least one update,
-				 * to ensure that gnome-vfs can determine the MIME type
+				 * to ensure that can determine the MIME type
 				 */
 				if (dcc->destfile != NULL && icon == NULL) {
-					GtkIconTheme *icon_theme;
-					char *icon;
-					char *mime;
+					GFile *file;
+					GFileInfo *info;
+					GIcon *icon;
+					GtkIconInfo *icon_info;
 					GdkPixbuf *mime_pixbuf, *file_icon, *direction_emblem;
 					int mime_w, mime_h;
 					gpointer image_data;
@@ -346,11 +346,27 @@
 						return;
 					}
 
-					/* Get MIME type from gnome-vfs, create the proper file icon for it. */
-					mime = gnome_vfs_get_mime_type (dcc->destfile);
-					icon_theme = gtk_icon_theme_get_default ();
-					icon = gnome_icon_lookup (icon_theme, NULL, NULL, NULL, NULL, mime, GNOME_ICON_LOOKUP_FLAGS_NONE, NULL);
-					mime_pixbuf = gtk_icon_theme_load_icon (icon_theme, icon, 48, 0, NULL);
+					file = g_file_new_for_path (dcc->destfile);
+					info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON,
+								  0, NULL, NULL);
+					g_object_unref (file);
+
+					if (!info) {
+						return;
+					}
+
+					icon = g_file_info_get_icon (info);
+					icon_info = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_default (),
+										    icon, 48, 0);
+					mime_pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+
+					gtk_icon_info_free (icon_info);
+					g_object_unref (file_info);
+					g_objet_unref (icon);
+
+					if (!mime_pixbuf) {
+						return;
+					}	
 
 					mime_w   = gdk_pixbuf_get_width  (mime_pixbuf);
 					mime_h   = gdk_pixbuf_get_height (mime_pixbuf);
@@ -386,8 +402,6 @@
 					                      1.0, 1.0,
 					                      GDK_INTERP_BILINEAR, 255);
 
-					g_free (icon);
-
 					gtk_list_store_set (window->transfer_store, &iter, ICON_COLUMN, file_icon, -1);
 
 					g_object_unref (mime_pixbuf);

Modified: trunk/src/fe-gnome/fe-gnome.c
==============================================================================
--- trunk/src/fe-gnome/fe-gnome.c	(original)
+++ trunk/src/fe-gnome/fe-gnome.c	Thu Sep  4 23:29:18 2008
@@ -24,7 +24,6 @@
 #include <string.h>
 #include <glib.h>
 #include <gnome.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <gconf/gconf-client.h>
 #include "gui.h"
 #include "navigation-tree.h"



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