/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 viz/branchwin.py

  • Committer: Curtis Hovey
  • Date: 2011-08-29 14:12:30 UTC
  • mto: This revision was merged to the branch mainline in revision 741.
  • Revision ID: sinzui.is@verizon.net-20110829141230-6nv7h0oxjrojb1y1
Updated hacking doc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
                       None for no limit.
39
39
        """
40
40
 
41
 
        super(BranchWindow, self).__init__(parent=parent)
 
41
        Window.__init__(self, parent=parent)
42
42
        self.set_border_width(0)
43
43
 
44
44
        self.branch      = branch
78
78
        self.accel_group = Gtk.AccelGroup()
79
79
        self.add_accel_group(self.accel_group)
80
80
 
 
81
        if getattr(Gtk.Action, 'set_tool_item_type', None) is not None:
 
82
            Gtk.Action.set_tool_item_type(Gtk.MenuToolButton)
 
83
 
81
84
        self.prev_rev_action = Gtk.Action("prev-rev", "_Previous Revision", "Go to the previous revision", Gtk.STOCK_GO_DOWN)
82
85
        self.prev_rev_action.set_accel_path("<viz>/Go/Previous Revision")
83
86
        self.prev_rev_action.set_accel_group(self.accel_group)
134
137
    def construct_paned(self):
135
138
        """Construct the main HPaned/VPaned contents."""
136
139
        if self.config.get_user_option('viz-vertical') == 'True':
137
 
            self.paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
 
140
            self.paned = Gtk.HPaned()
138
141
        else:
139
 
            self.paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
 
142
            self.paned = Gtk.VPaned()
140
143
 
141
144
        self.paned.pack1(self.construct_top(), resize=False, shrink=True)
142
145
        self.paned.pack2(self.construct_bottom(), resize=True, shrink=False)
336
339
        align.add(self.treeview)
337
340
        # user-configured size
338
341
        size = self._load_size('viz-graph-size')
 
342
        if size:
 
343
            width, height = size
 
344
            align.set_size_request(width, height)
 
345
        else:
 
346
            (width, height) = self.get_size()
 
347
            align.set_size_request(width, int(height / 2.5))
339
348
        self._save_size_on_destroy(align, 'viz-graph-size')
340
349
        align.show()
341
350
 
365
374
    def construct_bottom(self):
366
375
        """Construct the bottom half of the window."""
367
376
        if self.config.get_user_option('viz-wide-diffs') == 'True':
368
 
            self.diff_paned = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
 
377
            self.diff_paned = Gtk.VPaned()
369
378
        else:
370
 
            self.diff_paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
 
379
            self.diff_paned = Gtk.HPaned()
371
380
        (width, height) = self.get_size()
372
381
        self.diff_paned.set_size_request(20, 20) # shrinkable
373
382
 
423
432
                        except KeyError:
424
433
                            str = ""
425
434
 
426
 
                        item = Gtk.MenuItem(
427
 
                            label=parent.message.split("\n")[0] + str)
 
435
                        item = Gtk.MenuItem(parent.message.split("\n")[0] + str)
428
436
                        item.connect('activate', self._set_revision_cb, parent_id)
429
437
                        prev_menu.add(item)
430
438
                prev_menu.show_all()
445
453
                    except KeyError:
446
454
                        str = ""
447
455
 
448
 
                    item = Gtk.MenuItem(
449
 
                        label=child.message.split("\n")[0] + str)
 
456
                    item = Gtk.MenuItem(child.message.split("\n")[0] + str)
450
457
                    item.connect('activate', self._set_revision_cb, child_id)
451
458
                    next_menu.add(item)
452
459
                next_menu.show_all()
472
479
        else:
473
480
            parent_id = parents[0]
474
481
 
475
 
        if revision is not None:
476
 
            self.show_diff(revision.revision_id, parent_id)
477
 
        else:
478
 
            self.show_diff(NULL_REVISION)
 
482
        self.show_diff(revision.revision_id, parent_id)
479
483
        self.treeview.grab_focus()
480
484
 
481
485
    def _back_clicked_cb(self, *args):
539
543
        dialog = SearchDialog(index)
540
544
 
541
545
        if dialog.run() == Gtk.ResponseType.OK:
542
 
            revid = dialog.get_revision()
543
 
            if revid is not None:
544
 
                self.set_revision(revid)
 
546
            self.set_revision(dialog.get_revision())
545
547
 
546
548
        dialog.destroy()
547
549
 
567
569
        old = self.paned
568
570
        self.vbox.remove(old)
569
571
        self.vbox.pack_start(
570
 
            self.construct_paned(), True, True, 0)
 
572
            self.construct_paned(), True, True, True, 0)
571
573
        self._make_diff_paned_nonzero_size()
572
574
        self._make_diff_nonzero_size()
573
575
 
651
653
            return width, height
652
654
        return None
653
655
 
654
 
    def show_diff(self, revid, parentid=NULL_REVISION):
 
656
    def show_diff(self, revid=None, parentid=NULL_REVISION):
655
657
        """Open a new window to show a diff between the given revisions."""
656
658
        from bzrlib.plugins.gtk.diff import DiffWindow
657
659
        window = DiffWindow(parent=self)