gnome-panel r10809 - trunk/gnome-panel



Author: vuntz
Date: Mon Feb 11 10:49:32 2008
New Revision: 10809
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=10809&view=rev

Log:
2008-02-11  Vincent Untz  <vuntz gnome org>

	* panel-util.c: (panel_util_get_file_description): new, to get the
	description of a GFile
	(panel_util_get_label_for_uri): rework to use the description of the
	GFile when available


Modified:
   trunk/gnome-panel/ChangeLog
   trunk/gnome-panel/panel-util.c

Modified: trunk/gnome-panel/panel-util.c
==============================================================================
--- trunk/gnome-panel/panel-util.c	(original)
+++ trunk/gnome-panel/panel-util.c	Mon Feb 11 10:49:32 2008
@@ -1412,6 +1412,27 @@
 }
 
 static char *
+panel_util_get_file_description (GFile *file)
+{
+	GFileInfo *info;
+	char      *ret;
+
+	ret = NULL;
+
+	info = g_file_query_info (file, "standard::description",
+				  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+				  NULL, NULL);
+
+	if (info) {
+		ret = g_strdup (g_file_info_get_attribute_string (info,
+								  G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION));
+		g_object_unref (info);
+	}
+
+	return ret;
+}
+
+static char *
 panel_util_get_file_display_name (GFile    *file,
 				  gboolean  use_fallback)
 {
@@ -1510,17 +1531,18 @@
 {
 	GFile *file;
 	char  *label;
-	char *hostname;
-	char *displayname;
+	GFile *root;
+	char  *root_display;
 
 	/* Here's what we do:
 	 *  + x-nautilus-search: URI
 	 *  + check if the URI is a mount
 	 *  + if file: URI:
 	 *   - check for known file: URI
+	 *   - check for description of the GFile
 	 *   - use display name of the GFile
 	 *  + else:
-	 *   - if we have a hostname: "displayname on hostname"
+	 *   - check for description of the GFile
 	 *   - if the URI is a root: "root displayname"
 	 *   - else: "root displayname: displayname"
 	 */
@@ -1542,50 +1564,46 @@
 	if (g_str_has_prefix (text_uri, "file:")) {
 		label = panel_util_get_file_display_for_common_files (file);
 		if (!label)
+			label = panel_util_get_file_description (file);
+		if (!label)
 			label = panel_util_get_file_display_name (file, TRUE);
 		g_object_unref (file);
 
 		return label;
 	}
 
-	g_filename_from_uri (text_uri, &hostname, NULL);
-	displayname = panel_util_get_file_display_name (file, TRUE);
-
-	//FIXME: bah, doesn't work
-	if (hostname) {
-		/* Translators: the first string is a path and the second
-		 * string is a hostname. nautilus contains the same string to
-		 * translate. */
-		label = g_strdup_printf (_("%1$s on %2$s"),
-					 displayname, hostname);
-		g_free (hostname);
-	} else {
-		GFile *root;
-		char  *root_display;
+	label = panel_util_get_file_description (file);
+	if (label) {
+		g_object_unref (file);
+		return label;
+	}
 
-		root = panel_util_get_gfile_root (file);
+	root = panel_util_get_gfile_root (file);
+	root_display = panel_util_get_file_description (root);
+	if (!root_display)
 		root_display = panel_util_get_file_display_name (root, FALSE);
-		if (!root_display)
-			/* can happen with URI schemes non supported by gvfs */
-			root_display = g_file_get_uri_scheme (root);
-
-		if (g_file_equal (file, root))
-			label = root_display;
-		else {
-			/* Translators: the first string is the name of a gvfs
-			 * method, and the second string is a path. For
-			 * example, "Trash: some-directory". It means that the
-			 * directory called "some-directory" is in the trash.
-			 */
-			label = g_strdup_printf (_("%1$s: %2$s"),
-						 root_display, displayname);
-			g_free (root_display);
-		}
+	if (!root_display)
+		/* can happen with URI schemes non supported by gvfs */
+		root_display = g_file_get_uri_scheme (root);
 
-		g_object_unref (root);
+	if (g_file_equal (file, root))
+		label = root_display;
+	else {
+		char *displayname;
+
+		displayname = panel_util_get_file_display_name (file, TRUE);
+		/* Translators: the first string is the name of a gvfs
+		 * method, and the second string is a path. For
+		 * example, "Trash: some-directory". It means that the
+		 * directory called "some-directory" is in the trash.
+		 */
+		label = g_strdup_printf (_("%1$s: %2$s"),
+					 root_display, displayname);
+		g_free (root_display);
+		g_free (displayname);
 	}
 
-	g_free (displayname);
+	g_object_unref (root);
 	g_object_unref (file);
 
 	return label;



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