[sushi/alex-changes: 4/11] Use the display name for the file name label



commit 4834e886496c32c8b3caa8f03647b55eb81fc1c3
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Apr 29 09:29:32 2011 +0200

    Use the display name for the file name label
    
    This is needed, because the basename might not be proper utf8

 src/js/ui/mainWindow.js |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index d3e60be..6e51ba9 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -442,18 +442,33 @@ MainWindow.prototype = {
         return false;
     },
 
+
+    _updateLabel : function(file) {
+	file.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_DEFAULT, null,
+			      function (obj, res) {
+				  try {
+				      let info = obj.query_info_finish(res);
+
+				      if (info.has_attribute(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME))
+					  this._titleLabel.set_label(info.get_attribute_string(Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME));
+				  } catch (e) {
+				  }
+			      });
+    },
+
     /**************************************************************************
      ************************ titlebar helpers ********************************
      **************************************************************************/
     _createTitle : function(file) {
         if (this._titleLabel) {
-            this._titleLabel.set_label(file.get_basename());
+            this._updateLabel(file);
             this._titleActor.raise_top();
             this._quitActor.raise_top();
             return;
         }
 
-        this._titleLabel = new Gtk.Label({ label: file.get_basename() });
+        this._titleLabel = new Gtk.Label({ label: "" });
+        this._updateLabel(file);
         this._titleLabel.get_style_context().add_class("np-decoration");
         
         this._titleLabel.show();



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