gedit r6926 - in trunk: . gedit
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6926 - in trunk: . gedit
- Date: Sat, 28 Feb 2009 13:03:07 +0000 (UTC)
Author: pborelli
Date: Sat Feb 28 13:03:07 2009
New Revision: 6926
URL: http://svn.gnome.org/viewvc/gedit?rev=6926&view=rev
Log:
2009-02-28 Paolo Borelli <pborelli katamail com>
* gedit/gedit-utils.[ch]:
* gedit/gedit-window.c:
* gedit/gedit-tab.c:
Improve how the dirname in the titlebar is shown for remote files
which have a mount name. Bug #573286, based on a patch by Ignacio
Casal Quinteiro.
Modified:
trunk/ChangeLog
trunk/gedit/gedit-tab.c
trunk/gedit/gedit-utils.c
trunk/gedit/gedit-utils.h
trunk/gedit/gedit-window.c
Modified: trunk/gedit/gedit-tab.c
==============================================================================
--- trunk/gedit/gedit-tab.c (original)
+++ trunk/gedit/gedit-tab.c Sat Feb 28 13:03:07 2009
@@ -631,15 +631,16 @@
}
else
{
- gchar *uri;
- gchar *str;
-
- uri = gedit_document_get_uri_for_display (doc);
- str = gedit_utils_uri_get_dirname (uri);
- g_free (uri);
+ GFile *file;
- if (str != NULL)
+ file = gedit_document_get_location (doc);
+ if (file != NULL)
{
+ gchar *str;
+
+ str = gedit_utils_location_get_dirname_for_display (file);
+ g_object_unref (file);
+
/* use the remaining space for the dir, but use a min of 20 chars
* so that we do not end up with a dirname like "(a...b)".
* This means that in the worst case when the filename is long 99
Modified: trunk/gedit/gedit-utils.c
==============================================================================
--- trunk/gedit/gedit-utils.c (original)
+++ trunk/gedit/gedit-utils.c Sat Feb 28 13:03:07 2009
@@ -661,7 +661,9 @@
gchar *res;
gchar *str;
- // CHECK: does it work with uri chaining? - Paolo
+ g_return_val_if_fail (uri != NULL, NULL);
+
+ /* CHECK: does it work with uri chaining? - Paolo */
str = g_path_get_dirname (uri);
g_return_val_if_fail (str != NULL, ".");
@@ -679,6 +681,71 @@
return res;
}
+/**
+ * gedit_utils_location_get_dirname_for_display
+ * @file: the location
+ *
+ * Returns a string suitable to be displayed in the UI indicating
+ * the name of the directory where the file is located.
+ * For remote files it may also contain the hostname etc.
+ * For local files it tries to replace the home dir with ~.
+ *
+ * Returns: a string to display the dirname
+ */
+gchar *
+gedit_utils_location_get_dirname_for_display (GFile *location)
+{
+ gchar *uri;
+ gchar *res;
+ GMount *mount;
+
+ g_return_val_if_fail (location != NULL, NULL);
+
+ /* we use the parse name, that is either the local path
+ * or an uri but which is utf8 safe */
+ uri = g_file_get_parse_name (location);
+
+ /* FIXME: this is sync... is it a problem? */
+ mount = g_file_find_enclosing_mount (location, NULL, NULL);
+ if (mount != NULL)
+ {
+ gchar *mount_name;
+ gchar *path;
+
+ mount_name = g_mount_get_name (mount);
+ g_object_unref (mount);
+
+ /* obtain the "path" patrt of the uri */
+ if (gedit_utils_decode_uri (uri,
+ NULL, NULL,
+ NULL, NULL,
+ &path))
+ {
+ gchar *dirname;
+
+ dirname = gedit_utils_uri_get_dirname (path);
+ res = g_strdup_printf ("%s %s", mount_name, dirname);
+
+ g_free (path);
+ g_free (dirname);
+ g_free (mount_name);
+ }
+ else
+ {
+ res = mount_name;
+ }
+ }
+ else
+ {
+ /* fallback for local files or uris without mounts */
+ res = gedit_utils_uri_get_dirname (uri);
+ }
+
+ g_free (uri);
+
+ return res;
+}
+
gchar *
gedit_utils_replace_home_dir_with_tilde (const gchar *uri)
{
Modified: trunk/gedit/gedit-utils.h
==============================================================================
--- trunk/gedit/gedit-utils.h (original)
+++ trunk/gedit/gedit-utils.h Sat Feb 28 13:03:07 2009
@@ -111,6 +111,9 @@
/* Note that this function replace home dir with ~ */
gchar *gedit_utils_uri_get_dirname (const char *uri);
+gchar *gedit_utils_location_get_dirname_for_display
+ (GFile *location);
+
gchar *gedit_utils_replace_home_dir_with_tilde (const gchar *uri);
guint gedit_utils_get_current_workspace (GdkScreen *screen);
Modified: trunk/gedit/gedit-window.c
==============================================================================
--- trunk/gedit/gedit-window.c (original)
+++ trunk/gedit/gedit-window.c Sat Feb 28 13:03:07 2009
@@ -2125,15 +2125,16 @@
}
else
{
- gchar *uri;
- gchar *str;
+ GFile *file;
- uri = gedit_document_get_uri_for_display (doc);
- str = gedit_utils_uri_get_dirname (uri);
- g_free (uri);
-
- if (str != NULL)
+ file = gedit_document_get_location (doc);
+ if (file != NULL)
{
+ gchar *str;
+
+ str = gedit_utils_location_get_dirname_for_display (file);
+ g_object_unref (file);
+
/* use the remaining space for the dir, but use a min of 20 chars
* so that we do not end up with a dirname like "(a...b)".
* This means that in the worst case when the filename is long 99
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]