deskbar-applet r2013 - in trunk: . deskbar/handlers



Author: sebp
Date: Tue Mar 18 17:54:22 2008
New Revision: 2013
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2013&view=rev

Log:
Fixed bug #474496: Files inside archives
Files that are in archives will appear as "Open <archive> containing <file>"

Modified:
   trunk/ChangeLog
   trunk/deskbar/handlers/beagle-live.py

Modified: trunk/deskbar/handlers/beagle-live.py
==============================================================================
--- trunk/deskbar/handlers/beagle-live.py	(original)
+++ trunk/deskbar/handlers/beagle-live.py	Tue Mar 18 17:54:22 2008
@@ -51,7 +51,7 @@
         },
     "File"         : {
         "name"    : ("beagle:ExactFilename",),
-        "extra" : {"inside_archive": ("fixme:inside_archive",) },
+        "extra" : {"inside_archive": ("fixme:inside_archive",), "parent_file": ("parent:beagle:ExactFilename",) },
         "category": "files",
         "snippet": True,
         },
@@ -183,10 +183,12 @@
         return verb
     
 class OpenBeagleFileAction(OpenFileAction):
-    def __init__(self, name, uri, inside_archive):
+    def __init__(self, name, uri, inside_archive, parent_file):
         self._complete_uri = uri
+        self._parent_file = parent_file
         if inside_archive == "true":
             uri = self.__get_archive_uri(uri)
+            
         OpenFileAction.__init__(self, name, uri, False)
         
     def __get_archive_uri(self, uri):
@@ -194,6 +196,20 @@
         if match != None:
             return match.groups()[0]
         
+    def get_verb(self):
+        if self._parent_file != None:
+            # translators: in this case the file (2nd) is part of an archive (1st)
+            # e.g. README is part of deskbar-applet.tar.gz
+            return _("Open %s containing %s") % ("<b>%(parent)s</b>", "<b>%(name)s</b>")
+        else:
+            return _("Open %s") % "<b>%(name)s</b>"
+        
+    def get_name(self, text=None):
+        names = OpenFileAction.get_name (self)
+        if self._parent_file != None:
+            names["parent"] = self._parent_file
+        return names 
+        
     def get_hash(self):
         return self._complete_uri
 
@@ -248,13 +264,25 @@
         elif (result["type"] == "WebHistory"):
             self.add_action( OpenWebHistoryAction(result["name"], result["uri"], result["escaped_uri"]) )
         elif (result["type"] == "File" or result["type"] == "Directory"):
-            # Unescape URI again
             # For files inside archives only work with the archive itsself
             result["escaped_uri"] = result["escaped_uri"].split('#')[0]
+            # Unescape URI again
             unescaped_uri = gnomevfs.unescape_string_for_display(result["escaped_uri"])
             if not result.has_key("inside_archive"):
                 result["inside_archive"] = "false"
-            actions = [OpenBeagleFileAction(result["name"], result["uri"], result["inside_archive"])] \
+            
+            if result["inside_archive"] == "true":
+                file_open_action = OpenBeagleFileAction(result["name"],
+                                                        result["uri"],
+                                                        result["inside_archive"],
+                                                        result["parent_file"])
+            else:
+                file_open_action = OpenBeagleFileAction(result["name"],
+                                                        result["uri"],
+                                                        result["inside_archive"],
+                                                        None)
+                
+            actions = [file_open_action] \
                        + get_actions_for_uri( unescaped_uri,
                                               display_name=basename(unescaped_uri)
                                             )



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