/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: Szilveszter Farkas (Phanatic)
  • Date: 2007-11-07 09:42:33 UTC
  • mfrom: (330.5.6 bzr-gtk-0.92.0)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: szilveszter.farkas@gmail.com-20071107094233-shodhytmd3v1r4im
Merge changes from the 0.92.0 release branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib.plugins.gtk.window import Window
18
18
from bzrlib.osutils import format_date
 
19
from bzrlib.config import GlobalConfig
19
20
 
20
21
from linegraph import linegraph, same_branch
21
22
from graphcell import CellRendererGraph
41
42
        Window.__init__(self, parent=parent)
42
43
        self.set_border_width(0)
43
44
 
44
 
        self.branch = branch
45
 
        self.start  = start
46
 
        self.maxnum = maxnum
 
45
        self.branch      = branch
 
46
        self.start       = start
 
47
        self.maxnum      = maxnum
 
48
        self.config      = GlobalConfig()
 
49
 
 
50
        if self.config.get_user_option('viz-compact-view') == 'yes':
 
51
            self.compact_view = True
 
52
        else:
 
53
            self.compact_view = False
47
54
 
48
55
        self.set_title(branch.nick + " - revision history")
49
56
 
63
70
 
64
71
        self.construct()
65
72
 
 
73
    def set_revision(self, revision):
 
74
        self.treeview.set_revision(revision)
 
75
 
66
76
    def construct(self):
67
77
        """Construct the window contents."""
68
78
        vbox = gtk.VBox(spacing=5)
71
81
        vbox.pack_start(self.construct_navigation(), expand=False, fill=True)
72
82
        vbox.pack_start(self.construct_loading_msg(), expand=False, fill=True)
73
83
        
74
 
        paned = gtk.VPaned()
75
 
        paned.pack1(self.construct_top(), resize=True, shrink=False)
76
 
        paned.pack2(self.construct_bottom(), resize=False, shrink=True)
77
 
        paned.show()
78
 
        vbox.pack_start(paned, expand=True, fill=True)
79
 
        vbox.set_focus_child(paned)
 
84
        self.paned = gtk.VPaned()
 
85
        self.paned.pack1(self.construct_top(), resize=True, shrink=False)
 
86
        self.paned.pack2(self.construct_bottom(), resize=False, shrink=True)
 
87
        self.paned.show()
 
88
        vbox.pack_start(self.paned, expand=True, fill=True)
 
89
        vbox.set_focus_child(self.paned)
80
90
 
81
91
        vbox.show()
82
92
    
101
111
    def construct_top(self):
102
112
        """Construct the top-half of the window."""
103
113
        # FIXME: Make broken_line_length configurable
104
 
        self.treeview = TreeView(self.branch, self.start, self.maxnum, 32)
 
114
        if self.compact_view:
 
115
            brokenlines = 32
 
116
        else:
 
117
            brokenlines = None
 
118
 
 
119
        self.treeview = TreeView(self.branch, self.start, self.maxnum, brokenlines)
105
120
 
106
121
        self.treeview.connect("revision-selected",
107
122
                self._treeselection_changed_cb)
124
139
                                         0, 0)
125
140
        self.back_button.connect("clicked", self._back_clicked_cb)
126
141
        self.toolbar.insert(self.back_button, -1)
127
 
        self.back_button.show()
128
142
 
129
143
        self.fwd_button = gtk.ToolButton(stock_id=gtk.STOCK_GO_FORWARD)
130
144
        self.fwd_button.set_is_important(True)
132
146
                                        0, 0)
133
147
        self.fwd_button.connect("clicked", self._fwd_clicked_cb)
134
148
        self.toolbar.insert(self.fwd_button, -1)
135
 
        self.fwd_button.show()
136
 
 
137
 
        self.toolbar.show()
 
149
 
 
150
        self.toolbar.insert(gtk.SeparatorToolItem(), -1)
 
151
 
 
152
        brokenlines_button = gtk.ToggleToolButton()
 
153
        brokenlines_button.set_label("Compact View")
 
154
        brokenlines_button.set_active(self.compact_view)
 
155
        brokenlines_button.set_is_important(True)
 
156
        brokenlines_button.connect('toggled', self._brokenlines_toggled_cb)
 
157
        self.toolbar.insert(brokenlines_button, -1)
 
158
 
 
159
        self.toolbar.show_all()
138
160
 
139
161
        return self.toolbar
140
162
 
182
204
        self.treeview.show_diff(self.branch, revid, parentid)
183
205
        self.treeview.grab_focus()
184
206
 
 
207
    def _brokenlines_toggled_cb(self, button):
 
208
        self.compact_view = button.get_active()
 
209
 
 
210
        if self.compact_view:
 
211
            option = 'yes'
 
212
        else:
 
213
            option = 'no'
 
214
 
 
215
        self.config.set_user_option('viz-compact-view', option)
 
216
 
 
217
        revision = self.treeview.get_revision()
 
218
 
 
219
        self.treeview.destroy()
 
220
        self.paned.pack1(self.construct_top(), resize=True, shrink=False)
 
221
 
 
222
        gobject.idle_add(self.set_revision, revision.revision_id)