~bzr-gtk/bzr-gtk/0.95

« back to all changes in this revision

Viewing changes to olive/__init__.py

merge win32 fixes from my olive branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
    gladefile = "/usr/share/olive/olive.glade"
46
46
 
47
47
if not os.path.exists(gladefile):
48
 
    # Load from current directory if not installed
49
 
    gladefile = "olive.glade"
 
48
    # Load from sources directory if not installed
 
49
    dir_ = os.path.split(os.path.dirname(__file__))[0]
 
50
    gladefile = os.path.join(dir_, "olive.glade")
50
51
    # Check again
51
52
    if not os.path.exists(gladefile):
52
53
        # Fail
188
189
        self.notbranch = False
189
190
        try:
190
191
            self.wt, self.wtpath = WorkingTree.open_containing(self.path)
191
 
        except errors.NotBranchError:
 
192
        except (errors.NotBranchError, errors.NoWorkingTree):
192
193
            self.notbranch = True
193
194
 
194
195
    def get_path(self):
276
277
        #    tree_to.pull(branch_from)
277
278
        #else:
278
279
        #    branch_to.pull(branch_from)
279
 
        branch_to.pull(branch_from)
280
 
        
281
 
        # TODO: get the number of pulled revisions
282
 
        ret = 0
 
280
        ret = branch_to.pull(branch_from)
283
281
        
284
282
        info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
285
283
    
438
436
    def on_treeview_right_row_activated(self, treeview, path, view_column):
439
437
        """ Occurs when somebody double-clicks or enters an item in the
440
438
        file list. """
441
 
        import os.path
442
 
        
443
439
        from launch import launch
444
440
        
445
441
        newdir = self.get_selected_right()
447
443
        if newdir == '..':
448
444
            self.set_path(os.path.split(self.get_path())[0])
449
445
        else:
450
 
            fullpath = self.get_path() + os.sep + newdir
 
446
            fullpath = os.path.join(self.get_path(), newdir)
451
447
            if os.path.isdir(fullpath):
452
448
                # selected item is an existant directory
453
449
                self.set_path(fullpath)
497
493
        # Expand the tree
498
494
        self.treeview_left.expand_all()
499
495
 
 
496
    def _add_updir_to_dirlist(self, dirlist, curdir):
 
497
        """Add .. to the top of directories list if we not in root directory
 
498
 
 
499
        @param  dirlist:    list of directories (modified in place)
 
500
        @param  curdir:     current directory
 
501
        @return:            nothing
 
502
        """
 
503
        if curdir is None:
 
504
            curdir = self.path
 
505
 
 
506
        if sys.platform == 'win32':
 
507
            drive, tail = os.path.splitdrive(curdir)
 
508
            if tail in ('', '/', '\\'):
 
509
                return
 
510
        else:
 
511
            if curdir == '/':
 
512
                return
 
513
 
 
514
        # insert always as first element
 
515
        dirlist.insert(0, '..')
 
516
 
500
517
    def _load_right(self):
501
518
        """ Load data into the right panel. (Filelist) """
502
519
        # Create ListStore
503
520
        liststore = gtk.ListStore(str, str, str)
504
521
        
505
 
        dirs = ['..']
 
522
        dirs = []
506
523
        files = []
507
524
        
508
525
        # Fill the appropriate lists
518
535
        # Sort'em
519
536
        dirs.sort()
520
537
        files.sort()
 
538
 
 
539
        # add updir link to dirs
 
540
        self._add_updir_to_dirlist(dirs, self.path)
521
541
        
522
542
        if not self.notbranch:
523
543
            branch = self.wt.branch
679
699
        liststore = self.treeview_right.get_model()
680
700
        liststore.clear()
681
701
 
682
 
        dirs = ['..']
 
702
        dirs = []
683
703
        files = []
684
704
 
685
705
        # Fill the appropriate lists
695
715
        # Sort'em
696
716
        dirs.sort()
697
717
        files.sort()
698
 
        
 
718
 
 
719
        # add updir link to dirs
 
720
        self._add_updir_to_dirlist(dirs, path)
 
721
 
699
722
        # Try to open the working tree
700
723
        notbranch = False
701
724
        try:
702
725
            tree1 = WorkingTree.open_containing(path)[0]
703
 
        except errors.NotBranchError:
 
726
        except (errors.NotBranchError, errors.NoWorkingTree):
704
727
            notbranch = True
705
728
        except errors.PermissionDenied:
706
729
            print "DEBUG: permission denied."
789
812
        active = combobox.get_active()
790
813
        if active >= 0:
791
814
            drive = model[active][0]
 
815
            self.set_path(drive + '\\')
792
816
            self.refresh_right(drive + '\\')
793
817
 
794
818
import ConfigParser