gedit r6273 - in trunk: . gedit gedit/dialogs



Author: pborelli
Date: Fri May  9 16:59:28 2008
New Revision: 6273
URL: http://svn.gnome.org/viewvc/gedit?rev=6273&view=rev

Log:
2008-05-09  Paolo Borelli  <pborelli katamail com>

	* gedit/dialogs/gedit-open-location-dialog.c:
	* gedit/dialogs/gedit-open-location-dialog.h:
	* gedit/gedit-commands-file.c:
	Port the open location dialog to gio.



Modified:
   trunk/ChangeLog
   trunk/gedit/dialogs/gedit-open-location-dialog.c
   trunk/gedit/dialogs/gedit-open-location-dialog.h
   trunk/gedit/gedit-commands-file.c

Modified: trunk/gedit/dialogs/gedit-open-location-dialog.c
==============================================================================
--- trunk/gedit/dialogs/gedit-open-location-dialog.c	(original)
+++ trunk/gedit/dialogs/gedit-open-location-dialog.c	Fri May  9 16:59:28 2008
@@ -33,7 +33,8 @@
 #endif
 
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
+#include <gtk/gtk.h>
 
 #include "gedit-open-location-dialog.h"
 #include "gedit-history-entry.h"
@@ -82,6 +83,7 @@
                   gpointer                 data)
 {
 	gchar *uri;
+	const gchar *text;
 
 	switch (response_id)
 	{
@@ -94,21 +96,13 @@
 			break;
 
 		case GTK_RESPONSE_OK:
-			uri = gedit_open_location_dialog_get_uri (dlg);
-			if (uri != NULL)
+			text = gtk_entry_get_text
+					(GTK_ENTRY (dlg->priv->uri_text_entry));
+			if (*text != '\0')
 			{
-				const gchar *text;
-
-				text = gtk_entry_get_text
-						(GTK_ENTRY (dlg->priv->uri_text_entry));
-				if (*text != '\0')
-				{
-					gedit_history_entry_prepend_text
-							 (GEDIT_HISTORY_ENTRY (dlg->priv->uri_entry),
-							  text);
-				}
-
-				g_free (uri);
+				gedit_history_entry_prepend_text
+						 (GEDIT_HISTORY_ENTRY (dlg->priv->uri_entry),
+						  text);
 			}
 			break;
 	}
@@ -228,14 +222,11 @@
 	return dlg;
 }
 
-/* Always return a valid gnome vfs uri or NULL */
-gchar *
-gedit_open_location_dialog_get_uri (GeditOpenLocationDialog *dlg)
+GFile *
+gedit_open_location_dialog_get_location (GeditOpenLocationDialog *dlg)
 {
 	const gchar *str;
-	gchar *uri;
-	gchar *canonical_uri;
-	GnomeVFSURI *vfs_uri;
+	GFile *location;
 
 	g_return_val_if_fail (GEDIT_IS_OPEN_LOCATION_DIALOG (dlg), NULL);
 
@@ -245,25 +236,9 @@
 	if (str[0] == '\0')
 		return NULL;
 
-	uri = gnome_vfs_make_uri_from_input_with_dirs (str,
-						       GNOME_VFS_MAKE_URI_DIR_CURRENT);
-	g_return_val_if_fail (uri != NULL, NULL);
-
-	canonical_uri = gnome_vfs_make_uri_canonical (uri);
-	g_free (uri);
-
-	g_return_val_if_fail (canonical_uri != NULL, NULL);
-
-	vfs_uri = gnome_vfs_uri_new (canonical_uri);
-	if (vfs_uri == NULL)
-	{
-		g_free (canonical_uri);
-		return NULL;
-	}
-
-	gnome_vfs_uri_unref (vfs_uri);
+	location = g_file_new_for_commandline_arg (str);
 
-	return canonical_uri;
+	return location;
 }
 
 const GeditEncoding *

Modified: trunk/gedit/dialogs/gedit-open-location-dialog.h
==============================================================================
--- trunk/gedit/dialogs/gedit-open-location-dialog.h	(original)
+++ trunk/gedit/dialogs/gedit-open-location-dialog.h	Fri May  9 16:59:28 2008
@@ -31,6 +31,7 @@
 #ifndef __GEDIT_OPEN_LOCATION_DIALOG_H__
 #define __GEDIT_OPEN_LOCATION_DIALOG_H__
 
+#include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <gedit/gedit-encodings.h>
 
@@ -80,7 +81,7 @@
 
 GtkWidget		*gedit_open_location_dialog_new			(GtkWindow               *parent);
 
-gchar			*gedit_open_location_dialog_get_uri		(GeditOpenLocationDialog *dlg);
+GFile			*gedit_open_location_dialog_get_location	(GeditOpenLocationDialog *dlg);
 
 const GeditEncoding	*gedit_open_location_dialog_get_encoding	(GeditOpenLocationDialog *dlg);
 

Modified: trunk/gedit/gedit-commands-file.c
==============================================================================
--- trunk/gedit/gedit-commands-file.c	(original)
+++ trunk/gedit/gedit-commands-file.c	Fri May  9 16:59:28 2008
@@ -509,8 +509,9 @@
 				  gint                    response_id,
 				  GeditWindow             *window)
 {
-	gchar               *uri;
-	GSList              *uris = NULL;
+	GFile *location;
+	gchar *uri;
+	GSList *uris = NULL;
 	const GeditEncoding *encoding;
 
 	gedit_debug (DEBUG_COMMANDS);
@@ -522,48 +523,10 @@
 		return;
 	}
 
-	uri = gedit_open_location_dialog_get_uri (dlg);
-	if (uri == NULL)
-	{
-		GtkWidget      *msg;
-		GtkWindowGroup *wg;
-
-		wg = GTK_WINDOW (dlg)->group;
-
-		if (wg == NULL)
-		{
-			wg = gtk_window_group_new ();
-
-			gtk_window_group_add_window (wg, GTK_WINDOW (dlg));
-		}
-
-		msg = gtk_message_dialog_new (GTK_WINDOW (dlg),
-					      GTK_DIALOG_DESTROY_WITH_PARENT,
-					      GTK_MESSAGE_ERROR,
-					      GTK_BUTTONS_CLOSE,
-					      _("The entered location is not valid."));
-
-		gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (msg),
-							  _("Please check that you typed the "
-							    "location correctly and try again."));
-
-		gtk_window_group_add_window (wg, GTK_WINDOW (msg));
-
-		g_signal_connect (G_OBJECT (msg),
-				  "response",
-				  G_CALLBACK (gtk_widget_destroy),
-				  NULL);
-
-		gtk_window_set_resizable (GTK_WINDOW (msg), FALSE);
-		gtk_window_set_modal (GTK_WINDOW (msg), TRUE);
-
-		gtk_widget_show (msg);
-
-		return;
-	}
-
+	location = gedit_open_location_dialog_get_location (dlg);
 	encoding = gedit_open_location_dialog_get_encoding (dlg);
-	uris = g_slist_prepend (uris, uri);
+
+	uris = g_slist_prepend (uris, g_file_get_uri (location));
 
 	gtk_widget_destroy (GTK_WIDGET (dlg));
 



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