Improvements to path changes in Olive

Fix bug 229044 by adding PermissionDenied error check
Move creation of locationbar icon to window.py
Allow for locationbar icon to be a button so dialogs can be connected
Add info dialog to PermissionDenied error
Rework refresh_right to not double check paths and handle lock
exceptions (with dialog)

Besides this, I almost have a patch for colouring the statuses in Olive
but I think that can wait till after 0.95

After this patch is merged I'm ok with a release.

Jasper

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [EMAIL PROTECTED]
# target_branch: https://code.launchpad.net/~bzr-gtk/bzr-gtk/trunk
# testament_sha1: d902c2f48b42f35cc768e18802f659ea40ccf756
# timestamp: 2008-08-03 12:08:32 +0200
# source_branch: https://code.launchpad.net/~bzr-gtk/bzr-gtk/trunk
# base_revision_id: [EMAIL PROTECTED]
# 
# Begin patch
=== modified file 'olive/__init__.py'
--- olive/__init__.py	2008-08-03 08:32:49 +0000
+++ olive/__init__.py	2008-08-03 10:07:38 +0000
@@ -105,7 +105,6 @@
         self.button_location_up = self.window.button_location_up
         self.button_location_jump = self.window.button_location_jump
         self.entry_location = self.window.entry_location
-        self.image_location_error = self.window.image_location_error
         
         # Get the History widgets
         self.check_history = self.window.checkbutton_history
@@ -156,25 +155,26 @@
         self._just_started = False
 
     def set_path(self, path, force_remote=False):
+        self.window.location_status.destroy()
         self.notbranch = False
         
         if force_remote:
             # Forcing remote mode (reading data from inventory)
-            self._show_stock_image(gtk.STOCK_DISCONNECT)
+            self.window.set_location_status(gtk.STOCK_DISCONNECT)
             try:
                 br = Branch.open_containing(path)[0]
             except bzrerrors.NotBranchError:
-                self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
+                self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
                 self.check_history.set_active(False)
                 self.check_history.set_sensitive(False)
                 return False
             except bzrerrors.UnsupportedProtocol:
-                self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
+                self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
                 self.check_history.set_active(False)
                 self.check_history.set_sensitive(False)
                 return False
             
-            self._show_stock_image(gtk.STOCK_CONNECT)
+            self.window.set_location_status(gtk.STOCK_CONNECT)
             
             self.remote = True
            
@@ -203,7 +203,6 @@
                 self.button_location_up.set_sensitive(True)
         else:
             if os.path.isdir(path):
-                self.image_location_error.destroy()
                 self.remote = False
                 
                 # We're local
@@ -211,6 +210,12 @@
                     self.wt, self.wtpath = WorkingTree.open_containing(os.path.realpath(path))
                 except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
                     self.notbranch = True
+                except bzrerrors.PermissionDenied:
+                    self.window.set_location_status(gtk.STOCK_DIALOG_WARNING, allowPopup=True)
+                    self.window.location_status.connect_object('clicked', warning_dialog, 
+                                       *(_i18n('Branch information unreadable'),
+                                		_i18n('The current folder is a branch but the .bzr folder is not readable')))
+                    self.notbranch = True
                 
                 # If we're in the root, we cannot go up anymore
                 if sys.platform == 'win32':
@@ -227,21 +232,21 @@
             elif not os.path.isfile(path):
                 # Doesn't seem to be a file nor a directory, trying to open a
                 # remote location
-                self._show_stock_image(gtk.STOCK_DISCONNECT)
+                self.window.set_location_status(gtk.STOCK_DISCONNECT)
                 try:
                     br = Branch.open_containing(path)[0]
                 except bzrerrors.NotBranchError:
-                    self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
+                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
                     self.check_history.set_active(False)
                     self.check_history.set_sensitive(False)
                     return False
                 except bzrerrors.UnsupportedProtocol:
-                    self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
+                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
                     self.check_history.set_active(False)
                     self.check_history.set_sensitive(False)
                     return False
                 
-                self._show_stock_image(gtk.STOCK_CONNECT)
+                self.window.set_location_status(gtk.STOCK_CONNECT)
                 
                 self.remote = True
                
@@ -938,19 +943,14 @@
         # Add the ListStore to the TreeView
         self.window.treeview_left.set_model(liststore)
 
-    def refresh_right(self, path=None):
+    def refresh_right(self):
         """ Refresh the file list. """
         if not self.remote:
             # We're local
             from bzrlib.workingtree import WorkingTree
     
-            if path is None:
-                path = self.get_path()
-    
-            # A workaround for double-clicking Bookmarks
-            if not os.path.exists(path):
-                return
-    
+            path = self.get_path()
+            
             # Get ListStore and clear it
             liststore = self.window.filelist
             liststore.clear()
@@ -970,31 +970,31 @@
                 else:
                     files.append(item)
             
-            # Try to open the working tree
-            notbranch = False
-            try:
-                tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
-            except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
-                notbranch = True
-            
-            if not notbranch:
-                branch = tree1.branch
-                tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
-            
-                delta = tree1.changes_from(tree2, want_unchanged=True)
-                
-                # Show Status column
-            	self.window.col_status.set_visible(True)
-            else:
-                # Don't show Status column
-            	self.window.col_status.set_visible(False)
-                
+            self.window.col_status.set_visible(False)
+            if not self.notbranch:
+                try:
+                    tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
+                    branch = tree1.branch
+                    tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
+                
+                    delta = tree1.changes_from(tree2, want_unchanged=True)
+                    
+                    # Show Status column
+                    self.window.col_status.set_visible(True)
+                except bzrerrors.LockContention:
+                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR, allowPopup=True)
+                    self.window.location_status.connect_object('clicked', error_dialog, 
+                                       *(_i18n('Branch is locked'),
+                                		_i18n('The branch in the current folder is locked by another Bazaar program')))
+                    self.notbranch = True
+                    self.window.set_view_to_localbranch(False) 
+            
             # Add'em to the ListStore
             for item in dirs:
                 status = ''
                 st = ''
                 fileid = ''
-                if not notbranch:
+                if not self.notbranch:
                     filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
                     
                     st, status = self.statusmapper(filename, delta)
@@ -1022,7 +1022,7 @@
                 status = ''
                 st = ''
                 fileid = ''
-                if not notbranch:
+                if not self.notbranch:
                     filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
                     
                     st, status = self.statusmapper(filename, delta)
@@ -1059,7 +1059,7 @@
             dirs = []
             files = []
             
-            self._show_stock_image(gtk.STOCK_REFRESH)
+            self.window.set_location_status(gtk.STOCK_REFRESH)
             
             for (name, type) in self.remote_entries:
                 if type.kind == 'directory':
@@ -1124,7 +1124,7 @@
                 while gtk.events_pending():
                     gtk.main_iteration()
             
-            self.image_location_error.destroy()
+            self.window.location_status.destroy()
 
         # Columns should auto-size
         self.window.treeview_right.columns_autosize()
@@ -1212,7 +1212,7 @@
         if active >= 0:
             drive = model[active][0]
             self.set_path(drive + '\\')
-            self.refresh_right(drive + '\\')
+            self.refresh_right()
     
     def check_for_changes(self):
         """ Check whether there were changes in the current working tree. """
@@ -1291,19 +1291,6 @@
                     return True
             # Either it's not a directory or not in the inventory
             return False
-    
-    def _show_stock_image(self, stock_id):
-        """ Show a stock image next to the location entry. """
-        self.image_location_error.destroy()
-        self.image_location_error = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
-        self.hbox_location.pack_start(self.image_location_error, False, False, 0)
-        if sys.platform == 'win32':
-            self.hbox_location.reorder_child(self.image_location_error, 2)
-        else:
-            self.hbox_location.reorder_child(self.image_location_error, 1)
-        self.image_location_error.show()
-        while gtk.events_pending():
-            gtk.main_iteration()
 
 import ConfigParser
 

=== modified file 'olive/window.py'
--- olive/window.py	2008-08-03 08:32:49 +0000
+++ olive/window.py	2008-08-03 10:07:38 +0000
@@ -17,6 +17,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import os
+import sys
 import gtk
 import gobject
 
@@ -338,9 +339,9 @@
         self.entry_location.connect("activate", self.signal.on_button_location_jump_clicked)
         self.locationbar.pack_start(self.entry_location, True, True, 0)
         
-        self.image_location_error = gtk.Image()
-        self.image_location_error.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
-        self.locationbar.pack_start(self.image_location_error, False, False, 0)
+        self.location_status = gtk.Image()
+        self.location_status.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
+        self.locationbar.pack_start(self.location_status, False, False, 0)
         
         self.button_location_jump = gtk.Button(stock=gtk.STOCK_JUMP_TO)
         self.button_location_jump.set_relief(gtk.RELIEF_NONE)
@@ -517,3 +518,20 @@
         self.tb_pull.set_sensitive(False)
         self.tb_push.set_sensitive(False)
         self.tb_update.set_sensitive(False)
+    
+    def set_location_status(self, stock_id, allowPopup=False):
+        self.location_status.destroy()
+        if allowPopup:
+            self.location_status = gtk.Button()
+            self.location_status.set_relief(gtk.RELIEF_NONE)
+            image = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
+            image.show()
+            self.location_status.add(image)
+        else:
+            self.location_status = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
+        self.locationbar.pack_start(self.location_status, False, False, 0)
+        if sys.platform == 'win32':
+            self.locationbar.reorder_child(self.location_status, 2)
+        else:
+            self.locationbar.reorder_child(self.location_status, 1)
+        self.location_status.show()

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWc3MOWoABHf/gER0QARZ9///
f//emr////BgCTvvVu7qgAdUZfVH0BrpoUAAREk/UjTJtQGQHqAAaZNA0A0AAAMgNKhiGjTagAZA
AZAAA0AGQDQAlVPap4aIEmmQDIaAAAAAABoAAxE1NSehkpvKepPJlMEDIZAGAjBA0HoEDalNMqej
JPRoIGgyGhoaAAAAA0AAkiBBMTIm0RPQ00pmJlT0ejVPTUxpPQmJgmnqHqKACji1V1YmLmZTgPd6
Vho2gZf8C7dvXksyCmKA1smVURxiPFggcXFGG37d0D9mJkzU359RcbNiomBlX173uwXUS6s7ESQo
QKRAF+05ozF223yKTNer0MdDUjUzxjYCSvyL4AhBWJJMLZ4WZ8V/kyGTMgEgTSJ6pIHXF6GxLVVi
NilpWuICdRS09JpSaEkbcWjr6ArHIor5niJKaEFbPM2TXKPkPchXkiMPOMAmJGEEOnmZFADlKill
2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lfXUMNznSg6TPh7WgDOMyY+BFOOmg
3uUAd2f5uYFNgtUFuUDWBoTI1RLwq21k07ySAjeWIimgfSTxLNowZ7NvAYgW8DdttMVK0YFWMatw
RgqPEX1MkK9HwRSqezUFehJyp2wIECbCAywBEUbLhWDIppY6yMt1E22dS5nVzBZmZ4JJSDT2uLBc
NWmmn8QNYaeQ1pJWHoxwYbJesuXMkes1ExC8kMEVpPeP/jiKPl3tAF1k8Oo7CCh8hJ0beQ35kDSm
CCgNuKzznmLVqRcBomJFbX+LuSKcKEhm5hy1AA==

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
bzr-gtk mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.canonical.com/mailman/listinfo/bzr-gtk

Reply via email to