gedit r6357 - in trunk: . plugins/filebrowser



Author: jessevdk
Date: Wed Aug  6 20:59:06 2008
New Revision: 6357
URL: http://svn.gnome.org/viewvc/gedit?rev=6357&view=rev

Log:
	* plugins/filebrowser/gedit-file-browser-utils.[ch]: adapted to 
	new uri helper functions in gedit-utils and icon loading functions
	in gtk 2.14
	* plugins/filebrowser/gedit-file-browser-store.c: fixed problem with
	cancelling mount operation. Added use of gtk_mount_operation.
	* plugins/filebrowser/gedit-file-browser-widget.c: use gtk_show_uri
	instead of gnome_url_show


Modified:
   trunk/ChangeLog
   trunk/plugins/filebrowser/gedit-file-browser-store.c
   trunk/plugins/filebrowser/gedit-file-browser-utils.c
   trunk/plugins/filebrowser/gedit-file-browser-utils.h
   trunk/plugins/filebrowser/gedit-file-browser-widget.c

Modified: trunk/plugins/filebrowser/gedit-file-browser-store.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-store.c	(original)
+++ trunk/plugins/filebrowser/gedit-file-browser-store.c	Wed Aug  6 20:59:06 2008
@@ -2507,6 +2507,7 @@
 	GeditFileBrowserStore * model;
 	gchar * virtual_root;
 	GMountOperation * operation;
+	GCancellable * cancellable;
 } MountInfo;
 
 static void
@@ -2521,10 +2522,21 @@
 	
 	mounted_on = g_file_mount_mountable_finish (file, res, &error);
 	
-	if (mounted_on) {
+	if (g_cancellable_is_cancelled (mount_info->cancellable))
+	{
+		if (error)
+			g_error_free (error);
+		
+		// Reset because it might be reused?
+		g_cancellable_reset (mount_info->cancellable);
+	}
+	else if (mounted_on)
+	{
 		model_root_mounted (model, mount_info->virtual_root);
 		g_object_unref (mounted_on);
-	} else if (error->code != G_IO_ERROR_CANCELLED) {
+	}
+	else if (error->code != G_IO_ERROR_CANCELLED)
+	{
 		g_signal_emit (model, 
 			       model_signals[ERROR], 
 			       0, 
@@ -2548,7 +2560,9 @@
 	}
 	
 	g_object_unref (mount_info->operation);
+	g_object_unref (mount_info->cancellable);
 	g_free (mount_info->virtual_root);
+
 	g_free (mount_info);
 }
 
@@ -2573,14 +2587,17 @@
 			mount_info = g_new(MountInfo, 1);
 			mount_info->model = model;
 			mount_info->virtual_root = g_strdup (virtual_root);
-			mount_info->operation = g_mount_operation_new ();
 			
-			g_file_mount_mountable (model->priv->root->file, 
-						G_MOUNT_MOUNT_NONE,
-						mount_info->operation,
-						FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable,
-						(GAsyncReadyCallback)mount_cb,
-						mount_info);
+			/* FIXME: we should be setting the correct window */
+			mount_info->operation = gtk_mount_operation_new (NULL);
+			mount_info->cancellable = g_object_ref (FILE_BROWSER_NODE_DIR (model->priv->root)->cancellable);
+			
+			g_file_mount_enclosing_volume (model->priv->root->file, 
+						       G_MOUNT_MOUNT_NONE,
+						       mount_info->operation,
+						       mount_info->cancellable,
+						       (GAsyncReadyCallback)mount_cb,
+						       mount_info);
 						
 		}
 		

Modified: trunk/plugins/filebrowser/gedit-file-browser-utils.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-utils.c	(original)
+++ trunk/plugins/filebrowser/gedit-file-browser-utils.c	Wed Aug  6 20:59:06 2008
@@ -1,6 +1,5 @@
-#include <libgnomeui/libgnomeui.h>
-
 #include "gedit-file-browser-utils.h"
+#include <gedit/gedit-utils.h>
 
 static GdkPixbuf *
 process_icon_pixbuf (GdkPixbuf * pixbuf,
@@ -50,57 +49,25 @@
 	return pixbuf;
 }
 
-static GdkPixbuf *
-pixbuf_from_theme_icon (GThemedIcon * icon, gint size)
-{
-	gchar **names;
-	GtkIconInfo * info;
-	GdkPixbuf * pixbuf;
-	GError * error = NULL;
-	gchar * name;
-	
-	// Get the icon theme names
-	g_object_get (icon, "names", &names, NULL);
-	info = gtk_icon_theme_choose_icon (gtk_icon_theme_get_default (), 
-					   (gchar const **)names, 
-					   size, 
-					   0);
-	
-	pixbuf = gtk_icon_info_load_icon (info, &error);
-	gtk_icon_info_free (info);
-	
-	name = g_strjoinv (", ", names);
-	pixbuf = process_icon_pixbuf (pixbuf, name, size, error);
-
-	g_free (name);
-	g_strfreev (names);
-
-	return pixbuf;	
-}
-
-static GdkPixbuf *
-pixbuf_from_loadable_icon (GLoadableIcon * icon, gint size)
-{
-	// TODO: actual implement this
-	return NULL;
-}
-
 GdkPixbuf *
 gedit_file_browser_utils_pixbuf_from_icon (GIcon * icon,
                                            GtkIconSize size)
 {
 	GdkPixbuf * ret = NULL;
-	gint width;
+	GtkIconTheme *theme;
+	GtkIconInfo *info;
 	
 	if (!icon)
 		return NULL;
 
-	gtk_icon_size_lookup (size, &width, NULL);
+	theme = gtk_icon_theme_get_default ();
+	info = gtk_icon_theme_lookup_by_gicon (theme, icon, size, 0);
 	
-	if (G_IS_THEMED_ICON (icon))
-		ret = pixbuf_from_theme_icon (G_THEMED_ICON (icon), width);
-	else if (G_IS_LOADABLE_ICON (icon))
-		ret = pixbuf_from_loadable_icon (G_LOADABLE_ICON (icon), width);
+	if (!info)
+		return NULL;
+		
+	ret = gtk_icon_info_load_icon (info, NULL);
+	gtk_icon_info_free (info);
 	
 	return ret;
 }
@@ -132,19 +99,12 @@
 gchar *
 gedit_file_browser_utils_file_display (GFile * file)
 {
-	gchar * ret;
+	gchar *uri;
+	gchar *ret;
 	
-	GFileInfo * info = g_file_query_info (file,
-					     G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, 
-					     G_FILE_QUERY_INFO_NONE,
-					     NULL, 
-					     NULL);
-	
-	if (!info)
-		return NULL;
-
-	ret = g_strdup(g_file_info_get_display_name (info));
-	g_object_unref (info);
+	uri = g_file_get_uri (file);
+	ret = gedit_utils_uri_for_display (uri);
+	g_free (uri);
 	
 	return ret;
 }
@@ -152,27 +112,20 @@
 gchar *
 gedit_file_browser_utils_file_basename (GFile * file)
 {
-	gchar * display = gedit_file_browser_utils_file_display (file);
-	gchar * ret;
-
-	if (!display)
-		return g_file_get_basename (file);
-
-	ret = g_path_get_basename (display);
+	gchar *uri;
+	gchar *ret;
+	
+	uri = g_file_get_uri (file);
+	ret = gedit_file_browser_utils_uri_basename (uri);
+	g_free (uri);
 	
-	g_free (display);
 	return ret;
 }
 
 gchar *
 gedit_file_browser_utils_uri_basename (gchar const * uri)
 {
-	GFile * file = g_file_new_for_uri (uri);
-	gchar * ret = gedit_file_browser_utils_file_basename (file);
-	
-	g_object_unref (file);
-	
-	return ret;
+	return gedit_utils_basename_for_display (uri);
 }
 
 gboolean
@@ -226,16 +179,4 @@
 	return (ret == GTK_RESPONSE_OK);
 }
 
-gboolean
-_gedit_file_browser_utils_file_has_parent (GFile * file)
-{
-	GFile * parent = g_file_get_parent (file);
-	
-	if (!parent)
-		return FALSE;
-	
-	g_object_unref (parent);
-	return TRUE;
-}
-
 // ex:ts=8:noet:

Modified: trunk/plugins/filebrowser/gedit-file-browser-utils.h
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-utils.h	(original)
+++ trunk/plugins/filebrowser/gedit-file-browser-utils.h	Wed Aug  6 20:59:06 2008
@@ -23,8 +23,6 @@
 		                                           gchar const * button_stock, 
 		                                           gchar const * button_label);
 
-gboolean _gedit_file_browser_utils_file_has_parent	  (GFile * file);
-
 #endif /* __GEDIT_FILE_BROWSER_UTILS_H__ */
 
 // ex:ts=8:noet:

Modified: trunk/plugins/filebrowser/gedit-file-browser-widget.c
==============================================================================
--- trunk/plugins/filebrowser/gedit-file-browser-widget.c	(original)
+++ trunk/plugins/filebrowser/gedit-file-browser-widget.c	Wed Aug  6 20:59:06 2008
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
-#include <libgnome/gnome-url.h>
 #include <gdk/gdkkeysyms.h>
 #include <gedit/gedit-utils.h>
 #include <gedit/gedit-plugin.h>
@@ -625,7 +624,7 @@
 							   obj);
 		}
 
-		if (g_file_equal (current, loc->root) || !_gedit_file_browser_utils_file_has_parent (current)) {
+		if (g_file_equal (current, loc->root) || !gedit_utils_file_has_parent (current)) {
 			if (current != loc->virtual_root)
 				g_object_unref (current);
 			break;
@@ -2539,7 +2538,7 @@
 	if (FILE_IS_DIR (flags)) {
 		result = TRUE;
 
-		if (!gnome_url_show (uri, &error)) {
+		if (!gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (obj)), uri, GDK_CURRENT_TIME, &error)) {
 			g_signal_emit (obj, signals[ERROR], 0,
 				       GEDIT_FILE_BROWSER_ERROR_OPEN_DIRECTORY,
 				       error->message);



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