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