gedit r6275 - in trunk: . gedit



Author: pborelli
Date: Sat May 10 09:38:26 2008
New Revision: 6275
URL: http://svn.gnome.org/viewvc/gedit?rev=6275&view=rev

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

	* gedit-document.c:
	* gedit-document.h:
	* gedit-window.c:
	* gedit-window.h:
	Introduce gedit_document_get_location and port gedit-window to gio.



Modified:
   trunk/ChangeLog
   trunk/gedit/gedit-document.c
   trunk/gedit/gedit-document.h
   trunk/gedit/gedit-window.c
   trunk/gedit/gedit-window.h

Modified: trunk/gedit/gedit-document.c
==============================================================================
--- trunk/gedit/gedit-document.c	(original)
+++ trunk/gedit/gedit-document.c	Sat May 10 09:38:26 2008
@@ -844,6 +844,14 @@
 	g_object_notify (G_OBJECT (doc), "shortname");
 }
 
+GFile *
+gedit_document_get_location (GeditDocument *doc)
+{
+	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
+
+	return doc->priv->uri == NULL ? NULL : g_file_new_for_uri (doc->priv->uri);
+}
+
 gchar *
 gedit_document_get_uri (GeditDocument *doc)
 {

Modified: trunk/gedit/gedit-document.h
==============================================================================
--- trunk/gedit/gedit-document.h	(original)
+++ trunk/gedit/gedit-document.h	Sat May 10 09:38:26 2008
@@ -33,6 +33,7 @@
 #ifndef __GEDIT_DOCUMENT_H__
 #define __GEDIT_DOCUMENT_H__
 
+#include <gio/gio.h>
 #include <gtk/gtk.h>
 #include <gtksourceview/gtksourcebuffer.h>
 #include <libgnomevfs/gnome-vfs.h>
@@ -153,6 +154,8 @@
 
 GeditDocument   *gedit_document_new 		(void);
 
+GFile		*gedit_document_get_location	(GeditDocument       *doc);
+
 gchar		*gedit_document_get_uri 	(GeditDocument       *doc);
 void		 gedit_document_set_uri		(GeditDocument       *doc,
 						 const gchar 	     *uri);

Modified: trunk/gedit/gedit-window.c
==============================================================================
--- trunk/gedit/gedit-window.c	(original)
+++ trunk/gedit/gedit-window.c	Sat May 10 09:38:26 2008
@@ -37,7 +37,7 @@
 #include <string.h>
 
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gio.h>
 
 #include "gedit-ui.h"
 #include "gedit-window.h"
@@ -3617,45 +3617,63 @@
 }
 
 GeditTab *
-gedit_window_get_tab_from_uri (GeditWindow *window,
-			       const gchar *uri)
+gedit_window_get_tab_from_location (GeditWindow *window,
+				    GFile       *location)
 {
 	GList *tabs;
 	GList *l;
-	
+	GeditTab *ret = NULL;
+
 	g_return_val_if_fail (GEDIT_IS_WINDOW (window), NULL);
-	g_return_val_if_fail (uri != NULL, NULL);
-	
+	g_return_val_if_fail (G_IS_FILE (location), NULL);
+
 	tabs = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
 	
-	l = tabs;
-	while (l != NULL)
+	for (l = tabs; l != NULL; l = g_list_next (l))
 	{
-		gchar *u;
 		GeditDocument *d;
 		GeditTab *t;
-		
+		GFile *f;
+
 		t = GEDIT_TAB (l->data);
 		d = gedit_tab_get_document (t);
 
-		u = gedit_document_get_uri (d);
+		f = gedit_document_get_location (d);
 
-		if ((u != NULL) && gnome_vfs_uris_match (uri, u))
+		if ((f != NULL))
 		{
-			g_free (u);
-			
-			g_list_free (tabs);
-			
-			return t;
+			gboolean found = g_file_equal (location, f);
+
+			g_object_unref (f);
+
+			if (found)
+			{
+				ret = t;
+				break;
+			}
 		}
-		
-		g_free (u);
-		
-		l = g_list_next (l);
 	}
 	
 	g_list_free (tabs);
 	
-	return NULL;
+	return ret;
+}
+
+/* for backward compat since it is public api */
+GeditTab *
+gedit_window_get_tab_from_uri (GeditWindow *window,
+			       const gchar *uri)
+{
+	GFile *f;
+	GeditTab *tab;
+
+	g_return_val_if_fail (GEDIT_IS_WINDOW (window), NULL);
+	g_return_val_if_fail (uri != NULL, NULL);
+
+	f = g_file_new_for_uri (uri);
+	tab = gedit_window_get_tab_from_location (window, f);
+	g_object_unref (f);
+
+	return tab;
 }
 

Modified: trunk/gedit/gedit-window.h
==============================================================================
--- trunk/gedit/gedit-window.h	(original)
+++ trunk/gedit/gedit-window.h	Sat May 10 09:38:26 2008
@@ -31,6 +31,7 @@
 #ifndef __GEDIT_WINDOW_H__
 #define __GEDIT_WINDOW_H__
 
+#include <gio/gio.h>
 #include <gtk/gtk.h>
 
 #include <gedit/gedit-tab.h>
@@ -148,7 +149,10 @@
 GtkUIManager	*gedit_window_get_ui_manager		(GeditWindow         *window);
 
 GeditWindowState gedit_window_get_state 		(GeditWindow         *window);
-	
+
+GeditTab        *gedit_window_get_tab_from_location	(GeditWindow         *window,
+							 GFile               *location);
+
 GeditTab        *gedit_window_get_tab_from_uri		(GeditWindow         *window,
 							 const gchar         *uri);
 /*



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