bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
1  | 
# -*- coding: UTF-8 -*-
 | 
2  | 
"""Branch window.
 | 
|
3  | 
||
4  | 
This module contains the code to manage the branch information window,
 | 
|
5  | 
which contains both the revision graph and details panes.
 | 
|
6  | 
"""
 | 
|
7  | 
||
8  | 
__copyright__ = "Copyright © 2005 Canonical Ltd."  | 
|
9  | 
__author__ = "Scott James Remnant <scott@ubuntu.com>"  | 
|
10  | 
||
11  | 
||
12  | 
import gtk  | 
|
13  | 
import gobject  | 
|
14  | 
import pango  | 
|
15  | 
||
| 
450.4.1
by Daniel Schierbeck
 Added tag icon to branch history window.  | 
16  | 
from bzrlib.plugins.gtk import icon_path  | 
| 
523.3.2
by Jelmer Vernooij
 Share same menu for context menu and main menu.  | 
17  | 
from bzrlib.plugins.gtk.branchview import TreeView, treemodel  | 
| 
365
by Daniel Schierbeck
 Fixed locks and made tagging work.  | 
18  | 
from bzrlib.plugins.gtk.tags import AddTagDialog  | 
| 
338
by Daniel Schierbeck
 Added Preferences menu item.  | 
19  | 
from bzrlib.plugins.gtk.preferences import PreferencesWindow  | 
| 
523.3.2
by Jelmer Vernooij
 Share same menu for context menu and main menu.  | 
20  | 
from bzrlib.plugins.gtk.revisionmenu import RevisionMenu  | 
21  | 
from bzrlib.plugins.gtk.window import Window  | 
|
| 
511.6.1
by Jelmer Vernooij
 Add Branch/Index option if bzr-search is available.  | 
22  | 
|
23  | 
from bzrlib.config import BranchConfig, GlobalConfig  | 
|
| 
443
by Szilveszter Farkas (Phanatic)
 Trivial fix for #149061 (be able to show the diff for revision 1).  | 
24  | 
from bzrlib.revision import Revision, NULL_REVISION  | 
| 
511.6.1
by Jelmer Vernooij
 Add Branch/Index option if bzr-search is available.  | 
25  | 
from bzrlib.trace import mutter  | 
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
26  | 
|
| 
298.2.1
by Daniel Schierbeck
 Refactored the GTK window code, creating a single base window class that handles keyboard events.  | 
27  | 
class BranchWindow(Window):  | 
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
28  | 
"""Branch window.  | 
29  | 
||
30  | 
    This object represents and manages a single window containing information
 | 
|
31  | 
    for a particular branch.
 | 
|
32  | 
    """
 | 
|
33  | 
||
| 
452.4.1
by Jelmer Vernooij
 Support displaying multiple tips in viz.  | 
34  | 
def __init__(self, branch, start_revs, maxnum, parent=None):  | 
| 
322
by Jelmer Vernooij
 Add docstrings.  | 
35  | 
"""Create a new BranchWindow.  | 
36  | 
||
37  | 
        :param branch: Branch object for branch to show.
 | 
|
| 
452.4.1
by Jelmer Vernooij
 Support displaying multiple tips in viz.  | 
38  | 
        :param start_revs: Revision ids of top revisions.
 | 
| 
322
by Jelmer Vernooij
 Add docstrings.  | 
39  | 
        :param maxnum: Maximum number of revisions to display, 
 | 
40  | 
                       None for no limit.
 | 
|
41  | 
        """
 | 
|
42  | 
||
| 
298.2.1
by Daniel Schierbeck
 Refactored the GTK window code, creating a single base window class that handles keyboard events.  | 
43  | 
Window.__init__(self, parent=parent)  | 
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
44  | 
self.set_border_width(0)  | 
| 
315
by Daniel Schierbeck
 Removed BranchWindow.set_branch(), used constructor instead.  | 
45  | 
|
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
46  | 
self.branch = branch  | 
| 
452.4.1
by Jelmer Vernooij
 Support displaying multiple tips in viz.  | 
47  | 
self.start_revs = start_revs  | 
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
48  | 
self.maxnum = maxnum  | 
| 
330.2.5
by Daniel Schierbeck
 Support persistence of compact view option.  | 
49  | 
self.config = GlobalConfig()  | 
50  | 
||
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
51  | 
self._sizes = {} # window and widget sizes  | 
52  | 
||
| 
330.2.5
by Daniel Schierbeck
 Support persistence of compact view option.  | 
53  | 
if self.config.get_user_option('viz-compact-view') == 'yes':  | 
54  | 
self.compact_view = True  | 
|
55  | 
else:  | 
|
56  | 
self.compact_view = False  | 
|
| 
315
by Daniel Schierbeck
 Removed BranchWindow.set_branch(), used constructor instead.  | 
57  | 
|
58  | 
self.set_title(branch.nick + " - revision history")  | 
|
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
59  | 
|
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
60  | 
        # user-configured window size
 | 
| 
531.7.10
by Scott Scriven
 Simplified size-loading code. No longer saves identical config every time vis runs.  | 
61  | 
size = self._load_size('viz-window-size')  | 
62  | 
if size:  | 
|
63  | 
width, height = size  | 
|
| 
555.2.1
by Jasper Groenewegen
 Modify DiffWidget to include a checkbutton to wrap long lines in the diff view  | 
64  | 
else:  | 
65  | 
            # Use three-quarters of the screen by default
 | 
|
66  | 
screen = self.get_screen()  | 
|
67  | 
monitor = screen.get_monitor_geometry(0)  | 
|
68  | 
width = int(monitor.width * 0.75)  | 
|
69  | 
height = int(monitor.height * 0.75)  | 
|
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
70  | 
self.set_default_size(width, height)  | 
| 
531.7.8
by Scott Scriven
 Made viz window shrinkable.  | 
71  | 
self.set_size_request(width/3, height/3)  | 
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
72  | 
self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')  | 
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
73  | 
|
74  | 
        # FIXME AndyFitz!
 | 
|
75  | 
icon = self.render_icon(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON)  | 
|
76  | 
self.set_icon(icon)  | 
|
77  | 
||
| 
384
by Daniel Schierbeck
 Added accelerator for Next Revision action.  | 
78  | 
gtk.accel_map_add_entry("<viz>/Go/Next Revision", gtk.keysyms.Up, gtk.gdk.MOD1_MASK)  | 
| 
383
by Daniel Schierbeck
 Switched to using symbolic names for keyvals.  | 
79  | 
gtk.accel_map_add_entry("<viz>/Go/Previous Revision", gtk.keysyms.Down, gtk.gdk.MOD1_MASK)  | 
| 
499.1.1
by Russ Brown
 Added Refresh menu option with keyboard shortcut to viz  | 
80  | 
gtk.accel_map_add_entry("<viz>/View/Refresh", gtk.keysyms.F5, 0)  | 
| 
382
by Daniel Schierbeck
 Made accelerator for Previous Revision work.  | 
81  | 
|
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
82  | 
self.accel_group = gtk.AccelGroup()  | 
83  | 
self.add_accel_group(self.accel_group)  | 
|
84  | 
||
| 
388
by Daniel Schierbeck
 Switched to using the Previous/Next Revision actions to create tool buttons.  | 
85  | 
gtk.Action.set_tool_item_type(gtk.MenuToolButton)  | 
86  | 
||
| 
385
by Daniel Schierbeck
 Created a single action for Previous Revision.  | 
87  | 
self.prev_rev_action = gtk.Action("prev-rev", "_Previous Revision", "Go to the previous revision", gtk.STOCK_GO_DOWN)  | 
88  | 
self.prev_rev_action.set_accel_path("<viz>/Go/Previous Revision")  | 
|
89  | 
self.prev_rev_action.set_accel_group(self.accel_group)  | 
|
90  | 
self.prev_rev_action.connect("activate", self._back_clicked_cb)  | 
|
91  | 
self.prev_rev_action.connect_accelerator()  | 
|
92  | 
||
| 
386
by Daniel Schierbeck
 Created a single action for Next Revision.  | 
93  | 
self.next_rev_action = gtk.Action("next-rev", "_Next Revision", "Go to the next revision", gtk.STOCK_GO_UP)  | 
94  | 
self.next_rev_action.set_accel_path("<viz>/Go/Next Revision")  | 
|
95  | 
self.next_rev_action.set_accel_group(self.accel_group)  | 
|
96  | 
self.next_rev_action.connect("activate", self._fwd_clicked_cb)  | 
|
97  | 
self.next_rev_action.connect_accelerator()  | 
|
98  | 
||
| 
499.1.1
by Russ Brown
 Added Refresh menu option with keyboard shortcut to viz  | 
99  | 
self.refresh_action = gtk.Action("refresh", "_Refresh", "Refresh view", gtk.STOCK_REFRESH)  | 
100  | 
self.refresh_action.set_accel_path("<viz>/View/Refresh")  | 
|
101  | 
self.refresh_action.set_accel_group(self.accel_group)  | 
|
102  | 
self.refresh_action.connect("activate", self._refresh_clicked)  | 
|
103  | 
self.refresh_action.connect_accelerator()  | 
|
104  | 
||
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
105  | 
self.construct()  | 
106  | 
||
| 
369
by Daniel Schierbeck
 Fixed bug with compact view toggling.  | 
107  | 
def set_revision(self, revid):  | 
108  | 
self.treeview.set_revision_id(revid)  | 
|
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
109  | 
|
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
110  | 
def construct(self):  | 
111  | 
"""Construct the window contents."""  | 
|
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
112  | 
vbox = gtk.VBox(spacing=0)  | 
| 
44
by David Allouche
 reorganise branch window  | 
113  | 
self.add(vbox)  | 
114  | 
||
| 
375
by Daniel Schierbeck
 Fixed crash when toggling compact view.  | 
115  | 
self.paned = gtk.VPaned()  | 
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
116  | 
self.paned.pack1(self.construct_top(), resize=False, shrink=True)  | 
117  | 
self.paned.pack2(self.construct_bottom(), resize=True, shrink=False)  | 
|
| 
375
by Daniel Schierbeck
 Fixed crash when toggling compact view.  | 
118  | 
self.paned.show()  | 
| 
358
by Daniel Schierbeck
 Generalized the hiding/showing code.  | 
119  | 
|
| 
531.7.2
by Scott Scriven
 Made 'vis' save/load visibility of its toolbar.  | 
120  | 
nav = self.construct_navigation()  | 
121  | 
menubar = self.construct_menubar()  | 
|
122  | 
vbox.pack_start(menubar, expand=False, fill=True)  | 
|
123  | 
vbox.pack_start(nav, expand=False, fill=True)  | 
|
124  | 
||
| 
369
by Daniel Schierbeck
 Fixed bug with compact view toggling.  | 
125  | 
vbox.pack_start(self.paned, expand=True, fill=True)  | 
126  | 
vbox.set_focus_child(self.paned)  | 
|
| 
44
by David Allouche
 reorganise branch window  | 
127  | 
|
128  | 
vbox.show()  | 
|
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
129  | 
|
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
130  | 
def construct_menubar(self):  | 
131  | 
menubar = gtk.MenuBar()  | 
|
132  | 
||
133  | 
file_menu = gtk.Menu()  | 
|
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
134  | 
file_menuitem = gtk.MenuItem("_File")  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
135  | 
file_menuitem.set_submenu(file_menu)  | 
136  | 
||
| 
362
by Daniel Schierbeck
 Added accel group to File -> Close menu item.  | 
137  | 
file_menu_close = gtk.ImageMenuItem(gtk.STOCK_CLOSE, self.accel_group)  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
138  | 
file_menu_close.connect('activate', lambda x: self.destroy())  | 
139  | 
||
| 
363
by Daniel Schierbeck
 Added File -> Quit menu item.  | 
140  | 
file_menu_quit = gtk.ImageMenuItem(gtk.STOCK_QUIT, self.accel_group)  | 
141  | 
file_menu_quit.connect('activate', lambda x: gtk.main_quit())  | 
|
142  | 
||
| 
408
by Daniel Schierbeck
 Made the close menu item actually appear when the viz is opened from another window.  | 
143  | 
if self._parent is not None:  | 
| 
406
by Daniel Schierbeck
 Made the viz show the close menu item only if opened from another window.  | 
144  | 
file_menu.add(file_menu_close)  | 
| 
363
by Daniel Schierbeck
 Added File -> Quit menu item.  | 
145  | 
file_menu.add(file_menu_quit)  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
146  | 
|
| 
338
by Daniel Schierbeck
 Added Preferences menu item.  | 
147  | 
edit_menu = gtk.Menu()  | 
148  | 
edit_menuitem = gtk.MenuItem("_Edit")  | 
|
149  | 
edit_menuitem.set_submenu(edit_menu)  | 
|
150  | 
||
| 
361
by Daniel Schierbeck
 Added branch settings menu item.  | 
151  | 
edit_menu_branchopts = gtk.MenuItem("Branch Settings")  | 
152  | 
edit_menu_branchopts.connect('activate', lambda x: PreferencesWindow(self.branch.get_config()).show())  | 
|
153  | 
||
| 
407
by Daniel Schierbeck
 Renamed Preferences menu item into Global Settings.  | 
154  | 
edit_menu_globopts = gtk.MenuItem("Global Settings")  | 
155  | 
edit_menu_globopts.connect('activate', lambda x: PreferencesWindow().show())  | 
|
| 
338
by Daniel Schierbeck
 Added Preferences menu item.  | 
156  | 
|
| 
361
by Daniel Schierbeck
 Added branch settings menu item.  | 
157  | 
edit_menu.add(edit_menu_branchopts)  | 
| 
407
by Daniel Schierbeck
 Renamed Preferences menu item into Global Settings.  | 
158  | 
edit_menu.add(edit_menu_globopts)  | 
| 
338
by Daniel Schierbeck
 Added Preferences menu item.  | 
159  | 
|
| 
348
by Daniel Schierbeck
 Added toggle item for revision number column.  | 
160  | 
view_menu = gtk.Menu()  | 
161  | 
view_menuitem = gtk.MenuItem("_View")  | 
|
162  | 
view_menuitem.set_submenu(view_menu)  | 
|
163  | 
||
| 
499.1.1
by Russ Brown
 Added Refresh menu option with keyboard shortcut to viz  | 
164  | 
view_menu_refresh = self.refresh_action.create_menu_item()  | 
165  | 
view_menu_refresh.connect('activate', self._refresh_clicked)  | 
|
166  | 
||
167  | 
view_menu.add(view_menu_refresh)  | 
|
168  | 
view_menu.add(gtk.SeparatorMenuItem())  | 
|
169  | 
||
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
170  | 
view_menu_toolbar = gtk.CheckMenuItem("Show Toolbar")  | 
171  | 
view_menu_toolbar.set_active(True)  | 
|
| 
531.7.2
by Scott Scriven
 Made 'vis' save/load visibility of its toolbar.  | 
172  | 
if self.config.get_user_option('viz-toolbar-visible') == 'False':  | 
173  | 
view_menu_toolbar.set_active(False)  | 
|
174  | 
self.toolbar.hide()  | 
|
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
175  | 
view_menu_toolbar.connect('toggled', self._toolbar_visibility_changed)  | 
176  | 
||
| 
370
by Daniel Schierbeck
 Moved compact graph toggle to the menubar.  | 
177  | 
view_menu_compact = gtk.CheckMenuItem("Show Compact Graph")  | 
178  | 
view_menu_compact.set_active(self.compact_view)  | 
|
179  | 
view_menu_compact.connect('activate', self._brokenlines_toggled_cb)  | 
|
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
180  | 
|
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
181  | 
view_menu_diffs = gtk.CheckMenuItem("Show Diffs")  | 
| 
531.7.12
by Scott Scriven
 Made diff panel default to off.  | 
182  | 
view_menu_diffs.set_active(False)  | 
183  | 
if self.config.get_user_option('viz-show-diffs') == 'True':  | 
|
184  | 
view_menu_diffs.set_active(True)  | 
|
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
185  | 
view_menu_diffs.connect('toggled', self._diff_visibility_changed)  | 
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
186  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
187  | 
view_menu_wide_diffs = gtk.CheckMenuItem("Wide Diffs")  | 
188  | 
view_menu_wide_diffs.set_active(False)  | 
|
189  | 
if self.config.get_user_option('viz-wide-diffs') == 'True':  | 
|
190  | 
view_menu_wide_diffs.set_active(True)  | 
|
191  | 
view_menu_wide_diffs.connect('toggled', self._diff_placement_changed)  | 
|
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
192  | 
|
| 
571
by Jasper Groenewegen
 Merge addition of word wrap control to gdiff and visualise windows  | 
193  | 
view_menu_wrap_diffs = gtk.CheckMenuItem("Wrap _Long Lines in Diffs")  | 
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
194  | 
view_menu_wrap_diffs.set_active(False)  | 
195  | 
if self.config.get_user_option('viz-wrap-diffs') == 'True':  | 
|
196  | 
view_menu_wrap_diffs.set_active(True)  | 
|
197  | 
view_menu_wrap_diffs.connect('toggled', self._diff_wrap_changed)  | 
|
198  | 
||
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
199  | 
view_menu.add(view_menu_toolbar)  | 
| 
370
by Daniel Schierbeck
 Moved compact graph toggle to the menubar.  | 
200  | 
view_menu.add(view_menu_compact)  | 
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
201  | 
view_menu.add(gtk.SeparatorMenuItem())  | 
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
202  | 
view_menu.add(view_menu_diffs)  | 
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
203  | 
view_menu.add(view_menu_wide_diffs)  | 
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
204  | 
view_menu.add(view_menu_wrap_diffs)  | 
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
205  | 
view_menu.add(gtk.SeparatorMenuItem())  | 
| 
358
by Daniel Schierbeck
 Generalized the hiding/showing code.  | 
206  | 
|
| 
452.4.2
by Jelmer Vernooij
 Hide revision number column if more than one branch was specified.  | 
207  | 
self.mnu_show_revno_column = gtk.CheckMenuItem("Show Revision _Number Column")  | 
208  | 
self.mnu_show_date_column = gtk.CheckMenuItem("Show _Date Column")  | 
|
209  | 
||
210  | 
        # Revision numbers are pointless if there are multiple branches
 | 
|
211  | 
if len(self.start_revs) > 1:  | 
|
212  | 
self.mnu_show_revno_column.set_sensitive(False)  | 
|
213  | 
self.treeview.set_property('revno-column-visible', False)  | 
|
214  | 
||
215  | 
for (col, name) in [(self.mnu_show_revno_column, "revno"),  | 
|
216  | 
(self.mnu_show_date_column, "date")]:  | 
|
| 
358
by Daniel Schierbeck
 Generalized the hiding/showing code.  | 
217  | 
col.set_active(self.treeview.get_property(name + "-column-visible"))  | 
218  | 
col.connect('toggled', self._col_visibility_changed, name)  | 
|
219  | 
view_menu.add(col)  | 
|
| 
348
by Daniel Schierbeck
 Added toggle item for revision number column.  | 
220  | 
|
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
221  | 
go_menu = gtk.Menu()  | 
| 
382
by Daniel Schierbeck
 Made accelerator for Previous Revision work.  | 
222  | 
go_menu.set_accel_group(self.accel_group)  | 
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
223  | 
go_menuitem = gtk.MenuItem("_Go")  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
224  | 
go_menuitem.set_submenu(go_menu)  | 
225  | 
||
| 
390
by Daniel Schierbeck
 Made the Previous/Next Revision menu items local variables.  | 
226  | 
go_menu_next = self.next_rev_action.create_menu_item()  | 
227  | 
go_menu_prev = self.prev_rev_action.create_menu_item()  | 
|
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
228  | 
|
| 
450.4.1
by Daniel Schierbeck
 Added tag icon to branch history window.  | 
229  | 
tag_image = gtk.Image()  | 
230  | 
tag_image.set_from_file(icon_path("tag-16.png"))  | 
|
231  | 
self.go_menu_tags = gtk.ImageMenuItem("_Tags")  | 
|
232  | 
self.go_menu_tags.set_image(tag_image)  | 
|
| 
587
by Jelmer Vernooij
 Avoid determining tags until tags widget has been added.  | 
233  | 
self.treeview.connect('refreshed', lambda w: self._update_tags())  | 
| 
399
by Daniel Schierbeck
 Made tags menu insensitive when there are no tags to display.  | 
234  | 
|
| 
390
by Daniel Schierbeck
 Made the Previous/Next Revision menu items local variables.  | 
235  | 
go_menu.add(go_menu_next)  | 
236  | 
go_menu.add(go_menu_prev)  | 
|
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
237  | 
go_menu.add(gtk.SeparatorMenuItem())  | 
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
238  | 
go_menu.add(self.go_menu_tags)  | 
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
239  | 
|
| 
523.3.2
by Jelmer Vernooij
 Share same menu for context menu and main menu.  | 
240  | 
self.revision_menu = RevisionMenu(self.branch.repository, [], self.branch, parent=self)  | 
| 
335
by Daniel Schierbeck
 Added Revision menu.  | 
241  | 
revision_menuitem = gtk.MenuItem("_Revision")  | 
| 
523.3.2
by Jelmer Vernooij
 Share same menu for context menu and main menu.  | 
242  | 
revision_menuitem.set_submenu(self.revision_menu)  | 
| 
335
by Daniel Schierbeck
 Added Revision menu.  | 
243  | 
|
| 
334
by Daniel Schierbeck
 Added icons to menus.  | 
244  | 
branch_menu = gtk.Menu()  | 
245  | 
branch_menuitem = gtk.MenuItem("_Branch")  | 
|
246  | 
branch_menuitem.set_submenu(branch_menu)  | 
|
247  | 
||
| 
336
by Daniel Schierbeck
 Changed wording to comply with HIG guidelines.  | 
248  | 
branch_menu.add(gtk.MenuItem("Pu_ll Revisions"))  | 
249  | 
branch_menu.add(gtk.MenuItem("Pu_sh Revisions"))  | 
|
| 
371.1.1
by Daniel Schierbeck
 Added About dialog to the viz.  | 
250  | 
|
| 
511.6.1
by Jelmer Vernooij
 Add Branch/Index option if bzr-search is available.  | 
251  | 
try:  | 
252  | 
from bzrlib.plugins import search  | 
|
253  | 
except ImportError:  | 
|
254  | 
mutter("Didn't find search plugin")  | 
|
255  | 
else:  | 
|
| 
526
by Jelmer Vernooij
 Switch to found revision when clicking ok in search window.  | 
256  | 
branch_menu.add(gtk.SeparatorMenuItem())  | 
257  | 
||
| 
511.6.1
by Jelmer Vernooij
 Add Branch/Index option if bzr-search is available.  | 
258  | 
branch_index_menuitem = gtk.MenuItem("_Index")  | 
259  | 
branch_index_menuitem.connect('activate', self._branch_index_cb)  | 
|
260  | 
branch_menu.add(branch_index_menuitem)  | 
|
261  | 
||
| 
524
by Jelmer Vernooij
 Add search dialog.  | 
262  | 
branch_search_menuitem = gtk.MenuItem("_Search")  | 
263  | 
branch_search_menuitem.connect('activate', self._branch_search_cb)  | 
|
264  | 
branch_menu.add(branch_search_menuitem)  | 
|
265  | 
||
| 
423.9.1
by Daniel Schierbeck
 Added Help->About menu item to the viz.  | 
266  | 
help_menu = gtk.Menu()  | 
267  | 
help_menuitem = gtk.MenuItem("_Help")  | 
|
268  | 
help_menuitem.set_submenu(help_menu)  | 
|
269  | 
||
270  | 
help_about_menuitem = gtk.ImageMenuItem(gtk.STOCK_ABOUT, self.accel_group)  | 
|
271  | 
help_about_menuitem.connect('activate', self._about_dialog_cb)  | 
|
272  | 
||
273  | 
help_menu.add(help_about_menuitem)  | 
|
274  | 
||
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
275  | 
menubar.add(file_menuitem)  | 
| 
338
by Daniel Schierbeck
 Added Preferences menu item.  | 
276  | 
menubar.add(edit_menuitem)  | 
| 
348
by Daniel Schierbeck
 Added toggle item for revision number column.  | 
277  | 
menubar.add(view_menuitem)  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
278  | 
menubar.add(go_menuitem)  | 
| 
335
by Daniel Schierbeck
 Added Revision menu.  | 
279  | 
menubar.add(revision_menuitem)  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
280  | 
menubar.add(branch_menuitem)  | 
| 
423.9.1
by Daniel Schierbeck
 Added Help->About menu item to the viz.  | 
281  | 
menubar.add(help_menuitem)  | 
| 
331
by Daniel Schierbeck
 Added basic menu bar.  | 
282  | 
menubar.show_all()  | 
283  | 
||
284  | 
return menubar  | 
|
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
285  | 
|
286  | 
def construct_top(self):  | 
|
287  | 
"""Construct the top-half of the window."""  | 
|
| 
329
by Jelmer Vernooij
 Make broken_line_length setting from higher up.  | 
288  | 
        # FIXME: Make broken_line_length configurable
 | 
| 
330.2.5
by Daniel Schierbeck
 Support persistence of compact view option.  | 
289  | 
|
| 
452.4.1
by Jelmer Vernooij
 Support displaying multiple tips in viz.  | 
290  | 
self.treeview = TreeView(self.branch, self.start_revs, self.maxnum, self.compact_view)  | 
| 
315
by Daniel Schierbeck
 Removed BranchWindow.set_branch(), used constructor instead.  | 
291  | 
|
| 
373
by Daniel Schierbeck
 Made column display options persisted.  | 
292  | 
self.treeview.connect('revision-selected',  | 
| 
303
by Daniel Schierbeck
 Made basic signaling work.  | 
293  | 
self._treeselection_changed_cb)  | 
| 
423.1.17
by Gary van der Merwe
 Reuse the viz treeview in the revision browser.  | 
294  | 
self.treeview.connect('revision-activated',  | 
295  | 
self._tree_revision_activated)  | 
|
| 
303
by Daniel Schierbeck
 Made basic signaling work.  | 
296  | 
|
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
297  | 
self.treeview.connect('tag-added', lambda w, t, r: self._update_tags())  | 
298  | 
||
| 
373
by Daniel Schierbeck
 Made column display options persisted.  | 
299  | 
for col in ["revno", "date"]:  | 
300  | 
option = self.config.get_user_option(col + '-column-visible')  | 
|
301  | 
if option is not None:  | 
|
302  | 
self.treeview.set_property(col + '-column-visible', option == 'True')  | 
|
| 
464.1.1
by Adrian Wilkins
 Fixed column visibility properties not loading  | 
303  | 
else:  | 
304  | 
self.treeview.set_property(col + '-column-visible', False)  | 
|
| 
373
by Daniel Schierbeck
 Made column display options persisted.  | 
305  | 
|
| 
1
by Scott James Remnant
 Commit the first version of bzrk.  | 
306  | 
self.treeview.show()  | 
307  | 
||
| 
375
by Daniel Schierbeck
 Fixed crash when toggling compact view.  | 
308  | 
align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)  | 
309  | 
align.set_padding(5, 0, 0, 0)  | 
|
310  | 
align.add(self.treeview)  | 
|
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
311  | 
        # user-configured size
 | 
| 
531.7.10
by Scott Scriven
 Simplified size-loading code. No longer saves identical config every time vis runs.  | 
312  | 
size = self._load_size('viz-graph-size')  | 
313  | 
if size:  | 
|
314  | 
width, height = size  | 
|
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
315  | 
align.set_size_request(width, height)  | 
316  | 
else:  | 
|
317  | 
(width, height) = self.get_size()  | 
|
318  | 
align.set_size_request(width, int(height / 2.5))  | 
|
319  | 
align.connect('size-allocate', self._on_size_allocate, 'viz-graph-size')  | 
|
| 
375
by Daniel Schierbeck
 Fixed crash when toggling compact view.  | 
320  | 
align.show()  | 
321  | 
||
322  | 
return align  | 
|
| 
44
by David Allouche
 reorganise branch window  | 
323  | 
|
324  | 
def construct_navigation(self):  | 
|
325  | 
"""Construct the navigation buttons."""  | 
|
| 
325
by Daniel Schierbeck
 Switched to using a real toolbar for the viz navigation.  | 
326  | 
self.toolbar = gtk.Toolbar()  | 
327  | 
self.toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)  | 
|
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
328  | 
|
| 
388
by Daniel Schierbeck
 Switched to using the Previous/Next Revision actions to create tool buttons.  | 
329  | 
self.prev_button = self.prev_rev_action.create_tool_item()  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
330  | 
self.toolbar.insert(self.prev_button, -1)  | 
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
331  | 
|
| 
388
by Daniel Schierbeck
 Switched to using the Previous/Next Revision actions to create tool buttons.  | 
332  | 
self.next_button = self.next_rev_action.create_tool_item()  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
333  | 
self.toolbar.insert(self.next_button, -1)  | 
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
334  | 
|
| 
401.1.2
by Daniel Schierbeck
 Allowed the treeview to be refreshed.  | 
335  | 
self.toolbar.insert(gtk.SeparatorToolItem(), -1)  | 
336  | 
||
337  | 
refresh_button = gtk.ToolButton(gtk.STOCK_REFRESH)  | 
|
| 
404
by Daniel Schierbeck
 Made the refresh use proper locking.  | 
338  | 
refresh_button.connect('clicked', self._refresh_clicked)  | 
| 
401.1.2
by Daniel Schierbeck
 Allowed the treeview to be refreshed.  | 
339  | 
self.toolbar.insert(refresh_button, -1)  | 
340  | 
||
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
341  | 
self.toolbar.show_all()  | 
| 
325
by Daniel Schierbeck
 Switched to using a real toolbar for the viz navigation.  | 
342  | 
|
343  | 
return self.toolbar  | 
|
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
344  | 
|
345  | 
def construct_bottom(self):  | 
|
346  | 
"""Construct the bottom half of the window."""  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
347  | 
if self.config.get_user_option('viz-wide-diffs') == 'True':  | 
348  | 
self.diff_paned = gtk.VPaned()  | 
|
349  | 
else:  | 
|
350  | 
self.diff_paned = gtk.HPaned()  | 
|
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
351  | 
(width, height) = self.get_size()  | 
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
352  | 
self.diff_paned.set_size_request(20, 20) # shrinkable  | 
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
353  | 
|
| 
330.3.1
by Daniel Schierbeck
 Renamed logview 'revisionview'.  | 
354  | 
from bzrlib.plugins.gtk.revisionview import RevisionView  | 
| 
412.1.2
by Daniel Schierbeck
 Moved retrieval of tags into the revisionview itself.  | 
355  | 
self.revisionview = RevisionView(branch=self.branch)  | 
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
356  | 
self.revisionview.set_size_request(width/3, int(height / 2.5))  | 
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
357  | 
        # user-configured size
 | 
| 
531.7.10
by Scott Scriven
 Simplified size-loading code. No longer saves identical config every time vis runs.  | 
358  | 
size = self._load_size('viz-revisionview-size')  | 
359  | 
if size:  | 
|
360  | 
width, height = size  | 
|
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
361  | 
self.revisionview.set_size_request(width, height)  | 
362  | 
self.revisionview.connect('size-allocate', self._on_size_allocate, 'viz-revisionview-size')  | 
|
| 
330.3.1
by Daniel Schierbeck
 Renamed logview 'revisionview'.  | 
363  | 
self.revisionview.show()  | 
364  | 
self.revisionview.set_show_callback(self._show_clicked_cb)  | 
|
| 
412.1.9
by Daniel Schierbeck
 Removed the use of RevisionView.set_go_callback().  | 
365  | 
self.revisionview.connect('notify::revision', self._go_clicked_cb)  | 
| 
423.7.4
by Daniel Schierbeck
 Made revisionview and branchview update when a tag is added.  | 
366  | 
self.treeview.connect('tag-added', lambda w, t, r: self.revisionview.update_tags())  | 
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
367  | 
self.diff_paned.pack1(self.revisionview)  | 
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
368  | 
|
369  | 
from bzrlib.plugins.gtk.diff import DiffWidget  | 
|
370  | 
self.diff = DiffWidget()  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
371  | 
self.diff_paned.pack2(self.diff)  | 
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
372  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
373  | 
self.diff_paned.show_all()  | 
| 
531.7.12
by Scott Scriven
 Made diff panel default to off.  | 
374  | 
if self.config.get_user_option('viz-show-diffs') != 'True':  | 
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
375  | 
self.diff.hide()  | 
376  | 
||
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
377  | 
return self.diff_paned  | 
| 
332
by Daniel Schierbeck
 Made tag selection work.  | 
378  | 
|
379  | 
def _tag_selected_cb(self, menuitem, revid):  | 
|
| 
356
by Daniel Schierbeck
 Made revision a property on TreeView.  | 
380  | 
self.treeview.set_revision_id(revid)  | 
| 
341
by Daniel Schierbeck
 Merged with trunk.  | 
381  | 
|
| 
280.1.2
by Daniel Schierbeck
 Switched to handle the 'changed' signal from the treeview's treeselection instead of the 'cursor-changed' signal from the treeview itself, allowing more flexibility (particularly the ability to handle programmatic selections)  | 
382  | 
def _treeselection_changed_cb(self, selection, *args):  | 
| 
303
by Daniel Schierbeck
 Made basic signaling work.  | 
383  | 
"""callback for when the treeview changes."""  | 
384  | 
revision = self.treeview.get_revision()  | 
|
385  | 
parents = self.treeview.get_parents()  | 
|
386  | 
children = self.treeview.get_children()  | 
|
387  | 
||
| 
523.3.2
by Jelmer Vernooij
 Share same menu for context menu and main menu.  | 
388  | 
self.revision_menu.set_revision_ids([revision.revision_id])  | 
389  | 
||
| 
464.2.1
by Adrian Wilkins
 Detect the reserved null: revision in appropriate places.  | 
390  | 
if revision and revision != NULL_REVISION:  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
391  | 
prev_menu = gtk.Menu()  | 
| 
352.1.1
by Daniel Schierbeck
 Added dropdown menu to Back button.  | 
392  | 
if len(parents) > 0:  | 
| 
385
by Daniel Schierbeck
 Created a single action for Previous Revision.  | 
393  | 
self.prev_rev_action.set_sensitive(True)  | 
| 
352.1.1
by Daniel Schierbeck
 Added dropdown menu to Back button.  | 
394  | 
for parent_id in parents:  | 
| 
464.2.1
by Adrian Wilkins
 Detect the reserved null: revision in appropriate places.  | 
395  | 
if parent_id and parent_id != NULL_REVISION:  | 
396  | 
parent = self.branch.repository.get_revision(parent_id)  | 
|
397  | 
try:  | 
|
398  | 
str = ' (' + parent.properties['branch-nick'] + ')'  | 
|
399  | 
except KeyError:  | 
|
400  | 
str = ""  | 
|
| 
355
by Daniel Schierbeck
 Appended branch nick to parent and child popup menus.  | 
401  | 
|
| 
464.2.1
by Adrian Wilkins
 Detect the reserved null: revision in appropriate places.  | 
402  | 
item = gtk.MenuItem(parent.message.split("\n")[0] + str)  | 
403  | 
item.connect('activate', self._set_revision_cb, parent_id)  | 
|
404  | 
prev_menu.add(item)  | 
|
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
405  | 
prev_menu.show_all()  | 
| 
352.1.1
by Daniel Schierbeck
 Added dropdown menu to Back button.  | 
406  | 
else:  | 
| 
385
by Daniel Schierbeck
 Created a single action for Previous Revision.  | 
407  | 
self.prev_rev_action.set_sensitive(False)  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
408  | 
prev_menu.hide()  | 
409  | 
||
410  | 
self.prev_button.set_menu(prev_menu)  | 
|
411  | 
||
412  | 
next_menu = gtk.Menu()  | 
|
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
413  | 
if len(children) > 0:  | 
| 
386
by Daniel Schierbeck
 Created a single action for Next Revision.  | 
414  | 
self.next_rev_action.set_sensitive(True)  | 
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
415  | 
for child_id in children:  | 
416  | 
child = self.branch.repository.get_revision(child_id)  | 
|
| 
355
by Daniel Schierbeck
 Appended branch nick to parent and child popup menus.  | 
417  | 
try:  | 
418  | 
str = ' (' + child.properties['branch-nick'] + ')'  | 
|
419  | 
except KeyError:  | 
|
420  | 
str = ""  | 
|
421  | 
||
422  | 
item = gtk.MenuItem(child.message.split("\n")[0] + str)  | 
|
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
423  | 
item.connect('activate', self._set_revision_cb, child_id)  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
424  | 
next_menu.add(item)  | 
425  | 
next_menu.show_all()  | 
|
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
426  | 
else:  | 
| 
386
by Daniel Schierbeck
 Created a single action for Next Revision.  | 
427  | 
self.next_rev_action.set_sensitive(False)  | 
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
428  | 
next_menu.hide()  | 
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
429  | 
|
| 
376
by Daniel Schierbeck
 Changed 'back' into 'prev' and 'fwd' into 'next'.  | 
430  | 
self.next_button.set_menu(next_menu)  | 
| 
352.1.2
by Daniel Schierbeck
 Added dropdown menu to Forward button.  | 
431  | 
|
| 
412.1.13
by Daniel Schierbeck
 Re-added support for displaying the children of a revision.  | 
432  | 
self.revisionview.set_revision(revision)  | 
433  | 
self.revisionview.set_children(children)  | 
|
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
434  | 
self.update_diff_panel(revision, parents)  | 
| 
531.7.1
by Scott Scriven
 Added a diff panel to otherwise-blank area in 'bzr vis'.  | 
435  | 
|
| 
423.1.17
by Gary van der Merwe
 Reuse the viz treeview in the revision browser.  | 
436  | 
def _tree_revision_activated(self, widget, path, col):  | 
437  | 
        # TODO: more than one parent
 | 
|
438  | 
"""Callback for when a treeview row gets activated."""  | 
|
439  | 
revision = self.treeview.get_revision()  | 
|
440  | 
parents = self.treeview.get_parents()  | 
|
441  | 
||
442  | 
if len(parents) == 0:  | 
|
443  | 
parent_id = None  | 
|
444  | 
else:  | 
|
445  | 
parent_id = parents[0]  | 
|
446  | 
||
447  | 
self.show_diff(revision.revision_id, parent_id)  | 
|
448  | 
self.treeview.grab_focus()  | 
|
| 
463.3.1
by Javier Derderian
 Fixed menu entry 'View Changes'. Bug #215350  | 
449  | 
|
| 
3
by Scott James Remnant
 Split the display in two with a pane, we'll use the bottom half to show  | 
450  | 
def _back_clicked_cb(self, *args):  | 
451  | 
"""Callback for when the back button is clicked."""  | 
|
| 
304
by Daniel Schierbeck
 Made forward/back buttons work again.  | 
452  | 
self.treeview.back()  | 
453  | 
||
| 
5
by Scott James Remnant
 Reverse the meaning of the Back and Forward buttons so Back actually  | 
454  | 
def _fwd_clicked_cb(self, *args):  | 
455  | 
"""Callback for when the forward button is clicked."""  | 
|
| 
304
by Daniel Schierbeck
 Made forward/back buttons work again.  | 
456  | 
self.treeview.forward()  | 
| 
7
by Scott James Remnant
 Put some information about the highlighted revision in the bottom pane,  | 
457  | 
|
| 
412.1.9
by Daniel Schierbeck
 Removed the use of RevisionView.set_go_callback().  | 
458  | 
def _go_clicked_cb(self, w, p):  | 
| 
7
by Scott James Remnant
 Put some information about the highlighted revision in the bottom pane,  | 
459  | 
"""Callback for when the go button for a parent is clicked."""  | 
| 
412.1.9
by Daniel Schierbeck
 Removed the use of RevisionView.set_go_callback().  | 
460  | 
if self.revisionview.get_revision() is not None:  | 
461  | 
self.treeview.set_revision(self.revisionview.get_revision())  | 
|
| 
152
by Jelmer Vernooij
 Cleanup some more code.  | 
462  | 
|
| 
147
by Jelmer Vernooij
 Remove a bunch of duplicate functionality.  | 
463  | 
def _show_clicked_cb(self, revid, parentid):  | 
| 
7
by Scott James Remnant
 Put some information about the highlighted revision in the bottom pane,  | 
464  | 
"""Callback for when the show button for a parent is clicked."""  | 
| 
423.1.17
by Gary van der Merwe
 Reuse the viz treeview in the revision browser.  | 
465  | 
self.show_diff(revid, parentid)  | 
| 
13
by Scott James Remnant
 Keep the focus on the treeview  | 
466  | 
self.treeview.grab_focus()  | 
| 
46
by Wouter van Heyst
 show diff on row activation, LP# 44591  | 
467  | 
|
| 
352.1.1
by Daniel Schierbeck
 Added dropdown menu to Back button.  | 
468  | 
def _set_revision_cb(self, w, revision_id):  | 
| 
356
by Daniel Schierbeck
 Made revision a property on TreeView.  | 
469  | 
self.treeview.set_revision_id(revision_id)  | 
| 
352.1.1
by Daniel Schierbeck
 Added dropdown menu to Back button.  | 
470  | 
|
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
471  | 
def _brokenlines_toggled_cb(self, button):  | 
| 
330.2.5
by Daniel Schierbeck
 Support persistence of compact view option.  | 
472  | 
self.compact_view = button.get_active()  | 
473  | 
||
474  | 
if self.compact_view:  | 
|
475  | 
option = 'yes'  | 
|
| 
330.2.4
by Daniel Schierbeck
 Made use of compact view optional.  | 
476  | 
else:  | 
| 
330.2.5
by Daniel Schierbeck
 Support persistence of compact view option.  | 
477  | 
option = 'no'  | 
478  | 
||
479  | 
self.config.set_user_option('viz-compact-view', option)  | 
|
| 
401.1.3
by Daniel Schierbeck
 Made the compact view toggling cleaner.  | 
480  | 
self.treeview.set_property('compact', self.compact_view)  | 
481  | 
self.treeview.refresh()  | 
|
| 
368
by Daniel Schierbeck
 Merged with mainline.  | 
482  | 
|
| 
511.6.1
by Jelmer Vernooij
 Add Branch/Index option if bzr-search is available.  | 
483  | 
def _branch_index_cb(self, w):  | 
484  | 
from bzrlib.plugins.search import index as _mod_index  | 
|
485  | 
_mod_index.index_url(self.branch.base)  | 
|
486  | 
||
| 
524
by Jelmer Vernooij
 Add search dialog.  | 
487  | 
def _branch_search_cb(self, w):  | 
| 
533.11.1
by Jelmer Vernooij
 Ask user whether to index if there is no index present yet.  | 
488  | 
from bzrlib.plugins.search import index as _mod_index  | 
| 
524
by Jelmer Vernooij
 Add search dialog.  | 
489  | 
from bzrlib.plugins.gtk.search import SearchDialog  | 
| 
533.11.1
by Jelmer Vernooij
 Ask user whether to index if there is no index present yet.  | 
490  | 
from bzrlib.plugins.search import errors as search_errors  | 
491  | 
||
492  | 
try:  | 
|
493  | 
index = _mod_index.open_index_url(self.branch.base)  | 
|
494  | 
except search_errors.NoSearchIndex:  | 
|
495  | 
dialog = gtk.MessageDialog(self, type=gtk.MESSAGE_QUESTION,  | 
|
496  | 
buttons=gtk.BUTTONS_OK_CANCEL,  | 
|
497  | 
message_format="This branch has not been indexed yet. "  | 
|
498  | 
"Index now?")  | 
|
499  | 
if dialog.run() == gtk.RESPONSE_OK:  | 
|
| 
553
by Jelmer Vernooij
 Merge asking the user whether to create an index.  | 
500  | 
dialog.destroy()  | 
| 
533.11.1
by Jelmer Vernooij
 Ask user whether to index if there is no index present yet.  | 
501  | 
index = _mod_index.index_url(self.branch.base)  | 
502  | 
else:  | 
|
| 
553
by Jelmer Vernooij
 Merge asking the user whether to create an index.  | 
503  | 
dialog.destroy()  | 
| 
533.11.1
by Jelmer Vernooij
 Ask user whether to index if there is no index present yet.  | 
504  | 
                return
 | 
505  | 
||
506  | 
dialog = SearchDialog(index)  | 
|
| 
526
by Jelmer Vernooij
 Switch to found revision when clicking ok in search window.  | 
507  | 
|
508  | 
if dialog.run() == gtk.RESPONSE_OK:  | 
|
509  | 
self.set_revision(dialog.get_revision())  | 
|
510  | 
||
511  | 
dialog.destroy()  | 
|
| 
524
by Jelmer Vernooij
 Add search dialog.  | 
512  | 
|
| 
423.9.1
by Daniel Schierbeck
 Added Help->About menu item to the viz.  | 
513  | 
def _about_dialog_cb(self, w):  | 
514  | 
from bzrlib.plugins.gtk.about import AboutDialog  | 
|
515  | 
||
516  | 
AboutDialog().run()  | 
|
517  | 
||
| 
348
by Daniel Schierbeck
 Added toggle item for revision number column.  | 
518  | 
def _col_visibility_changed(self, col, property):  | 
| 
373
by Daniel Schierbeck
 Made column display options persisted.  | 
519  | 
self.config.set_user_option(property + '-column-visible', col.get_active())  | 
| 
348
by Daniel Schierbeck
 Added toggle item for revision number column.  | 
520  | 
self.treeview.set_property(property + '-column-visible', col.get_active())  | 
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
521  | 
|
522  | 
def _toolbar_visibility_changed(self, col):  | 
|
523  | 
if col.get_active():  | 
|
| 
531.7.2
by Scott Scriven
 Made 'vis' save/load visibility of its toolbar.  | 
524  | 
self.toolbar.show()  | 
| 
351
by Daniel Schierbeck
 Added option to hide the toolbar.  | 
525  | 
else:  | 
526  | 
self.toolbar.hide()  | 
|
| 
531.7.2
by Scott Scriven
 Made 'vis' save/load visibility of its toolbar.  | 
527  | 
self.config.set_user_option('viz-toolbar-visible', col.get_active())  | 
| 
371.1.1
by Daniel Schierbeck
 Added About dialog to the viz.  | 
528  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
529  | 
def _make_diff_nonzero_size(self):  | 
530  | 
"""make sure the diff isn't zero-width or zero-height"""  | 
|
531  | 
alloc = self.diff.get_allocation()  | 
|
532  | 
if (alloc.width < 10) or (alloc.height < 10):  | 
|
533  | 
width, height = self.get_size()  | 
|
534  | 
self.revisionview.set_size_request(width/3, int(height / 2.5))  | 
|
535  | 
||
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
536  | 
def _diff_visibility_changed(self, col):  | 
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
537  | 
"""Hide or show the diff panel."""  | 
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
538  | 
if col.get_active():  | 
539  | 
self.diff.show()  | 
|
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
540  | 
self._make_diff_nonzero_size()  | 
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
541  | 
else:  | 
542  | 
self.diff.hide()  | 
|
543  | 
self.config.set_user_option('viz-show-diffs', str(col.get_active()))  | 
|
544  | 
self.update_diff_panel()  | 
|
545  | 
||
| 
531.7.14
by Scott Scriven
 Made diff placement configurable (bottom-right, or bottom full-width).  | 
546  | 
def _diff_placement_changed(self, col):  | 
547  | 
"""Toggle the diff panel's position."""  | 
|
548  | 
self.config.set_user_option('viz-wide-diffs', str(col.get_active()))  | 
|
549  | 
||
550  | 
old = self.paned.get_child2()  | 
|
551  | 
self.paned.remove(old)  | 
|
552  | 
self.paned.pack2(self.construct_bottom(), resize=True, shrink=False)  | 
|
553  | 
self._make_diff_nonzero_size()  | 
|
554  | 
||
555  | 
self.treeview.emit('revision-selected')  | 
|
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
556  | 
|
557  | 
def _diff_wrap_changed(self, widget):  | 
|
558  | 
"""Toggle word wrap in the diff widget."""  | 
|
559  | 
self.config.set_user_option('viz-wrap-diffs', widget.get_active())  | 
|
560  | 
self.diff._on_wraplines_toggled(widget)  | 
|
561  | 
||
| 
371.1.1
by Daniel Schierbeck
 Added About dialog to the viz.  | 
562  | 
def _show_about_cb(self, w):  | 
563  | 
dialog = AboutDialog()  | 
|
564  | 
dialog.connect('response', lambda d,r: d.destroy())  | 
|
565  | 
dialog.run()  | 
|
| 
404
by Daniel Schierbeck
 Made the refresh use proper locking.  | 
566  | 
|
567  | 
def _refresh_clicked(self, w):  | 
|
| 
423.1.13
by Gary van der Merwe
 Move viz loading msg from branchwin to treeview.  | 
568  | 
self.treeview.refresh()  | 
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
569  | 
|
570  | 
def _update_tags(self):  | 
|
571  | 
menu = gtk.Menu()  | 
|
572  | 
||
573  | 
if self.branch.supports_tags():  | 
|
574  | 
tags = self.branch.tags.get_tag_dict().items()  | 
|
| 
576.5.1
by Jelmer Vernooij
 Disable the ability to click on tags that are not available in the current view.  | 
575  | 
tags.sort(reverse=True)  | 
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
576  | 
for tag, revid in tags:  | 
| 
450.4.1
by Daniel Schierbeck
 Added tag icon to branch history window.  | 
577  | 
tag_image = gtk.Image()  | 
578  | 
tag_image.set_from_file(icon_path('tag-16.png'))  | 
|
579  | 
tag_item = gtk.ImageMenuItem(tag.replace('_', '__'))  | 
|
580  | 
tag_item.set_image(tag_image)  | 
|
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
581  | 
tag_item.connect('activate', self._tag_selected_cb, revid)  | 
| 
576.5.1
by Jelmer Vernooij
 Disable the ability to click on tags that are not available in the current view.  | 
582  | 
tag_item.set_sensitive(self.treeview.has_revision_id(revid))  | 
| 
423.7.5
by Daniel Schierbeck
 Made the revision history window update the Go->Tags menu when a tag is added.  | 
583  | 
menu.add(tag_item)  | 
584  | 
self.go_menu_tags.set_submenu(menu)  | 
|
585  | 
||
586  | 
self.go_menu_tags.set_sensitive(len(tags) != 0)  | 
|
587  | 
else:  | 
|
588  | 
self.go_menu_tags.set_sensitive(False)  | 
|
589  | 
||
590  | 
self.go_menu_tags.show_all()  | 
|
591  | 
||
| 
531.7.10
by Scott Scriven
 Simplified size-loading code. No longer saves identical config every time vis runs.  | 
592  | 
def _load_size(self, name):  | 
593  | 
"""Read and parse 'name' from self.config.  | 
|
594  | 
        The value is a string, formatted as WIDTHxHEIGHT
 | 
|
595  | 
        Returns None, or (width, height)
 | 
|
596  | 
        """
 | 
|
597  | 
size = self.config.get_user_option(name)  | 
|
598  | 
if size:  | 
|
599  | 
width, height = [int(num) for num in size.split('x')]  | 
|
600  | 
            # avoid writing config every time we start
 | 
|
601  | 
self._sizes[name] = (width, height)  | 
|
602  | 
return width, height  | 
|
603  | 
return None  | 
|
604  | 
||
| 
531.7.9
by Scott Scriven
 Made vis remember window and panel sizes.  | 
605  | 
def _on_size_allocate(self, widget, allocation, name):  | 
606  | 
"""When window has been resized, save the new size."""  | 
|
607  | 
width, height = 0, 0  | 
|
608  | 
if name in self._sizes:  | 
|
609  | 
width, height = self._sizes[name]  | 
|
610  | 
||
611  | 
size_changed = (width != allocation.width) or \  | 
|
612  | 
(height != allocation.height)  | 
|
613  | 
||
614  | 
if size_changed:  | 
|
615  | 
width, height = allocation.width, allocation.height  | 
|
616  | 
self._sizes[name] = (width, height)  | 
|
617  | 
value = '%sx%s' % (width, height)  | 
|
618  | 
self.config.set_user_option(name, value)  | 
|
619  | 
||
| 
423.1.17
by Gary van der Merwe
 Reuse the viz treeview in the revision browser.  | 
620  | 
def show_diff(self, revid=None, parentid=None):  | 
621  | 
"""Open a new window to show a diff between the given revisions."""  | 
|
622  | 
from bzrlib.plugins.gtk.diff import DiffWindow  | 
|
623  | 
window = DiffWindow(parent=self)  | 
|
624  | 
||
625  | 
if parentid is None:  | 
|
626  | 
parentid = NULL_REVISION  | 
|
627  | 
||
628  | 
rev_tree = self.branch.repository.revision_tree(revid)  | 
|
629  | 
parent_tree = self.branch.repository.revision_tree(parentid)  | 
|
630  | 
||
631  | 
description = revid + " - " + self.branch.nick  | 
|
632  | 
window.set_diff(description, rev_tree, parent_tree)  | 
|
633  | 
window.show()  | 
|
634  | 
||
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
635  | 
def update_diff_panel(self, revision=None, parents=None):  | 
636  | 
"""Show the current revision in the diff panel."""  | 
|
| 
531.7.12
by Scott Scriven
 Made diff panel default to off.  | 
637  | 
if self.config.get_user_option('viz-show-diffs') != 'True':  | 
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
638  | 
            return
 | 
639  | 
||
640  | 
if not revision: # default to selected row  | 
|
641  | 
revision = self.treeview.get_revision()  | 
|
642  | 
if (not revision) or (revision == NULL_REVISION):  | 
|
643  | 
            return
 | 
|
644  | 
||
645  | 
if not parents: # default to selected row's parents  | 
|
646  | 
parents = self.treeview.get_parents()  | 
|
647  | 
if len(parents) == 0:  | 
|
648  | 
parent_id = None  | 
|
649  | 
else:  | 
|
650  | 
parent_id = parents[0]  | 
|
651  | 
||
652  | 
rev_tree = self.branch.repository.revision_tree(revision.revision_id)  | 
|
653  | 
parent_tree = self.branch.repository.revision_tree(parent_id)  | 
|
| 
531.7.5
by Scott Scriven
 Fixed DiffWidget so more than one call to set_diff() will work.  | 
654  | 
|
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
655  | 
self.diff.set_diff(rev_tree, parent_tree)  | 
| 
555.2.2
by Jasper Groenewegen
 Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff  | 
656  | 
if self.config.get_user_option('viz-wrap-diffs') == 'True':  | 
657  | 
self.diff._on_wraplines_toggled(wrap=True)  | 
|
| 
531.7.3
by Scott Scriven
 Added an option to show/hide the diff panel.  | 
658  | 
self.diff.show_all()  |