/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/__init__.py

  • Committer: Jasper Groenewegen
  • Date: 2008-08-03 21:26:48 UTC
  • mfrom: (585.1.1 LP229044)
  • Revision ID: colbrac@xs4all.nl-20080803212648-l27zmnl5q95gmpes
Merge Olive path change handling improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
        self.button_location_up = self.window.button_location_up
106
106
        self.button_location_jump = self.window.button_location_jump
107
107
        self.entry_location = self.window.entry_location
108
 
        self.image_location_error = self.window.image_location_error
109
108
        
110
109
        # Get the History widgets
111
110
        self.check_history = self.window.checkbutton_history
156
155
        self._just_started = False
157
156
 
158
157
    def set_path(self, path, force_remote=False):
 
158
        self.window.location_status.destroy()
159
159
        self.notbranch = False
160
160
        
161
161
        if force_remote:
162
162
            # Forcing remote mode (reading data from inventory)
163
 
            self._show_stock_image(gtk.STOCK_DISCONNECT)
 
163
            self.window.set_location_status(gtk.STOCK_DISCONNECT)
164
164
            try:
165
165
                br = Branch.open_containing(path)[0]
166
166
            except bzrerrors.NotBranchError:
167
 
                self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
 
167
                self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
168
168
                self.check_history.set_active(False)
169
169
                self.check_history.set_sensitive(False)
170
170
                return False
171
171
            except bzrerrors.UnsupportedProtocol:
172
 
                self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
 
172
                self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
173
173
                self.check_history.set_active(False)
174
174
                self.check_history.set_sensitive(False)
175
175
                return False
176
176
            
177
 
            self._show_stock_image(gtk.STOCK_CONNECT)
 
177
            self.window.set_location_status(gtk.STOCK_CONNECT)
178
178
            
179
179
            self.remote = True
180
180
           
203
203
                self.button_location_up.set_sensitive(True)
204
204
        else:
205
205
            if os.path.isdir(path):
206
 
                self.image_location_error.destroy()
207
206
                self.remote = False
208
207
                
209
208
                # We're local
211
210
                    self.wt, self.wtpath = WorkingTree.open_containing(os.path.realpath(path))
212
211
                except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
213
212
                    self.notbranch = True
 
213
                except bzrerrors.PermissionDenied:
 
214
                    self.window.set_location_status(gtk.STOCK_DIALOG_WARNING, allowPopup=True)
 
215
                    self.window.location_status.connect_object('clicked', warning_dialog, 
 
216
                                       *(_i18n('Branch information unreadable'),
 
217
                                                _i18n('The current folder is a branch but the .bzr folder is not readable')))
 
218
                    self.notbranch = True
214
219
                
215
220
                # If we're in the root, we cannot go up anymore
216
221
                if sys.platform == 'win32':
227
232
            elif not os.path.isfile(path):
228
233
                # Doesn't seem to be a file nor a directory, trying to open a
229
234
                # remote location
230
 
                self._show_stock_image(gtk.STOCK_DISCONNECT)
 
235
                self.window.set_location_status(gtk.STOCK_DISCONNECT)
231
236
                try:
232
237
                    br = Branch.open_containing(path)[0]
233
238
                except bzrerrors.NotBranchError:
234
 
                    self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
 
239
                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
235
240
                    self.check_history.set_active(False)
236
241
                    self.check_history.set_sensitive(False)
237
242
                    return False
238
243
                except bzrerrors.UnsupportedProtocol:
239
 
                    self._show_stock_image(gtk.STOCK_DIALOG_ERROR)
 
244
                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR)
240
245
                    self.check_history.set_active(False)
241
246
                    self.check_history.set_sensitive(False)
242
247
                    return False
243
248
                
244
 
                self._show_stock_image(gtk.STOCK_CONNECT)
 
249
                self.window.set_location_status(gtk.STOCK_CONNECT)
245
250
                
246
251
                self.remote = True
247
252
               
938
943
        # Add the ListStore to the TreeView
939
944
        self.window.treeview_left.set_model(liststore)
940
945
 
941
 
    def refresh_right(self, path=None):
 
946
    def refresh_right(self):
942
947
        """ Refresh the file list. """
943
948
        if not self.remote:
944
949
            # We're local
945
950
            from bzrlib.workingtree import WorkingTree
946
951
    
947
 
            if path is None:
948
 
                path = self.get_path()
949
 
    
950
 
            # A workaround for double-clicking Bookmarks
951
 
            if not os.path.exists(path):
952
 
                return
953
 
    
 
952
            path = self.get_path()
 
953
            
954
954
            # Get ListStore and clear it
955
955
            liststore = self.window.filelist
956
956
            liststore.clear()
970
970
                else:
971
971
                    files.append(item)
972
972
            
973
 
            # Try to open the working tree
974
 
            notbranch = False
975
 
            try:
976
 
                tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
977
 
            except (bzrerrors.NotBranchError, bzrerrors.NoWorkingTree):
978
 
                notbranch = True
979
 
            
980
 
            if not notbranch:
981
 
                branch = tree1.branch
982
 
                tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
983
 
            
984
 
                delta = tree1.changes_from(tree2, want_unchanged=True)
985
 
                
986
 
                # Show Status column
987
 
                self.window.col_status.set_visible(True)
988
 
            else:
989
 
                # Don't show Status column
990
 
                self.window.col_status.set_visible(False)
991
 
                
 
973
            self.window.col_status.set_visible(False)
 
974
            if not self.notbranch:
 
975
                try:
 
976
                    tree1 = WorkingTree.open_containing(os.path.realpath(path))[0]
 
977
                    branch = tree1.branch
 
978
                    tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
 
979
                
 
980
                    delta = tree1.changes_from(tree2, want_unchanged=True)
 
981
                    
 
982
                    # Show Status column
 
983
                    self.window.col_status.set_visible(True)
 
984
                except bzrerrors.LockContention:
 
985
                    self.window.set_location_status(gtk.STOCK_DIALOG_ERROR, allowPopup=True)
 
986
                    self.window.location_status.connect_object('clicked', error_dialog, 
 
987
                                       *(_i18n('Branch is locked'),
 
988
                                                _i18n('The branch in the current folder is locked by another Bazaar program')))
 
989
                    self.notbranch = True
 
990
                    self.window.set_view_to_localbranch(False) 
 
991
            
992
992
            # Add'em to the ListStore
993
993
            for item in dirs:
994
994
                status = ''
995
995
                st = ''
996
996
                fileid = ''
997
 
                if not notbranch:
 
997
                if not self.notbranch:
998
998
                    filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
999
999
                    
1000
1000
                    st, status = self.statusmapper(filename, delta)
1022
1022
                status = ''
1023
1023
                st = ''
1024
1024
                fileid = ''
1025
 
                if not notbranch:
 
1025
                if not self.notbranch:
1026
1026
                    filename = tree1.relpath(os.path.join(os.path.realpath(path), item))
1027
1027
                    
1028
1028
                    st, status = self.statusmapper(filename, delta)
1059
1059
            dirs = []
1060
1060
            files = []
1061
1061
            
1062
 
            self._show_stock_image(gtk.STOCK_REFRESH)
 
1062
            self.window.set_location_status(gtk.STOCK_REFRESH)
1063
1063
            
1064
1064
            for (name, type) in self.remote_entries:
1065
1065
                if type.kind == 'directory':
1124
1124
                while gtk.events_pending():
1125
1125
                    gtk.main_iteration()
1126
1126
            
1127
 
            self.image_location_error.destroy()
 
1127
            self.window.location_status.destroy()
1128
1128
 
1129
1129
        # Columns should auto-size
1130
1130
        self.window.treeview_right.columns_autosize()
1212
1212
        if active >= 0:
1213
1213
            drive = model[active][0]
1214
1214
            self.set_path(drive + '\\')
1215
 
            self.refresh_right(drive + '\\')
 
1215
            self.refresh_right()
1216
1216
    
1217
1217
    def check_for_changes(self):
1218
1218
        """ Check whether there were changes in the current working tree. """
1291
1291
                    return True
1292
1292
            # Either it's not a directory or not in the inventory
1293
1293
            return False
1294
 
    
1295
 
    def _show_stock_image(self, stock_id):
1296
 
        """ Show a stock image next to the location entry. """
1297
 
        self.image_location_error.destroy()
1298
 
        self.image_location_error = gtk.image_new_from_stock(stock_id, gtk.ICON_SIZE_BUTTON)
1299
 
        self.hbox_location.pack_start(self.image_location_error, False, False, 0)
1300
 
        if sys.platform == 'win32':
1301
 
            self.hbox_location.reorder_child(self.image_location_error, 2)
1302
 
        else:
1303
 
            self.hbox_location.reorder_child(self.image_location_error, 1)
1304
 
        self.image_location_error.show()
1305
 
        while gtk.events_pending():
1306
 
            gtk.main_iteration()
1307
1294
 
1308
1295
import ConfigParser
1309
1296