/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-10-24 21:25:38 UTC
  • mfrom: (93.1.5 bzr-gtk.win32.bialix)
  • Revision ID: Szilveszter.Farkas@gmail.com-20061024212538-c5ef777cec5ab9df
Merged Alexander Belchenko's Win32 fixes and additions.

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
55
56
 
56
57
from dialog import error_dialog, info_dialog
57
58
 
 
59
# import this classes only once
 
60
try:
 
61
    from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
 
62
    from bzrlib.plugins.gtk.viz.branchwin import BranchWindow
 
63
except ImportError:
 
64
    # olive+bzr-gtk not installed. try to import from sources
 
65
    path = os.path.dirname(os.path.dirname(__file__))
 
66
    if path not in sys.path:
 
67
        sys.path.append(path)
 
68
    from viz.diffwin import DiffWindow
 
69
    from viz.branchwin import BranchWindow
 
70
 
 
71
 
58
72
class OliveGtk:
59
73
    """ The main Olive GTK frontend class. This is called when launching the
60
74
    program. """
191
205
        
192
206
        try:
193
207
            self.wt, self.wtpath = WorkingTree.open_containing(self.path)
194
 
        except errors.NotBranchError:
 
208
        except (errors.NotBranchError, errors.NoWorkingTree):
195
209
            self.notbranch = True
196
210
        
197
211
        self.statusbar.push(self.context_id, path)
281
295
        #    tree_to.pull(branch_from)
282
296
        #else:
283
297
        #    branch_to.pull(branch_from)
284
 
        branch_to.pull(branch_from)
285
 
        
286
 
        # TODO: get the number of pulled revisions
287
 
        ret = 0
 
298
        ret = branch_to.pull(branch_from)
288
299
        
289
300
        info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
290
301
    
358
369
    
359
370
    def on_menuitem_stats_diff_activate(self, widget):
360
371
        """ Statistics/Differences... menu handler. """
361
 
        from bzrlib.plugins.gtk.viz.diffwin import DiffWindow
362
372
        window = DiffWindow()
363
373
        parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
364
374
        window.set_diff(self.wt.branch.nick, self.wt, parent_tree)
372
382
    
373
383
    def on_menuitem_stats_log_activate(self, widget):
374
384
        """ Statistics/Log... menu handler. """
375
 
        from bzrlib.plugins.gtk.viz.branchwin import BranchWindow
376
385
        window = BranchWindow()
377
386
        window.set_branch(self.wt.branch, self.wt.branch.last_revision(), None)
378
387
        window.show()
446
455
    def on_treeview_right_row_activated(self, treeview, path, view_column):
447
456
        """ Occurs when somebody double-clicks or enters an item in the
448
457
        file list. """
449
 
        import os.path
450
 
        
451
458
        from launch import launch
452
459
        
453
460
        newdir = self.get_selected_right()
455
462
        if newdir == '..':
456
463
            self.set_path(os.path.split(self.get_path())[0])
457
464
        else:
458
 
            fullpath = self.get_path() + os.sep + newdir
 
465
            fullpath = os.path.join(self.get_path(), newdir)
459
466
            if os.path.isdir(fullpath):
460
467
                # selected item is an existant directory
461
468
                self.set_path(fullpath)
505
512
        # Expand the tree
506
513
        self.treeview_left.expand_all()
507
514
 
 
515
    def _add_updir_to_dirlist(self, dirlist, curdir):
 
516
        """Add .. to the top of directories list if we not in root directory
 
517
 
 
518
        @param  dirlist:    list of directories (modified in place)
 
519
        @param  curdir:     current directory
 
520
        @return:            nothing
 
521
        """
 
522
        if curdir is None:
 
523
            curdir = self.path
 
524
 
 
525
        if sys.platform == 'win32':
 
526
            drive, tail = os.path.splitdrive(curdir)
 
527
            if tail in ('', '/', '\\'):
 
528
                return
 
529
        else:
 
530
            if curdir == '/':
 
531
                return
 
532
 
 
533
        # insert always as first element
 
534
        dirlist.insert(0, '..')
 
535
 
508
536
    def _load_right(self):
509
537
        """ Load data into the right panel. (Filelist) """
510
538
        # Create ListStore
511
539
        liststore = gtk.ListStore(str, str, str)
512
540
        
513
 
        dirs = ['..']
 
541
        dirs = []
514
542
        files = []
515
543
        
516
544
        # Fill the appropriate lists
526
554
        # Sort'em
527
555
        dirs.sort()
528
556
        files.sort()
 
557
 
 
558
        # add updir link to dirs
 
559
        self._add_updir_to_dirlist(dirs, self.path)
529
560
        
530
561
        if not self.notbranch:
531
562
            branch = self.wt.branch
688
719
        liststore = self.treeview_right.get_model()
689
720
        liststore.clear()
690
721
 
691
 
        dirs = ['..']
 
722
        dirs = []
692
723
        files = []
693
724
 
694
725
        # Fill the appropriate lists
704
735
        # Sort'em
705
736
        dirs.sort()
706
737
        files.sort()
707
 
        
 
738
 
 
739
        # add updir link to dirs
 
740
        self._add_updir_to_dirlist(dirs, path)
 
741
 
708
742
        # Try to open the working tree
709
743
        notbranch = False
710
744
        try:
711
745
            tree1 = WorkingTree.open_containing(path)[0]
712
 
        except errors.NotBranchError:
 
746
        except (errors.NotBranchError, errors.NoWorkingTree):
713
747
            notbranch = True
714
748
        except errors.PermissionDenied:
715
749
            print "DEBUG: permission denied."
798
832
        active = combobox.get_active()
799
833
        if active >= 0:
800
834
            drive = model[active][0]
 
835
            self.set_path(drive + '\\')
801
836
            self.refresh_right(drive + '\\')
802
837
 
803
838
import ConfigParser