/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 __init__.py

  • Committer: Aaron Bentley
  • Date: 2008-04-28 21:20:43 UTC
  • mfrom: (450.8.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 472.
  • Revision ID: aaron@aaronbentley.com-20080428212043-5di54rn0vzymooch
Get viz working on graphs with ghosts

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
    return os.path.dirname(__file__)
110
110
 
111
111
 
 
112
def icon_path(*args):
 
113
    basedirs = [os.path.join(data_path()),
 
114
             "/usr/share/bzr-gtk", 
 
115
             "/usr/local/share/bzr-gtk"]
 
116
    for basedir in basedirs:
 
117
        path = os.path.join(basedir, 'icons', *args)
 
118
        if os.path.exists(path):
 
119
            return path
 
120
    return None
 
121
 
 
122
 
112
123
class GTKCommand(Command):
113
124
    """Abstract class providing GTK specific run commands."""
114
125
 
215
226
            wt.unlock()
216
227
 
217
228
 
218
 
def start_viz_window(branch, revision, limit=None):
 
229
def start_viz_window(branch, revisions, limit=None):
219
230
    """Start viz on branch with revision revision.
220
231
    
221
232
    :return: The viz window object.
222
233
    """
223
234
    from viz import BranchWindow
224
 
    return BranchWindow(branch, revision, limit)
 
235
    return BranchWindow(branch, revisions, limit)
225
236
 
226
237
 
227
238
class cmd_visualise(Command):
237
248
        "revision",
238
249
        Option('limit', "Maximum number of revisions to display.",
239
250
               int, 'count')]
240
 
    takes_args = [ "location?" ]
 
251
    takes_args = [ "locations*" ]
241
252
    aliases = [ "visualize", "vis", "viz" ]
242
253
 
243
 
    def run(self, location=".", revision=None, limit=None):
 
254
    def run(self, locations_list, revision=None, limit=None):
244
255
        set_ui_factory()
245
 
        (br, path) = branch.Branch.open_containing(location)
246
 
        if revision is None:
247
 
            revid = br.last_revision()
248
 
            if revid is None:
249
 
                return
250
 
        else:
251
 
            (revno, revid) = revision[0].in_history(br)
252
 
 
 
256
        if locations_list is None:
 
257
            locations_list = ["."]
 
258
        revids = []
 
259
        for location in locations_list:
 
260
            (br, path) = branch.Branch.open_containing(location)
 
261
            if revision is None:
 
262
                revids.append(br.last_revision())
 
263
            else:
 
264
                (revno, revid) = revision[0].in_history(br)
 
265
                revids.append(revid)
253
266
        import gtk
254
 
        pp = start_viz_window(br, revid, limit)
 
267
        pp = start_viz_window(br, revids, limit)
255
268
        pp.connect("destroy", lambda w: gtk.main_quit())
256
269
        pp.show()
257
270
        gtk.main()
370
383
    
371
384
    aliases = [ "gst" ]
372
385
    takes_args = ['PATH?']
373
 
    takes_options = []
 
386
    takes_options = ['revision']
374
387
 
375
 
    def run(self, path='.'):
 
388
    def run(self, path='.', revision=None):
376
389
        import os
377
390
        gtk = self.open_display()
378
391
        from status import StatusDialog
379
392
        (wt, wt_path) = workingtree.WorkingTree.open_containing(path)
380
 
        status = StatusDialog(wt, wt_path)
 
393
        
 
394
        if revision is not None:
 
395
            try:
 
396
                revision_id = revision[0].in_history(wt.branch).rev_id
 
397
            except:
 
398
                from bzrlib.errors import BzrError
 
399
                raise BzrError('Revision %r doesn\'t exist' % revision[0].user_spec )
 
400
        else:
 
401
            revision_id = None
 
402
 
 
403
        status = StatusDialog(wt, wt_path, revision_id)
381
404
        status.connect("destroy", gtk.main_quit)
382
405
        status.run()
383
406
 
514
537
        from notify import NotifyPopupMenu
515
538
        gtk = self.open_display()
516
539
        menu = NotifyPopupMenu()
517
 
        icon = gtk.status_icon_new_from_file(os.path.join(data_path(), "bzr-icon-64.png"))
 
540
        icon = gtk.status_icon_new_from_file(icon_path("bzr-icon-64.png"))
518
541
        icon.connect('popup-menu', menu.display)
519
542
 
520
543
        import cgi
527
550
        from bzrlib.transport import get_transport
528
551
        if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
529
552
            import dbus.glib
530
 
        from bzrlib.plugins.dbus import activity
 
553
        BROADCAST_INTERFACE = "org.bazaarvcs.plugins.dbus.Broadcast"
531
554
        bus = dbus.SessionBus()
532
 
        # get the object so we can subscribe to callbacks from it.
533
 
        broadcast_service = bus.get_object(
534
 
            activity.Broadcast.DBUS_NAME,
535
 
            activity.Broadcast.DBUS_PATH)
536
555
 
537
556
        def catch_branch(revision_id, urls):
538
557
            # TODO: show all the urls, or perhaps choose the 'best'.
569
588
            except Exception, e:
570
589
                print e
571
590
                raise
572
 
        broadcast_service.connect_to_signal("Revision", catch_branch,
573
 
            dbus_interface=activity.Broadcast.DBUS_INTERFACE)
 
591
        bus.add_signal_receiver(catch_branch,
 
592
                                dbus_interface=BROADCAST_INTERFACE,
 
593
                                signal_name="Revision")
574
594
        pynotify.init("bzr commit-notify")
575
595
        gtk.main()
576
596