[kupfer] Add alias 'Home Folder' to home and hide the home app



commit a01e02491da8cd0471f20bd588d798e70264fc52
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Apr 3 17:03:50 2011 +0200

    Add alias 'Home Folder' to home and hide the home app
    
    Hide the application that calls itself "Home Folder". At the same
    time, give the home folder this alias.

 kupfer/obj/objects.py         |    4 +++-
 kupfer/obj/sources.py         |    8 +++++++-
 kupfer/plugin/applications.py |    6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/obj/objects.py b/kupfer/obj/objects.py
index d6d1659..a059814 100644
--- a/kupfer/obj/objects.py
+++ b/kupfer/obj/objects.py
@@ -49,7 +49,7 @@ class FileLeaf (Leaf, TextRepresentation):
 	"""
 	serializable = 1
 
-	def __init__(self, obj, name=None):
+	def __init__(self, obj, name=None, alias=None):
 		"""Construct a FileLeaf
 
 		The display name of the file is normally derived from the full path,
@@ -65,6 +65,8 @@ class FileLeaf (Leaf, TextRepresentation):
 		if not name:
 			name = gobject.filename_display_basename(obj)
 		super(FileLeaf, self).__init__(obj, name)
+		if alias:
+			self.kupfer_add_alias(alias)
 
 	def __eq__(self, other):
 		try:
diff --git a/kupfer/obj/sources.py b/kupfer/obj/sources.py
index d00f24f..34ec81b 100644
--- a/kupfer/obj/sources.py
+++ b/kupfer/obj/sources.py
@@ -56,6 +56,7 @@ class FileSource (Source):
 
 	def get_icon_name(self):
 		return "folder-saved-search"
+
 	def provides(self):
 		return ConstructFileLeafTypes()
 
@@ -108,7 +109,12 @@ class DirectorySource (Source, PicklingHelperMixin, FilesystemWatchMixin):
 		return "folder"
 
 	def get_leaf_repr(self):
-		return FileLeaf(self.directory)
+		if os.path.samefile(self.directory, os.path.expanduser("~")):
+			alias = _("Home Folder")
+		else:
+			alias = None
+		return FileLeaf(self.directory, alias=alias)
+
 	def provides(self):
 		return ConstructFileLeafTypes()
 
diff --git a/kupfer/plugin/applications.py b/kupfer/plugin/applications.py
index 6026552..2b3454b 100644
--- a/kupfer/plugin/applications.py
+++ b/kupfer/plugin/applications.py
@@ -58,9 +58,13 @@ class AppSource (Source, FilesystemWatchMixin):
 			"gstreamer-properties.desktop",
 			"notification-properties.desktop",
 			])
+		blacklist = set([
+			"nautilus-home.desktop",
+		])
 
 		for item in app_info_get_all():
-			if item.should_show() or item.get_id() in whitelist:
+			id_ = item.get_id()
+			if id_ in whitelist or (item.should_show() and not id_ in blacklist):
 				yield AppLeaf(item)
 
 	def should_sort_lexically(self):



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