Status: | Merged |
---|---|
Merge reported by: | Curtis Hovey |
Merged at revision: | not available |
Proposed branch: | lp:~sinzui/bzr-gtk/gtk3 |
Merge into: | lp:bzr-gtk/gtk2 |
Diff against target: |
6859 lines (+1691/-1595) 53 files modified
HACKING (+1/-3) README (+2/-2) __init__.py (+2/-11) about.py (+4/-9) annotate/colormap.py (+6/-2) annotate/config.py (+4/-4) annotate/gannotate.py (+98/-92) annotate/spanselector.py (+30/-31) avatarsbox.py (+38/-41) branch.py (+28/-35) branchbox.py (+15/-18) branchview/graphcell.py (+57/-37) branchview/treemodel.py (+58/-98) branchview/treeview.py (+100/-91) bzr-handle-patch (+1/-1) bzr-notify (+1/-1) checkout.py (+35/-41) commands.py (+19/-22) commit.py (+103/-105) conflicts.py (+35/-41) dialog.py (+10/-16) diff.py (+59/-62) initialize.py (+25/-28) keyring.py (+4/-7) lock.py (+10/-8) loom.py (+18/-25) merge.py (+27/-34) mergedirective.py (+21/-27) missing.py (+12/-18) nautilus-bzr.py (+5/-5) notify.py (+13/-18) preferences/__init__.py (+12/-17) preferences/identity.py (+57/-47) preferences/notifications.py (+28/-33) preferences/plugins.py (+40/-43) push.py (+24/-27) revbrowser.py (+11/-18) revidbox.py (+9/-15) revisionmenu.py (+17/-22) revisionview.py (+142/-141) search.py (+37/-32) setup.py (+1/-1) status.py (+9/-15) tags.py (+84/-86) tests/__init__.py (+2/-0) tests/test_commit.py (+48/-27) tests/test_diff.py (+1/-1) tests/test_graphcell.py (+81/-0) tests/test_revisionview.py (+2/-1) tests/test_treemodel.py (+101/-0) ui.py (+47/-47) viz/branchwin.py (+87/-80) window.py (+10/-9) |
To merge this branch: | bzr merge lp:~sinzui/bzr-gtk/gtk3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Approve | ||
Jelmer Vernooij | Pending | ||
Review via email: mp+74472@code.launchpad.net |
Commit message
Description of the change
Update bzr-gtk to Gtk3.
Launchpad bug: https:/
Pre-
bzr-gtk commands, widgets, cannot be used in a process that has imported gtk3.
Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the
same process is not supported Trace/breakpoint trap
The general approach to fix this is to
create a gtk3 series
Run pygi.convert.sh found in pygi's tree
Update all the obsolete 2.x calls to 3.
The majority of this branch is mechanical changes as outlined in the rules
below. There are three changes that should be given more attention in the
review:
* I noticed that The plugins tab of the preferences window used
'
is emitted on enter/double-click. I change the signal to cursor-changed
which is emitted when the use move the cursor via the arrow keys or
single-
work the way most people expect.
* pygtk's GenericTreeModel is not supported. I chose to reimplement
the class by subclassing ListStore. I removed many unneeded methods,
and added two required methods. I added a test.
* pygtk's GenericCellRenderer is not supported. I tried subclassing
all the cellrenders, but all create widgets except for CellRenderPixbuf.
The render method only need two changes, and I added other methods
to disable the behaviours inherited from the superclass. There are
many Pango and Cairo enums and macros that are missing from gi. The
bugs are already reported. I chose to copy the definitions needed to
keep the class operational. I added a test.
This branch works very well for my self, but I am sure that there are gtk3
conversion issues that I have not discovered. I more users are now needed
to find bugs.
I am seeing three warnings that I do not yet understand, but I am seeing
these issues in other gtk3 apps. I am not seeing failures, so I
think these should be fixed in a separate effort. The issues may be in
upstream code:
* gpreferences
(bzr:18153): Gtk-WARNING **: gtk_widget_
underallocate GtkNotebook's child
bzrlib+
Allocation is 311x398, but minimum required size is 315x220.
^ Changing the preferred sized does not fix this.
* viz
(bzr:6942): Gtk-WARNING **: gtk_widget_
underallocate GtkTreeView's child GtkButton 0x901c960. Allocation is
1x27, but minimum required size is 12x27.
^ I have no idea how to set the size of the button/label used by
the treeview's column headings.
* gannotate
/
g_
return info.invoke(*args, **kwargs)
^ I do not know what is causing this and the error only appeared a
few days ago minutes after a gtk update to oneiric
* setup.py check
(
assertion `GDK_IS_WINDOW (window)' failed
^ This is because widget.show() is not called in test_commit.py when
which is very annoying. The tests do work, so I chose not to change
the affected tests.
-------
RULES
* Run pygi.convert.sh found in pygi's tree
* Removed pygtk import and require('2.0')
* Gdk.EventMask.
* Gtk.Dialog.vbox -> Gtk.Dialog.
* Replace kwargs with args because gi does not provide defaults. Because
There are no defaults, many arguments must be added that pygtk was
providing:
* pack_end(widget, expand) -> pack_end(widget, expand, fill, padding)
* pack_start(widget, expand) -> pack_start(widget, expand, fill, padding)
* buffer.
* GTKTreeView.
* Either use kwargs with implicit constructors, or use the
explicit constructor
* GtkComboBoxEntry -> Gtk.ComboBox.
* Gtk.RadioButton() -> Gtk.RadioButton
* gi does not support the integer-tuple conversion used by pygtk. There
is not generic treemodel and cellrender classes to create python
implement
* int_or_tuple -> Gtk.TreePath(
* treemodel.py GenericTreeModel -> ListStore
* graphcell.py GenericCellRenderer -> CellRendererPixbuf
QA
* Run every command from the menus for the appropriate branch/repo
* I also test this using the commands called by gedit-developer
bzr.
LINT
There is a tremendous number of style issues. pygi.convert.sh created
many long lines. I can fix these before I merge. I decided not to fix
them for the review so the diff was clear about what changed on each line.
TEST
./setup.py check
IMPLEMENTATION
New implementation and hacks:
branchview/
branchview/
tests/
tests/
Mechanical changes by script or by addressing reported argument changes.
HACKING
README
__init__.py
about.py
annotate/
annotate/
annotate/
annotate/
avatarsbox.py
branch.py
branchbox.py
branchview/
bzr-
bzr-notify
checkout.py
commands.py
commit.py
conflicts.py
dialog.py
diff.py
initialize.py
keyring.py
lock.py
loom.py
merge.py
mergedirect
missing.py
nautilus-bzr.py
notify.py
preferences
preferences
preferences
preferences
push.py
revbrowser.py
revidbox.py
revisionmenu.py
revisionview.py
search.py
setup.py
status.py
tags.py
tests/
tests/
tests/
tests/
ui.py
viz/
window.py
Jelmer Vernooij (jelmer) wrote : | # |
- 787. By Curtis Hovey
-
Fixed packing args.
Curtis Hovey (sinzui) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/07/2011 04:59 PM, Jelmer Vernooij wrote:
> Hi Curtis,
>
> Thanks again for working on this, much appreciated. :)
>
> Feel free to already push to lp:bzr-gtk/gtk3, which was a branch
created earlier for gtk3 porting. I think we should create a
lp:bzr-gtk/gtk2 once we merge your work into trunk, for people who are
still using older versions of GNOME/GTK.
I pushed to lp:bzr-gtk/gtk3 after addressing the two packing argument
errors you reported. The were several other pack_end() calls that I had
missed.
> Trying out your branch on Oneiric I'm getting the following error
> on
the terminal, and no visual graph in the "viz" window:
> TypeError: Couldn't find conversion for foreign struct
> 'cairo.Context'
I saw several errors like this when python was trying to create the
context. I was confident that changes to avoid creating contexts was
complete.
> This seems like a Cairo bug to me - do I need a newer version or
> something?
I believe these are the libs in play, though as said, cairo is not
directly used. The gi chain may be importing.
libcairo2 1.10.2-6ubuntu3
gir1.2-freedesktop 1.29.17-0ubuntu1
python-cairo 1.8.8-1ubuntu2
python-object-cairo 2.90.3-1svn1
- --
Curtis Hovey
http://
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEARECAAYFAk5
cYsAnimY1r4Z8KB
=ZX4l
-----END PGP SIGNATURE-----
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 09/07/2011 06:40 PM, Curtis Hovey wrote:
> Curtis Hovey has proposed merging lp:~sinzui/bzr-gtk/gtk3 into lp:bzr-gtk.
>
> Requested reviews:
> Bazaar GTK maintainers (bzr-gtk)
>
> For more details, see:
> https:/
>
> Update bzr-gtk to Gtk3.
>
> Launchpad bug: https:/
> Pre-implementation: no one
>
> bzr-gtk commands, widgets, cannot be used in a process that has imported gtk3.
> Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the
> same process is not supported Trace/breakpoint trap
>
> The general approach to fix this is to
> create a gtk3 series
> Run pygi.convert.sh found in pygi's tree
> Update all the obsolete 2.x calls to 3.
>
> The majority of this branch is mechanical changes as outlined in the rules
> below. There are three changes that should be given more attention in the
> review:
I don't think bzr-gtk is particularly well supported by "upstream" at
this point. So I'm going to rubber stamp your work, assuming you did a
good job. We can wait a bit, and see if anyone complains before landing
it. But the patch is large enough, I don't think people will really go
through it anyway.
review: approve
> This branch works very well for my self, but I am sure that there are gtk3
> conversion issues that I have not discovered. I more users are now needed
> to find bugs.
I think that is a pretty good estimate, though.
I think overall this is an improvement, which may not be perfect, but it
better than the status quo, so it should be merged.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAk5
X1YAoNM+
=sgU+
-----END PGP SIGNATURE-----
Preview Diff
1 | === modified file 'HACKING' |
2 | --- HACKING 2008-07-17 11:51:03 +0000 |
3 | +++ HACKING 2011-09-08 03:12:25 +0000 |
4 | @@ -8,8 +8,6 @@ |
5 | (http://developer.gnome.org/projects/gup/hig/) should be followed where |
6 | possible. |
7 | |
8 | -Several parts of bzr-gtk are currently using glade. However, we are slowly |
9 | -trying to move away from glade so please don't add new code that uses glade and |
10 | -try to remove the use of glade. |
11 | +Don't add new code that uses glade. |
12 | |
13 | Please update the NEWS file when closing bugs or adding new features. |
14 | |
15 | === modified file 'README' |
16 | --- README 2009-05-26 13:58:24 +0000 |
17 | +++ README 2011-09-08 03:12:25 +0000 |
18 | @@ -15,7 +15,7 @@ |
19 | |
20 | * Python 2.4 |
21 | * Bazaar with the same major version as bzr-gtk |
22 | - * PyGTK 2.8 or later |
23 | + * PyGObject |
24 | |
25 | In order to see graphs in the visualisation tool, you will also need: |
26 | |
27 | @@ -119,7 +119,7 @@ |
28 | |
29 | - Python: http://www.python.org/download/releases/2.4.3/ |
30 | - GTK: http://gladewin32.sourceforge.net/ |
31 | - - PyGTK: http://www.mapr.ucl.ac.be/~gustin/win32_ports (pygtk, pygobject and pycairo) |
32 | + - PyGTK: http://www.mapr.ucl.ac.be/~gustin/win32_ports (pygobject and pycairo) |
33 | - Bazaar: http://bazaar-vcs.org/WindowsDownloads (Python-based should be okay) |
34 | - pyWin32: http://sourceforge.net/project/showfiles.php?group_id=78018 |
35 | |
36 | |
37 | === modified file '__init__.py' |
38 | --- __init__.py 2011-04-10 18:44:39 +0000 |
39 | +++ __init__.py 2011-09-08 03:12:25 +0000 |
40 | @@ -75,17 +75,8 @@ |
41 | from bzrlib.trace import warning |
42 | warning("Not running as bzrlib.plugins.gtk, things may break.") |
43 | |
44 | -def import_pygtk(): |
45 | - try: |
46 | - import pygtk |
47 | - except ImportError: |
48 | - raise errors.BzrCommandError("PyGTK not installed.") |
49 | - pygtk.require('2.0') |
50 | - return pygtk |
51 | - |
52 | |
53 | def set_ui_factory(): |
54 | - import_pygtk() |
55 | from ui import GtkUIFactory |
56 | import bzrlib.ui |
57 | bzrlib.ui.ui_factory = GtkUIFactory() |
58 | @@ -168,8 +159,8 @@ |
59 | try: |
60 | result = basic_tests |
61 | try: |
62 | - import_pygtk() |
63 | - except errors.BzrCommandError: |
64 | + import gi.repository.Gtk |
65 | + except ImportError: |
66 | return basic_tests |
67 | basic_tests.addTest(loader.loadTestsFromModuleNames( |
68 | ["%s.%s" % (__name__, tmn) for tmn in testmod_names])) |
69 | |
70 | === modified file 'about.py' |
71 | --- about.py 2011-03-14 20:12:19 +0000 |
72 | +++ about.py 2011-09-08 03:12:25 +0000 |
73 | @@ -14,13 +14,8 @@ |
74 | # along with this program; if not, write to the Free Software |
75 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
76 | |
77 | -try: |
78 | - import pygtk |
79 | - pygtk.require("2.0") |
80 | -except: |
81 | - pass |
82 | - |
83 | -import gtk |
84 | +from gi.repository import Gtk |
85 | +from gi.repository import GdkPixbuf |
86 | import os |
87 | |
88 | import bzrlib |
89 | @@ -49,14 +44,14 @@ |
90 | return credits |
91 | |
92 | |
93 | -class AboutDialog(gtk.AboutDialog): |
94 | +class AboutDialog(Gtk.AboutDialog): |
95 | def __init__(self): |
96 | super(AboutDialog, self).__init__() |
97 | self.set_name("Bazaar GTK") |
98 | self.set_version(bzrlib.plugins.gtk.version_string) |
99 | self.set_website("http://bazaar-vcs.org/BzrGtk") |
100 | self.set_license(read_license()) |
101 | - self.set_logo(gtk.gdk.pixbuf_new_from_file(icon_path("bzr-icon-64.png"))) |
102 | + self.set_logo(GdkPixbuf.Pixbuf.new_from_file(icon_path("bzr-icon-64.png"))) |
103 | credits = load_credits() |
104 | if credits is not None: |
105 | (authors, documenters, artists, translators) = credits |
106 | |
107 | === modified file 'annotate/colormap.py' |
108 | --- annotate/colormap.py 2011-03-14 20:12:19 +0000 |
109 | +++ annotate/colormap.py 2011-09-08 03:12:25 +0000 |
110 | @@ -14,9 +14,12 @@ |
111 | # along with this program; if not, write to the Free Software |
112 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
113 | |
114 | +__metaclass__ = type |
115 | + |
116 | import sys |
117 | |
118 | -class AnnotateColorMap(object): |
119 | + |
120 | +class AnnotateColorMap: |
121 | |
122 | really_old_color = "#0046FF" |
123 | |
124 | @@ -62,9 +65,10 @@ |
125 | |
126 | return color |
127 | |
128 | + |
129 | class AnnotateColorSaturation(AnnotateColorMap): |
130 | def __init__(self, span=340.): |
131 | - AnnotateColorMap.__init__(self, span) |
132 | + super(AnnotateColorSaturation, self).__init__(span) |
133 | self.current_angle = 0 |
134 | |
135 | def hue(self, angle): |
136 | |
137 | === modified file 'annotate/config.py' |
138 | --- annotate/config.py 2011-06-17 12:54:05 +0000 |
139 | +++ annotate/config.py 2011-09-08 03:12:25 +0000 |
140 | @@ -16,7 +16,7 @@ |
141 | |
142 | import os |
143 | |
144 | -import gtk.gdk |
145 | +from gi.repository import Gdk |
146 | |
147 | from bzrlib import config |
148 | try: |
149 | @@ -38,7 +38,7 @@ |
150 | """ |
151 | |
152 | def __init__(self, window): |
153 | - configobj.ConfigObj.__init__(self, gannotate_config_filename()) |
154 | + super(GAnnotateConfig, self).__init__(gannotate_config_filename()) |
155 | self.window = window |
156 | self.pane = window.pane |
157 | |
158 | @@ -74,7 +74,7 @@ |
159 | self.pane.connect("notify", self._save_pane_props) |
160 | |
161 | def _save_window_props(self, w, e, *args): |
162 | - if e.window.get_state() & gtk.gdk.WINDOW_STATE_MAXIMIZED: |
163 | + if e.window.get_state() & Gdk.WindowState.MAXIMIZED: |
164 | maximized = True |
165 | else: |
166 | self["window"]["width"], self["window"]["height"] = w.get_size() |
167 | @@ -84,7 +84,7 @@ |
168 | return False |
169 | |
170 | def _save_pane_props(self, w, gparam): |
171 | - if gparam.name == "position": |
172 | + if gparam and gparam.name == "position": |
173 | self["window"]["pane_position"] = w.get_position() |
174 | |
175 | return False |
176 | |
177 | === modified file 'annotate/gannotate.py' |
178 | --- annotate/gannotate.py 2011-03-23 09:49:44 +0000 |
179 | +++ annotate/gannotate.py 2011-09-08 03:12:25 +0000 |
180 | @@ -16,11 +16,10 @@ |
181 | |
182 | import time |
183 | |
184 | -import pygtk |
185 | -pygtk.require("2.0") |
186 | -import gobject |
187 | -import gtk |
188 | -import pango |
189 | +from gi.repository import GObject |
190 | +from gi.repository import Gdk |
191 | +from gi.repository import Gtk |
192 | +from gi.repository import Pango |
193 | import re |
194 | |
195 | from bzrlib import patiencediff |
196 | @@ -50,9 +49,10 @@ |
197 | self.plain = plain |
198 | self._branch = branch |
199 | |
200 | - Window.__init__(self, parent) |
201 | + super(GAnnotateWindow, self).__init__(parent=parent) |
202 | |
203 | - self.set_icon(self.render_icon(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON)) |
204 | + self.set_icon( |
205 | + self.render_icon_pixbuf(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON)) |
206 | self.annotate_colormap = AnnotateColorSaturation() |
207 | |
208 | self._create() |
209 | @@ -70,12 +70,12 @@ |
210 | lambda: CURRENT_REVISION)() |
211 | |
212 | # [revision id, line number, author, revno, highlight color, line] |
213 | - self.annomodel = gtk.ListStore(gobject.TYPE_STRING, |
214 | - gobject.TYPE_INT, |
215 | - gobject.TYPE_STRING, |
216 | - gobject.TYPE_STRING, |
217 | - gobject.TYPE_STRING, |
218 | - gobject.TYPE_STRING) |
219 | + self.annomodel = Gtk.ListStore(GObject.TYPE_STRING, |
220 | + GObject.TYPE_INT, |
221 | + GObject.TYPE_STRING, |
222 | + GObject.TYPE_STRING, |
223 | + GObject.TYPE_STRING, |
224 | + GObject.TYPE_STRING) |
225 | |
226 | last_seen = None |
227 | try: |
228 | @@ -129,8 +129,9 @@ |
229 | else: |
230 | row = lineno - 1 |
231 | |
232 | - self.annoview.set_cursor(row) |
233 | - self.annoview.scroll_to_cell(row, use_align=True) |
234 | + tree_path = Gtk.TreePath(path=row) |
235 | + self.annoview.set_cursor(tree_path, None, False) |
236 | + self.annoview.scroll_to_cell(tree_path, use_align=True) |
237 | |
238 | |
239 | def _annotate(self, tree, file_id): |
240 | @@ -167,8 +168,9 @@ |
241 | def _highlight_annotation(self, model, path, iter, now): |
242 | revision_id, = model.get(iter, REVISION_ID_COL) |
243 | revision = self.revisions[revision_id] |
244 | - model.set(iter, HIGHLIGHT_COLOR_COL, |
245 | - self.annotate_colormap.get_color(revision, now)) |
246 | + # XXX sinzui 2011-08-12: What does get_color return? |
247 | + color = self.annotate_colormap.get_color(revision, now) |
248 | + model.set_value(iter, HIGHLIGHT_COLOR_COL, color) |
249 | |
250 | def _selected_revision(self): |
251 | (path, col) = self.annoview.get_cursor() |
252 | @@ -193,46 +195,46 @@ |
253 | self.revisionview = self._create_log_view() |
254 | self.annoview = self._create_annotate_view() |
255 | |
256 | - vbox = gtk.VBox(False) |
257 | + vbox = Gtk.VBox(homogeneous=False, spacing=0) |
258 | vbox.show() |
259 | |
260 | - sw = gtk.ScrolledWindow() |
261 | - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
262 | - sw.set_shadow_type(gtk.SHADOW_IN) |
263 | + sw = Gtk.ScrolledWindow() |
264 | + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
265 | + sw.set_shadow_type(Gtk.ShadowType.IN) |
266 | sw.add(self.annoview) |
267 | self.annoview.gwindow = self |
268 | sw.show() |
269 | |
270 | - swbox = gtk.VBox() |
271 | - swbox.pack_start(sw) |
272 | + swbox = Gtk.VBox() |
273 | + swbox.pack_start(sw, True, True, 0) |
274 | swbox.show() |
275 | |
276 | - hbox = gtk.HBox(False, 6) |
277 | + hbox = Gtk.HBox(homogeneous=False, spacing=6) |
278 | self.back_button = self._create_back_button() |
279 | - hbox.pack_start(self.back_button, expand=False, fill=True) |
280 | + hbox.pack_start(self.back_button, False, True, 0) |
281 | self.forward_button = self._create_forward_button() |
282 | - hbox.pack_start(self.forward_button, expand=False, fill=True) |
283 | + hbox.pack_start(self.forward_button, False, True, 0) |
284 | self.find_button = self._create_find_button() |
285 | - hbox.pack_start(self.find_button, expand=False, fill=True) |
286 | + hbox.pack_start(self.find_button, False, True, 0) |
287 | self.goto_button = self._create_goto_button() |
288 | - hbox.pack_start(self.goto_button, expand=False, fill=True) |
289 | + hbox.pack_start(self.goto_button, False, True, 0) |
290 | hbox.show() |
291 | - vbox.pack_start(hbox, expand=False, fill=True) |
292 | + vbox.pack_start(hbox, False, True, 0) |
293 | |
294 | - self.pane = pane = gtk.VPaned() |
295 | + self.pane = pane = Gtk.VPaned() |
296 | pane.add1(swbox) |
297 | pane.add2(self.revisionview) |
298 | pane.show() |
299 | - vbox.pack_start(pane, expand=True, fill=True) |
300 | + vbox.pack_start(pane, True, True, 0) |
301 | |
302 | self._search = SearchBox() |
303 | - swbox.pack_start(self._search, expand=False, fill=True) |
304 | - accels = gtk.AccelGroup() |
305 | - accels.connect_group(gtk.keysyms.f, gtk.gdk.CONTROL_MASK, |
306 | - gtk.ACCEL_LOCKED, |
307 | + swbox.pack_start(self._search, False, True, 0) |
308 | + accels = Gtk.AccelGroup() |
309 | + accels.connect(Gdk.KEY_f, Gdk.ModifierType.CONTROL_MASK, |
310 | + Gtk.AccelFlags.LOCKED, |
311 | self._search_by_text) |
312 | - accels.connect_group(gtk.keysyms.g, gtk.gdk.CONTROL_MASK, |
313 | - gtk.ACCEL_LOCKED, |
314 | + accels.connect(Gdk.KEY_g, Gdk.ModifierType.CONTROL_MASK, |
315 | + Gtk.AccelFlags.LOCKED, |
316 | self._search_by_line) |
317 | self.add_accel_group(accels) |
318 | |
319 | @@ -247,7 +249,7 @@ |
320 | self._search.set_target(self.annoview, LINE_NUM_COL) |
321 | |
322 | def line_diff(self, tv, path, tvc): |
323 | - row = path[0] |
324 | + row = path.get_indices()[0] |
325 | revision = self.annotations[row] |
326 | repository = self.branch.repository |
327 | if revision.revision_id == CURRENT_REVISION: |
328 | @@ -267,52 +269,52 @@ |
329 | |
330 | |
331 | def _create_annotate_view(self): |
332 | - tv = gtk.TreeView() |
333 | + tv = Gtk.TreeView() |
334 | tv.set_rules_hint(False) |
335 | tv.connect("cursor-changed", self._activate_selected_revision) |
336 | tv.show() |
337 | tv.connect("row-activated", self.line_diff) |
338 | |
339 | - cell = gtk.CellRendererText() |
340 | + cell = Gtk.CellRendererText() |
341 | cell.set_property("xalign", 1.0) |
342 | cell.set_property("ypad", 0) |
343 | cell.set_property("family", "Monospace") |
344 | cell.set_property("cell-background-gdk", |
345 | - tv.get_style().bg[gtk.STATE_NORMAL]) |
346 | - col = gtk.TreeViewColumn() |
347 | + tv.get_style().bg[Gtk.StateType.NORMAL]) |
348 | + col = Gtk.TreeViewColumn() |
349 | col.set_resizable(False) |
350 | - col.pack_start(cell, expand=True) |
351 | + col.pack_start(cell, True) |
352 | col.add_attribute(cell, "text", LINE_NUM_COL) |
353 | tv.append_column(col) |
354 | |
355 | - cell = gtk.CellRendererText() |
356 | + cell = Gtk.CellRendererText() |
357 | cell.set_property("ypad", 0) |
358 | - cell.set_property("ellipsize", pango.ELLIPSIZE_END) |
359 | + cell.set_property("ellipsize", Pango.EllipsizeMode.END) |
360 | cell.set_property("cell-background-gdk", |
361 | - self.get_style().bg[gtk.STATE_NORMAL]) |
362 | - col = gtk.TreeViewColumn("Committer") |
363 | + self.get_style().bg[Gtk.StateType.NORMAL]) |
364 | + col = Gtk.TreeViewColumn("Committer") |
365 | col.set_resizable(True) |
366 | - col.pack_start(cell, expand=True) |
367 | + col.pack_start(cell, True) |
368 | col.add_attribute(cell, "text", COMMITTER_COL) |
369 | tv.append_column(col) |
370 | |
371 | - cell = gtk.CellRendererText() |
372 | + cell = Gtk.CellRendererText() |
373 | cell.set_property("xalign", 1.0) |
374 | cell.set_property("ypad", 0) |
375 | cell.set_property("cell-background-gdk", |
376 | - self.get_style().bg[gtk.STATE_NORMAL]) |
377 | - col = gtk.TreeViewColumn("Revno") |
378 | + self.get_style().bg[Gtk.StateType.NORMAL]) |
379 | + col = Gtk.TreeViewColumn("Revno") |
380 | col.set_resizable(False) |
381 | - col.pack_start(cell, expand=True) |
382 | + col.pack_start(cell, True) |
383 | col.add_attribute(cell, "markup", REVNO_COL) |
384 | tv.append_column(col) |
385 | |
386 | - cell = gtk.CellRendererText() |
387 | + cell = Gtk.CellRendererText() |
388 | cell.set_property("ypad", 0) |
389 | cell.set_property("family", "Monospace") |
390 | - col = gtk.TreeViewColumn() |
391 | + col = Gtk.TreeViewColumn() |
392 | col.set_resizable(False) |
393 | - col.pack_start(cell, expand=True) |
394 | + col.pack_start(cell, True) |
395 | # col.add_attribute(cell, "foreground", HIGHLIGHT_COLOR_COL) |
396 | col.add_attribute(cell, "background", HIGHLIGHT_COLOR_COL) |
397 | col.add_attribute(cell, "text", TEXT_LINE_COL) |
398 | @@ -323,7 +325,7 @@ |
399 | return model.get_value(iter, TEXT_LINE_COL).lower().find(key.lower()) == -1 |
400 | |
401 | tv.set_enable_search(True) |
402 | - tv.set_search_equal_func(search_equal_func) |
403 | + tv.set_search_equal_func(search_equal_func, None) |
404 | |
405 | return tv |
406 | |
407 | @@ -333,41 +335,41 @@ |
408 | return lv |
409 | |
410 | def _create_back_button(self): |
411 | - button = gtk.Button() |
412 | + button = Gtk.Button() |
413 | button.set_use_stock(True) |
414 | button.set_label("gtk-go-back") |
415 | button.connect("clicked", lambda w: self.go_back()) |
416 | - button.set_relief(gtk.RELIEF_NONE) |
417 | + button.set_relief(Gtk.ReliefStyle.NONE) |
418 | button.show() |
419 | return button |
420 | |
421 | def _create_forward_button(self): |
422 | - button = gtk.Button() |
423 | + button = Gtk.Button() |
424 | button.set_use_stock(True) |
425 | button.set_label("gtk-go-forward") |
426 | button.connect("clicked", lambda w: self.go_forward()) |
427 | - button.set_relief(gtk.RELIEF_NONE) |
428 | + button.set_relief(Gtk.ReliefStyle.NONE) |
429 | button.show() |
430 | button.set_sensitive(False) |
431 | return button |
432 | |
433 | def _create_find_button(self): |
434 | - button = gtk.Button() |
435 | + button = Gtk.Button() |
436 | button.set_use_stock(True) |
437 | button.set_label("gtk-find") |
438 | button.set_tooltip_text("Search for text (Ctrl+F)") |
439 | button.connect("clicked", self._search_by_text) |
440 | - button.set_relief(gtk.RELIEF_NONE) |
441 | + button.set_relief(Gtk.ReliefStyle.NONE) |
442 | button.show() |
443 | button.set_sensitive(True) |
444 | return button |
445 | |
446 | def _create_goto_button(self): |
447 | - button = gtk.Button() |
448 | + button = Gtk.Button() |
449 | button.set_label("Goto Line") |
450 | button.set_tooltip_text("Scroll to a line by entering its number (Ctrl+G)") |
451 | button.connect("clicked", self._search_by_line) |
452 | - button.set_relief(gtk.RELIEF_NONE) |
453 | + button.set_relief(Gtk.ReliefStyle.NONE) |
454 | button.show() |
455 | button.set_sensitive(True) |
456 | return button |
457 | @@ -396,12 +398,14 @@ |
458 | rev_id = self._selected_revision() |
459 | if self.file_id in target_tree: |
460 | offset = self.get_scroll_offset(target_tree) |
461 | - (row,), col = self.annoview.get_cursor() |
462 | + path, col = self.annoview.get_cursor() |
463 | + (row,) = path.get_indices() |
464 | self.annotate(target_tree, self.branch, self.file_id) |
465 | new_row = row+offset |
466 | if new_row < 0: |
467 | new_row = 0 |
468 | - self.annoview.set_cursor(new_row) |
469 | + new_path = Gtk.TreePath(path=new_row) |
470 | + self.annoview.set_cursor(new_path, None, False) |
471 | return True |
472 | else: |
473 | return False |
474 | @@ -409,7 +413,8 @@ |
475 | def get_scroll_offset(self, tree): |
476 | old = self.tree.get_file(self.file_id) |
477 | new = tree.get_file(self.file_id) |
478 | - (row,), col = self.annoview.get_cursor() |
479 | + path, col = self.annoview.get_cursor() |
480 | + (row,) = path.get_indices() |
481 | matcher = patiencediff.PatienceSequenceMatcher(None, old.readlines(), |
482 | new.readlines()) |
483 | for i, j, n in matcher.get_matching_blocks(): |
484 | @@ -452,57 +457,58 @@ |
485 | self.__cache[revision_id] = revision |
486 | return self.__cache[revision_id] |
487 | |
488 | -class SearchBox(gtk.HBox): |
489 | + |
490 | +class SearchBox(Gtk.HBox): |
491 | """A button box for searching in text or lines of annotations""" |
492 | def __init__(self): |
493 | - gtk.HBox.__init__(self, False, 6) |
494 | + super(SearchBox, self).__init__(homogeneous=False, spacing=6) |
495 | |
496 | # Close button |
497 | - button = gtk.Button() |
498 | - image = gtk.Image() |
499 | - image.set_from_stock('gtk-stop', gtk.ICON_SIZE_BUTTON) |
500 | + button = Gtk.Button() |
501 | + image = Gtk.Image() |
502 | + image.set_from_stock('gtk-stop', Gtk.IconSize.BUTTON) |
503 | button.set_image(image) |
504 | - button.set_relief(gtk.RELIEF_NONE) |
505 | - button.connect("clicked", lambda w: self.hide_all()) |
506 | - self.pack_start(button, expand=False, fill=False) |
507 | + button.set_relief(Gtk.ReliefStyle.NONE) |
508 | + button.connect("clicked", lambda w: self.hide()) |
509 | + self.pack_start(button, False, False, 0) |
510 | |
511 | # Search entry |
512 | - label = gtk.Label() |
513 | + label = Gtk.Label() |
514 | self._label = label |
515 | - self.pack_start(label, expand=False, fill=False) |
516 | + self.pack_start(label, False, False, 0) |
517 | |
518 | - entry = gtk.Entry() |
519 | + entry = Gtk.Entry() |
520 | self._entry = entry |
521 | entry.connect("activate", lambda w, d: self._do_search(d), |
522 | 'forward') |
523 | - self.pack_start(entry, expand=False, fill=False) |
524 | + self.pack_start(entry, False, False, 0) |
525 | |
526 | # Next/previous buttons |
527 | - button = gtk.Button('_Next') |
528 | - image = gtk.Image() |
529 | - image.set_from_stock('gtk-go-forward', gtk.ICON_SIZE_BUTTON) |
530 | + button = Gtk.Button('_Next') |
531 | + image = Gtk.Image() |
532 | + image.set_from_stock('gtk-go-forward', Gtk.IconSize.BUTTON) |
533 | button.set_image(image) |
534 | button.connect("clicked", lambda w, d: self._do_search(d), |
535 | 'forward') |
536 | - self.pack_start(button, expand=False, fill=False) |
537 | + self.pack_start(button, False, False, 0) |
538 | |
539 | - button = gtk.Button('_Previous') |
540 | - image = gtk.Image() |
541 | - image.set_from_stock('gtk-go-back', gtk.ICON_SIZE_BUTTON) |
542 | + button = Gtk.Button('_Previous') |
543 | + image = Gtk.Image() |
544 | + image.set_from_stock('gtk-go-back', Gtk.IconSize.BUTTON) |
545 | button.set_image(image) |
546 | button.connect("clicked", lambda w, d: self._do_search(d), |
547 | 'backward') |
548 | - self.pack_start(button, expand=False, fill=False) |
549 | + self.pack_start(button, False, False, 0) |
550 | |
551 | # Search options |
552 | - check = gtk.CheckButton('Match case') |
553 | + check = Gtk.CheckButton('Match case') |
554 | self._match_case = check |
555 | - self.pack_start(check, expand=False, fill=False) |
556 | + self.pack_start(check, False, False, 0) |
557 | |
558 | - check = gtk.CheckButton('Regexp') |
559 | + check = Gtk.CheckButton('Regexp') |
560 | check.connect("toggled", lambda w: self._set_label()) |
561 | self._regexp = check |
562 | - self.pack_start(check, expand=False, fill=False) |
563 | + self.pack_start(check, False, False, 0) |
564 | |
565 | self._view = None |
566 | self._column = None |
567 | @@ -588,6 +594,6 @@ |
568 | for row in iterate(model, start): |
569 | if self._match(model, row, self._column): |
570 | path = model.get_path(row) |
571 | - self._view.set_cursor(path) |
572 | + self._view.set_cursor(path, None, False) |
573 | self._view.scroll_to_cell(path, use_align=True) |
574 | break |
575 | |
576 | === modified file 'annotate/spanselector.py' |
577 | --- annotate/spanselector.py 2011-03-14 20:12:19 +0000 |
578 | +++ annotate/spanselector.py 2011-09-08 03:12:25 +0000 |
579 | @@ -15,10 +15,8 @@ |
580 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
581 | |
582 | |
583 | -import pygtk |
584 | -pygtk.require("2.0") |
585 | -import gobject |
586 | -import gtk |
587 | +from gi.repository import GObject |
588 | +from gi.repository import Gtk |
589 | |
590 | |
591 | ( |
592 | @@ -29,7 +27,7 @@ |
593 | ) = range(4) |
594 | |
595 | |
596 | -class SpanSelector(gtk.HBox): |
597 | +class SpanSelector(Gtk.HBox): |
598 | """Encapsulates creation and functionality of widgets used for changing |
599 | highlight spans. |
600 | |
601 | @@ -41,18 +39,19 @@ |
602 | last_selected = None |
603 | |
604 | def __init__(self, homogeneous=False, spacing=6): |
605 | - gtk.HBox.__init__(self, homogeneous, spacing) |
606 | + super(SpanSelector, self).__init__( |
607 | + homogeneous=homogeneous, spacing=spacing) |
608 | |
609 | self.model = self._create_model() |
610 | self.combo = self._create_combobox(self.model) |
611 | self.entry = self._create_custom_entry() |
612 | |
613 | - label = gtk.Label("Highlighting spans:") |
614 | + label = Gtk.Label(label="Highlighting spans:") |
615 | label.show() |
616 | |
617 | - self.pack_start(label, expand=False, fill=True) |
618 | - self.pack_start(self.combo, expand=False, fill=False) |
619 | - self.pack_start(self.entry, expand=False, fill=False) |
620 | + self.pack_start(label, False, True, True, 0) |
621 | + self.pack_start(self.combo, False, False, True, 0) |
622 | + self.pack_start(self.entry, False, False, True, 0) |
623 | |
624 | def set_to_oldest_span(self, span): |
625 | """Set the span associated with the "to Oldest Revision" entry.""" |
626 | @@ -67,7 +66,7 @@ |
627 | self.max_custom_spans = n |
628 | |
629 | def activate(self, iter): |
630 | - """Activate the row pointed to by gtk.TreeIter iter.""" |
631 | + """Activate the row pointed to by Gtk.TreeIter iter.""" |
632 | index = self._get_index_from_iter(iter) |
633 | self.combo.set_active(index) |
634 | |
635 | @@ -100,7 +99,7 @@ |
636 | self.emit("span-changed", model.get_value(iter, SPAN_DAYS_COL)) |
637 | |
638 | def _activate_custom_span_cb(self, w): |
639 | - self.entry.hide_all() |
640 | + self.entry.hide() |
641 | self.combo.show() |
642 | |
643 | span = float(w.get_text()) |
644 | @@ -137,10 +136,10 @@ |
645 | def _create_model(self): |
646 | # [span in days, span as string, row is seperator?, row is select |
647 | # default?] |
648 | - m = gtk.ListStore(gobject.TYPE_FLOAT, |
649 | - gobject.TYPE_STRING, |
650 | - gobject.TYPE_BOOLEAN, |
651 | - gobject.TYPE_BOOLEAN) |
652 | + m = Gtk.ListStore(GObject.TYPE_FLOAT, |
653 | + GObject.TYPE_STRING, |
654 | + GObject.TYPE_BOOLEAN, |
655 | + GObject.TYPE_BOOLEAN) |
656 | |
657 | self.separator = [0., "", True, False] |
658 | |
659 | @@ -157,10 +156,10 @@ |
660 | return m |
661 | |
662 | def _create_combobox(self, model): |
663 | - cb = gtk.ComboBox(model) |
664 | + cb = Gtk.ComboBox(model) |
665 | cb.set_row_separator_func( |
666 | lambda m, i: m.get_value(i, SPAN_IS_SEPARATOR_COL)) |
667 | - cell = gtk.CellRendererText() |
668 | + cell = Gtk.CellRendererText() |
669 | cb.pack_start(cell, False) |
670 | cb.add_attribute(cell, "text", SPAN_STR_COL) |
671 | cb.connect("changed", self._combo_changed_cb) |
672 | @@ -169,19 +168,19 @@ |
673 | return cb |
674 | |
675 | def _create_custom_entry(self): |
676 | - entry = gtk.HBox(False, 6) |
677 | + entry = Gtk.HBox(False, 6) |
678 | |
679 | - spin = gtk.SpinButton(digits=2) |
680 | + spin = Gtk.SpinButton(digits=2) |
681 | spin.set_numeric(True) |
682 | spin.set_increments(1., 10.) |
683 | spin.set_range(0., 100 * 365) # I presume 100 years is sufficient |
684 | spin.connect("activate", self._activate_custom_span_cb) |
685 | spin.connect("show", lambda w: w.grab_focus()) |
686 | |
687 | - label = gtk.Label("Days") |
688 | + label = Gtk.Label(label="Days") |
689 | |
690 | - entry.pack_start(spin, expand=False, fill=False) |
691 | - entry.pack_start(label, expand=False, fill=False) |
692 | + entry.pack_start(spin, False, False, True, 0) |
693 | + entry.pack_start(label, False, False, True, 0) |
694 | |
695 | return entry |
696 | |
697 | @@ -191,18 +190,18 @@ |
698 | |
699 | Callback signature: def callback(SpanSelector, span, [user_param, ...]) |
700 | """ |
701 | -gobject.signal_new("span-changed", SpanSelector, |
702 | - gobject.SIGNAL_RUN_LAST, |
703 | - gobject.TYPE_NONE, |
704 | - (gobject.TYPE_FLOAT,)) |
705 | +GObject.signal_new("span-changed", SpanSelector, |
706 | + GObject.SignalFlags.RUN_LAST, |
707 | + None, |
708 | + (GObject.TYPE_FLOAT,)) |
709 | |
710 | """The "custom-span-added" signal is emitted after a custom span has been |
711 | added, but before it has been selected. |
712 | |
713 | Callback signature: def callback(SpanSelector, span, [user_param, ...]) |
714 | """ |
715 | -gobject.signal_new("custom-span-added", SpanSelector, |
716 | - gobject.SIGNAL_RUN_LAST, |
717 | - gobject.TYPE_NONE, |
718 | - (gobject.TYPE_FLOAT,)) |
719 | +GObject.signal_new("custom-span-added", SpanSelector, |
720 | + GObject.SignalFlags.RUN_LAST, |
721 | + None, |
722 | + (GObject.TYPE_FLOAT,)) |
723 | |
724 | |
725 | === modified file 'avatarsbox.py' |
726 | --- avatarsbox.py 2011-09-03 21:24:24 +0000 |
727 | +++ avatarsbox.py 2011-09-08 03:12:25 +0000 |
728 | @@ -14,7 +14,8 @@ |
729 | # along with this program; if not, write to the Free Software |
730 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
731 | |
732 | -import gtk |
733 | +from gi.repository import Gtk |
734 | +from gi.repository import GdkPixbuf |
735 | |
736 | from bzrlib.config import parse_username |
737 | |
738 | @@ -25,12 +26,12 @@ |
739 | ) |
740 | |
741 | |
742 | -class Avatar(gtk.HBox): |
743 | +class Avatar(Gtk.HBox): |
744 | """ Author or committer avatar """ |
745 | |
746 | def __init__(self, apparent_username): |
747 | """ Constructor """ |
748 | - gtk.HBox.__init__(self) |
749 | + super(Avatar, self).__init__() |
750 | |
751 | self.apparent_username = apparent_username |
752 | self.username, self.email = parse_username(apparent_username) |
753 | @@ -43,44 +44,41 @@ |
754 | |
755 | def show_spinner(self): |
756 | """ |
757 | - Replace the current content of the Avatar with a gtk.Spinner |
758 | - if an email address has been parsed. If not, show an gtk.Label with |
759 | + Replace the current content of the Avatar with a Gtk.Spinner |
760 | + if an email address has been parsed. If not, show an Gtk.Label with |
761 | the translatable 'No email' text. |
762 | """ |
763 | if self.email: |
764 | tooltip = _i18n("Retrieving avatar for %s...") % self.email |
765 | - if getattr(gtk, "Spinner", False): |
766 | - spinner = gtk.Spinner() |
767 | - spinner.start() |
768 | - self.pack_start(spinner, False) |
769 | - spinner.set_tooltip_text(tooltip) |
770 | - spinner.set_size_request(20, 20) |
771 | - spinner.show() |
772 | - else: |
773 | - spinner = gtk.Label(tooltip) |
774 | - self.pack_start(spinner) |
775 | - self.set_tooltip_text(self.apparent_username) |
776 | - spinner.show() |
777 | + spinner = Gtk.Spinner() |
778 | + spinner.start() |
779 | + self.pack_start(spinner, False, True, 0) |
780 | + spinner.set_tooltip_text(tooltip) |
781 | + spinner.set_size_request(20, 20) |
782 | + spinner.show() |
783 | else: |
784 | - no_email = gtk.Label(_i18n("No email")) |
785 | - self.pack_start(no_email) |
786 | + no_email = Gtk.Label(label=_i18n("No email")) |
787 | + self.pack_start(no_email, True, True, 0) |
788 | self.set_tooltip_text(self.apparent_username) |
789 | no_email.show() |
790 | |
791 | def show_image(self): |
792 | - """Replace the current content of the Avatar with the gtk.Image """ |
793 | + """Replace the current content of the Avatar with the Gtk.Image """ |
794 | if self.email and self.image: |
795 | - self.remove(self.get_children()[0]) |
796 | - self.pack_start(self.image) |
797 | + children = self.get_children() |
798 | + if children != []: |
799 | + self.remove(children[0]) |
800 | + self.pack_start(self.image, True, True, 0) |
801 | self.image.set_tooltip_text(self.apparent_username) |
802 | self.image.show() |
803 | |
804 | |
805 | -class AvatarBox(gtk.HBox): |
806 | +class AvatarBox(Gtk.HBox): |
807 | """HBox showing an avatar.""" |
808 | |
809 | def __init__(self, homogeneous=False, spacing=0): |
810 | - gtk.HBox.__init__(self, homogeneous, spacing) |
811 | + super(AvatarBox, self).__init__( |
812 | + homogeneous=homogeneous, spacing=spacing) |
813 | self.__avatars = {} |
814 | self.avatar = None |
815 | self.__displaying = None |
816 | @@ -129,9 +127,9 @@ |
817 | return self |
818 | |
819 | def update_avatar_image_from_pixbuf_loader(self, loader): |
820 | - """Replace the gtk.Spinner with the given loader.""" |
821 | + """Replace the Gtk.Spinner with the given loader.""" |
822 | if self.avatar: |
823 | - self.avatar.image = gtk.Image() |
824 | + self.avatar.image = Gtk.Image() |
825 | self.avatar.image.set_from_pixbuf(loader.get_pixbuf()) |
826 | self.avatar.show_image() |
827 | self.__displaying = self.avatar |
828 | @@ -139,31 +137,30 @@ |
829 | def come_back_to_gui(self): |
830 | """Render back avatar in the GUI.""" |
831 | if self.avatar: |
832 | - self.pack_start(self.avatar) |
833 | + self.pack_start(self.avatar, True, True, 0) |
834 | self.__displaying = self.avatar |
835 | else: |
836 | self._show_no_email() |
837 | |
838 | def _new_cell_for_avatar(self, avatar): |
839 | - """Create a new cell in this box with a gtk.Spinner.""" |
840 | + """Create a new cell in this box with a Gtk.Spinner.""" |
841 | avatar.show_spinner() |
842 | - self.pack_start(avatar) |
843 | + self.pack_start(avatar, True, True, 0) |
844 | avatar.show() |
845 | self.__displaying = avatar |
846 | |
847 | def _show_no_email(self): |
848 | - """Show a gtk.Label with test 'No email'.""" |
849 | - no_email = gtk.Label(_i18n("No email")) |
850 | - self.pack_start(no_email) |
851 | + """Show a Gtk.Label with text 'No email'.""" |
852 | + no_email = Gtk.Label(label=_i18n("No email")) |
853 | + self.pack_start(no_email, True, True, 0) |
854 | no_email.show() |
855 | |
856 | |
857 | -class AvatarsBox(gtk.HBox): |
858 | +class AvatarsBox(Gtk.HBox): |
859 | """GTK container for author and committer avatars.""" |
860 | |
861 | def __init__(self): |
862 | - gtk.HBox.__init__(self, False, 10) |
863 | - |
864 | + super(AvatarsBox, self).__init__(homogeneous=False, spacing=10) |
865 | self.__committer_box = None |
866 | self.__authors_box = None |
867 | self._init_gui() |
868 | @@ -215,15 +212,15 @@ |
869 | |
870 | def _init_gui(self): |
871 | """Create boxes where avatars will be displayed.""" |
872 | - # 2 gtk.HBox: One for the committer and one for authors |
873 | + # 2 Gtk.HBox: One for the committer and one for authors |
874 | # Committer |
875 | self.__committer_box = AvatarBox() |
876 | self.__committer_box.set_size_request(80, 80) |
877 | - self.pack_end(self.__committer_box, False) |
878 | + self.pack_end(self.__committer_box, False, True, 0) |
879 | self.__committer_box.show() |
880 | # Authors |
881 | self.__authors_box = AvatarBox() |
882 | - self.pack_end(self.__authors_box, False) |
883 | + self.pack_end(self.__authors_box, False, True, 0) |
884 | self.__authors_box.set_spacing(10) |
885 | self.__authors_box.show() |
886 | |
887 | @@ -234,8 +231,8 @@ |
888 | :param email: used to identify item from self.__avatars. |
889 | """ |
890 | if email: |
891 | - # Convert downloaded image from provider to gtk.Image |
892 | - loader = gtk.gdk.PixbufLoader() |
893 | + # Convert downloaded image from provider to Gtk.Image |
894 | + loader = GdkPixbuf.PixbufLoader() |
895 | loader.write(response.read()) |
896 | loader.close() |
897 | |
898 | @@ -244,7 +241,7 @@ |
899 | email).update_avatar_image_from_pixbuf_loader(loader) |
900 | |
901 | def _role_box_for(self, role): |
902 | - """ Return the gtk.HBox for the given role """ |
903 | + """ Return the Gtk.HBox for the given role """ |
904 | if role == "committer": |
905 | return self.__committer_box |
906 | else: |
907 | |
908 | === modified file 'branch.py' |
909 | --- branch.py 2011-04-10 18:44:39 +0000 |
910 | +++ branch.py 2011-09-08 03:12:25 +0000 |
911 | @@ -16,13 +16,7 @@ |
912 | |
913 | import os |
914 | |
915 | -try: |
916 | - import pygtk |
917 | - pygtk.require("2.0") |
918 | -except: |
919 | - pass |
920 | - |
921 | -import gtk |
922 | +from gi.repository import Gtk |
923 | |
924 | from bzrlib import ( |
925 | errors, |
926 | @@ -36,33 +30,32 @@ |
927 | from bzrlib.plugins.gtk.branchbox import BranchSelectionBox |
928 | |
929 | |
930 | -class BranchDialog(gtk.Dialog): |
931 | +class BranchDialog(Gtk.Dialog): |
932 | """ New implementation of the Branch dialog. """ |
933 | |
934 | def __init__(self, path=None, parent=None, remote_path=None): |
935 | """ Initialize the Branch dialog. """ |
936 | - gtk.Dialog.__init__(self, title="Branch - Olive", |
937 | - parent=parent, |
938 | - flags=0, |
939 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
940 | + super(BranchDialog, self).__init__( |
941 | + title="Branch - Olive", parent=parent, flags=0, |
942 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
943 | |
944 | # Get arguments |
945 | self.path = path |
946 | |
947 | # Create the widgets |
948 | - self._button_branch = gtk.Button(_i18n("_Branch"), use_underline=True) |
949 | + self._button_branch = Gtk.Button(_i18n("_Branch"), use_underline=True) |
950 | self._remote_branch = BranchSelectionBox() |
951 | - self._button_revision = gtk.Button('') |
952 | - self._label_location = gtk.Label(_i18n("Branch location:")) |
953 | + self._button_revision = Gtk.Button('') |
954 | + self._label_location = Gtk.Label(label=_i18n("Branch location:")) |
955 | self._label_location.set_alignment(0, 0.5) |
956 | - self._label_destination = gtk.Label(_i18n("Destination:")) |
957 | - self._label_nick = gtk.Label(_i18n("Branck nick:")) |
958 | - self._label_revision = gtk.Label(_i18n("Revision:")) |
959 | - self._filechooser = gtk.FileChooserButton(_i18n("Please select a folder")) |
960 | - self._filechooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) |
961 | - self._hbox_revision = gtk.HBox() |
962 | - self._entry_revision = gtk.Entry() |
963 | - self._entry_nick = gtk.Entry() |
964 | + self._label_destination = Gtk.Label(label=_i18n("Destination:")) |
965 | + self._label_nick = Gtk.Label(label=_i18n("Branck nick:")) |
966 | + self._label_revision = Gtk.Label(label=_i18n("Revision:")) |
967 | + self._filechooser = Gtk.FileChooserButton(_i18n("Please select a folder")) |
968 | + self._filechooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER) |
969 | + self._hbox_revision = Gtk.HBox() |
970 | + self._entry_revision = Gtk.Entry() |
971 | + self._entry_nick = Gtk.Entry() |
972 | |
973 | # Set callbacks |
974 | self._button_branch.connect('clicked', self._on_branch_clicked) |
975 | @@ -70,7 +63,7 @@ |
976 | self._remote_branch.connect('branch-changed', self._on_branch_changed) |
977 | |
978 | # Create the table and pack the widgets into it |
979 | - self._table = gtk.Table(rows=3, columns=2) |
980 | + self._table = Gtk.Table(rows=3, columns=2) |
981 | self._table.attach(self._label_location, 0, 1, 0, 1) |
982 | self._table.attach(self._remote_branch, 1, 2, 0, 1) |
983 | self._table.attach(self._label_destination, 0, 1, 1, 2) |
984 | @@ -81,8 +74,8 @@ |
985 | self._table.attach(self._hbox_revision, 1, 2, 3, 4) |
986 | |
987 | # Set properties |
988 | - self._image_browse = gtk.Image() |
989 | - self._image_browse.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON) |
990 | + self._image_browse = Gtk.Image() |
991 | + self._image_browse.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON) |
992 | self._button_revision.set_image(self._image_browse) |
993 | self._button_revision.set_sensitive(False) |
994 | self._label_destination.set_alignment(0, 0.5) |
995 | @@ -90,20 +83,20 @@ |
996 | self._label_revision.set_alignment(0, 0.5) |
997 | self._table.set_row_spacings(3) |
998 | self._table.set_col_spacings(3) |
999 | - self.vbox.set_spacing(3) |
1000 | + self.get_content_area().set_spacing(3) |
1001 | if remote_path is not None: |
1002 | self._remote_branch.set_url(remote_path) |
1003 | if self.path is not None: |
1004 | self._filechooser.set_filename(self.path) |
1005 | |
1006 | # Pack some widgets |
1007 | - self._hbox_revision.pack_start(self._entry_revision, True, True) |
1008 | - self._hbox_revision.pack_start(self._button_revision, False, False) |
1009 | - self.vbox.add(self._table) |
1010 | - self.action_area.pack_end(self._button_branch) |
1011 | + self._hbox_revision.pack_start(self._entry_revision, True, True, 0) |
1012 | + self._hbox_revision.pack_start(self._button_revision, False, False, 0) |
1013 | + self.get_content_area().add(self._table) |
1014 | + self.action_area.pack_end(self._button_branch, False, False, 0) |
1015 | |
1016 | # Show the dialog |
1017 | - self.vbox.show_all() |
1018 | + self.get_content_area().show_all() |
1019 | |
1020 | def _get_last_revno(self): |
1021 | """ Get the revno of the last revision (if any). """ |
1022 | @@ -124,10 +117,10 @@ |
1023 | return |
1024 | revb = RevisionBrowser(br, self) |
1025 | response = revb.run() |
1026 | - if response != gtk.RESPONSE_NONE: |
1027 | + if response != Gtk.ResponseType.NONE: |
1028 | revb.hide() |
1029 | |
1030 | - if response == gtk.RESPONSE_OK: |
1031 | + if response == Gtk.ResponseType.OK: |
1032 | if revb.selected_revno is not None: |
1033 | self._entry_revision.set_text(revb.selected_revno) |
1034 | |
1035 | @@ -181,7 +174,7 @@ |
1036 | info_dialog(_i18n('Branching successful'), |
1037 | _i18n('%d revision(s) branched.') % revs) |
1038 | |
1039 | - self.response(gtk.RESPONSE_OK) |
1040 | + self.response(Gtk.ResponseType.OK) |
1041 | |
1042 | def _on_branch_changed(self, widget, event): |
1043 | """ We try to get the last revision if focus lost. """ |
1044 | |
1045 | === modified file 'branchbox.py' |
1046 | --- branchbox.py 2011-03-14 20:12:19 +0000 |
1047 | +++ branchbox.py 2011-09-08 03:12:25 +0000 |
1048 | @@ -14,26 +14,22 @@ |
1049 | # along with this program; if not, write to the Free Software |
1050 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1051 | |
1052 | -try: |
1053 | - import pygtk |
1054 | - pygtk.require("2.0") |
1055 | -except: |
1056 | - pass |
1057 | - |
1058 | -import gtk |
1059 | -import gobject |
1060 | +from gi.repository import Gtk |
1061 | +from gi.repository import GObject |
1062 | |
1063 | from bzrlib.branch import Branch |
1064 | from bzrlib.config import GlobalConfig |
1065 | |
1066 | from bzrlib.plugins.gtk.history import UrlHistory |
1067 | |
1068 | -class BranchSelectionBox(gtk.HBox): |
1069 | + |
1070 | +class BranchSelectionBox(Gtk.HBox): |
1071 | |
1072 | def __init__(self, path=None): |
1073 | - gobject.GObject.__init__(self) |
1074 | - self._combo = gtk.ComboBoxEntry() |
1075 | - self._combo.child.connect('focus-out-event', self._on_combo_changed) |
1076 | + super(BranchSelectionBox, self).__init__() |
1077 | + self._combo = Gtk.ComboBox.new_with_entry() |
1078 | + self._combo.get_child().connect( |
1079 | + 'focus-out-event', self._on_combo_changed) |
1080 | |
1081 | # Build branch history |
1082 | self._history = UrlHistory(GlobalConfig(), 'branch_history') |
1083 | @@ -55,18 +51,19 @@ |
1084 | |
1085 | def _build_history(self): |
1086 | """ Build up the branch history. """ |
1087 | - self._combo_model = gtk.ListStore(str) |
1088 | + self._combo_model = Gtk.ListStore(str) |
1089 | |
1090 | for item in self._history.get_entries(): |
1091 | self._combo_model.append([ item ]) |
1092 | |
1093 | self._combo.set_model(self._combo_model) |
1094 | - self._combo.set_text_column(0) |
1095 | + self._combo.set_entry_text_column(0) |
1096 | |
1097 | def _on_combo_changed(self, widget, event): |
1098 | self.emit('branch-changed', widget) |
1099 | |
1100 | -gobject.signal_new('branch-changed', BranchSelectionBox, |
1101 | - gobject.SIGNAL_RUN_LAST, |
1102 | - gobject.TYPE_NONE, (gobject.TYPE_OBJECT,)) |
1103 | -gobject.type_register(BranchSelectionBox) |
1104 | + |
1105 | +GObject.signal_new('branch-changed', BranchSelectionBox, |
1106 | + GObject.SignalFlags.RUN_LAST, |
1107 | + None, (GObject.TYPE_OBJECT,)) |
1108 | +GObject.type_register(BranchSelectionBox) |
1109 | |
1110 | === modified file 'branchview/graphcell.py' |
1111 | --- branchview/graphcell.py 2011-03-14 20:12:19 +0000 |
1112 | +++ branchview/graphcell.py 2011-09-08 03:12:25 +0000 |
1113 | @@ -10,19 +10,34 @@ |
1114 | just be for the background. |
1115 | """ |
1116 | |
1117 | -__copyright__ = "Copyright © 2005 Canonical Ltd." |
1118 | +__copyright__ = "Copyright © 2005-2011 Canonical Ltd." |
1119 | __author__ = "Scott James Remnant <scott@ubuntu.com>" |
1120 | |
1121 | |
1122 | import math |
1123 | |
1124 | -import gtk |
1125 | -import gobject |
1126 | -import pango |
1127 | -import cairo |
1128 | - |
1129 | - |
1130 | -class CellRendererGraph(gtk.GenericCellRenderer): |
1131 | +from gi.repository import Gtk |
1132 | +from gi.repository import GObject |
1133 | +from gi.repository import Pango |
1134 | +from gi.repository import PangoCairo |
1135 | + |
1136 | + |
1137 | +# Cairo constants are not exported yet. These are taken from documentation. |
1138 | +CAIRO_LINE_CAP_BUTT = 0 |
1139 | +CAIRO_LINE_CAP_ROUND = 1 |
1140 | +CAIRO_LINE_CAP_SQUARE = 2 |
1141 | + |
1142 | + |
1143 | +CAIRO_FILL_RULE_WINDING = 0 |
1144 | +CAIRO_FILL_RULE_EVEN_ODD = 1 |
1145 | + |
1146 | + |
1147 | +# Macro from Pango header. |
1148 | +def PANGO_PIXELS(d): |
1149 | + return (d + 512) / 1000 |
1150 | + |
1151 | + |
1152 | +class CellRendererGraph(Gtk.CellRendererPixbuf): |
1153 | """Cell renderer for directed graph. |
1154 | |
1155 | Properties: |
1156 | @@ -34,21 +49,21 @@ |
1157 | columns_len = 0 |
1158 | |
1159 | __gproperties__ = { |
1160 | - "node": ( gobject.TYPE_PYOBJECT, "node", |
1161 | + "node": ( GObject.TYPE_PYOBJECT, "node", |
1162 | "revision node instruction", |
1163 | - gobject.PARAM_WRITABLE |
1164 | + GObject.PARAM_WRITABLE |
1165 | ), |
1166 | - "tags": ( gobject.TYPE_PYOBJECT, "tags", |
1167 | + "tags": ( GObject.TYPE_PYOBJECT, "tags", |
1168 | "list of tags associated with the node", |
1169 | - gobject.PARAM_WRITABLE |
1170 | + GObject.PARAM_WRITABLE |
1171 | ), |
1172 | - "in-lines": ( gobject.TYPE_PYOBJECT, "in-lines", |
1173 | + "in-lines": ( GObject.TYPE_PYOBJECT, "in-lines", |
1174 | "instructions to draw lines into the cell", |
1175 | - gobject.PARAM_WRITABLE |
1176 | + GObject.PARAM_WRITABLE |
1177 | ), |
1178 | - "out-lines": ( gobject.TYPE_PYOBJECT, "out-lines", |
1179 | + "out-lines": ( GObject.TYPE_PYOBJECT, "out-lines", |
1180 | "instructions to draw lines out of the cell", |
1181 | - gobject.PARAM_WRITABLE |
1182 | + GObject.PARAM_WRITABLE |
1183 | ), |
1184 | } |
1185 | |
1186 | @@ -76,11 +91,9 @@ |
1187 | except AttributeError: |
1188 | pango_ctx = widget.get_pango_context() |
1189 | font_desc = widget.get_style().font_desc |
1190 | - metrics = pango_ctx.get_metrics(font_desc) |
1191 | - |
1192 | - ascent = pango.PIXELS(metrics.get_ascent()) |
1193 | - descent = pango.PIXELS(metrics.get_descent()) |
1194 | - |
1195 | + metrics = pango_ctx.get_metrics(font_desc, None) |
1196 | + ascent = PANGO_PIXELS(metrics.get_ascent()) |
1197 | + descent = PANGO_PIXELS(metrics.get_descent()) |
1198 | self._box_size = ascent + descent + 6 |
1199 | return self._box_size |
1200 | |
1201 | @@ -113,7 +126,15 @@ |
1202 | |
1203 | ctx.set_source_rgb(red, green, blue) |
1204 | |
1205 | - def on_get_size(self, widget, cell_area): |
1206 | + def do_activate(event, widget, path, bg_area, cell_area, flags): |
1207 | + """Renderers cannot be activated; always return True.""" |
1208 | + return True |
1209 | + |
1210 | + def do_editing_started(event, widget, path, fb_area, cell_area, flags): |
1211 | + """Renderers cannot be edited; always return None.""" |
1212 | + return None |
1213 | + |
1214 | + def do_get_size(self, widget, cell_area): |
1215 | """Return the size we need for this cell. |
1216 | |
1217 | Each cell is drawn individually and is only as wide as it needs |
1218 | @@ -128,7 +149,7 @@ |
1219 | # FIXME I have no idea how to use cell_area properly |
1220 | return (0, 0, width, height) |
1221 | |
1222 | - def on_render(self, window, widget, bg_area, cell_area, exp_area, flags): |
1223 | + def do_render(self, ctx, widget, bg_area, cell_area, flags): |
1224 | """Render an individual cell. |
1225 | |
1226 | Draws the cell contents using cairo, taking care to clip what we |
1227 | @@ -142,7 +163,6 @@ |
1228 | instead of a pure diagonal ... this reduces confusion by an |
1229 | incredible amount. |
1230 | """ |
1231 | - ctx = window.cairo_create() |
1232 | ctx.rectangle(bg_area.x, bg_area.y, bg_area.width, bg_area.height) |
1233 | ctx.clip() |
1234 | |
1235 | @@ -168,7 +188,7 @@ |
1236 | cell_area.y + cell_area.height / 2, |
1237 | box_size / 4, 0, 2 * math.pi) |
1238 | |
1239 | - if flags & gtk.CELL_RENDERER_SELECTED: |
1240 | + if flags & Gtk.CellRendererState.SELECTED: |
1241 | ctx.set_source_rgb(1.0, 1.0, 1.0) |
1242 | ctx.set_line_width(box_size / 4) |
1243 | ctx.stroke_preserve() |
1244 | @@ -182,9 +202,10 @@ |
1245 | |
1246 | self.render_tags(ctx, widget.create_pango_context(), cell_area, box_size) |
1247 | |
1248 | - def render_line(self, ctx, cell_area, box_size, mid, height, start, end, colour, flags): |
1249 | + def render_line(self, ctx, cell_area, box_size, |
1250 | + mid, height, start, end, colour, flags): |
1251 | if start is None: |
1252 | - ctx.set_line_cap(cairo.LINE_CAP_ROUND) |
1253 | + ctx.set_line_cap(CAIRO_LINE_CAP_ROUND) |
1254 | x = cell_area.x + box_size * end + box_size / 2 |
1255 | ctx.move_to(x, mid + height / 3) |
1256 | ctx.line_to(x, mid + height / 3) |
1257 | @@ -192,7 +213,7 @@ |
1258 | ctx.line_to(x, mid + height / 6) |
1259 | |
1260 | elif end is None: |
1261 | - ctx.set_line_cap(cairo.LINE_CAP_ROUND) |
1262 | + ctx.set_line_cap(CAIRO_LINE_CAP_ROUND) |
1263 | x = cell_area.x + box_size * start + box_size / 2 |
1264 | ctx.move_to(x, mid - height / 3) |
1265 | ctx.line_to(x, mid - height / 3) |
1266 | @@ -200,7 +221,7 @@ |
1267 | ctx.line_to(x, mid - height / 6) |
1268 | |
1269 | else: |
1270 | - ctx.set_line_cap(cairo.LINE_CAP_BUTT) |
1271 | + ctx.set_line_cap(CAIRO_LINE_CAP_BUTT) |
1272 | startx = cell_area.x + box_size * start + box_size / 2 |
1273 | endx = cell_area.x + box_size * end + box_size / 2 |
1274 | |
1275 | @@ -217,7 +238,7 @@ |
1276 | endx, mid + height / 5 , |
1277 | endx, mid + height / 2 + 1) |
1278 | |
1279 | - if flags & gtk.CELL_RENDERER_SELECTED: |
1280 | + if flags & Gtk.CellRendererState.SELECTED: |
1281 | ctx.set_source_rgb(1.0, 1.0, 1.0) |
1282 | ctx.set_line_width(box_size / 5) |
1283 | ctx.stroke_preserve() |
1284 | @@ -233,17 +254,17 @@ |
1285 | |
1286 | (column, colour) = self.node |
1287 | |
1288 | - font_desc = pango.FontDescription() |
1289 | - font_desc.set_size(pango.SCALE * 7) |
1290 | + font_desc = Pango.FontDescription() |
1291 | + font_desc.set_size(Pango.SCALE * 7) |
1292 | |
1293 | - tag_layout = pango.Layout(pango_ctx) |
1294 | + tag_layout = Pango.Layout(pango_ctx) |
1295 | tag_layout.set_font_description(font_desc) |
1296 | |
1297 | # The width of the tag label stack |
1298 | width = 0 |
1299 | |
1300 | for tag_idx, tag in enumerate(self.tags): |
1301 | - tag_layout.set_text(" " + tag + " ") |
1302 | + tag_layout.set_text(" " + tag + " ", -1) |
1303 | text_width, text_height = tag_layout.get_pixel_size() |
1304 | |
1305 | x0 = cell_area.x + \ |
1306 | @@ -272,12 +293,11 @@ |
1307 | self.set_colour(ctx, TAG_COLOUR_ID, 0.0, 0.5) |
1308 | ctx.stroke_preserve() |
1309 | |
1310 | - ctx.set_fill_rule (cairo.FILL_RULE_EVEN_ODD) |
1311 | + ctx.set_fill_rule (CAIRO_FILL_RULE_EVEN_ODD) |
1312 | self.set_colour(ctx, TAG_COLOUR_ID, 0.5, 1.0) |
1313 | ctx.fill() |
1314 | |
1315 | # Draw the tag text |
1316 | self.set_colour(ctx, 0, 0.0, 0.0) |
1317 | ctx.move_to(x0, y0) |
1318 | - ctx.show_layout(tag_layout) |
1319 | - |
1320 | + PangoCairo.show_layout(ctx, tag_layout) |
1321 | |
1322 | === modified file 'branchview/treemodel.py' |
1323 | --- branchview/treemodel.py 2011-03-14 20:12:19 +0000 |
1324 | +++ branchview/treemodel.py 2011-09-08 03:12:25 +0000 |
1325 | @@ -1,14 +1,12 @@ |
1326 | # -*- coding: UTF-8 -*- |
1327 | -"""Tree model. |
1328 | - |
1329 | -""" |
1330 | +"""BranchTreeModel.""" |
1331 | |
1332 | __copyright__ = "Copyright © 2005 Canonical Ltd." |
1333 | -__author__ = "Gary van der Merwe <garyvdm@gmail.com>" |
1334 | - |
1335 | - |
1336 | -import gtk |
1337 | -import gobject |
1338 | +__author__ = "Gary van der Merwe <garyvdm@gmail.com>" |
1339 | + |
1340 | + |
1341 | +from gi.repository import Gtk |
1342 | +from gi.repository import GObject |
1343 | from xml.sax.saxutils import escape |
1344 | |
1345 | from bzrlib.config import parse_username |
1346 | @@ -19,6 +17,7 @@ |
1347 | localtime, |
1348 | ) |
1349 | |
1350 | + |
1351 | REVID = 0 |
1352 | NODE = 1 |
1353 | LINES = 2 |
1354 | @@ -34,19 +33,34 @@ |
1355 | TAGS = 12 |
1356 | AUTHORS = 13 |
1357 | |
1358 | -class TreeModel(gtk.GenericTreeModel): |
1359 | - |
1360 | - def __init__ (self, branch, line_graph_data): |
1361 | - gtk.GenericTreeModel.__init__(self) |
1362 | + |
1363 | +class BranchTreeModel(Gtk.ListStore): |
1364 | + """A model of branch's merge history.""" |
1365 | + |
1366 | + def __init__(self, branch, line_graph_data): |
1367 | + super(BranchTreeModel, self).__init__( |
1368 | + GObject.TYPE_STRING, |
1369 | + GObject.TYPE_PYOBJECT, |
1370 | + GObject.TYPE_PYOBJECT, |
1371 | + GObject.TYPE_PYOBJECT, |
1372 | + GObject.TYPE_STRING, |
1373 | + GObject.TYPE_STRING, |
1374 | + GObject.TYPE_STRING, |
1375 | + GObject.TYPE_STRING, |
1376 | + GObject.TYPE_STRING, |
1377 | + GObject.TYPE_PYOBJECT, |
1378 | + GObject.TYPE_PYOBJECT, |
1379 | + GObject.TYPE_PYOBJECT, |
1380 | + GObject.TYPE_PYOBJECT, |
1381 | + GObject.TYPE_STRING) |
1382 | self.revisions = {} |
1383 | self.branch = branch |
1384 | self.repository = branch.repository |
1385 | - self.line_graph_data = line_graph_data |
1386 | - |
1387 | if self.branch.supports_tags(): |
1388 | self.tags = self.branch.tags.get_reverse_tag_dict() |
1389 | else: |
1390 | self.tags = {} |
1391 | + self.set_line_graph_data(line_graph_data) |
1392 | |
1393 | def add_tag(self, tag, revid): |
1394 | self.branch.tags.set_tag(tag, revid) |
1395 | @@ -55,93 +69,39 @@ |
1396 | except KeyError: |
1397 | self.tags[revid] = [tag] |
1398 | |
1399 | - def on_get_flags(self): |
1400 | - return gtk.TREE_MODEL_LIST_ONLY |
1401 | - |
1402 | - def on_get_n_columns(self): |
1403 | - return 14 |
1404 | - |
1405 | - def on_get_column_type(self, index): |
1406 | - if index == REVID: return gobject.TYPE_STRING |
1407 | - if index == NODE: return gobject.TYPE_PYOBJECT |
1408 | - if index == LINES: return gobject.TYPE_PYOBJECT |
1409 | - if index == LAST_LINES: return gobject.TYPE_PYOBJECT |
1410 | - if index == REVNO: return gobject.TYPE_STRING |
1411 | - if index == SUMMARY: return gobject.TYPE_STRING |
1412 | - if index == MESSAGE: return gobject.TYPE_STRING |
1413 | - if index == COMMITTER: return gobject.TYPE_STRING |
1414 | - if index == TIMESTAMP: return gobject.TYPE_STRING |
1415 | - if index == REVISION: return gobject.TYPE_PYOBJECT |
1416 | - if index == PARENTS: return gobject.TYPE_PYOBJECT |
1417 | - if index == CHILDREN: return gobject.TYPE_PYOBJECT |
1418 | - if index == TAGS: return gobject.TYPE_PYOBJECT |
1419 | - if index == AUTHORS: return gobject.TYPE_STRING |
1420 | - |
1421 | - def on_get_iter(self, path): |
1422 | - return path[0] |
1423 | - |
1424 | - def on_get_path(self, rowref): |
1425 | - return rowref |
1426 | - |
1427 | - def on_get_value(self, rowref, column): |
1428 | - if len(self.line_graph_data) > 0: |
1429 | - (revid, node, lines, parents, |
1430 | - children, revno_sequence) = self.line_graph_data[rowref] |
1431 | + def _line_graph_item_to_model_row(self, rowref, data): |
1432 | + revid, node, lines, parents, children, revno_sequence = data |
1433 | + if rowref > 0: |
1434 | + last_lines = self.line_graph_data[rowref - 1][2] |
1435 | else: |
1436 | - (revid, node, lines, parents, |
1437 | - children, revno_sequence) = (None, (0, 0), (), (), |
1438 | - (), ()) |
1439 | - if column == REVID: return revid |
1440 | - if column == NODE: return node |
1441 | - if column == LINES: return lines |
1442 | - if column == PARENTS: return parents |
1443 | - if column == CHILDREN: return children |
1444 | - if column == LAST_LINES: |
1445 | - if rowref>0: |
1446 | - return self.line_graph_data[rowref-1][2] |
1447 | - return [] |
1448 | - if column == REVNO: return ".".join(["%d" % (revno) |
1449 | - for revno in revno_sequence]) |
1450 | - |
1451 | - if column == TAGS: return self.tags.get(revid, []) |
1452 | - |
1453 | + last_lines = [] |
1454 | + revno = ".".join(["%d" % (revno) for revno in revno_sequence]) |
1455 | + tags = self.tags.get(revid, []) |
1456 | if not revid or revid == NULL_REVISION: |
1457 | - return None |
1458 | - if revid not in self.revisions: |
1459 | + revision = None |
1460 | + elif revid not in self.revisions: |
1461 | revision = self.repository.get_revisions([revid])[0] |
1462 | self.revisions[revid] = revision |
1463 | else: |
1464 | revision = self.revisions[revid] |
1465 | - |
1466 | - if column == REVISION: return revision |
1467 | - if column == SUMMARY: return escape(revision.get_summary()) |
1468 | - if column == MESSAGE: return escape(revision.message) |
1469 | - if column == COMMITTER: return parse_username(revision.committer)[0] |
1470 | - if column == TIMESTAMP: |
1471 | - return strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp)) |
1472 | - if column == AUTHORS: |
1473 | - return ", ".join([ |
1474 | - parse_username(author)[0] for author in revision.get_apparent_authors()]) |
1475 | - |
1476 | - def on_iter_next(self, rowref): |
1477 | - if rowref < len(self.line_graph_data) - 1: |
1478 | - return rowref+1 |
1479 | - return None |
1480 | - |
1481 | - def on_iter_children(self, parent): |
1482 | - if parent is None: return 0 |
1483 | - return None |
1484 | - |
1485 | - def on_iter_has_child(self, rowref): |
1486 | - return False |
1487 | - |
1488 | - def on_iter_n_children(self, rowref): |
1489 | - if rowref is None: return len(self.line_graph_data) |
1490 | - return 0 |
1491 | - |
1492 | - def on_iter_nth_child(self, parent, n): |
1493 | - if parent is None: return n |
1494 | - return None |
1495 | - |
1496 | - def on_iter_parent(self, child): |
1497 | - return None |
1498 | + if revision is None: |
1499 | + summary = message = committer = timestamp = authors = None |
1500 | + else: |
1501 | + summary = escape(revision.get_summary()) |
1502 | + message = escape(revision.message) |
1503 | + committer = parse_username(revision.committer)[0] |
1504 | + timestamp = strftime( |
1505 | + "%Y-%m-%d %H:%M", localtime(revision.timestamp)) |
1506 | + authors = ", ".join([ |
1507 | + parse_username(author)[0] |
1508 | + for author in revision.get_apparent_authors()]) |
1509 | + return (revid, node, lines, last_lines, revno, summary, message, |
1510 | + committer, timestamp, revision, parents, children, tags, |
1511 | + authors) |
1512 | + |
1513 | + def set_line_graph_data(self, line_graph_data): |
1514 | + self.clear() |
1515 | + self.line_graph_data = line_graph_data |
1516 | + for rowref, data in enumerate(self.line_graph_data): |
1517 | + row = self._line_graph_item_to_model_row(rowref, data) |
1518 | + self.append(row) |
1519 | |
1520 | === modified file 'branchview/treeview.py' |
1521 | --- branchview/treeview.py 2011-04-15 01:07:44 +0000 |
1522 | +++ branchview/treeview.py 2011-09-08 03:12:25 +0000 |
1523 | @@ -6,9 +6,9 @@ |
1524 | __copyright__ = "Copyright © 2005 Canonical Ltd." |
1525 | __author__ = "Daniel Schierbeck <daniel.schierbeck@gmail.com>" |
1526 | |
1527 | -import gtk |
1528 | -import gobject |
1529 | -import pango |
1530 | +from gi.repository import Gtk |
1531 | +from gi.repository import GObject |
1532 | +from gi.repository import Pango |
1533 | |
1534 | from bzrlib import ui |
1535 | from bzrlib.revision import NULL_REVISION |
1536 | @@ -20,78 +20,78 @@ |
1537 | from bzrlib.plugins.gtk.branchview.graphcell import CellRendererGraph |
1538 | |
1539 | |
1540 | -class TreeView(gtk.VBox): |
1541 | +class TreeView(Gtk.VBox): |
1542 | |
1543 | __gproperties__ = { |
1544 | - 'branch': (gobject.TYPE_PYOBJECT, |
1545 | + 'branch': (GObject.TYPE_PYOBJECT, |
1546 | 'Branch', |
1547 | 'The Bazaar branch being visualized', |
1548 | - gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE), |
1549 | + GObject.PARAM_CONSTRUCT_ONLY | GObject.PARAM_WRITABLE), |
1550 | |
1551 | - 'revision': (gobject.TYPE_PYOBJECT, |
1552 | + 'revision': (GObject.TYPE_PYOBJECT, |
1553 | 'Revision', |
1554 | 'The currently selected revision', |
1555 | - gobject.PARAM_READWRITE), |
1556 | + GObject.PARAM_READWRITE), |
1557 | |
1558 | - 'revision-number': (gobject.TYPE_STRING, |
1559 | + 'revision-number': (GObject.TYPE_STRING, |
1560 | 'Revision number', |
1561 | 'The number of the selected revision', |
1562 | '', |
1563 | - gobject.PARAM_READABLE), |
1564 | + GObject.PARAM_READABLE), |
1565 | |
1566 | - 'children': (gobject.TYPE_PYOBJECT, |
1567 | + 'children': (GObject.TYPE_PYOBJECT, |
1568 | 'Child revisions', |
1569 | 'Children of the currently selected revision', |
1570 | - gobject.PARAM_READABLE), |
1571 | + GObject.PARAM_READABLE), |
1572 | |
1573 | - 'parents': (gobject.TYPE_PYOBJECT, |
1574 | + 'parents': (GObject.TYPE_PYOBJECT, |
1575 | 'Parent revisions', |
1576 | 'Parents to the currently selected revision', |
1577 | - gobject.PARAM_READABLE), |
1578 | + GObject.PARAM_READABLE), |
1579 | |
1580 | - 'revno-column-visible': (gobject.TYPE_BOOLEAN, |
1581 | + 'revno-column-visible': (GObject.TYPE_BOOLEAN, |
1582 | 'Revision number column', |
1583 | 'Show revision number column', |
1584 | True, |
1585 | - gobject.PARAM_READWRITE), |
1586 | + GObject.PARAM_READWRITE), |
1587 | |
1588 | - 'graph-column-visible': (gobject.TYPE_BOOLEAN, |
1589 | + 'graph-column-visible': (GObject.TYPE_BOOLEAN, |
1590 | 'Graph column', |
1591 | 'Show graph column', |
1592 | True, |
1593 | - gobject.PARAM_READWRITE), |
1594 | + GObject.PARAM_READWRITE), |
1595 | |
1596 | - 'date-column-visible': (gobject.TYPE_BOOLEAN, |
1597 | + 'date-column-visible': (GObject.TYPE_BOOLEAN, |
1598 | 'Date', |
1599 | 'Show date column', |
1600 | False, |
1601 | - gobject.PARAM_READWRITE), |
1602 | + GObject.PARAM_READWRITE), |
1603 | |
1604 | - 'compact': (gobject.TYPE_BOOLEAN, |
1605 | + 'compact': (GObject.TYPE_BOOLEAN, |
1606 | 'Compact view', |
1607 | 'Break ancestry lines to save space', |
1608 | True, |
1609 | - gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE), |
1610 | + GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE), |
1611 | |
1612 | - 'mainline-only': (gobject.TYPE_BOOLEAN, |
1613 | + 'mainline-only': (GObject.TYPE_BOOLEAN, |
1614 | 'Mainline only', |
1615 | 'Only show the mainline history.', |
1616 | False, |
1617 | - gobject.PARAM_CONSTRUCT | gobject.PARAM_READWRITE), |
1618 | + GObject.PARAM_CONSTRUCT | GObject.PARAM_READWRITE), |
1619 | |
1620 | } |
1621 | |
1622 | __gsignals__ = { |
1623 | - 'revision-selected': (gobject.SIGNAL_RUN_FIRST, |
1624 | - gobject.TYPE_NONE, |
1625 | + 'revision-selected': (GObject.SignalFlags.RUN_FIRST, |
1626 | + None, |
1627 | ()), |
1628 | - 'revision-activated': (gobject.SIGNAL_RUN_FIRST, |
1629 | - gobject.TYPE_NONE, |
1630 | - (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)), |
1631 | - 'tag-added': (gobject.SIGNAL_RUN_FIRST, |
1632 | - gobject.TYPE_NONE, |
1633 | - (gobject.TYPE_STRING, gobject.TYPE_STRING)), |
1634 | - 'refreshed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, |
1635 | + 'revision-activated': (GObject.SignalFlags.RUN_FIRST, |
1636 | + None, |
1637 | + (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT)), |
1638 | + 'tag-added': (GObject.SignalFlags.RUN_FIRST, |
1639 | + None, |
1640 | + (GObject.TYPE_STRING, GObject.TYPE_STRING)), |
1641 | + 'refreshed': (GObject.SignalFlags.RUN_FIRST, None, |
1642 | ()) |
1643 | } |
1644 | |
1645 | @@ -105,20 +105,20 @@ |
1646 | :param broken_line_length: After how much lines to break |
1647 | branches. |
1648 | """ |
1649 | - gtk.VBox.__init__(self, spacing=0) |
1650 | + super(TreeView, self).__init__(homogeneous=False, spacing=0) |
1651 | |
1652 | self.progress_widget = ProgressPanel() |
1653 | - self.pack_start(self.progress_widget, expand=False, fill=True) |
1654 | + self.pack_start(self.progress_widget, False, True, 0) |
1655 | if getattr(ui.ui_factory, "set_progress_bar_widget", None) is not None: |
1656 | # We'are using our own ui, let's tell it to use our widget. |
1657 | ui.ui_factory.set_progress_bar_widget(self.progress_widget) |
1658 | |
1659 | - self.scrolled_window = gtk.ScrolledWindow() |
1660 | - self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, |
1661 | - gtk.POLICY_AUTOMATIC) |
1662 | - self.scrolled_window.set_shadow_type(gtk.SHADOW_IN) |
1663 | + self.scrolled_window = Gtk.ScrolledWindow() |
1664 | + self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, |
1665 | + Gtk.PolicyType.AUTOMATIC) |
1666 | + self.scrolled_window.set_shadow_type(Gtk.ShadowType.IN) |
1667 | self.scrolled_window.show() |
1668 | - self.pack_start(self.scrolled_window, expand=True, fill=True) |
1669 | + self.pack_start(self.scrolled_window, True, True, 0) |
1670 | |
1671 | self.scrolled_window.add(self.construct_treeview()) |
1672 | |
1673 | @@ -131,8 +131,8 @@ |
1674 | self.maxnum = maxnum |
1675 | self.compact = compact |
1676 | |
1677 | - self.model = treemodel.TreeModel(self.branch, []) |
1678 | - gobject.idle_add(self.populate) |
1679 | + self.model = treemodel.BranchTreeModel(self.branch, []) |
1680 | + GObject.idle_add(self.populate) |
1681 | |
1682 | self.connect("destroy", self._on_destroy) |
1683 | |
1684 | @@ -211,7 +211,8 @@ |
1685 | |
1686 | :param revid: Revision id of revision to display. |
1687 | """ |
1688 | - self.treeview.set_cursor(self.index[revid]) |
1689 | + self.treeview.set_cursor( |
1690 | + Gtk.TreePath(path=self.index[revid]), None, False) |
1691 | self.treeview.grab_focus() |
1692 | |
1693 | def get_children(self): |
1694 | @@ -243,7 +244,7 @@ |
1695 | self.emit('tag-added', tag, revid) |
1696 | |
1697 | def refresh(self): |
1698 | - gobject.idle_add(self.populate, self.get_revision()) |
1699 | + GObject.idle_add(self.populate, self.get_revision()) |
1700 | |
1701 | def update(self): |
1702 | try: |
1703 | @@ -259,7 +260,7 @@ |
1704 | def back(self): |
1705 | """Signal handler for the Back button.""" |
1706 | parents = self.get_parents() |
1707 | - if not len(parents): |
1708 | + if not parents: |
1709 | return |
1710 | |
1711 | for parent_id in parents: |
1712 | @@ -274,7 +275,7 @@ |
1713 | def forward(self): |
1714 | """Signal handler for the Forward button.""" |
1715 | children = self.get_children() |
1716 | - if not len(children): |
1717 | + if not children: |
1718 | return |
1719 | |
1720 | for child_id in children: |
1721 | @@ -311,26 +312,30 @@ |
1722 | show_graph = self.graph_column.get_visible() |
1723 | |
1724 | self.branch.lock_read() |
1725 | - (linegraphdata, index, columns_len) = linegraph(self.branch.repository.get_graph(), |
1726 | - self.start, |
1727 | - self.maxnum, |
1728 | - broken_line_length, |
1729 | - show_graph, |
1730 | - self.mainline_only, |
1731 | - self.progress_bar) |
1732 | + (linegraphdata, index, columns_len) = linegraph( |
1733 | + self.branch.repository.get_graph(), |
1734 | + self.start, |
1735 | + self.maxnum, |
1736 | + broken_line_length, |
1737 | + show_graph, |
1738 | + self.mainline_only, |
1739 | + self.progress_bar) |
1740 | |
1741 | - self.model.line_graph_data = linegraphdata |
1742 | + self.model.set_line_graph_data(linegraphdata) |
1743 | self.graph_cell.columns_len = columns_len |
1744 | - width = self.graph_cell.get_size(self.treeview)[2] |
1745 | + width = self.graph_cell.get_preferred_width(self.treeview)[1] |
1746 | if width > 500: |
1747 | width = 500 |
1748 | + elif width == 0: |
1749 | + # The get_preferred_width() call got an insane value. |
1750 | + width = 200 |
1751 | self.graph_column.set_fixed_width(width) |
1752 | self.graph_column.set_max_width(width) |
1753 | self.index = index |
1754 | self.treeview.set_model(self.model) |
1755 | |
1756 | if not revision or revision == NULL_REVISION: |
1757 | - self.treeview.set_cursor(0) |
1758 | + self.treeview.set_cursor(Gtk.TreePath(path=0), None, False) |
1759 | else: |
1760 | self.set_revision(revision) |
1761 | |
1762 | @@ -340,7 +345,7 @@ |
1763 | self.progress_bar.finished() |
1764 | |
1765 | def construct_treeview(self): |
1766 | - self.treeview = gtk.TreeView() |
1767 | + self.treeview = Gtk.TreeView() |
1768 | |
1769 | self.treeview.set_rules_hint(True) |
1770 | # combined revno/summary interactive search |
1771 | @@ -353,13 +358,11 @@ |
1772 | return (model.get_value(iter, treemodel.REVNO).find(key) != 0 |
1773 | and model.get_value(iter, treemodel.MESSAGE).lower().find(key.lower()) == -1) |
1774 | |
1775 | - self.treeview.set_search_equal_func(search_equal_func) |
1776 | + self.treeview.set_search_equal_func(search_equal_func, None) |
1777 | self.treeview.set_enable_search(True) |
1778 | |
1779 | - # Fix old PyGTK bug - by JAM |
1780 | - set_tooltip = getattr(self.treeview, 'set_tooltip_column', None) |
1781 | - if set_tooltip is not None: |
1782 | - set_tooltip(treemodel.MESSAGE) |
1783 | + self.treeview.set_tooltip_column(treemodel.MESSAGE) |
1784 | + self.treeview.set_headers_visible(True) |
1785 | |
1786 | self._prev_cursor_path = None |
1787 | self.treeview.connect("cursor-changed", |
1788 | @@ -375,60 +378,66 @@ |
1789 | |
1790 | self.treeview.show() |
1791 | |
1792 | - cell = gtk.CellRendererText() |
1793 | + cell = Gtk.CellRendererText() |
1794 | cell.set_property("width-chars", 15) |
1795 | - cell.set_property("ellipsize", pango.ELLIPSIZE_END) |
1796 | - self.revno_column = gtk.TreeViewColumn("Revision No") |
1797 | + cell.set_property("ellipsize", Pango.EllipsizeMode.END) |
1798 | + self.revno_column = Gtk.TreeViewColumn("Revision No") |
1799 | self.revno_column.set_resizable(True) |
1800 | - self.revno_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) |
1801 | - self.revno_column.set_fixed_width(cell.get_size(self.treeview)[2]) |
1802 | - self.revno_column.pack_start(cell, expand=True) |
1803 | + self.revno_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) |
1804 | + self.revno_column.set_fixed_width( |
1805 | + cell.get_preferred_width(self.treeview)[1]) |
1806 | + self.revno_column.pack_start(cell, True) |
1807 | self.revno_column.add_attribute(cell, "text", treemodel.REVNO) |
1808 | self.treeview.append_column(self.revno_column) |
1809 | |
1810 | self.graph_cell = CellRendererGraph() |
1811 | - self.graph_column = gtk.TreeViewColumn() |
1812 | + self.graph_column = Gtk.TreeViewColumn() |
1813 | self.graph_column.set_resizable(True) |
1814 | - self.graph_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) |
1815 | - self.graph_column.pack_start(self.graph_cell, expand=True) |
1816 | - self.graph_column.add_attribute(self.graph_cell, "node", treemodel.NODE) |
1817 | - self.graph_column.add_attribute(self.graph_cell, "tags", treemodel.TAGS) |
1818 | - self.graph_column.add_attribute(self.graph_cell, "in-lines", treemodel.LAST_LINES) |
1819 | - self.graph_column.add_attribute(self.graph_cell, "out-lines", treemodel.LINES) |
1820 | + self.graph_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) |
1821 | + self.graph_column.pack_start(self.graph_cell, True) |
1822 | + self.graph_column.add_attribute( |
1823 | + self.graph_cell, "node", treemodel.NODE) |
1824 | + self.graph_column.add_attribute( |
1825 | + self.graph_cell, "tags", treemodel.TAGS) |
1826 | + self.graph_column.add_attribute( |
1827 | + self.graph_cell, "in-lines", treemodel.LAST_LINES) |
1828 | + self.graph_column.add_attribute( |
1829 | + self.graph_cell, "out-lines", treemodel.LINES) |
1830 | self.treeview.append_column(self.graph_column) |
1831 | |
1832 | - cell = gtk.CellRendererText() |
1833 | + cell = Gtk.CellRendererText() |
1834 | cell.set_property("width-chars", 65) |
1835 | - cell.set_property("ellipsize", pango.ELLIPSIZE_END) |
1836 | - self.summary_column = gtk.TreeViewColumn("Summary") |
1837 | + cell.set_property("ellipsize", Pango.EllipsizeMode.END) |
1838 | + self.summary_column = Gtk.TreeViewColumn("Summary") |
1839 | self.summary_column.set_resizable(True) |
1840 | self.summary_column.set_expand(True) |
1841 | - self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) |
1842 | - self.summary_column.set_fixed_width(cell.get_size(self.treeview)[2]) |
1843 | - self.summary_column.pack_start(cell, expand=True) |
1844 | + self.summary_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) |
1845 | + self.summary_column.set_fixed_width( |
1846 | + cell.get_preferred_width(self.treeview)[1]) |
1847 | + self.summary_column.pack_start(cell, True) |
1848 | self.summary_column.add_attribute(cell, "markup", treemodel.SUMMARY) |
1849 | self.treeview.append_column(self.summary_column) |
1850 | |
1851 | - cell = gtk.CellRendererText() |
1852 | + cell = Gtk.CellRendererText() |
1853 | cell.set_property("width-chars", 15) |
1854 | - cell.set_property("ellipsize", pango.ELLIPSIZE_END) |
1855 | - self.authors_column = gtk.TreeViewColumn("Author(s)") |
1856 | + cell.set_property("ellipsize", Pango.EllipsizeMode.END) |
1857 | + self.authors_column = Gtk.TreeViewColumn("Author(s)") |
1858 | self.authors_column.set_resizable(False) |
1859 | - self.authors_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) |
1860 | + self.authors_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) |
1861 | self.authors_column.set_fixed_width(200) |
1862 | - self.authors_column.pack_start(cell, expand=True) |
1863 | + self.authors_column.pack_start(cell, True) |
1864 | self.authors_column.add_attribute(cell, "text", treemodel.AUTHORS) |
1865 | self.treeview.append_column(self.authors_column) |
1866 | |
1867 | - cell = gtk.CellRendererText() |
1868 | + cell = Gtk.CellRendererText() |
1869 | cell.set_property("width-chars", 20) |
1870 | - cell.set_property("ellipsize", pango.ELLIPSIZE_END) |
1871 | - self.date_column = gtk.TreeViewColumn("Date") |
1872 | + cell.set_property("ellipsize", Pango.EllipsizeMode.END) |
1873 | + self.date_column = Gtk.TreeViewColumn("Date") |
1874 | self.date_column.set_visible(False) |
1875 | self.date_column.set_resizable(True) |
1876 | - self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) |
1877 | + self.date_column.set_sizing(Gtk.TreeViewColumnSizing.FIXED) |
1878 | self.date_column.set_fixed_width(130) |
1879 | - self.date_column.pack_start(cell, expand=True) |
1880 | + self.date_column.pack_start(cell, True) |
1881 | self.date_column.add_attribute(cell, "text", treemodel.TIMESTAMP) |
1882 | self.treeview.append_column(self.date_column) |
1883 | |
1884 | |
1885 | === modified file 'bzr-handle-patch' |
1886 | --- bzr-handle-patch 2011-04-04 17:52:28 +0000 |
1887 | +++ bzr-handle-patch 2011-09-08 03:12:25 +0000 |
1888 | @@ -31,7 +31,7 @@ |
1889 | controller = MergeDirectiveController(path, directive) |
1890 | window = controller.window |
1891 | window.show() |
1892 | - gtk = open_display() |
1893 | + Gtk = open_display() |
1894 | window.connect("destroy", gtk.main_quit) |
1895 | except Exception, e: |
1896 | from bzrlib.plugins.gtk.dialog import error_dialog |
1897 | |
1898 | === modified file 'bzr-notify' |
1899 | --- bzr-notify 2011-04-02 12:42:35 +0000 |
1900 | +++ bzr-notify 2011-09-08 03:12:25 +0000 |
1901 | @@ -12,7 +12,7 @@ |
1902 | from bzrlib.plugins.gtk.commands import open_display |
1903 | |
1904 | from bzrlib.plugins.gtk.notify import NotifyPopupMenu |
1905 | -gtk = open_display() |
1906 | +Gtk = open_display() |
1907 | |
1908 | import cgi |
1909 | import dbus |
1910 | |
1911 | === modified file 'checkout.py' |
1912 | --- checkout.py 2011-04-10 18:44:39 +0000 |
1913 | +++ checkout.py 2011-09-08 03:12:25 +0000 |
1914 | @@ -16,13 +16,8 @@ |
1915 | |
1916 | import os |
1917 | |
1918 | -try: |
1919 | - import pygtk |
1920 | - pygtk.require("2.0") |
1921 | -except: |
1922 | - pass |
1923 | - |
1924 | -import gtk |
1925 | +from gi.repository import GObject |
1926 | +from gi.repository import Gtk |
1927 | |
1928 | from bzrlib.branch import Branch |
1929 | from bzrlib.config import GlobalConfig |
1930 | @@ -33,42 +28,41 @@ |
1931 | from bzrlib.plugins.gtk.i18n import _i18n |
1932 | |
1933 | |
1934 | -class CheckoutDialog(gtk.Dialog): |
1935 | +class CheckoutDialog(Gtk.Dialog): |
1936 | """ New implementation of the Checkout dialog. """ |
1937 | |
1938 | def __init__(self, path=None, parent=None, remote_path=None): |
1939 | """ Initialize the Checkout dialog. """ |
1940 | - gtk.Dialog.__init__(self, title="Checkout - Olive", |
1941 | - parent=parent, |
1942 | - flags=0, |
1943 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
1944 | + super(CheckoutDialog, self).__init__( |
1945 | + title="Checkout - Olive", parent=parent, flags=0, |
1946 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
1947 | |
1948 | # Get arguments |
1949 | self.path = path |
1950 | |
1951 | # Create the widgets |
1952 | - self._button_checkout = gtk.Button(_i18n("Check_out"), use_underline=True) |
1953 | - self._button_revision = gtk.Button('') |
1954 | - self._image_browse = gtk.Image() |
1955 | - self._filechooser = gtk.FileChooserButton(_i18n("Please select a folder")) |
1956 | - self._combo = gtk.ComboBoxEntry() |
1957 | - self._label_location = gtk.Label(_i18n("Branch location:")) |
1958 | - self._label_destination = gtk.Label(_i18n("Destination:")) |
1959 | - self._label_nick = gtk.Label(_i18n("Branch nick:")) |
1960 | - self._label_revision = gtk.Label(_i18n("Revision:")) |
1961 | - self._hbox_revision = gtk.HBox() |
1962 | - self._entry_revision = gtk.Entry() |
1963 | - self._entry_nick = gtk.Entry() |
1964 | - self._check_lightweight = gtk.CheckButton(_i18n("_Lightweight checkout"), |
1965 | + self._button_checkout = Gtk.Button(_i18n("Check_out"), use_underline=True) |
1966 | + self._button_revision = Gtk.Button('') |
1967 | + self._image_browse = Gtk.Image() |
1968 | + self._filechooser = Gtk.FileChooserButton(_i18n("Please select a folder")) |
1969 | + self._combo = Gtk.ComboBox.new_with_entry() |
1970 | + self._label_location = Gtk.Label(label=_i18n("Branch location:")) |
1971 | + self._label_destination = Gtk.Label(label=_i18n("Destination:")) |
1972 | + self._label_nick = Gtk.Label(label=_i18n("Branch nick:")) |
1973 | + self._label_revision = Gtk.Label(label=_i18n("Revision:")) |
1974 | + self._hbox_revision = Gtk.HBox() |
1975 | + self._entry_revision = Gtk.Entry() |
1976 | + self._entry_nick = Gtk.Entry() |
1977 | + self._check_lightweight = Gtk.CheckButton(_i18n("_Lightweight checkout"), |
1978 | use_underline=True) |
1979 | |
1980 | # Set callbacks |
1981 | self._button_checkout.connect('clicked', self._on_checkout_clicked) |
1982 | self._button_revision.connect('clicked', self._on_revision_clicked) |
1983 | - self._combo.child.connect('focus-out-event', self._on_combo_changed) |
1984 | + self._combo.get_child().connect('focus-out-event', self._on_combo_changed) |
1985 | |
1986 | # Create the table and pack the widgets into it |
1987 | - self._table = gtk.Table(rows=3, columns=2) |
1988 | + self._table = Gtk.Table(rows=3, columns=2) |
1989 | self._table.attach(self._label_location, 0, 1, 0, 1) |
1990 | self._table.attach(self._label_destination, 0, 1, 1, 2) |
1991 | self._table.attach(self._label_nick, 0, 1, 2, 3) |
1992 | @@ -80,30 +74,30 @@ |
1993 | self._table.attach(self._check_lightweight, 1, 2, 4, 5) |
1994 | |
1995 | # Set properties |
1996 | - self._image_browse.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON) |
1997 | + self._image_browse.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON) |
1998 | self._button_revision.set_image(self._image_browse) |
1999 | self._button_revision.set_sensitive(False) |
2000 | - self._filechooser.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) |
2001 | + self._filechooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER) |
2002 | self._label_location.set_alignment(0, 0.5) |
2003 | self._label_destination.set_alignment(0, 0.5) |
2004 | self._label_nick.set_alignment(0, 0.5) |
2005 | self._label_revision.set_alignment(0, 0.5) |
2006 | self._table.set_row_spacings(3) |
2007 | self._table.set_col_spacings(3) |
2008 | - self.vbox.set_spacing(3) |
2009 | + self.get_content_area().set_spacing(3) |
2010 | if self.path is not None: |
2011 | self._filechooser.set_filename(self.path) |
2012 | if remote_path is not None: |
2013 | - self._combo.child.set_text(remote_path) |
2014 | + self._combo.get_child().set_text(remote_path) |
2015 | |
2016 | # Pack some widgets |
2017 | - self._hbox_revision.pack_start(self._entry_revision, True, True) |
2018 | - self._hbox_revision.pack_start(self._button_revision, False, False) |
2019 | - self.vbox.add(self._table) |
2020 | - self.action_area.pack_end(self._button_checkout) |
2021 | + self._hbox_revision.pack_start(self._entry_revision, True, True, 0) |
2022 | + self._hbox_revision.pack_start(self._button_revision, False, False, 0) |
2023 | + self.get_content_area().add(self._table) |
2024 | + self.action_area.pack_end(self._button_checkout, False, False, 0) |
2025 | |
2026 | # Show the dialog |
2027 | - self.vbox.show_all() |
2028 | + self.get_content_area().show_all() |
2029 | |
2030 | # Build checkout history |
2031 | self._history = UrlHistory(GlobalConfig(), 'branch_history') |
2032 | @@ -111,13 +105,13 @@ |
2033 | |
2034 | def _build_history(self): |
2035 | """ Build up the checkout history. """ |
2036 | - self._combo_model = gtk.ListStore(str) |
2037 | + self._combo_model = Gtk.ListStore(str) |
2038 | |
2039 | for item in self._history.get_entries(): |
2040 | self._combo_model.append([ item ]) |
2041 | |
2042 | self._combo.set_model(self._combo_model) |
2043 | - self._combo.set_text_column(0) |
2044 | + self._combo.set_entry_text_column(0) |
2045 | |
2046 | def _get_last_revno(self): |
2047 | """ Get the revno of the last revision (if any). """ |
2048 | @@ -142,10 +136,10 @@ |
2049 | else: |
2050 | revb = RevisionBrowser(br, self) |
2051 | response = revb.run() |
2052 | - if response != gtk.RESPONSE_NONE: |
2053 | + if response != Gtk.ResponseType.NONE: |
2054 | revb.hide() |
2055 | |
2056 | - if response == gtk.RESPONSE_OK: |
2057 | + if response == Gtk.ResponseType.OK: |
2058 | if revb.selected_revno is not None: |
2059 | self._entry_revision.set_text(revb.selected_revno) |
2060 | |
2061 | @@ -182,7 +176,7 @@ |
2062 | |
2063 | self._history.add_entry(location) |
2064 | |
2065 | - self.response(gtk.RESPONSE_OK) |
2066 | + self.response(Gtk.ResponseType.OK) |
2067 | |
2068 | def _on_combo_changed(self, widget, event): |
2069 | """ We try to get the last revision if focus lost. """ |
2070 | |
2071 | === modified file 'commands.py' |
2072 | --- commands.py 2011-04-10 18:44:39 +0000 |
2073 | +++ commands.py 2011-09-08 03:12:25 +0000 |
2074 | @@ -32,7 +32,6 @@ |
2075 | from bzrlib.option import Option |
2076 | |
2077 | from bzrlib.plugins.gtk import ( |
2078 | - import_pygtk, |
2079 | set_ui_factory, |
2080 | ) |
2081 | from bzrlib.plugins.gtk.i18n import _i18n |
2082 | @@ -46,14 +45,13 @@ |
2083 | |
2084 | |
2085 | def open_display(): |
2086 | - pygtk = import_pygtk() |
2087 | try: |
2088 | - import gtk |
2089 | + from gi.repository import Gtk |
2090 | except RuntimeError, e: |
2091 | if str(e) == "could not open display": |
2092 | raise NoDisplayError |
2093 | set_ui_factory() |
2094 | - return gtk |
2095 | + return Gtk |
2096 | |
2097 | |
2098 | |
2099 | @@ -150,9 +148,9 @@ |
2100 | tree2 = tree1.basis_tree() |
2101 | |
2102 | from diff import DiffWindow |
2103 | - import gtk |
2104 | + from gi.repository import Gtk |
2105 | window = DiffWindow() |
2106 | - window.connect("destroy", gtk.main_quit) |
2107 | + window.connect("destroy", Gtk.main_quit) |
2108 | window.set_diff("Working Tree", tree1, tree2) |
2109 | if filename is not None: |
2110 | tree_filename = wt.relpath(filename) |
2111 | @@ -166,7 +164,7 @@ |
2112 | filename) |
2113 | window.show() |
2114 | |
2115 | - gtk.main() |
2116 | + Gtk.main() |
2117 | finally: |
2118 | wt.unlock() |
2119 | |
2120 | @@ -209,11 +207,11 @@ |
2121 | revids.append(br.last_revision()) |
2122 | else: |
2123 | revids.append(revision[0].as_revision_id(br)) |
2124 | - import gtk |
2125 | + from gi.repository import Gtk |
2126 | pp = start_viz_window(br, revids, limit) |
2127 | - pp.connect("destroy", lambda w: gtk.main_quit()) |
2128 | + pp.connect("destroy", lambda w: Gtk.main_quit()) |
2129 | pp.show() |
2130 | - gtk.main() |
2131 | + Gtk.main() |
2132 | |
2133 | |
2134 | class cmd_gannotate(GTKCommand): |
2135 | @@ -236,7 +234,7 @@ |
2136 | aliases = ["gblame", "gpraise"] |
2137 | |
2138 | def run(self, filename, all=False, plain=False, line='1', revision=None): |
2139 | - gtk = open_display() |
2140 | + Gtk = open_display() |
2141 | |
2142 | try: |
2143 | line = int(line) |
2144 | @@ -267,7 +265,7 @@ |
2145 | revision_id = getattr(tree, 'get_revision_id', lambda: None)() |
2146 | |
2147 | window = GAnnotateWindow(all, plain, branch=br) |
2148 | - window.connect("destroy", lambda w: gtk.main_quit()) |
2149 | + window.connect("destroy", lambda w: Gtk.main_quit()) |
2150 | config = GAnnotateConfig(window) |
2151 | window.show() |
2152 | br.lock_read() |
2153 | @@ -276,7 +274,7 @@ |
2154 | try: |
2155 | window.annotate(tree, br, file_id) |
2156 | window.jump_to_line(line) |
2157 | - gtk.main() |
2158 | + Gtk.main() |
2159 | finally: |
2160 | br.unlock() |
2161 | if wt is not None: |
2162 | @@ -331,7 +329,7 @@ |
2163 | takes_options = ['revision'] |
2164 | |
2165 | def run(self, path='.', revision=None): |
2166 | - gtk = open_display() |
2167 | + Gtk = open_display() |
2168 | from bzrlib.plugins.gtk.status import StatusWindow |
2169 | (wt, wt_path) = workingtree.WorkingTree.open_containing(path) |
2170 | |
2171 | @@ -346,9 +344,9 @@ |
2172 | revision_id = None |
2173 | |
2174 | status = StatusWindow(wt, wt_path, revision_id) |
2175 | - status.connect("destroy", gtk.main_quit) |
2176 | + status.connect("destroy", Gtk.main_quit) |
2177 | status.show() |
2178 | - gtk.main() |
2179 | + Gtk.main() |
2180 | |
2181 | |
2182 | class cmd_gsend(GTKCommand): |
2183 | @@ -357,11 +355,11 @@ |
2184 | """ |
2185 | def run(self): |
2186 | (br, path) = branch.Branch.open_containing(".") |
2187 | - gtk = open_display() |
2188 | + Gtk = open_display() |
2189 | from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog |
2190 | from StringIO import StringIO |
2191 | dialog = SendMergeDirectiveDialog(br) |
2192 | - if dialog.run() == gtk.RESPONSE_OK: |
2193 | + if dialog.run() == Gtk.ResponseType.OK: |
2194 | outf = StringIO() |
2195 | outf.writelines(dialog.get_merge_directive().to_lines()) |
2196 | mail_client = br.get_config().get_mail_client() |
2197 | @@ -424,9 +422,8 @@ |
2198 | """ |
2199 | takes_args = ["other_branch?"] |
2200 | def run(self, other_branch=None): |
2201 | - pygtk = import_pygtk() |
2202 | try: |
2203 | - import gtk |
2204 | + from gi.repository import Gtk |
2205 | except RuntimeError, e: |
2206 | if str(e) == "could not open display": |
2207 | raise NoDisplayError |
2208 | @@ -476,8 +473,8 @@ |
2209 | def run(self): |
2210 | br = branch.Branch.open_containing('.')[0] |
2211 | |
2212 | - gtk = open_display() |
2213 | + Gtk = open_display() |
2214 | from tags import TagsWindow |
2215 | window = TagsWindow(br) |
2216 | window.show() |
2217 | - gtk.main() |
2218 | + Gtk.main() |
2219 | |
2220 | === modified file 'commit.py' |
2221 | --- commit.py 2011-04-10 18:44:39 +0000 |
2222 | +++ commit.py 2011-09-08 03:12:25 +0000 |
2223 | @@ -16,15 +16,10 @@ |
2224 | |
2225 | import re |
2226 | |
2227 | -try: |
2228 | - import pygtk |
2229 | - pygtk.require("2.0") |
2230 | -except: |
2231 | - pass |
2232 | - |
2233 | -import gtk |
2234 | -import gobject |
2235 | -import pango |
2236 | +from gi.repository import Gdk |
2237 | +from gi.repository import Gtk |
2238 | +from gi.repository import GObject |
2239 | +from gi.repository import Pango |
2240 | |
2241 | from bzrlib import ( |
2242 | errors, |
2243 | @@ -109,16 +104,16 @@ |
2244 | return fixed_newline.decode('utf-8') |
2245 | |
2246 | |
2247 | -class CommitDialog(gtk.Dialog): |
2248 | +class CommitDialog(Gtk.Dialog): |
2249 | """Implementation of Commit.""" |
2250 | |
2251 | def __init__(self, wt, selected=None, parent=None): |
2252 | - gtk.Dialog.__init__(self, title="Commit to %s" % wt.basedir, |
2253 | - parent=parent, flags=0,) |
2254 | + super(CommitDialog, self).__init__( |
2255 | + title="Commit to %s" % wt.basedir, parent=parent, flags=0) |
2256 | self.connect('delete-event', self._on_delete_window) |
2257 | self._question_dialog = question_dialog |
2258 | |
2259 | - self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) |
2260 | + self.set_type_hint(Gdk.WindowTypeHint.NORMAL) |
2261 | |
2262 | self._wt = wt |
2263 | # TODO: Do something with this value, it is used by Olive |
2264 | @@ -127,7 +122,8 @@ |
2265 | self._enable_per_file_commits = True |
2266 | self._commit_all_changes = True |
2267 | self.committed_revision_id = None # Nothing has been committed yet |
2268 | - self._saved_commit_messages_manager = SavedCommitMessagesManager(self._wt, self._wt.branch) |
2269 | + self._saved_commit_messages_manager = SavedCommitMessagesManager( |
2270 | + self._wt, self._wt.branch) |
2271 | |
2272 | self.setup_params() |
2273 | self.construct() |
2274 | @@ -232,7 +228,7 @@ |
2275 | # This sets the cursor, which causes the expander to close, which |
2276 | # causes the _file_message_text_view to never get realized. So we have |
2277 | # to give it a little kick, or it warns when we try to grab the focus |
2278 | - self._treeview_files.set_cursor(initial_cursor) |
2279 | + self._treeview_files.set_cursor(initial_cursor, None, False) |
2280 | |
2281 | def _realize_file_message_tree_view(*args): |
2282 | self._file_message_text_view.realize() |
2283 | @@ -286,13 +282,13 @@ |
2284 | """Build up the dialog widgets.""" |
2285 | # The primary pane which splits it into left and right (adjustable) |
2286 | # sections. |
2287 | - self._hpane = gtk.HPaned() |
2288 | + self._hpane = Gtk.HPaned() |
2289 | |
2290 | self._construct_left_pane() |
2291 | self._construct_right_pane() |
2292 | self._construct_action_pane() |
2293 | |
2294 | - self.vbox.pack_start(self._hpane) |
2295 | + self.get_content_area().pack_start(self._hpane, True, True, 0) |
2296 | self._hpane.show() |
2297 | self.set_focus(self._global_message_text_view) |
2298 | |
2299 | @@ -317,22 +313,22 @@ |
2300 | self._hpane.set_position(300) |
2301 | |
2302 | def _construct_accelerators(self): |
2303 | - group = gtk.AccelGroup() |
2304 | - group.connect_group(gtk.gdk.keyval_from_name('N'), |
2305 | - gtk.gdk.CONTROL_MASK, 0, self._on_accel_next) |
2306 | + group = Gtk.AccelGroup() |
2307 | + group.connect(Gdk.keyval_from_name('N'), |
2308 | + Gdk.ModifierType.CONTROL_MASK, 0, self._on_accel_next) |
2309 | self.add_accel_group(group) |
2310 | |
2311 | # ignore the escape key (avoid closing the window) |
2312 | self.connect_object('close', self.emit_stop_by_name, 'close') |
2313 | |
2314 | def _construct_left_pane(self): |
2315 | - self._left_pane_box = gtk.VBox(homogeneous=False, spacing=5) |
2316 | + self._left_pane_box = Gtk.VBox(homogeneous=False, spacing=5) |
2317 | self._construct_file_list() |
2318 | self._construct_pending_list() |
2319 | |
2320 | - self._check_local = gtk.CheckButton(_i18n("_Only commit locally"), |
2321 | + self._check_local = Gtk.CheckButton(_i18n("_Only commit locally"), |
2322 | use_underline=True) |
2323 | - self._left_pane_box.pack_end(self._check_local, False, False) |
2324 | + self._left_pane_box.pack_end(self._check_local, False, False, 0) |
2325 | self._check_local.set_active(False) |
2326 | |
2327 | self._hpane.pack1(self._left_pane_box, resize=False, shrink=False) |
2328 | @@ -345,7 +341,7 @@ |
2329 | # commit, and 1 for file commit, and it looked good. But I don't seem |
2330 | # to have a way to do that with the gtk boxes... :( (Which is extra |
2331 | # weird since wx uses gtk on Linux...) |
2332 | - self._right_pane_table = gtk.Table(rows=10, columns=1, homogeneous=False) |
2333 | + self._right_pane_table = Gtk.Table(rows=10, columns=1, homogeneous=False) |
2334 | self._right_pane_table.set_row_spacings(5) |
2335 | self._right_pane_table.set_col_spacings(5) |
2336 | self._right_pane_table_row = 0 |
2337 | @@ -357,15 +353,17 @@ |
2338 | self._hpane.pack2(self._right_pane_table, resize=True, shrink=True) |
2339 | |
2340 | def _construct_action_pane(self): |
2341 | - self._button_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) |
2342 | + self._button_cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL) |
2343 | self._button_cancel.connect('clicked', self._on_cancel_clicked) |
2344 | self._button_cancel.show() |
2345 | - self.action_area.pack_end(self._button_cancel) |
2346 | - self._button_commit = gtk.Button(_i18n("Comm_it"), use_underline=True) |
2347 | + self.get_action_area().pack_end( |
2348 | + self._button_cancel, True, True, 0) |
2349 | + self._button_commit = Gtk.Button(_i18n("Comm_it"), use_underline=True) |
2350 | self._button_commit.connect('clicked', self._on_commit_clicked) |
2351 | - self._button_commit.set_flags(gtk.CAN_DEFAULT) |
2352 | + self._button_commit.set_can_default(True) |
2353 | self._button_commit.show() |
2354 | - self.action_area.pack_end(self._button_commit) |
2355 | + self.get_action_area().pack_end( |
2356 | + self._button_commit, True, True, 0) |
2357 | self._button_commit.grab_default() |
2358 | |
2359 | def _add_to_right_table(self, widget, weight, expanding=False): |
2360 | @@ -377,7 +375,7 @@ |
2361 | """ |
2362 | end_row = self._right_pane_table_row + weight |
2363 | options = 0 |
2364 | - expand_opts = gtk.EXPAND | gtk.FILL | gtk.SHRINK |
2365 | + expand_opts = Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL | Gtk.AttachOptions.SHRINK |
2366 | if expanding: |
2367 | options = expand_opts |
2368 | self._right_pane_table.attach(widget, 0, 1, |
2369 | @@ -386,20 +384,20 @@ |
2370 | self._right_pane_table_row = end_row |
2371 | |
2372 | def _construct_file_list(self): |
2373 | - self._files_box = gtk.VBox(homogeneous=False, spacing=0) |
2374 | - file_label = gtk.Label(_i18n('Files')) |
2375 | + self._files_box = Gtk.VBox(homogeneous=False, spacing=0) |
2376 | + file_label = Gtk.Label(label=_i18n('Files')) |
2377 | # file_label.show() |
2378 | - self._files_box.pack_start(file_label, expand=False) |
2379 | + self._files_box.pack_start(file_label, False, True, 0) |
2380 | |
2381 | - self._commit_all_files_radio = gtk.RadioButton( |
2382 | + self._commit_all_files_radio = Gtk.RadioButton.new_with_label( |
2383 | None, _i18n("Commit all changes")) |
2384 | - self._files_box.pack_start(self._commit_all_files_radio, expand=False) |
2385 | + self._files_box.pack_start(self._commit_all_files_radio, False, True, 0) |
2386 | self._commit_all_files_radio.show() |
2387 | self._commit_all_files_radio.connect('toggled', |
2388 | self._toggle_commit_selection) |
2389 | - self._commit_selected_radio = gtk.RadioButton( |
2390 | + self._commit_selected_radio = Gtk.RadioButton.new_with_label_from_widget( |
2391 | self._commit_all_files_radio, _i18n("Only commit selected changes")) |
2392 | - self._files_box.pack_start(self._commit_selected_radio, expand=False) |
2393 | + self._files_box.pack_start(self._commit_selected_radio, False, True, 0) |
2394 | self._commit_selected_radio.show() |
2395 | self._commit_selected_radio.connect('toggled', |
2396 | self._toggle_commit_selection) |
2397 | @@ -408,45 +406,44 @@ |
2398 | self._commit_all_files_radio.set_sensitive(False) |
2399 | self._commit_selected_radio.set_sensitive(False) |
2400 | |
2401 | - scroller = gtk.ScrolledWindow() |
2402 | - scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
2403 | - self._treeview_files = gtk.TreeView() |
2404 | + scroller = Gtk.ScrolledWindow() |
2405 | + scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
2406 | + self._treeview_files = Gtk.TreeView() |
2407 | self._treeview_files.show() |
2408 | scroller.add(self._treeview_files) |
2409 | - scroller.set_shadow_type(gtk.SHADOW_IN) |
2410 | + scroller.set_shadow_type(Gtk.ShadowType.IN) |
2411 | scroller.show() |
2412 | - self._files_box.pack_start(scroller, |
2413 | - expand=True, fill=True) |
2414 | + self._files_box.pack_start(scroller, True, True, 0) |
2415 | self._files_box.show() |
2416 | - self._left_pane_box.pack_start(self._files_box) |
2417 | + self._left_pane_box.pack_start(self._files_box, True, True, 0) |
2418 | |
2419 | # Keep note that all strings stored in a ListStore must be UTF-8 |
2420 | # strings. GTK does not support directly setting and restoring Unicode |
2421 | # objects. |
2422 | - liststore = gtk.ListStore( |
2423 | - gobject.TYPE_STRING, # [0] file_id |
2424 | - gobject.TYPE_STRING, # [1] real path |
2425 | - gobject.TYPE_BOOLEAN, # [2] checkbox |
2426 | - gobject.TYPE_STRING, # [3] display path |
2427 | - gobject.TYPE_STRING, # [4] changes type |
2428 | - gobject.TYPE_STRING, # [5] commit message |
2429 | + liststore = Gtk.ListStore( |
2430 | + GObject.TYPE_STRING, # [0] file_id |
2431 | + GObject.TYPE_STRING, # [1] real path |
2432 | + GObject.TYPE_BOOLEAN, # [2] checkbox |
2433 | + GObject.TYPE_STRING, # [3] display path |
2434 | + GObject.TYPE_STRING, # [4] changes type |
2435 | + GObject.TYPE_STRING, # [5] commit message |
2436 | ) |
2437 | self._files_store = liststore |
2438 | self._treeview_files.set_model(liststore) |
2439 | - crt = gtk.CellRendererToggle() |
2440 | + crt = Gtk.CellRendererToggle() |
2441 | crt.set_property('activatable', not bool(self._pending)) |
2442 | crt.connect("toggled", self._toggle_commit, self._files_store) |
2443 | if self._pending: |
2444 | name = _i18n('Commit*') |
2445 | else: |
2446 | name = _i18n('Commit') |
2447 | - commit_col = gtk.TreeViewColumn(name, crt, active=2) |
2448 | + commit_col = Gtk.TreeViewColumn(name, crt, active=2) |
2449 | commit_col.set_visible(False) |
2450 | self._treeview_files.append_column(commit_col) |
2451 | - self._treeview_files.append_column(gtk.TreeViewColumn(_i18n('Path'), |
2452 | - gtk.CellRendererText(), text=3)) |
2453 | - self._treeview_files.append_column(gtk.TreeViewColumn(_i18n('Type'), |
2454 | - gtk.CellRendererText(), text=4)) |
2455 | + self._treeview_files.append_column(Gtk.TreeViewColumn(_i18n('Path'), |
2456 | + Gtk.CellRendererText(), text=3)) |
2457 | + self._treeview_files.append_column(Gtk.TreeViewColumn(_i18n('Type'), |
2458 | + Gtk.CellRendererText(), text=4)) |
2459 | self._treeview_files.connect('cursor-changed', |
2460 | self._on_treeview_files_cursor_changed) |
2461 | |
2462 | @@ -467,49 +464,48 @@ |
2463 | checked_col.set_visible(False) |
2464 | else: |
2465 | checked_col.set_visible(True) |
2466 | - renderer = checked_col.get_cell_renderers()[0] |
2467 | + renderer = checked_col.get_cells()[0] |
2468 | renderer.set_property('activatable', not all_files) |
2469 | |
2470 | def _construct_pending_list(self): |
2471 | # Pending information defaults to hidden, we put it all in 1 box, so |
2472 | # that we can show/hide all of them at once |
2473 | - self._pending_box = gtk.VBox() |
2474 | + self._pending_box = Gtk.VBox() |
2475 | self._pending_box.hide() |
2476 | |
2477 | - pending_message = gtk.Label() |
2478 | + pending_message = Gtk.Label() |
2479 | pending_message.set_markup( |
2480 | _i18n('<i>* Cannot select specific files when merging</i>')) |
2481 | - self._pending_box.pack_start(pending_message, expand=False, padding=5) |
2482 | + self._pending_box.pack_start(pending_message, False, True, 5) |
2483 | pending_message.show() |
2484 | |
2485 | - pending_label = gtk.Label(_i18n('Pending Revisions')) |
2486 | - self._pending_box.pack_start(pending_label, expand=False, padding=0) |
2487 | + pending_label = Gtk.Label(label=_i18n('Pending Revisions')) |
2488 | + self._pending_box.pack_start(pending_label, False, True, 0) |
2489 | pending_label.show() |
2490 | |
2491 | - scroller = gtk.ScrolledWindow() |
2492 | - scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
2493 | - self._treeview_pending = gtk.TreeView() |
2494 | + scroller = Gtk.ScrolledWindow() |
2495 | + scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
2496 | + self._treeview_pending = Gtk.TreeView() |
2497 | scroller.add(self._treeview_pending) |
2498 | - scroller.set_shadow_type(gtk.SHADOW_IN) |
2499 | + scroller.set_shadow_type(Gtk.ShadowType.IN) |
2500 | scroller.show() |
2501 | - self._pending_box.pack_start(scroller, |
2502 | - expand=True, fill=True, padding=5) |
2503 | + self._pending_box.pack_start(scroller, True, True, 5) |
2504 | self._treeview_pending.show() |
2505 | - self._left_pane_box.pack_start(self._pending_box) |
2506 | + self._left_pane_box.pack_start(self._pending_box, True, True, 0) |
2507 | |
2508 | - liststore = gtk.ListStore(gobject.TYPE_STRING, # revision_id |
2509 | - gobject.TYPE_STRING, # date |
2510 | - gobject.TYPE_STRING, # committer |
2511 | - gobject.TYPE_STRING, # summary |
2512 | + liststore = Gtk.ListStore(GObject.TYPE_STRING, # revision_id |
2513 | + GObject.TYPE_STRING, # date |
2514 | + GObject.TYPE_STRING, # committer |
2515 | + GObject.TYPE_STRING, # summary |
2516 | ) |
2517 | self._pending_store = liststore |
2518 | self._treeview_pending.set_model(liststore) |
2519 | - self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Date'), |
2520 | - gtk.CellRendererText(), text=1)) |
2521 | - self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Committer'), |
2522 | - gtk.CellRendererText(), text=2)) |
2523 | - self._treeview_pending.append_column(gtk.TreeViewColumn(_i18n('Summary'), |
2524 | - gtk.CellRendererText(), text=3)) |
2525 | + self._treeview_pending.append_column(Gtk.TreeViewColumn(_i18n('Date'), |
2526 | + Gtk.CellRendererText(), text=1)) |
2527 | + self._treeview_pending.append_column(Gtk.TreeViewColumn(_i18n('Committer'), |
2528 | + Gtk.CellRendererText(), text=2)) |
2529 | + self._treeview_pending.append_column(Gtk.TreeViewColumn(_i18n('Summary'), |
2530 | + Gtk.CellRendererText(), text=3)) |
2531 | |
2532 | def _construct_diff_view(self): |
2533 | from bzrlib.plugins.gtk.diff import DiffView |
2534 | @@ -518,7 +514,7 @@ |
2535 | # decide that we really don't ever want to display it, we should |
2536 | # actually remove it, and other references to it, along with the |
2537 | # tests that it is set properly. |
2538 | - self._diff_label = gtk.Label(_i18n('Diff for whole tree')) |
2539 | + self._diff_label = Gtk.Label(label=_i18n('Diff for whole tree')) |
2540 | self._diff_label.set_alignment(0, 0) |
2541 | self._right_pane_table.set_row_spacing(self._right_pane_table_row, 0) |
2542 | self._add_to_right_table(self._diff_label, 1, False) |
2543 | @@ -529,27 +525,28 @@ |
2544 | self._diff_view.show() |
2545 | |
2546 | def _construct_file_message(self): |
2547 | - scroller = gtk.ScrolledWindow() |
2548 | - scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
2549 | + scroller = Gtk.ScrolledWindow() |
2550 | + scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
2551 | |
2552 | - self._file_message_text_view = gtk.TextView() |
2553 | + self._file_message_text_view = Gtk.TextView() |
2554 | scroller.add(self._file_message_text_view) |
2555 | - scroller.set_shadow_type(gtk.SHADOW_IN) |
2556 | + scroller.set_shadow_type(Gtk.ShadowType.IN) |
2557 | scroller.show() |
2558 | |
2559 | - self._file_message_text_view.modify_font(pango.FontDescription("Monospace")) |
2560 | - self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD) |
2561 | + self._file_message_text_view.modify_font(Pango.FontDescription("Monospace")) |
2562 | + self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD) |
2563 | self._file_message_text_view.set_accepts_tab(False) |
2564 | self._file_message_text_view.show() |
2565 | |
2566 | - self._file_message_expander = gtk.Expander(_i18n('File commit message')) |
2567 | + self._file_message_expander = Gtk.Expander( |
2568 | + label=_i18n('File commit message')) |
2569 | self._file_message_expander.set_expanded(True) |
2570 | self._file_message_expander.add(scroller) |
2571 | self._add_to_right_table(self._file_message_expander, 1, False) |
2572 | self._file_message_expander.show() |
2573 | |
2574 | def _construct_global_message(self): |
2575 | - self._global_message_label = gtk.Label(_i18n('Global Commit Message')) |
2576 | + self._global_message_label = Gtk.Label(label=_i18n('Global Commit Message')) |
2577 | self._global_message_label.set_markup( |
2578 | _i18n('<b>Global Commit Message</b>')) |
2579 | self._global_message_label.set_alignment(0, 0) |
2580 | @@ -558,17 +555,17 @@ |
2581 | # Can we remove the spacing between the label and the box? |
2582 | self._global_message_label.show() |
2583 | |
2584 | - scroller = gtk.ScrolledWindow() |
2585 | - scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
2586 | + scroller = Gtk.ScrolledWindow() |
2587 | + scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
2588 | |
2589 | - self._global_message_text_view = gtk.TextView() |
2590 | + self._global_message_text_view = Gtk.TextView() |
2591 | self._set_global_commit_message(self._saved_commit_messages_manager.get()[0]) |
2592 | - self._global_message_text_view.modify_font(pango.FontDescription("Monospace")) |
2593 | + self._global_message_text_view.modify_font(Pango.FontDescription("Monospace")) |
2594 | scroller.add(self._global_message_text_view) |
2595 | - scroller.set_shadow_type(gtk.SHADOW_IN) |
2596 | + scroller.set_shadow_type(Gtk.ShadowType.IN) |
2597 | scroller.show() |
2598 | self._add_to_right_table(scroller, 2, True) |
2599 | - self._file_message_text_view.set_wrap_mode(gtk.WRAP_WORD) |
2600 | + self._file_message_text_view.set_wrap_mode(Gtk.WrapMode.WORD) |
2601 | self._file_message_text_view.set_accepts_tab(False) |
2602 | self._global_message_text_view.show() |
2603 | |
2604 | @@ -599,12 +596,13 @@ |
2605 | # We have either made it to the end of the list, or nothing was |
2606 | # selected. Either way, select All Files, and jump to the global |
2607 | # commit message. |
2608 | - self._treeview_files.set_cursor((0,)) |
2609 | + self._treeview_files.set_cursor( |
2610 | + Gtk.TreePath(path=0), None, False) |
2611 | self._global_message_text_view.grab_focus() |
2612 | else: |
2613 | # Set the cursor to this entry, and jump to the per-file commit |
2614 | # message |
2615 | - self._treeview_files.set_cursor(model.get_path(next)) |
2616 | + self._treeview_files.set_cursor(model.get_path(next), None, False) |
2617 | self._file_message_text_view.grab_focus() |
2618 | |
2619 | def _save_current_file_message(self): |
2620 | @@ -612,7 +610,7 @@ |
2621 | return # Nothing to save |
2622 | text_buffer = self._file_message_text_view.get_buffer() |
2623 | cur_text = text_buffer.get_text(text_buffer.get_start_iter(), |
2624 | - text_buffer.get_end_iter()) |
2625 | + text_buffer.get_end_iter(), True) |
2626 | last_selected = self._files_store.get_iter(self._last_selected_file) |
2627 | self._files_store.set_value(last_selected, 5, cur_text) |
2628 | |
2629 | @@ -689,11 +687,11 @@ |
2630 | _i18n('Commit cancelled'), |
2631 | _i18n('Do you want to save your commit messages ?'), |
2632 | parent=self) |
2633 | - if response == gtk.RESPONSE_NO: |
2634 | + if response == Gtk.ResponseType.NO: |
2635 | # save nothing and destroy old comments if any |
2636 | mgr = SavedCommitMessagesManager() |
2637 | mgr.save(self._wt, self._wt.branch) |
2638 | - self.response(gtk.RESPONSE_CANCEL) # close window |
2639 | + self.response(Gtk.ResponseType.CANCEL) # close window |
2640 | |
2641 | @show_bzr_error |
2642 | def _on_commit_clicked(self, button): |
2643 | @@ -708,7 +706,7 @@ |
2644 | _i18n('Commit with an empty message?'), |
2645 | _i18n('You can describe your commit intent in the message.'), |
2646 | parent=self) |
2647 | - if response == gtk.RESPONSE_NO: |
2648 | + if response == Gtk.ResponseType.NO: |
2649 | # Kindly give focus to message area |
2650 | self._global_message_text_view.grab_focus() |
2651 | return |
2652 | @@ -730,7 +728,7 @@ |
2653 | _i18n("Unknown files exist in the working tree. Commit anyway?"), |
2654 | parent=self) |
2655 | # Doesn't set a parent for the dialog.. |
2656 | - if response == gtk.RESPONSE_NO: |
2657 | + if response == Gtk.ResponseType.NO: |
2658 | return |
2659 | break |
2660 | |
2661 | @@ -751,7 +749,7 @@ |
2662 | _i18n('There are no changes in the working tree.' |
2663 | ' Do you want to commit anyway?'), |
2664 | parent=self) |
2665 | - if response == gtk.RESPONSE_YES: |
2666 | + if response == Gtk.ResponseType.YES: |
2667 | rev_id = self._wt.commit(message, |
2668 | allow_pointless=True, |
2669 | strict=False, |
2670 | @@ -761,12 +759,12 @@ |
2671 | self.committed_revision_id = rev_id |
2672 | # destroy old comments if any |
2673 | SavedCommitMessagesManager().save(self._wt, self._wt.branch) |
2674 | - self.response(gtk.RESPONSE_OK) |
2675 | + self.response(Gtk.ResponseType.OK) |
2676 | |
2677 | def _get_global_commit_message(self): |
2678 | buf = self._global_message_text_view.get_buffer() |
2679 | start, end = buf.get_bounds() |
2680 | - text = buf.get_text(start, end) |
2681 | + text = buf.get_text(start, end, True) |
2682 | return _sanitize_and_decode_message(text) |
2683 | |
2684 | def _set_global_commit_message(self, message): |
2685 | |
2686 | === modified file 'conflicts.py' |
2687 | --- conflicts.py 2011-03-14 20:12:19 +0000 |
2688 | +++ conflicts.py 2011-09-08 03:12:25 +0000 |
2689 | @@ -14,73 +14,67 @@ |
2690 | # along with this program; if not, write to the Free Software |
2691 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2692 | |
2693 | -try: |
2694 | - import pygtk |
2695 | - pygtk.require("2.0") |
2696 | -except: |
2697 | - pass |
2698 | - |
2699 | import subprocess |
2700 | |
2701 | -import gtk |
2702 | -import gobject |
2703 | +from gi.repository import Gtk |
2704 | +from gi.repository import GObject |
2705 | |
2706 | from bzrlib.config import GlobalConfig |
2707 | -from bzrlib.plugins.gtk import _i18n |
2708 | +from bzrlib.plugins.gtk.i18n import _i18n |
2709 | from bzrlib.plugins.gtk.dialog import ( |
2710 | error_dialog, |
2711 | warning_dialog, |
2712 | ) |
2713 | |
2714 | |
2715 | -class ConflictsDialog(gtk.Dialog): |
2716 | +class ConflictsDialog(Gtk.Dialog): |
2717 | """ This dialog displays the list of conflicts. """ |
2718 | |
2719 | def __init__(self, wt, parent=None): |
2720 | """ Initialize the Conflicts dialog. """ |
2721 | - gtk.Dialog.__init__(self, title="Conflicts - Olive", |
2722 | - parent=parent, |
2723 | - flags=0, |
2724 | - buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL)) |
2725 | + super(ConflictsDialog, self).__init__( |
2726 | + title="Conflicts - Olive", parent=parent, flags=0, |
2727 | + buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CANCEL)) |
2728 | |
2729 | # Get arguments |
2730 | self.wt = wt |
2731 | |
2732 | # Create the widgets |
2733 | - self._scrolledwindow = gtk.ScrolledWindow() |
2734 | - self._treeview = gtk.TreeView() |
2735 | - self._label_diff3 = gtk.Label(_i18n("External utility:")) |
2736 | - self._entry_diff3 = gtk.Entry() |
2737 | - self._image_diff3 = gtk.Image() |
2738 | - self._button_diff3 = gtk.Button() |
2739 | - self._hbox_diff3 = gtk.HBox() |
2740 | + self._scrolledwindow = Gtk.ScrolledWindow() |
2741 | + self._treeview = Gtk.TreeView() |
2742 | + self._label_diff3 = Gtk.Label(label=_i18n("External utility:")) |
2743 | + self._entry_diff3 = Gtk.Entry() |
2744 | + self._image_diff3 = Gtk.Image() |
2745 | + self._button_diff3 = Gtk.Button() |
2746 | + self._hbox_diff3 = Gtk.HBox() |
2747 | |
2748 | # Set callbacks |
2749 | self._button_diff3.connect('clicked', self._on_diff3_clicked) |
2750 | |
2751 | # Set properties |
2752 | - self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, |
2753 | - gtk.POLICY_AUTOMATIC) |
2754 | - self._image_diff3.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON) |
2755 | + self._scrolledwindow.set_policy(Gtk.PolicyType.AUTOMATIC, |
2756 | + Gtk.PolicyType.AUTOMATIC) |
2757 | + self._image_diff3.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON) |
2758 | self._button_diff3.set_image(self._image_diff3) |
2759 | self._entry_diff3.set_text(self._get_diff3()) |
2760 | self._hbox_diff3.set_spacing(3) |
2761 | - self.vbox.set_spacing(3) |
2762 | + content_area = self.get_content_area() |
2763 | + content_area.set_spacing(3) |
2764 | self.set_default_size(400, 300) |
2765 | |
2766 | # Construct dialog |
2767 | - self._hbox_diff3.pack_start(self._label_diff3, False, False) |
2768 | - self._hbox_diff3.pack_start(self._entry_diff3, True, True) |
2769 | - self._hbox_diff3.pack_start(self._button_diff3, False, False) |
2770 | + self._hbox_diff3.pack_start(self._label_diff3, False, False, 0) |
2771 | + self._hbox_diff3.pack_start(self._entry_diff3, True, True, 0) |
2772 | + self._hbox_diff3.pack_start(self._button_diff3, False, False, 0) |
2773 | self._scrolledwindow.add(self._treeview) |
2774 | - self.vbox.pack_start(self._scrolledwindow, True, True) |
2775 | - self.vbox.pack_start(self._hbox_diff3, False, False) |
2776 | + content_area.pack_start(self._scrolledwindow, True, True, 0) |
2777 | + content_area.pack_start(self._hbox_diff3, False, False, 0) |
2778 | |
2779 | # Create the conflict list |
2780 | self._create_conflicts() |
2781 | |
2782 | # Show the dialog |
2783 | - self.vbox.show_all() |
2784 | + content_area.show_all() |
2785 | |
2786 | def _get_diff3(self): |
2787 | """ Get the specified diff3 utility. Default is meld. """ |
2788 | @@ -98,22 +92,22 @@ |
2789 | def _create_conflicts(self): |
2790 | """ Construct the list of conflicts. """ |
2791 | if len(self.wt.conflicts()) == 0: |
2792 | - self.model = gtk.ListStore(gobject.TYPE_STRING) |
2793 | + self.model = Gtk.ListStore(GObject.TYPE_STRING) |
2794 | self._treeview.set_model(self.model) |
2795 | - self._treeview.append_column(gtk.TreeViewColumn(_i18n('Conflicts'), |
2796 | - gtk.CellRendererText(), text=0)) |
2797 | + self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Conflicts'), |
2798 | + Gtk.CellRendererText(), text=0)) |
2799 | self._treeview.set_headers_visible(False) |
2800 | self.model.append([ _i18n("No conflicts in working tree.") ]) |
2801 | self._button_diff3.set_sensitive(False) |
2802 | else: |
2803 | - self.model = gtk.ListStore(gobject.TYPE_STRING, |
2804 | - gobject.TYPE_STRING, |
2805 | - gobject.TYPE_STRING) |
2806 | + self.model = Gtk.ListStore(GObject.TYPE_STRING, |
2807 | + GObject.TYPE_STRING, |
2808 | + GObject.TYPE_STRING) |
2809 | self._treeview.set_model(self.model) |
2810 | - self._treeview.append_column(gtk.TreeViewColumn(_i18n('Path'), |
2811 | - gtk.CellRendererText(), text=0)) |
2812 | - self._treeview.append_column(gtk.TreeViewColumn(_i18n('Type'), |
2813 | - gtk.CellRendererText(), text=1)) |
2814 | + self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Path'), |
2815 | + Gtk.CellRendererText(), text=0)) |
2816 | + self._treeview.append_column(Gtk.TreeViewColumn(_i18n('Type'), |
2817 | + Gtk.CellRendererText(), text=1)) |
2818 | self._treeview.set_search_column(0) |
2819 | for conflict in self.wt.conflicts(): |
2820 | if conflict.typestring == 'path conflict': |
2821 | |
2822 | === modified file 'dialog.py' |
2823 | --- dialog.py 2011-03-14 20:12:19 +0000 |
2824 | +++ dialog.py 2011-09-08 03:12:25 +0000 |
2825 | @@ -14,24 +14,18 @@ |
2826 | # along with this program; if not, write to the Free Software |
2827 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2828 | |
2829 | -try: |
2830 | - import pygtk |
2831 | - pygtk.require("2.0") |
2832 | -except: |
2833 | - pass |
2834 | - |
2835 | -import gtk |
2836 | - |
2837 | - |
2838 | -def _message_dialog(type, primary, secondary, parent=None, buttons=gtk.BUTTONS_OK): |
2839 | +from gi.repository import Gtk |
2840 | + |
2841 | + |
2842 | +def _message_dialog(type, primary, secondary, parent=None, buttons=Gtk.ButtonsType.OK): |
2843 | """ Display a given type of MessageDialog with the given message. |
2844 | |
2845 | :param type: message dialog type |
2846 | |
2847 | :param message: the message you want to display. |
2848 | """ |
2849 | - dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL, type=type, parent=parent, |
2850 | - buttons=buttons) |
2851 | + dialog = Gtk.MessageDialog(parent=parent, flags=Gtk.DialogFlags.MODAL, |
2852 | + type=type, buttons=buttons) |
2853 | dialog.set_markup('<big><b>' + primary + '</b></big>') |
2854 | dialog.format_secondary_text(secondary) |
2855 | response = dialog.run() |
2856 | @@ -40,16 +34,16 @@ |
2857 | |
2858 | def error_dialog(primary, secondary, parent=None): |
2859 | """ Display an error dialog with the given message. """ |
2860 | - return _message_dialog(gtk.MESSAGE_ERROR, primary, secondary, parent) |
2861 | + return _message_dialog(Gtk.MessageType.ERROR, primary, secondary, parent) |
2862 | |
2863 | def info_dialog(primary, secondary, parent=None): |
2864 | """ Display an info dialog with the given message. """ |
2865 | - return _message_dialog(gtk.MESSAGE_INFO, primary, secondary, parent) |
2866 | + return _message_dialog(Gtk.MessageType.INFO, primary, secondary, parent) |
2867 | |
2868 | def warning_dialog(primary, secondary, parent=None): |
2869 | """ Display a warning dialog with the given message. """ |
2870 | - return _message_dialog(gtk.MESSAGE_WARNING, primary, secondary, parent) |
2871 | + return _message_dialog(Gtk.MessageType.WARNING, primary, secondary, parent) |
2872 | |
2873 | def question_dialog(primary, secondary, parent=None): |
2874 | """ Display a dialog with the given question. """ |
2875 | - return _message_dialog(gtk.MESSAGE_QUESTION, primary, secondary, parent, gtk.BUTTONS_YES_NO) |
2876 | + return _message_dialog(Gtk.MessageType.QUESTION, primary, secondary, parent, Gtk.ButtonsType.YES_NO) |
2877 | |
2878 | === modified file 'diff.py' |
2879 | --- diff.py 2011-04-10 18:44:39 +0000 |
2880 | +++ diff.py 2011-09-08 03:12:25 +0000 |
2881 | @@ -10,10 +10,8 @@ |
2882 | |
2883 | from cStringIO import StringIO |
2884 | |
2885 | -import pygtk |
2886 | -pygtk.require("2.0") |
2887 | -import gtk |
2888 | -import pango |
2889 | +from gi.repository import Gtk |
2890 | +from gi.repository import Pango |
2891 | import os |
2892 | import re |
2893 | import sys |
2894 | @@ -24,12 +22,12 @@ |
2895 | from elementtree.ElementTree import Element, SubElement, tostring |
2896 | |
2897 | try: |
2898 | - import gtksourceview2 |
2899 | + from gi.repository import GtkSource |
2900 | have_gtksourceview = True |
2901 | except ImportError: |
2902 | have_gtksourceview = False |
2903 | try: |
2904 | - import gconf |
2905 | + from gi.repository import GConf |
2906 | have_gconf = True |
2907 | except ImportError: |
2908 | have_gconf = False |
2909 | @@ -66,37 +64,35 @@ |
2910 | pass |
2911 | |
2912 | |
2913 | -class DiffFileView(gtk.ScrolledWindow): |
2914 | +class DiffFileView(Gtk.ScrolledWindow): |
2915 | """Window for displaying diffs from a diff file""" |
2916 | |
2917 | def __init__(self): |
2918 | - gtk.ScrolledWindow.__init__(self) |
2919 | + super(DiffFileView, self).__init__() |
2920 | self.construct() |
2921 | self._diffs = {} |
2922 | |
2923 | def construct(self): |
2924 | - self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
2925 | - self.set_shadow_type(gtk.SHADOW_IN) |
2926 | + self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
2927 | + self.set_shadow_type(Gtk.ShadowType.IN) |
2928 | |
2929 | if have_gtksourceview: |
2930 | - self.buffer = gtksourceview2.Buffer() |
2931 | - slm = gtksourceview2.LanguageManager() |
2932 | - guess_language = getattr(gtksourceview2.LanguageManager, |
2933 | - "guess_language", fallback_guess_language) |
2934 | - gsl = guess_language(slm, content_type="text/x-patch") |
2935 | + self.buffer = GtkSource.Buffer() |
2936 | + lang_manager = GtkSource.LanguageManager.get_default() |
2937 | + language = lang_manager.guess_language(None, "text/x-patch") |
2938 | if have_gconf: |
2939 | self.apply_gedit_colors(self.buffer) |
2940 | self.apply_colordiff_colors(self.buffer) |
2941 | - self.buffer.set_language(gsl) |
2942 | + self.buffer.set_language(language) |
2943 | self.buffer.set_highlight_syntax(True) |
2944 | |
2945 | - self.sourceview = gtksourceview2.View(self.buffer) |
2946 | + self.sourceview = GtkSource.View(buffer=self.buffer) |
2947 | else: |
2948 | - self.buffer = gtk.TextBuffer() |
2949 | - self.sourceview = gtk.TextView(self.buffer) |
2950 | + self.buffer = Gtk.TextBuffer() |
2951 | + self.sourceview = Gtk.TextView(self.buffer) |
2952 | |
2953 | self.sourceview.set_editable(False) |
2954 | - self.sourceview.modify_font(pango.FontDescription("Monospace")) |
2955 | + self.sourceview.modify_font(Pango.FontDescription("Monospace")) |
2956 | self.add(self.sourceview) |
2957 | self.sourceview.show() |
2958 | |
2959 | @@ -106,15 +102,15 @@ |
2960 | |
2961 | This method needs the gconf module. |
2962 | |
2963 | - :param buf: a gtksourceview2.Buffer object. |
2964 | + :param buf: a GtkSource.Buffer object. |
2965 | """ |
2966 | GEDIT_SCHEME_PATH = '/apps/gedit-2/preferences/editor/colors/scheme' |
2967 | GEDIT_USER_STYLES_PATH = os.path.expanduser('~/.gnome2/gedit/styles') |
2968 | |
2969 | - client = gconf.client_get_default() |
2970 | + client = GConf.Client.get_default() |
2971 | style_scheme_name = client.get_string(GEDIT_SCHEME_PATH) |
2972 | if style_scheme_name is not None: |
2973 | - style_scheme_mgr = gtksourceview2.StyleSchemeManager() |
2974 | + style_scheme_mgr = GtkSource.StyleSchemeManager() |
2975 | style_scheme_mgr.append_search_path(GEDIT_USER_STYLES_PATH) |
2976 | |
2977 | style_scheme = style_scheme_mgr.get_scheme(style_scheme_name) |
2978 | @@ -128,9 +124,9 @@ |
2979 | |
2980 | Both ~/.colordiffrc and ~/.colordiffrc.bzr-gtk are read. |
2981 | |
2982 | - :param buf: a "Diff" gtksourceview2.Buffer object. |
2983 | + :param buf: a "Diff" GtkSource.Buffer object. |
2984 | """ |
2985 | - scheme_manager = gtksourceview2.StyleSchemeManager() |
2986 | + scheme_manager = GtkSource.StyleSchemeManager() |
2987 | style_scheme = scheme_manager.get_scheme('colordiff') |
2988 | |
2989 | # if style scheme not found, we'll generate it from colordiffrc |
2990 | @@ -254,7 +250,7 @@ |
2991 | """This is the soft and chewy filling for a DiffWindow.""" |
2992 | |
2993 | def __init__(self): |
2994 | - DiffFileView.__init__(self) |
2995 | + super(DiffView, self).__init__() |
2996 | self.rev_tree = None |
2997 | self.parent_tree = None |
2998 | |
2999 | @@ -284,7 +280,7 @@ |
3000 | self.buffer.set_text(decoded.encode('UTF-8')) |
3001 | |
3002 | |
3003 | -class DiffWidget(gtk.HPaned): |
3004 | +class DiffWidget(Gtk.HPaned): |
3005 | """Diff widget |
3006 | |
3007 | """ |
3008 | @@ -292,24 +288,24 @@ |
3009 | super(DiffWidget, self).__init__() |
3010 | |
3011 | # The file hierarchy: a scrollable treeview |
3012 | - scrollwin = gtk.ScrolledWindow() |
3013 | - scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) |
3014 | - scrollwin.set_shadow_type(gtk.SHADOW_IN) |
3015 | + scrollwin = Gtk.ScrolledWindow() |
3016 | + scrollwin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) |
3017 | + scrollwin.set_shadow_type(Gtk.ShadowType.IN) |
3018 | self.pack1(scrollwin) |
3019 | scrollwin.show() |
3020 | |
3021 | - self.model = gtk.TreeStore(str, str) |
3022 | - self.treeview = gtk.TreeView(self.model) |
3023 | + self.model = Gtk.TreeStore(str, str) |
3024 | + self.treeview = Gtk.TreeView(model=self.model) |
3025 | self.treeview.set_headers_visible(False) |
3026 | self.treeview.set_search_column(1) |
3027 | self.treeview.connect("cursor-changed", self._treeview_cursor_cb) |
3028 | scrollwin.add(self.treeview) |
3029 | self.treeview.show() |
3030 | |
3031 | - cell = gtk.CellRendererText() |
3032 | + cell = Gtk.CellRendererText() |
3033 | cell.set_property("width-chars", 20) |
3034 | - column = gtk.TreeViewColumn() |
3035 | - column.pack_start(cell, expand=True) |
3036 | + column = Gtk.TreeViewColumn() |
3037 | + column.pack_start(cell, True) |
3038 | column.add_attribute(cell, "text", 0) |
3039 | self.treeview.append_column(column) |
3040 | |
3041 | @@ -386,7 +382,7 @@ |
3042 | break |
3043 | if tv_path is None: |
3044 | raise errors.NoSuchFile(file_path) |
3045 | - self.treeview.set_cursor(tv_path) |
3046 | + self.treeview.set_cursor(tv_path, None, False) |
3047 | self.treeview.scroll_to_cell(tv_path) |
3048 | |
3049 | def _treeview_cursor_cb(self, *args): |
3050 | @@ -403,9 +399,9 @@ |
3051 | def _on_wraplines_toggled(self, widget=None, wrap=False): |
3052 | """Callback for when the wrap lines checkbutton is toggled""" |
3053 | if wrap or widget.get_active(): |
3054 | - self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_WORD) |
3055 | + self.diff_view.sourceview.set_wrap_mode(Gtk.WrapMode.WORD) |
3056 | else: |
3057 | - self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_NONE) |
3058 | + self.diff_view.sourceview.set_wrap_mode(Gtk.WrapMode.NONE) |
3059 | |
3060 | class DiffWindow(Window): |
3061 | """Diff window. |
3062 | @@ -415,7 +411,7 @@ |
3063 | """ |
3064 | |
3065 | def __init__(self, parent=None, operations=None): |
3066 | - Window.__init__(self, parent) |
3067 | + super(DiffWindow, self).__init__(parent=parent) |
3068 | self.set_border_width(0) |
3069 | self.set_title("bzrk diff") |
3070 | |
3071 | @@ -429,7 +425,7 @@ |
3072 | |
3073 | def construct(self, operations): |
3074 | """Construct the window contents.""" |
3075 | - self.vbox = gtk.VBox() |
3076 | + self.vbox = Gtk.VBox() |
3077 | self.add(self.vbox) |
3078 | self.vbox.show() |
3079 | self.diff = DiffWidget() |
3080 | @@ -444,11 +440,12 @@ |
3081 | |
3082 | |
3083 | def _get_menu_bar(self): |
3084 | - menubar = gtk.MenuBar() |
3085 | + menubar = Gtk.MenuBar() |
3086 | # View menu |
3087 | - mb_view = gtk.MenuItem(_i18n("_View")) |
3088 | - mb_view_menu = gtk.Menu() |
3089 | - mb_view_wrapsource = gtk.CheckMenuItem(_i18n("Wrap _Long Lines")) |
3090 | + mb_view = Gtk.MenuItem.new_with_mnemonic(_i18n("_View")) |
3091 | + mb_view_menu = Gtk.Menu() |
3092 | + mb_view_wrapsource = Gtk.CheckMenuItem.new_with_mnemonic( |
3093 | + _i18n("Wrap _Long Lines")) |
3094 | mb_view_wrapsource.connect('activate', self.diff._on_wraplines_toggled) |
3095 | mb_view_wrapsource.show() |
3096 | mb_view_menu.append(mb_view_wrapsource) |
3097 | @@ -466,26 +463,26 @@ |
3098 | """ |
3099 | if operations is None: |
3100 | return None |
3101 | - hbox = gtk.HButtonBox() |
3102 | - hbox.set_layout(gtk.BUTTONBOX_START) |
3103 | + hbox = Gtk.HButtonBox() |
3104 | + hbox.set_layout(Gtk.ButtonBoxStyle.START) |
3105 | for title, method in operations: |
3106 | - merge_button = gtk.Button(title) |
3107 | + merge_button = Gtk.Button(title) |
3108 | merge_button.show() |
3109 | - merge_button.set_relief(gtk.RELIEF_NONE) |
3110 | + merge_button.set_relief(Gtk.ReliefStyle.NONE) |
3111 | merge_button.connect("clicked", method) |
3112 | hbox.pack_start(merge_button, expand=False, fill=True) |
3113 | hbox.show() |
3114 | return hbox |
3115 | |
3116 | def _get_merge_target(self): |
3117 | - d = gtk.FileChooserDialog('Merge branch', self, |
3118 | - gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, |
3119 | - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, |
3120 | - gtk.STOCK_CANCEL, |
3121 | - gtk.RESPONSE_CANCEL,)) |
3122 | + d = Gtk.FileChooserDialog('Merge branch', self, |
3123 | + Gtk.FileChooserAction.SELECT_FOLDER, |
3124 | + buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK, |
3125 | + Gtk.STOCK_CANCEL, |
3126 | + Gtk.ResponseType.CANCEL,)) |
3127 | try: |
3128 | result = d.run() |
3129 | - if result != gtk.RESPONSE_OK: |
3130 | + if result != Gtk.ResponseType.OK: |
3131 | raise SelectCancelled() |
3132 | return d.get_current_folder_uri() |
3133 | finally: |
3134 | @@ -505,15 +502,15 @@ |
3135 | error_dialog('Error', str(e)) |
3136 | |
3137 | def _get_save_path(self, basename): |
3138 | - d = gtk.FileChooserDialog('Save As', self, |
3139 | - gtk.FILE_CHOOSER_ACTION_SAVE, |
3140 | - buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, |
3141 | - gtk.STOCK_CANCEL, |
3142 | - gtk.RESPONSE_CANCEL,)) |
3143 | + d = Gtk.FileChooserDialog('Save As', self, |
3144 | + Gtk.FileChooserAction.SAVE, |
3145 | + buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK, |
3146 | + Gtk.STOCK_CANCEL, |
3147 | + Gtk.ResponseType.CANCEL,)) |
3148 | d.set_current_name(basename) |
3149 | try: |
3150 | result = d.run() |
3151 | - if result != gtk.RESPONSE_OK: |
3152 | + if result != Gtk.ResponseType.OK: |
3153 | raise SelectCancelled() |
3154 | return urlutils.local_path_from_url(d.get_uri()) |
3155 | finally: |
3156 | @@ -581,8 +578,8 @@ |
3157 | class MergeDirectiveController(DiffController): |
3158 | |
3159 | def __init__(self, path, directive, window=None): |
3160 | - DiffController.__init__(self, path, directive.patch.splitlines(True), |
3161 | - window) |
3162 | + super(MergeDirectiveController, self).__init__( |
3163 | + path, directive.patch.splitlines(True), window) |
3164 | self.directive = directive |
3165 | self.merge_target = None |
3166 | |
3167 | |
3168 | === modified file 'initialize.py' |
3169 | --- initialize.py 2011-04-10 18:44:39 +0000 |
3170 | +++ initialize.py 2011-09-08 03:12:25 +0000 |
3171 | @@ -14,13 +14,8 @@ |
3172 | # along with this program; if not, write to the Free Software |
3173 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3174 | |
3175 | -try: |
3176 | - import pygtk |
3177 | - pygtk.require("2.0") |
3178 | -except: |
3179 | - pass |
3180 | - |
3181 | -import gtk |
3182 | +from gi.repository import GObject |
3183 | +from gi.repository import Gtk |
3184 | |
3185 | import os |
3186 | |
3187 | @@ -35,26 +30,27 @@ |
3188 | from bzrlib.plugins.gtk.i18n import _i18n |
3189 | |
3190 | |
3191 | -class InitDialog(gtk.Dialog): |
3192 | +class InitDialog(Gtk.Dialog): |
3193 | """ Initialize dialog. """ |
3194 | |
3195 | def __init__(self, path, parent=None): |
3196 | """ Initialize the Initialize dialog. """ |
3197 | - gtk.Dialog.__init__(self, title="Initialize - Olive", |
3198 | - parent=parent, |
3199 | - flags=0, |
3200 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
3201 | + super(InitDialog, self).__init__( |
3202 | + title="Initialize - Olive", parent=parent, flags=0, |
3203 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
3204 | |
3205 | # Get arguments |
3206 | self.path = path |
3207 | |
3208 | # Create the widgets |
3209 | - self._button_init = gtk.Button(_i18n("_Initialize"), use_underline=True) |
3210 | - self._label_question = gtk.Label(_i18n("Which directory do you want to initialize?")) |
3211 | - self._radio_current = gtk.RadioButton(None, _i18n("Current directory")) |
3212 | - self._radio_custom = gtk.RadioButton(self._radio_current, _i18n("Create a new directory with the name:")) |
3213 | - self._entry_custom = gtk.Entry() |
3214 | - self._hbox_custom = gtk.HBox() |
3215 | + self._button_init = Gtk.Button(_i18n("_Initialize"), use_underline=True) |
3216 | + self._label_question = Gtk.Label(label=_i18n("Which directory do you want to initialize?")) |
3217 | + self._radio_current = Gtk.RadioButton.new_with_label( |
3218 | + None, _i18n("Current directory")) |
3219 | + self._radio_custom = Gtk.RadioButton.new_with_label_from_widget( |
3220 | + self._radio_current, _i18n("Create a new directory with the name:")) |
3221 | + self._entry_custom = Gtk.Entry() |
3222 | + self._hbox_custom = Gtk.HBox() |
3223 | |
3224 | # Set callbacks |
3225 | self._button_init.connect('clicked', self._on_init_clicked) |
3226 | @@ -64,17 +60,18 @@ |
3227 | self._entry_custom.set_sensitive(False) |
3228 | |
3229 | # Construct the dialog |
3230 | - self.action_area.pack_end(self._button_init) |
3231 | - |
3232 | - self._hbox_custom.pack_start(self._radio_custom, False, False) |
3233 | - self._hbox_custom.pack_start(self._entry_custom, True, True) |
3234 | - |
3235 | - self.vbox.pack_start(self._label_question) |
3236 | - self.vbox.pack_start(self._radio_current) |
3237 | - self.vbox.pack_start(self._hbox_custom) |
3238 | + self.action_area.pack_end(self._button_init, False, False, 0) |
3239 | + |
3240 | + self._hbox_custom.pack_start(self._radio_custom, False, False, 0) |
3241 | + self._hbox_custom.pack_start(self._entry_custom, True, True, 0) |
3242 | + |
3243 | + content_area = self.get_content_area() |
3244 | + content_area.pack_start(self._label_question, True, True, 0) |
3245 | + content_area.pack_start(self._radio_current, True, True, 0) |
3246 | + content_area.pack_start(self._hbox_custom, True, True, 0) |
3247 | |
3248 | # Display the dialog |
3249 | - self.vbox.show_all() |
3250 | + content_area.show_all() |
3251 | |
3252 | def _on_custom_toggled(self, widget): |
3253 | """ Occurs if the Custom radiobutton is toggled. """ |
3254 | @@ -120,4 +117,4 @@ |
3255 | branch = existing_bzrdir.create_branch() |
3256 | existing_bzrdir.create_workingtree() |
3257 | |
3258 | - self.response(gtk.RESPONSE_OK) |
3259 | + self.response(Gtk.ResponseType.OK) |
3260 | |
3261 | === modified file 'keyring.py' |
3262 | --- keyring.py 2010-06-04 12:12:59 +0000 |
3263 | +++ keyring.py 2011-09-08 03:12:25 +0000 |
3264 | @@ -14,7 +14,7 @@ |
3265 | # along with this program; if not, write to the Free Software |
3266 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3267 | |
3268 | -import gobject |
3269 | +from gi.repository import GObject |
3270 | try: |
3271 | import gnomekeyring |
3272 | except ImportError: |
3273 | @@ -28,15 +28,12 @@ |
3274 | class GnomeKeyringCredentialStore(CredentialStore): |
3275 | |
3276 | def __init__(self): |
3277 | - CredentialStore.__init__(self) |
3278 | - # Older versions of gobject don't provide get_application_name so we |
3279 | - # can't always check. |
3280 | - get_app_name = getattr(gobject, 'get_application_name', None) |
3281 | - if get_app_name is None or get_app_name() is None: |
3282 | + super(GnomeKeyringCredentialStore, self).__init__() |
3283 | + if GObject.get_application_name() is None: |
3284 | # External applications that load bzrlib may already have set the |
3285 | # application name so we don't contradict them (when we can |
3286 | # determine it that is). |
3287 | - gobject.set_application_name("bzr") |
3288 | + GObject.set_application_name("bzr") |
3289 | |
3290 | def decode_password(self, credentials): |
3291 | if gnomekeyring is None: |
3292 | |
3293 | === modified file 'lock.py' |
3294 | --- lock.py 2011-03-14 20:12:19 +0000 |
3295 | +++ lock.py 2011-09-08 03:12:25 +0000 |
3296 | @@ -1,8 +1,8 @@ |
3297 | -import gtk |
3298 | +from gi.repository import Gtk |
3299 | |
3300 | |
3301 | RESPONSE_BREAK = 0 |
3302 | -RESPONSE_CANCEL = gtk.RESPONSE_CANCEL |
3303 | +RESPONSE_CANCEL = Gtk.ResponseType.CANCEL |
3304 | |
3305 | READ = "read" |
3306 | WRITE = "write" |
3307 | @@ -43,19 +43,21 @@ |
3308 | return True |
3309 | |
3310 | |
3311 | -class LockDialog(gtk.Dialog): |
3312 | +class LockDialog(Gtk.Dialog): |
3313 | |
3314 | def __init__(self, branch): |
3315 | - gtk.Dialog.__init__(self) |
3316 | + super(LockDialog, self).__init__() |
3317 | |
3318 | self.branch = branch |
3319 | |
3320 | self.set_title('Lock Not Held') |
3321 | |
3322 | - self.vbox.add(gtk.Label('This operation cannot be completed as ' \ |
3323 | - 'another application has locked the branch.')) |
3324 | + self.get_content_area().add( |
3325 | + Gtk.Label(label=( |
3326 | + 'This operation cannot be completed as ' |
3327 | + 'another application has locked the branch.'))) |
3328 | |
3329 | self.add_button('Break Lock', RESPONSE_BREAK) |
3330 | - self.add_button(gtk.STOCK_CANCEL, RESPONSE_CANCEL) |
3331 | + self.add_button(Gtk.STOCK_CANCEL, RESPONSE_CANCEL) |
3332 | |
3333 | - self.vbox.show_all() |
3334 | + self.get_content_area().show_all() |
3335 | |
3336 | === modified file 'loom.py' |
3337 | --- loom.py 2011-04-10 18:44:39 +0000 |
3338 | +++ loom.py 2011-09-08 03:12:25 +0000 |
3339 | @@ -14,14 +14,8 @@ |
3340 | # along with this program; if not, write to the Free Software |
3341 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3342 | |
3343 | -try: |
3344 | - import pygtk |
3345 | - pygtk.require("2.0") |
3346 | -except: |
3347 | - pass |
3348 | - |
3349 | -import gtk |
3350 | -import gobject |
3351 | +from gi.repository import Gtk |
3352 | +from gi.repository import GObject |
3353 | |
3354 | from bzrlib.plugins.gtk.diff import DiffWidget |
3355 | from bzrlib.plugins.gtk.dialog import question_dialog |
3356 | @@ -32,14 +26,13 @@ |
3357 | from bzrlib.plugins.gtk.i18n import _i18n |
3358 | |
3359 | |
3360 | -class LoomDialog(gtk.Dialog): |
3361 | +class LoomDialog(Gtk.Dialog): |
3362 | """Simple Loom browse dialog.""" |
3363 | |
3364 | def __init__(self, branch, tree=None, parent=None): |
3365 | - gtk.Dialog.__init__(self, title="Threads", |
3366 | - parent=parent, |
3367 | - flags=0, |
3368 | - buttons=(gtk.STOCK_CLOSE,gtk.RESPONSE_OK)) |
3369 | + super(LoomDialog, self).__init__( |
3370 | + title="Threads", parent=parent, flags=0, |
3371 | + buttons=(Gtk.STOCK_CLOSE,Gtk.ResponseType.OK)) |
3372 | self.branch = branch |
3373 | if tree is not None: |
3374 | self.tree = loom_tree.LoomTreeDecorator(tree) |
3375 | @@ -57,7 +50,7 @@ |
3376 | _i18n("Branch is not a loom branch. Upgrade to Loom format?"), |
3377 | parent=self) |
3378 | # Doesn't set a parent for the dialog.. |
3379 | - if response == gtk.RESPONSE_NO: |
3380 | + if response == Gtk.ResponseType.NO: |
3381 | return |
3382 | assert self.branch.nick is not None |
3383 | loom_branch.loomify(self.branch) |
3384 | @@ -65,29 +58,29 @@ |
3385 | return super(LoomDialog, self).run() |
3386 | |
3387 | def _construct(self): |
3388 | - hbox = gtk.HBox() |
3389 | + hbox = Gtk.HBox() |
3390 | |
3391 | - self._threads_scroller = gtk.ScrolledWindow() |
3392 | - self._threads_scroller.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
3393 | - self._threads_view = gtk.TreeView() |
3394 | + self._threads_scroller = Gtk.ScrolledWindow() |
3395 | + self._threads_scroller.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
3396 | + self._threads_view = Gtk.TreeView() |
3397 | self._threads_scroller.add(self._threads_view) |
3398 | - self._threads_scroller.set_shadow_type(gtk.SHADOW_IN) |
3399 | - hbox.pack_start(self._threads_scroller) |
3400 | + self._threads_scroller.set_shadow_type(Gtk.ShadowType.IN) |
3401 | + hbox.pack_start(self._threads_scroller, True, True, 0) |
3402 | |
3403 | - self._threads_store = gtk.ListStore( |
3404 | - gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gobject.TYPE_STRING) |
3405 | + self._threads_store = Gtk.ListStore( |
3406 | + GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_PYOBJECT, GObject.TYPE_STRING) |
3407 | self._threads_view.set_model(self._threads_store) |
3408 | - self._threads_view.append_column(gtk.TreeViewColumn("Name", gtk.CellRendererText(), text=0)) |
3409 | + self._threads_view.append_column(Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=0)) |
3410 | self._threads_view.connect('cursor-changed', self._on_view_thread) |
3411 | if self.tree is not None: |
3412 | self._threads_view.connect('row-activated', self._on_switch_thread) |
3413 | |
3414 | self._diff = DiffWidget() |
3415 | self._diff.show() |
3416 | - hbox.pack_end(self._diff) |
3417 | + hbox.pack_end(self._diff, False, False, 0) |
3418 | |
3419 | hbox.show_all() |
3420 | - self.vbox.pack_start(hbox) |
3421 | + self.get_content_area().pack_start(hbox, True, True, 0) |
3422 | |
3423 | # FIXME: Buttons: combine-thread, revert-loom, record |
3424 | self.set_default_size(500, 350) |
3425 | |
3426 | === modified file 'merge.py' |
3427 | --- merge.py 2011-04-10 18:44:39 +0000 |
3428 | +++ merge.py 2011-09-08 03:12:25 +0000 |
3429 | @@ -16,13 +16,7 @@ |
3430 | |
3431 | import os |
3432 | |
3433 | -try: |
3434 | - import pygtk |
3435 | - pygtk.require("2.0") |
3436 | -except: |
3437 | - pass |
3438 | - |
3439 | -import gtk |
3440 | +from gi.repository import Gtk |
3441 | |
3442 | from bzrlib.branch import Branch |
3443 | import bzrlib.errors as errors |
3444 | @@ -37,15 +31,14 @@ |
3445 | from bzrlib.plugins.gtk.i18n import _i18n |
3446 | |
3447 | |
3448 | -class MergeDialog(gtk.Dialog): |
3449 | +class MergeDialog(Gtk.Dialog): |
3450 | """ Display the Merge dialog and perform the needed actions. """ |
3451 | |
3452 | def __init__(self, wt, wtpath, default_branch_path=None, parent=None): |
3453 | """ Initialize the Merge dialog. """ |
3454 | - gtk.Dialog.__init__(self, title="Merge changes", |
3455 | - parent=parent, |
3456 | - flags=0, |
3457 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
3458 | + super(MergeDialog, self).__init__( |
3459 | + title="Merge changes", parent=parent, flags=0, |
3460 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
3461 | self.set_icon_from_file(icon_path("bzr-icon-64.png")) |
3462 | # Get arguments |
3463 | self.wt = wt |
3464 | @@ -54,25 +47,25 @@ |
3465 | self.parent_window = parent |
3466 | |
3467 | # Create widgets |
3468 | - self._hbox = gtk.HBox() |
3469 | - self._source = gtk.HBox() |
3470 | - self._label_merge_from = gtk.Label(_i18n("Merge from")) |
3471 | - self._combo_source = gtk.combo_box_new_text() |
3472 | + self._hbox = Gtk.HBox() |
3473 | + self._source = Gtk.HBox() |
3474 | + self._label_merge_from = Gtk.Label(label=_i18n("Merge from")) |
3475 | + self._combo_source = Gtk.ComboBoxText() |
3476 | for entry in [_i18n("Folder"),_i18n("Custom Location")]: |
3477 | self._combo_source.append_text(entry) |
3478 | self._combo_source.connect("changed", self._on_combo_changed) |
3479 | - self._button_merge = gtk.Button(_i18n("_Merge")) |
3480 | - self._button_merge_icon = gtk.Image() |
3481 | - self._button_merge_icon.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON) |
3482 | + self._button_merge = Gtk.Button(_i18n("_Merge")) |
3483 | + self._button_merge_icon = Gtk.Image() |
3484 | + self._button_merge_icon.set_from_stock(Gtk.STOCK_APPLY, Gtk.IconSize.BUTTON) |
3485 | self._button_merge.set_image(self._button_merge_icon) |
3486 | self._button_merge.connect('clicked', self._on_merge_clicked) |
3487 | |
3488 | # Add widgets to dialog |
3489 | - self.vbox.pack_start(self._hbox, False, False, 0) |
3490 | + self.get_content_area().pack_start(self._hbox, False, False, 0) |
3491 | self._hbox.add(self._label_merge_from) |
3492 | self._hbox.add(self._combo_source) |
3493 | self._hbox.set_spacing(5) |
3494 | - self.action_area.pack_end(self._button_merge) |
3495 | + self.action_area.pack_end(self._button_merge, False, False, 0) |
3496 | |
3497 | if self.default_branch_path and os.path.isdir( |
3498 | self.default_branch_path.partition('file://')[2]): |
3499 | @@ -83,37 +76,37 @@ |
3500 | else: |
3501 | # If no default_branch_path give, default to folder source with current folder |
3502 | self._combo_source.set_active(0) |
3503 | - self.vbox.show_all() |
3504 | + self.get_content_area().show_all() |
3505 | |
3506 | def _on_folder_source(self): |
3507 | """ Merge from folder, create a filechooser dialog and button """ |
3508 | - self._source = gtk.HBox() |
3509 | - self._filechooser_dialog = gtk.FileChooserDialog(title="Please select a folder", |
3510 | + self._source = Gtk.HBox() |
3511 | + self._filechooser_dialog = Gtk.FileChooserDialog(title="Please select a folder", |
3512 | parent=self.parent_window, |
3513 | - action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, |
3514 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
3515 | - gtk.STOCK_OPEN, gtk.RESPONSE_OK)) |
3516 | - self._filechooser_dialog.set_default_response(gtk.RESPONSE_OK) |
3517 | - self._filechooser = gtk.FileChooserButton(self._filechooser_dialog) |
3518 | + action=Gtk.FileChooserAction.SELECT_FOLDER, |
3519 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, |
3520 | + Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) |
3521 | + self._filechooser_dialog.set_default_response(Gtk.ResponseType.OK) |
3522 | + self._filechooser = Gtk.FileChooserButton(self._filechooser_dialog) |
3523 | self._filechooser.show() |
3524 | directory = getattr(self, 'directory', None) |
3525 | if not directory: |
3526 | directory = os.path.dirname(self.wt.abspath(self.wtpath)) |
3527 | self._filechooser_dialog.set_current_folder(directory) |
3528 | self._source.pack_start(self._filechooser, True, True, 0) |
3529 | - self.vbox.pack_start(self._source, True, True, 5) |
3530 | + self.get_content_area().pack_start(self._source, True, True, 5) |
3531 | self._source.show() |
3532 | |
3533 | def _on_custom_source(self): |
3534 | """ Merge from a custom source (can be folder, remote, etc), create entry """ |
3535 | - self._source = gtk.HBox() |
3536 | - self._custom_entry = gtk.Entry() |
3537 | + self._source = Gtk.HBox() |
3538 | + self._custom_entry = Gtk.Entry() |
3539 | if self.default_branch_path: |
3540 | self._custom_entry.set_text(self.default_branch_path) |
3541 | self._custom_entry.connect("activate", self._on_merge_clicked) |
3542 | self._custom_entry.show() |
3543 | self._source.pack_start(self._custom_entry, True, True, 0) |
3544 | - self.vbox.pack_start(self._source, True, True, 5) |
3545 | + self.get_content_area().pack_start(self._source, True, True, 5) |
3546 | self._source.show() |
3547 | |
3548 | def _on_combo_changed(self, widget): |
3549 | @@ -155,4 +148,4 @@ |
3550 | warning_dialog(_i18n('Conflicts encountered'), |
3551 | _i18n('Please resolve the conflicts manually before committing.')) |
3552 | |
3553 | - self.response(gtk.RESPONSE_OK) |
3554 | + self.response(Gtk.ResponseType.OK) |
3555 | |
3556 | === modified file 'mergedirective.py' |
3557 | --- mergedirective.py 2011-03-14 20:12:19 +0000 |
3558 | +++ mergedirective.py 2011-09-08 03:12:25 +0000 |
3559 | @@ -14,17 +14,11 @@ |
3560 | # along with this program; if not, write to the Free Software |
3561 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3562 | |
3563 | -try: |
3564 | - import pygtk |
3565 | - pygtk.require("2.0") |
3566 | -except: |
3567 | - pass |
3568 | - |
3569 | -import gtk |
3570 | +from gi.repository import Gtk |
3571 | |
3572 | from bzrlib.plugins.gtk.branchbox import BranchSelectionBox |
3573 | |
3574 | -class CreateMergeDirectiveDialog(gtk.Dialog): |
3575 | +class CreateMergeDirectiveDialog(Gtk.Dialog): |
3576 | def __init__(self, branch, stop_revid=None): |
3577 | super(CreateMergeDirectiveDialog, self).__init__() |
3578 | self.branch = branch |
3579 | @@ -42,7 +36,7 @@ |
3580 | pass |
3581 | |
3582 | |
3583 | -class SendMergeDirectiveDialog(gtk.Dialog): |
3584 | +class SendMergeDirectiveDialog(Gtk.Dialog): |
3585 | def __init__(self, branch, parent=None): |
3586 | super(SendMergeDirectiveDialog, self).__init__(parent) |
3587 | self.branch = branch |
3588 | @@ -50,31 +44,31 @@ |
3589 | self._create() |
3590 | |
3591 | def _create(self): |
3592 | - table = gtk.Table(rows=3, columns=2) |
3593 | - self.vbox.add(table) |
3594 | + table = Gtk.Table(rows=3, columns=2) |
3595 | + self.get_content_area().add(table) |
3596 | |
3597 | - label = gtk.Label() |
3598 | + label = Gtk.Label() |
3599 | label.set_markup("<b>Branch to Submit:</b>") |
3600 | - table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) |
3601 | - |
3602 | - label = gtk.Label(str(self.branch)) |
3603 | - table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL) |
3604 | - |
3605 | - label = gtk.Label() |
3606 | + table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3607 | + |
3608 | + label = Gtk.Label(label=str(self.branch)) |
3609 | + table.attach(label, 1, 2, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3610 | + |
3611 | + label = Gtk.Label() |
3612 | label.set_markup("<b>Target Branch:</b>") |
3613 | - table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) |
3614 | + table.attach(label, 0, 1, 1, 2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3615 | |
3616 | self.submit_branch = BranchSelectionBox(self.branch.get_submit_branch()) |
3617 | - table.attach(self.submit_branch, 1, 2, 1, 2, gtk.FILL, gtk.FILL) |
3618 | + table.attach(self.submit_branch, 1, 2, 1, 2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3619 | |
3620 | # TODO: Display number of revisions to be send whenever |
3621 | # submit branch changes |
3622 | |
3623 | - label = gtk.Label() |
3624 | + label = Gtk.Label() |
3625 | label.set_markup("<b>Email To:</b>") |
3626 | - table.attach(label, 0, 1, 2, 3, gtk.FILL, gtk.FILL) |
3627 | + table.attach(label, 0, 1, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3628 | |
3629 | - self.mail_to = gtk.ComboBoxEntry() |
3630 | + self.mail_to = Gtk.ComboBox.new_with_entry() |
3631 | mail_to = self.branch.get_config().get_user_option('submit_to') |
3632 | if mail_to is None: |
3633 | submit_branch = self.submit_branch.get_branch() |
3634 | @@ -83,10 +77,10 @@ |
3635 | 'child_submit_to') |
3636 | if mail_to is not None: |
3637 | self.mail_to.get_child().set_text(mail_to) |
3638 | - table.attach(self.mail_to, 1, 2, 2, 3, gtk.FILL, gtk.FILL) |
3639 | + table.attach(self.mail_to, 1, 2, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3640 | |
3641 | - self.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
3642 | - gtk.STOCK_OK, gtk.RESPONSE_OK) |
3643 | + self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, |
3644 | + Gtk.STOCK_OK, Gtk.ResponseType.OK) |
3645 | |
3646 | self.show_all() |
3647 | |
3648 | @@ -110,6 +104,6 @@ |
3649 | |
3650 | |
3651 | |
3652 | -class ApplyMergeDirectiveDialog(gtk.Dialog): |
3653 | +class ApplyMergeDirectiveDialog(Gtk.Dialog): |
3654 | def __init__(self): |
3655 | super(ApplyMergeDirectiveDialog, self).__init__() |
3656 | |
3657 | === modified file 'missing.py' |
3658 | --- missing.py 2011-02-18 13:01:03 +0000 |
3659 | +++ missing.py 2011-09-08 03:12:25 +0000 |
3660 | @@ -14,25 +14,19 @@ |
3661 | # along with this program; if not, write to the Free Software |
3662 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3663 | |
3664 | -try: |
3665 | - import pygtk |
3666 | - pygtk.require("2.0") |
3667 | -except: |
3668 | - pass |
3669 | - |
3670 | -import gtk |
3671 | +from gi.repository import Gtk |
3672 | |
3673 | from bzrlib.missing import find_unmerged |
3674 | |
3675 | from bzrlib.plugins.gtk.revisionview import RevisionView |
3676 | |
3677 | |
3678 | -class MissingWindow(gtk.Dialog): |
3679 | +class MissingWindow(Gtk.Dialog): |
3680 | """Displays revisions present in one branch but missing in |
3681 | another.""" |
3682 | def __init__(self, local_branch, remote_branch): |
3683 | """ Initialize the Status window. """ |
3684 | - super(MissingWindow, self).__init__(flags=gtk.DIALOG_MODAL) |
3685 | + super(MissingWindow, self).__init__(flags=Gtk.DialogFlags.MODAL) |
3686 | self.set_title("Missing Revisions") |
3687 | self.local_branch = local_branch |
3688 | self.remote_branch = remote_branch |
3689 | @@ -41,21 +35,21 @@ |
3690 | self._create() |
3691 | |
3692 | def _create_revisions_frame(self, revisions): |
3693 | - extra_revs = gtk.ScrolledWindow() |
3694 | - vbox = gtk.VBox() |
3695 | + extra_revs = Gtk.ScrolledWindow() |
3696 | + vbox = Gtk.VBox() |
3697 | for rev in revisions: |
3698 | rv = RevisionView() |
3699 | rv.set_revision(rev) |
3700 | - vbox.pack_start(rv, True, True) |
3701 | + vbox.pack_start(rv, True, True, 0) |
3702 | extra_revs.add_with_viewport(vbox) |
3703 | - extra_revs.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) |
3704 | + extra_revs.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) |
3705 | return extra_revs |
3706 | |
3707 | def _create(self): |
3708 | self.set_default_size(600, 600) |
3709 | - paned = gtk.VPaned() |
3710 | + paned = Gtk.VPaned() |
3711 | |
3712 | - frame = gtk.Frame("You have the following extra revisions:") |
3713 | + frame = Gtk.Frame(label="You have the following extra revisions:") |
3714 | |
3715 | extra_revs = self._create_revisions_frame( |
3716 | self.local_branch.repository.get_revisions( |
3717 | @@ -67,10 +61,10 @@ |
3718 | self.remote_branch.repository.get_revisions( |
3719 | map(lambda (x,y):y, self.remote_extra))) |
3720 | |
3721 | - frame = gtk.Frame("You are missing following revisions:") |
3722 | + frame = Gtk.Frame(label="You are missing following revisions:") |
3723 | frame.add(missing_revs) |
3724 | |
3725 | paned.pack2(frame, resize=False, shrink=True) |
3726 | |
3727 | - self.vbox.pack_start(paned, True, True) |
3728 | - self.vbox.show_all() |
3729 | + self.get_content_area().pack_start(paned, True, True, 0) |
3730 | + self.get_content_area().show_all() |
3731 | |
3732 | === modified file 'nautilus-bzr.py' |
3733 | --- nautilus-bzr.py 2011-03-14 20:12:19 +0000 |
3734 | +++ nautilus-bzr.py 2011-09-08 03:12:25 +0000 |
3735 | @@ -6,7 +6,7 @@ |
3736 | # |
3737 | # Published under the GNU GPL |
3738 | |
3739 | -import gtk |
3740 | +from gi.repository import Gtk |
3741 | import nautilus |
3742 | from bzrlib.branch import Branch |
3743 | from bzrlib.bzrdir import BzrDir |
3744 | @@ -143,7 +143,7 @@ |
3745 | |
3746 | dialog = BranchDialog(vfs_file.get_name()) |
3747 | response = dialog.run() |
3748 | - if response != gtk.RESPONSE_NONE: |
3749 | + if response != Gtk.ResponseType.NONE: |
3750 | dialog.hide() |
3751 | dialog.destroy() |
3752 | |
3753 | @@ -171,7 +171,7 @@ |
3754 | from bzrlib.plugins.gtk.commit import CommitDialog |
3755 | dialog = CommitDialog(tree, path) |
3756 | response = dialog.run() |
3757 | - if response != gtk.RESPONSE_NONE: |
3758 | + if response != Gtk.ResponseType.NONE: |
3759 | dialog.hide() |
3760 | dialog.destroy() |
3761 | |
3762 | @@ -190,7 +190,7 @@ |
3763 | |
3764 | pp = start_viz_window(branch, [branch.last_revision()]) |
3765 | pp.show() |
3766 | - gtk.main() |
3767 | + Gtk.main() |
3768 | |
3769 | def pull_cb(self, menu, vfs_file): |
3770 | # We can only cope with local files |
3771 | @@ -208,7 +208,7 @@ |
3772 | from bzrlib.plugins.gtk.pull import PullDialog |
3773 | dialog = PullDialog(tree, path) |
3774 | dialog.display() |
3775 | - gtk.main() |
3776 | + Gtk.main() |
3777 | |
3778 | def merge_cb(self, menu, vfs_file): |
3779 | # We can only cope with local files |
3780 | |
3781 | === modified file 'notify.py' |
3782 | --- notify.py 2011-02-18 13:01:03 +0000 |
3783 | +++ notify.py 2011-09-08 03:12:25 +0000 |
3784 | @@ -16,13 +16,7 @@ |
3785 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3786 | """Notification area icon and notification for Bazaar.""" |
3787 | |
3788 | -try: |
3789 | - import pygtk |
3790 | - pygtk.require("2.0") |
3791 | -except: |
3792 | - pass |
3793 | - |
3794 | -import gtk |
3795 | +from gi.repository import Gtk |
3796 | import bzrlib |
3797 | |
3798 | |
3799 | @@ -34,7 +28,7 @@ |
3800 | return (getattr(bzrlib.plugins, "avahi", None) is not None) |
3801 | |
3802 | |
3803 | -class NotifyPopupMenu(gtk.Menu): |
3804 | +class NotifyPopupMenu(Gtk.Menu): |
3805 | |
3806 | def __init__(self): |
3807 | super(NotifyPopupMenu, self).__init__() |
3808 | @@ -42,10 +36,10 @@ |
3809 | |
3810 | def create_items(self): |
3811 | from bzrlib import errors |
3812 | - item = gtk.CheckMenuItem('_Gateway to LAN') |
3813 | + item = Gtk.CheckMenuItem.new_with_mnemonic('_Gateway to LAN') |
3814 | item.connect('toggled', self.toggle_lan_gateway) |
3815 | self.append(item) |
3816 | - self.append(gtk.SeparatorMenuItem()) |
3817 | + self.append(Gtk.SeparatorMenuItem()) |
3818 | try: |
3819 | from bzrlib.plugins.dbus.activity import LanGateway |
3820 | self.langateway = LanGateway() |
3821 | @@ -56,10 +50,11 @@ |
3822 | # process is already running. |
3823 | item.set_sensitive(False) |
3824 | |
3825 | - item = gtk.CheckMenuItem('Announce _branches on LAN') |
3826 | + item = Gtk.CheckMenuItem.new_with_mnemonic( |
3827 | + 'Announce _branches on LAN') |
3828 | item.connect('toggled', self.toggle_announce_branches) |
3829 | self.append(item) |
3830 | - self.append(gtk.SeparatorMenuItem()) |
3831 | + self.append(Gtk.SeparatorMenuItem()) |
3832 | try: |
3833 | from bzrlib.plugins.avahi.share import ZeroConfServer |
3834 | from bzrlib import urlutils |
3835 | @@ -67,20 +62,20 @@ |
3836 | except ImportError: |
3837 | item.set_sensitive(False) |
3838 | |
3839 | - item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None) |
3840 | + item = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES, None) |
3841 | item.connect('activate', self.show_preferences) |
3842 | self.append(item) |
3843 | - item = gtk.ImageMenuItem(gtk.STOCK_ABOUT, None) |
3844 | + item = Gtk.ImageMenuItem(Gtk.STOCK_ABOUT, None) |
3845 | item.connect('activate', self.show_about) |
3846 | self.append(item) |
3847 | - self.append(gtk.SeparatorMenuItem()) |
3848 | - item = gtk.ImageMenuItem(gtk.STOCK_QUIT, None) |
3849 | - item.connect('activate', gtk.main_quit) |
3850 | + self.append(Gtk.SeparatorMenuItem()) |
3851 | + item = Gtk.ImageMenuItem(Gtk.STOCK_QUIT, None) |
3852 | + item.connect('activate', Gtk.main_quit) |
3853 | self.append(item) |
3854 | self.show_all() |
3855 | |
3856 | def display(self, icon, event_button, event_time): |
3857 | - self.popup(None, None, gtk.status_icon_position_menu, |
3858 | + self.popup(None, None, Gtk.status_icon_position_menu, |
3859 | event_button, event_time, icon) |
3860 | |
3861 | def toggle_lan_gateway(self, item): |
3862 | |
3863 | === modified file 'preferences/__init__.py' |
3864 | --- preferences/__init__.py 2011-03-14 20:12:19 +0000 |
3865 | +++ preferences/__init__.py 2011-09-08 03:12:25 +0000 |
3866 | @@ -14,20 +14,14 @@ |
3867 | # along with this program; if not, write to the Free Software |
3868 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3869 | |
3870 | -try: |
3871 | - import pygtk |
3872 | - pygtk.require("2.0") |
3873 | -except: |
3874 | - pass |
3875 | - |
3876 | -import gtk |
3877 | +from gi.repository import Gtk |
3878 | |
3879 | from bzrlib.config import GlobalConfig |
3880 | from bzrlib.plugins.gtk.preferences.identity import IdentityPage |
3881 | from bzrlib.plugins.gtk.preferences.plugins import PluginsPage |
3882 | from bzrlib.plugins.gtk.preferences.notifications import NotificationsPage |
3883 | |
3884 | -class PreferencesWindow(gtk.Dialog): |
3885 | +class PreferencesWindow(Gtk.Dialog): |
3886 | """Displays global preferences windows.""" |
3887 | # Note that we don't allow configuration of aliases or |
3888 | # default log formats. This is because doing so wouldn't make |
3889 | @@ -36,9 +30,8 @@ |
3890 | |
3891 | def __init__(self, config=None): |
3892 | """ Initialize the Status window. """ |
3893 | - super(PreferencesWindow, self).__init__(flags=gtk.DIALOG_MODAL) |
3894 | + super(PreferencesWindow, self).__init__(flags=Gtk.DialogFlags.MODAL) |
3895 | self.set_title("Bazaar Preferences") |
3896 | - self.set_has_separator(False) |
3897 | self.config = config |
3898 | if self.config is None: |
3899 | self.config = GlobalConfig() |
3900 | @@ -48,16 +41,17 @@ |
3901 | self.set_default_size(320, 480) |
3902 | self.set_border_width(0) |
3903 | |
3904 | - notebook = gtk.Notebook() |
3905 | + notebook = Gtk.Notebook() |
3906 | notebook.set_border_width(12) |
3907 | for (label, page) in self._create_pages(): |
3908 | - notebook.append_page(page, gtk.Label(label)) |
3909 | + notebook.append_page(page, Gtk.Label(label=label)) |
3910 | |
3911 | notebook.set_current_page(0) |
3912 | - self.vbox.set_border_width(0) |
3913 | - self.vbox.pack_start(notebook, True, True) |
3914 | - self.vbox.show_all() |
3915 | - self.action_area.set_border_width(12) |
3916 | + content_area = self.get_content_area() |
3917 | + content_area.set_border_width(0) |
3918 | + content_area.pack_start(notebook, True, True, 0) |
3919 | + content_area.show_all() |
3920 | + self.get_action_area().set_border_width(12) |
3921 | |
3922 | def _create_pages(self): |
3923 | return [("Identity", IdentityPage(self.config)), |
3924 | @@ -70,7 +64,8 @@ |
3925 | def close(self, widget=None): |
3926 | self.window.destroy() |
3927 | |
3928 | -class BranchPreferencesWindow(gtk.Dialog): |
3929 | + |
3930 | +class BranchPreferencesWindow(Gtk.Dialog): |
3931 | """Displays global preferences windows.""" |
3932 | def __init__(self, config=None): |
3933 | super(BranchPreferencesWindow, self).__init__(config) |
3934 | |
3935 | === modified file 'preferences/identity.py' |
3936 | --- preferences/identity.py 2011-03-14 20:12:19 +0000 |
3937 | +++ preferences/identity.py 2011-09-08 03:12:25 +0000 |
3938 | @@ -14,78 +14,88 @@ |
3939 | # along with this program; if not, write to the Free Software |
3940 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3941 | |
3942 | -try: |
3943 | - import pygtk |
3944 | - pygtk.require("2.0") |
3945 | -except: |
3946 | - pass |
3947 | - |
3948 | -import gtk |
3949 | - |
3950 | - |
3951 | -class IdentityPage(gtk.Table): |
3952 | +from gi.repository import Gtk |
3953 | + |
3954 | + |
3955 | +class IdentityPage(Gtk.Table): |
3956 | |
3957 | def __init__(self, config): |
3958 | self.config = config |
3959 | - gtk.Table.__init__(self, rows=4, columns=2) |
3960 | + super(IdentityPage, self).__init__(rows=4, columns=2) |
3961 | self.set_border_width(12) |
3962 | self.set_row_spacings(6) |
3963 | self.set_col_spacings(6) |
3964 | |
3965 | - align = gtk.Alignment(0.0, 0.5) |
3966 | - label = gtk.Label() |
3967 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
3968 | + label = Gtk.Label() |
3969 | label.set_markup("E-Mail:") |
3970 | align.add(label) |
3971 | - self.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL) |
3972 | + self.attach( |
3973 | + align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3974 | |
3975 | - self.username = gtk.Entry() |
3976 | + self.username = Gtk.Entry() |
3977 | self.username.set_text(self.config.username()) |
3978 | - self.attach(self.username, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL) |
3979 | + self.attach( |
3980 | + self.username, 1, 2, 0, 1, |
3981 | + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, |
3982 | + Gtk.AttachOptions.FILL) |
3983 | |
3984 | - align = gtk.Alignment(0.0, 0.5) |
3985 | - label = gtk.Label() |
3986 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
3987 | + label = Gtk.Label() |
3988 | label.set_markup("GPG signing command:") |
3989 | align.add(label) |
3990 | - self.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL) |
3991 | + self.attach( |
3992 | + align, 0, 1, 1, 2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
3993 | |
3994 | - self.email = gtk.Entry() |
3995 | + self.email = Gtk.Entry() |
3996 | self.email.set_text(self.config.gpg_signing_command()) |
3997 | - self.attach(self.email, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL) |
3998 | + self.attach( |
3999 | + self.email, 1, 2, 1, 2, |
4000 | + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, |
4001 | + Gtk.AttachOptions.FILL) |
4002 | |
4003 | - align = gtk.Alignment(0.0, 0.1) |
4004 | - label = gtk.Label() |
4005 | + align = Gtk.Alignment.new(0.0, 0.1, 0.0, 0.0) |
4006 | + label = Gtk.Label() |
4007 | label.set_markup("Check GPG Signatures:") |
4008 | align.add(label) |
4009 | - self.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL) |
4010 | + self.attach( |
4011 | + align, 0, 1, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4012 | |
4013 | - sigvals = gtk.VBox() |
4014 | - self.check_sigs_if_possible = gtk.RadioButton(None, |
4015 | - "_Check if possible") |
4016 | - sigvals.pack_start(self.check_sigs_if_possible) |
4017 | - self.check_sigs_always = gtk.RadioButton(self.check_sigs_if_possible, |
4018 | - "Check _always") |
4019 | - sigvals.pack_start(self.check_sigs_always) |
4020 | - self.check_sigs_never = gtk.RadioButton(self.check_sigs_if_possible, |
4021 | - "Check _never") |
4022 | - sigvals.pack_start(self.check_sigs_never) |
4023 | + sigvals = Gtk.VBox() |
4024 | + self.check_sigs_if_possible = Gtk.RadioButton.new_with_label( |
4025 | + None, "_Check if possible") |
4026 | + sigvals.pack_start(self.check_sigs_if_possible, True, True, 0) |
4027 | + self.check_sigs_always = Gtk.RadioButton.new_with_label_from_widget( |
4028 | + self.check_sigs_if_possible, "Check _always") |
4029 | + sigvals.pack_start(self.check_sigs_always, True, True, 0) |
4030 | + self.check_sigs_never = Gtk.RadioButton.new_with_label_from_widget( |
4031 | + self.check_sigs_if_possible, "Check _never") |
4032 | + sigvals.pack_start(self.check_sigs_never, True, True, 0) |
4033 | # FIXME: Set default |
4034 | - self.attach(sigvals, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4035 | + self.attach( |
4036 | + sigvals, 1, 2, 2, 3, |
4037 | + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, |
4038 | + Gtk.AttachOptions.FILL) |
4039 | |
4040 | - align = gtk.Alignment(0.0, 0.1) |
4041 | - label = gtk.Label() |
4042 | + align = Gtk.Alignment.new(0.0, 0.1, 0.0, 0.0) |
4043 | + label = Gtk.Label() |
4044 | label.set_markup("Create GPG Signatures:") |
4045 | align.add(label) |
4046 | - self.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL) |
4047 | + self.attach( |
4048 | + align, 0, 1, 3, 4, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4049 | |
4050 | - create_sigs = gtk.VBox() |
4051 | - self.create_sigs_when_required = gtk.RadioButton(None, |
4052 | - "Sign When _Required") |
4053 | - create_sigs.pack_start(self.create_sigs_when_required) |
4054 | - self.create_sigs_always = gtk.RadioButton( |
4055 | + create_sigs = Gtk.VBox() |
4056 | + self.create_sigs_when_required = Gtk.RadioButton.new_with_label( |
4057 | + None, "Sign When _Required") |
4058 | + create_sigs.pack_start(self.create_sigs_when_required, True, True, 0) |
4059 | + self.create_sigs_always = Gtk.RadioButton.new_with_label_from_widget( |
4060 | self.create_sigs_when_required, "Sign _Always") |
4061 | - create_sigs.pack_start(self.create_sigs_always) |
4062 | - self.create_sigs_never = gtk.RadioButton( |
4063 | + create_sigs.pack_start(self.create_sigs_always, True, True, 0) |
4064 | + self.create_sigs_never = Gtk.RadioButton.new_with_label_from_widget( |
4065 | self.create_sigs_when_required, "Sign _Never") |
4066 | - create_sigs.pack_start(self.create_sigs_never) |
4067 | + create_sigs.pack_start(self.create_sigs_never, True, True, 0) |
4068 | # FIXME: Set default |
4069 | - self.attach(create_sigs, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4070 | + self.attach( |
4071 | + create_sigs, 1, 2, 3, 4, |
4072 | + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, |
4073 | + Gtk.AttachOptions.FILL) |
4074 | |
4075 | === modified file 'preferences/notifications.py' |
4076 | --- preferences/notifications.py 2011-03-14 20:12:19 +0000 |
4077 | +++ preferences/notifications.py 2011-09-08 03:12:25 +0000 |
4078 | @@ -14,13 +14,7 @@ |
4079 | # along with this program; if not, write to the Free Software |
4080 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4081 | |
4082 | -try: |
4083 | - import pygtk |
4084 | - pygtk.require("2.0") |
4085 | -except: |
4086 | - pass |
4087 | - |
4088 | -import gtk |
4089 | +from gi.repository import Gtk |
4090 | |
4091 | import bzrlib.plugins.gtk |
4092 | from bzrlib.plugins.gtk.notify import ( |
4093 | @@ -36,49 +30,50 @@ |
4094 | return (getattr(bzrlib.plugins, "cia", None) is not None) |
4095 | |
4096 | |
4097 | -class NotificationsPage(gtk.VBox): |
4098 | +class NotificationsPage(Gtk.VBox): |
4099 | |
4100 | def __init__(self, config, homogeneous=False, spacing=6): |
4101 | self.config = config |
4102 | - gtk.VBox.__init__(self, homogeneous=homogeneous, spacing=spacing) |
4103 | + super(NotificationsPage, self).__init__( |
4104 | + homogeneous=homogeneous, spacing=spacing) |
4105 | self.set_spacing(spacing) # The vertical one |
4106 | |
4107 | - lan_frame = gtk.Frame("LAN Notifications") |
4108 | + lan_frame = Gtk.Frame(label="LAN Notifications") |
4109 | |
4110 | - lan_vbox = gtk.VBox() |
4111 | + lan_vbox = Gtk.VBox() |
4112 | lan_frame.add(lan_vbox) |
4113 | |
4114 | - self.gateway_to_lan = gtk.CheckButton("_Gateway to LAN") |
4115 | - lan_vbox.pack_start(self.gateway_to_lan) |
4116 | + self.gateway_to_lan = Gtk.CheckButton("_Gateway to LAN") |
4117 | + lan_vbox.pack_start(self.gateway_to_lan, False, False, 0) |
4118 | self.gateway_to_lan.set_sensitive(has_dbus()) |
4119 | |
4120 | - self.announce_on_lan = gtk.CheckButton("_Announce on LAN") |
4121 | - lan_vbox.pack_start(self.announce_on_lan) |
4122 | + self.announce_on_lan = Gtk.CheckButton("_Announce on LAN") |
4123 | + lan_vbox.pack_start(self.announce_on_lan, False, False, 0) |
4124 | self.announce_on_lan.set_sensitive(has_avahi()) |
4125 | |
4126 | - self.pack_start(lan_frame) |
4127 | - |
4128 | - email_frame = gtk.Frame("E-mail notifications") |
4129 | - |
4130 | - email_hbox = gtk.HBox() |
4131 | - self.send_email = gtk.CheckButton("Send _E-Mail to") |
4132 | - email_hbox.pack_start(self.send_email) |
4133 | - self.send_email_to = gtk.Entry() |
4134 | - email_hbox.pack_start(self.send_email_to) |
4135 | + self.pack_start(lan_frame, False, False, 0) |
4136 | + |
4137 | + email_frame = Gtk.Frame(label="E-mail notifications") |
4138 | + |
4139 | + email_hbox = Gtk.HBox() |
4140 | + self.send_email = Gtk.CheckButton("Send _E-Mail to") |
4141 | + email_hbox.pack_start(self.send_email, False, False, 0) |
4142 | + self.send_email_to = Gtk.Entry() |
4143 | + email_hbox.pack_start(self.send_email_to, False, False, 0) |
4144 | |
4145 | email_frame.add(email_hbox) |
4146 | email_frame.set_sensitive(has_email()) |
4147 | |
4148 | - self.pack_start(email_frame) |
4149 | - |
4150 | - cia_frame = gtk.Frame("CIA notifications") |
4151 | - |
4152 | - cia_user_hbox = gtk.HBox() |
4153 | - cia_user_hbox.pack_start(gtk.Label("Author name")) |
4154 | - self.cia_user = gtk.Entry() |
4155 | - cia_user_hbox.pack_start(self.cia_user) |
4156 | + self.pack_start(email_frame, False, False, 0) |
4157 | + |
4158 | + cia_frame = Gtk.Frame(label="CIA notifications") |
4159 | + |
4160 | + cia_user_hbox = Gtk.HBox() |
4161 | + cia_user_hbox.pack_start(Gtk.Label("Author name"), False, False, 0) |
4162 | + self.cia_user = Gtk.Entry() |
4163 | + cia_user_hbox.pack_start(self.cia_user, False, False, 0) |
4164 | |
4165 | cia_frame.add(cia_user_hbox) |
4166 | cia_frame.set_sensitive(has_cia()) |
4167 | |
4168 | - self.pack_start(cia_frame) |
4169 | + self.pack_start(cia_frame, False, False, 0) |
4170 | |
4171 | === modified file 'preferences/plugins.py' |
4172 | --- preferences/plugins.py 2011-03-14 20:12:19 +0000 |
4173 | +++ preferences/plugins.py 2011-09-08 03:12:25 +0000 |
4174 | @@ -14,31 +14,26 @@ |
4175 | # along with this program; if not, write to the Free Software |
4176 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4177 | |
4178 | -try: |
4179 | - import pygtk |
4180 | - pygtk.require("2.0") |
4181 | -except: |
4182 | - pass |
4183 | - |
4184 | -import gtk |
4185 | - |
4186 | - |
4187 | -class PluginsPage(gtk.VPaned): |
4188 | +from gi.repository import Gtk |
4189 | + |
4190 | + |
4191 | +class PluginsPage(Gtk.VPaned): |
4192 | |
4193 | def __init__(self): |
4194 | - gtk.VPaned.__init__(self) |
4195 | + super(PluginsPage, self).__init__() |
4196 | self.set_border_width(12) |
4197 | self.set_position(216) |
4198 | |
4199 | - scrolledwindow = gtk.ScrolledWindow() |
4200 | - scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
4201 | - scrolledwindow.set_shadow_type(gtk.SHADOW_IN) |
4202 | - self.model = gtk.ListStore(str, str) |
4203 | - treeview = gtk.TreeView() |
4204 | + scrolledwindow = Gtk.ScrolledWindow() |
4205 | + scrolledwindow.set_policy( |
4206 | + Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
4207 | + scrolledwindow.set_shadow_type(Gtk.ShadowType.IN) |
4208 | + self.model = Gtk.ListStore(str, str) |
4209 | + treeview = Gtk.TreeView() |
4210 | scrolledwindow.add(treeview) |
4211 | self.pack1(scrolledwindow, resize=True, shrink=False) |
4212 | |
4213 | - self.table = gtk.Table(columns=2) |
4214 | + self.table = Gtk.Table(columns=2) |
4215 | self.table.set_border_width(12) |
4216 | self.table.set_row_spacings(6) |
4217 | self.table.set_col_spacings(6) |
4218 | @@ -46,16 +41,17 @@ |
4219 | treeview.set_headers_visible(False) |
4220 | treeview.set_model(self.model) |
4221 | treeview.connect("row-activated", self.row_selected) |
4222 | + treeview.connect("cursor-changed", self.row_selected) |
4223 | |
4224 | - cell = gtk.CellRendererText() |
4225 | - column = gtk.TreeViewColumn() |
4226 | - column.pack_start(cell, expand=True) |
4227 | + cell = Gtk.CellRendererText() |
4228 | + column = Gtk.TreeViewColumn() |
4229 | + column.pack_start(cell, True) |
4230 | column.add_attribute(cell, "text", 0) |
4231 | treeview.append_column(column) |
4232 | |
4233 | - cell = gtk.CellRendererText() |
4234 | - column = gtk.TreeViewColumn() |
4235 | - column.pack_start(cell, expand=True) |
4236 | + cell = Gtk.CellRendererText() |
4237 | + column = Gtk.TreeViewColumn() |
4238 | + column.pack_start(cell, True) |
4239 | column.add_attribute(cell, "text", 1) |
4240 | treeview.append_column(column) |
4241 | |
4242 | @@ -66,13 +62,16 @@ |
4243 | for name in plugin_names: |
4244 | self.model.append([name, getattr(plugins[name], '__file__', None)]) |
4245 | |
4246 | - scrolledwindow = gtk.ScrolledWindow() |
4247 | - scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
4248 | + scrolledwindow = Gtk.ScrolledWindow() |
4249 | + scrolledwindow.set_policy( |
4250 | + Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
4251 | scrolledwindow.add_with_viewport(self.table) |
4252 | self.pack2(scrolledwindow, resize=False, shrink=True) |
4253 | self.show() |
4254 | |
4255 | - def row_selected(self, tv, path, tvc): |
4256 | + def row_selected(self, tv, path=None, tvc=None): |
4257 | + if path is None: |
4258 | + (path, focus) = tv.get_cursor() |
4259 | import bzrlib |
4260 | p = bzrlib.plugin.plugins()[self.model[path][0]].module |
4261 | from inspect import getdoc |
4262 | @@ -81,45 +80,43 @@ |
4263 | self.table.remove(w) |
4264 | |
4265 | if getattr(p, '__author__', None) is not None: |
4266 | - align = gtk.Alignment(0.0, 0.5) |
4267 | - label = gtk.Label() |
4268 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4269 | + label = Gtk.Label() |
4270 | label.set_markup("<b>Author:</b>") |
4271 | align.add(label) |
4272 | - self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL) |
4273 | + self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4274 | align.show() |
4275 | label.show() |
4276 | |
4277 | - align = gtk.Alignment(0.0, 0.5) |
4278 | - author = gtk.Label() |
4279 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4280 | + author = Gtk.Label() |
4281 | author.set_text(p.__author__) |
4282 | author.set_selectable(True) |
4283 | align.add(author) |
4284 | - self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4285 | + self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4286 | |
4287 | if getattr(p, '__version__', None) is not None: |
4288 | - align = gtk.Alignment(0.0, 0.5) |
4289 | - label = gtk.Label() |
4290 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4291 | + label = Gtk.Label() |
4292 | label.set_markup("<b>Version:</b>") |
4293 | align.add(label) |
4294 | - self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL) |
4295 | + self.table.attach(align, 0, 1, 0, 1, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4296 | align.show() |
4297 | label.show() |
4298 | |
4299 | - align = gtk.Alignment(0.0, 0.5) |
4300 | - author = gtk.Label() |
4301 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4302 | + author = Gtk.Label() |
4303 | author.set_text(p.__version__) |
4304 | author.set_selectable(True) |
4305 | align.add(author) |
4306 | - self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4307 | + self.table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4308 | |
4309 | if getdoc(p) is not None: |
4310 | - align = gtk.Alignment(0.0, 0.5) |
4311 | - description = gtk.Label() |
4312 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4313 | + description = Gtk.Label() |
4314 | description.set_text(getdoc(p)) |
4315 | description.set_selectable(True) |
4316 | align.add(description) |
4317 | - self.table.attach(align, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4318 | + self.table.attach(align, 0, 2, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4319 | |
4320 | self.table.show_all() |
4321 | - |
4322 | - |
4323 | |
4324 | === modified file 'push.py' |
4325 | --- push.py 2011-04-10 18:44:39 +0000 |
4326 | +++ push.py 2011-09-08 03:12:25 +0000 |
4327 | @@ -15,13 +15,8 @@ |
4328 | # along with this program; if not, write to the Free Software |
4329 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4330 | |
4331 | -try: |
4332 | - import pygtk |
4333 | - pygtk.require("2.0") |
4334 | -except: |
4335 | - pass |
4336 | - |
4337 | -import gtk |
4338 | +from gi.repository import GObject |
4339 | +from gi.repository import Gtk |
4340 | |
4341 | from errors import show_bzr_error |
4342 | |
4343 | @@ -36,15 +31,15 @@ |
4344 | from bzrlib.plugins.gtk.i18n import _i18n |
4345 | |
4346 | |
4347 | -class PushDialog(gtk.Dialog): |
4348 | +class PushDialog(Gtk.Dialog): |
4349 | """New implementation of the Push dialog.""" |
4350 | |
4351 | def __init__(self, repository, revid, branch=None, parent=None): |
4352 | """Initialize the Push dialog. """ |
4353 | - gtk.Dialog.__init__(self, title="Push", |
4354 | - parent=parent, |
4355 | - flags=0, |
4356 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
4357 | + super(PushDialog, self).__init__( |
4358 | + title="Push", parent=parent, flags=0, |
4359 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
4360 | + |
4361 | |
4362 | # Get arguments |
4363 | self.repository = repository |
4364 | @@ -52,10 +47,10 @@ |
4365 | self.branch = branch |
4366 | |
4367 | # Create the widgets |
4368 | - self._label_location = gtk.Label(_i18n("Location:")) |
4369 | - self._combo = gtk.ComboBoxEntry() |
4370 | - self._button_push = gtk.Button(_i18n("_Push"), use_underline=True) |
4371 | - self._hbox_location = gtk.HBox() |
4372 | + self._label_location = Gtk.Label(label=_i18n("Location:")) |
4373 | + self._combo = Gtk.ComboBox.new_with_entry() |
4374 | + self._button_push = Gtk.Button(_i18n("_Push"), use_underline=True) |
4375 | + self._hbox_location = Gtk.HBox() |
4376 | |
4377 | # Set callbacks |
4378 | self._button_push.connect('clicked', self._on_push_clicked) |
4379 | @@ -63,16 +58,18 @@ |
4380 | # Set properties |
4381 | self._label_location.set_alignment(0, 0.5) |
4382 | self._hbox_location.set_spacing(3) |
4383 | - self.vbox.set_spacing(3) |
4384 | + self.get_content_area().set_spacing(3) |
4385 | |
4386 | # Pack widgets |
4387 | - self._hbox_location.pack_start(self._label_location, False, False) |
4388 | - self._hbox_location.pack_start(self._combo, True, True) |
4389 | - self.vbox.pack_start(self._hbox_location) |
4390 | - self.action_area.pack_end(self._button_push) |
4391 | + self._hbox_location.pack_start( |
4392 | + self._label_location, False, False, 0) |
4393 | + self._hbox_location.pack_start(self._combo, True, True, 0) |
4394 | + self.get_content_area().pack_start(self._hbox_location, True, True, 0) |
4395 | + # XXX sinzui 2011-08-12: maybe False, False, 0 |
4396 | + self.get_action_area().pack_end(self._button_push, True, True, 0) |
4397 | |
4398 | # Show the dialog |
4399 | - self.vbox.show_all() |
4400 | + self.get_content_area().show_all() |
4401 | |
4402 | # Build location history |
4403 | self._history = UrlHistory(self.branch.get_config(), 'push_history') |
4404 | @@ -80,11 +77,11 @@ |
4405 | |
4406 | def _build_history(self): |
4407 | """Build up the location history. """ |
4408 | - self._combo_model = gtk.ListStore(str) |
4409 | + self._combo_model = Gtk.ListStore(str) |
4410 | for item in self._history.get_entries(): |
4411 | self._combo_model.append([ item ]) |
4412 | self._combo.set_model(self._combo_model) |
4413 | - self._combo.set_text_column(0) |
4414 | + self._combo.set_entry_text_column(0) |
4415 | |
4416 | if self.branch is not None: |
4417 | location = self.branch.get_push_location() |
4418 | @@ -102,7 +99,7 @@ |
4419 | except errors.DivergedBranches: |
4420 | response = question_dialog(_i18n('Branches have been diverged'), |
4421 | _i18n('You cannot push if branches have diverged.\nOverwrite?')) |
4422 | - if response == gtk.RESPONSE_YES: |
4423 | + if response == Gtk.ResponseType.YES: |
4424 | revs = do_push(self.branch, location=location, overwrite=True) |
4425 | |
4426 | if self.branch is not None and self.branch.get_push_location() is None: |
4427 | @@ -112,7 +109,7 @@ |
4428 | info_dialog(_i18n('Push successful'), |
4429 | _i18n("%d revision(s) pushed.") % revs) |
4430 | |
4431 | - self.response(gtk.RESPONSE_OK) |
4432 | + self.response(Gtk.ResponseType.OK) |
4433 | |
4434 | |
4435 | def do_push(br_from, location, overwrite): |
4436 | @@ -143,7 +140,7 @@ |
4437 | except errors.NoSuchFile: |
4438 | response = question_dialog(_i18n('Non existing parent directory'), |
4439 | _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location) |
4440 | - if response == gtk.RESPONSE_OK: |
4441 | + if response == Gtk.ResponseType.OK: |
4442 | transport.create_prefix() |
4443 | else: |
4444 | return |
4445 | |
4446 | === modified file 'revbrowser.py' |
4447 | --- revbrowser.py 2011-04-10 18:44:39 +0000 |
4448 | +++ revbrowser.py 2011-09-08 03:12:25 +0000 |
4449 | @@ -14,32 +14,25 @@ |
4450 | # along with this program; if not, write to the Free Software |
4451 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4452 | |
4453 | -try: |
4454 | - import pygtk |
4455 | - pygtk.require("2.0") |
4456 | -except: |
4457 | - pass |
4458 | - |
4459 | -import gobject |
4460 | -import gtk |
4461 | +from gi.repository import Gtk |
4462 | |
4463 | from bzrlib.plugins.gtk.branchview.treeview import TreeView |
4464 | from bzrlib.plugins.gtk.i18n import _i18n |
4465 | |
4466 | |
4467 | -class RevisionBrowser(gtk.Dialog): |
4468 | +class RevisionBrowser(Gtk.Dialog): |
4469 | """ Revision Browser main window. """ |
4470 | def __init__(self, branch, parent=None): |
4471 | - gtk.Dialog.__init__(self, title="Revision Browser - Olive", |
4472 | - parent=parent, |
4473 | - flags=gtk.DIALOG_MODAL, |
4474 | - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) |
4475 | + super(RevisionBrowser, self).__init__( |
4476 | + title="Revision Browser - Olive", parent=parent, |
4477 | + flags=Gtk.DialogFlags.MODAL, |
4478 | + buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) |
4479 | |
4480 | # Get arguments |
4481 | self.branch = branch |
4482 | |
4483 | # Create the widgets |
4484 | - self._button_select = gtk.Button(_i18n("_Select"), use_underline=True) |
4485 | + self._button_select = Gtk.Button(_i18n("_Select"), use_underline=True) |
4486 | start_revs = [branch.last_revision(),] |
4487 | self.treeview = TreeView(branch, start_revs, None) |
4488 | |
4489 | @@ -50,15 +43,15 @@ |
4490 | |
4491 | # Set properties |
4492 | self.set_default_size(600, 400) |
4493 | - self.vbox.set_spacing(3) |
4494 | + self.get_content_area().set_spacing(3) |
4495 | self.treeview.set_property('graph-column-visible', False) |
4496 | self.treeview.set_property('date-column-visible', True) |
4497 | self.treeview.set_property('mainline-only', True) |
4498 | |
4499 | # Construct the dialog |
4500 | - self.action_area.pack_end(self._button_select) |
4501 | + self.action_area.pack_end(self._button_select, False, False, 0) |
4502 | |
4503 | - self.vbox.pack_start(self.treeview, True, True) |
4504 | + self.get_content_area().pack_start(self.treeview, True, True, 0) |
4505 | |
4506 | # Show the dialog |
4507 | self.show_all() |
4508 | @@ -74,4 +67,4 @@ |
4509 | self.selected_revno = self.treeview.get_property('revision-number') |
4510 | self.selected_revid = \ |
4511 | self.treeview.get_property('revision').revision_id |
4512 | - self.response(gtk.RESPONSE_OK) |
4513 | + self.response(Gtk.ResponseType.OK) |
4514 | |
4515 | === modified file 'revidbox.py' |
4516 | --- revidbox.py 2011-03-14 20:12:19 +0000 |
4517 | +++ revidbox.py 2011-09-08 03:12:25 +0000 |
4518 | @@ -15,23 +15,17 @@ |
4519 | # along with this program; if not, write to the Free Software |
4520 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4521 | |
4522 | -try: |
4523 | - import pygtk |
4524 | - pygtk.require("2.0") |
4525 | -except: |
4526 | - pass |
4527 | - |
4528 | -import gtk |
4529 | - |
4530 | -class RevisionSelectionBox(gtk.HBox): |
4531 | +from gi.repository import Gtk |
4532 | + |
4533 | +class RevisionSelectionBox(Gtk.HBox): |
4534 | |
4535 | def __init__(self, branch): |
4536 | super(RevisionSelectionBox, self).__init__() |
4537 | self._branch = branch |
4538 | - self._entry_revid = gtk.Entry() |
4539 | - self._button_revid = gtk.Button('') |
4540 | - self._button_revid.set_image(gtk.image_new_from_stock( |
4541 | - gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)) |
4542 | + self._entry_revid = Gtk.Entry() |
4543 | + self._button_revid = Gtk.Button('') |
4544 | + self._button_revid.set_image(Gtk.Image.new_from_stock( |
4545 | + Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON)) |
4546 | self.pack_start(self._entry_revid, True, True) |
4547 | self.pack_start(self._button_revid, False, False) |
4548 | |
4549 | @@ -45,10 +39,10 @@ |
4550 | # JRV 20070715 |
4551 | revb = RevisionBrowser(self._branch) |
4552 | response = revb.run() |
4553 | - if response != gtk.RESPONSE_NONE: |
4554 | + if response != Gtk.ResponseType.NONE: |
4555 | revb.hide() |
4556 | |
4557 | - if response == gtk.RESPONSE_OK: |
4558 | + if response == Gtk.ResponseType.OK: |
4559 | if revb.selected_revno is not None: |
4560 | self._entry_revid.set_text(revb.selected_revid) |
4561 | |
4562 | |
4563 | === modified file 'revisionmenu.py' |
4564 | --- revisionmenu.py 2011-03-14 20:12:19 +0000 |
4565 | +++ revisionmenu.py 2011-09-08 03:12:25 +0000 |
4566 | @@ -15,24 +15,18 @@ |
4567 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4568 | """Simple popup menu for revisions.""" |
4569 | |
4570 | -try: |
4571 | - import pygtk |
4572 | - pygtk.require("2.0") |
4573 | -except: |
4574 | - pass |
4575 | - |
4576 | -import gtk |
4577 | -import gobject |
4578 | +from gi.repository import Gtk |
4579 | +from gi.repository import GObject |
4580 | from bzrlib import ui |
4581 | from bzrlib.revision import NULL_REVISION |
4582 | |
4583 | -class RevisionMenu(gtk.Menu): |
4584 | +class RevisionMenu(Gtk.Menu): |
4585 | |
4586 | __gsignals__ = { |
4587 | 'tag-added': ( |
4588 | - gobject.SIGNAL_RUN_FIRST, |
4589 | - gobject.TYPE_NONE, |
4590 | - (gobject.TYPE_STRING, gobject.TYPE_STRING) |
4591 | + GObject.SignalFlags.RUN_FIRST, |
4592 | + None, |
4593 | + (GObject.TYPE_STRING, GObject.TYPE_STRING) |
4594 | ) |
4595 | } |
4596 | |
4597 | @@ -53,28 +47,29 @@ |
4598 | |
4599 | def create_items(self): |
4600 | if len(self.revids) == 1: |
4601 | - item = gtk.MenuItem("View _Changes") |
4602 | + item = Gtk.MenuItem.new_with_mnemonic("View _Changes") |
4603 | item.connect('activate', self.show_diff) |
4604 | self.append(item) |
4605 | |
4606 | - item = gtk.MenuItem("_Push") |
4607 | + item = Gtk.MenuItem.new_with_mnemonic("_Push") |
4608 | item.connect('activate', self.show_push) |
4609 | self.append(item) |
4610 | |
4611 | - item = gtk.MenuItem("_Tag Revision") |
4612 | + item = Gtk.MenuItem.new_with_mnemonic("_Tag Revision") |
4613 | item.connect('activate', self.show_tag) |
4614 | self.append(item) |
4615 | |
4616 | - item = gtk.MenuItem("_Merge Directive") |
4617 | + item = Gtk.MenuItem.new_with_mnemonic("_Merge Directive") |
4618 | item.connect('activate', self.store_merge_directive) |
4619 | # FIXME: self.append(item) |
4620 | |
4621 | - item = gtk.MenuItem("_Send Merge Directive") |
4622 | + item = Gtk.MenuItem.new_with_mnemonic("_Send Merge Directive") |
4623 | item.connect('activate', self.send_merge_directive) |
4624 | self.append(item) |
4625 | |
4626 | if self.wt: |
4627 | - item = gtk.MenuItem("_Revert to this revision") |
4628 | + item = Gtk.MenuItem.new_with_mnemonic( |
4629 | + "_Revert to this revision") |
4630 | item.connect('activate', self.revert) |
4631 | self.append(item) |
4632 | |
4633 | @@ -89,7 +84,7 @@ |
4634 | from bzrlib.plugins.gtk.mergedirective import SendMergeDirectiveDialog |
4635 | from cStringIO import StringIO |
4636 | window = SendMergeDirectiveDialog(self.branch, self.revids[0]) |
4637 | - if window.run() == gtk.RESPONSE_OK: |
4638 | + if window.run() == Gtk.ResponseType.OK: |
4639 | outf = StringIO() |
4640 | outf.writelines(window.get_merge_directive().to_lines()) |
4641 | mail_client = self.branch.get_config().get_mail_client() |
4642 | @@ -115,7 +110,7 @@ |
4643 | dialog = PushDialog(self.repository, self.revids[0], self.branch) |
4644 | response = dialog.run() |
4645 | |
4646 | - if response != gtk.RESPONSE_NONE: |
4647 | + if response != Gtk.ResponseType.NONE: |
4648 | dialog.destroy() |
4649 | |
4650 | def show_tag(self, item): |
4651 | @@ -123,10 +118,10 @@ |
4652 | dialog = AddTagDialog(self.repository, self.revids[0], self.branch) |
4653 | response = dialog.run() |
4654 | |
4655 | - if response != gtk.RESPONSE_NONE: |
4656 | + if response != Gtk.ResponseType.NONE: |
4657 | dialog.hide() |
4658 | |
4659 | - if response == gtk.RESPONSE_OK: |
4660 | + if response == Gtk.ResponseType.OK: |
4661 | self.emit('tag-added', dialog.tagname, dialog._revid) |
4662 | |
4663 | dialog.destroy() |
4664 | |
4665 | === modified file 'revisionview.py' |
4666 | --- revisionview.py 2011-03-14 20:12:19 +0000 |
4667 | +++ revisionview.py 2011-09-08 03:12:25 +0000 |
4668 | @@ -15,11 +15,9 @@ |
4669 | # along with this program; if not, write to the Free Software |
4670 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4671 | |
4672 | -import pygtk |
4673 | -pygtk.require("2.0") |
4674 | -import gtk |
4675 | -import pango |
4676 | -import gobject |
4677 | +from gi.repository import Gtk |
4678 | +from gi.repository import Pango |
4679 | +from gi.repository import GObject |
4680 | import webbrowser |
4681 | |
4682 | from bzrlib import trace |
4683 | @@ -53,34 +51,31 @@ |
4684 | webbrowser._tryorder.insert(0, '%s "%%s"' % cmd) |
4685 | webbrowser.open(uri) |
4686 | |
4687 | -if getattr(gtk, 'link_button_set_uri_hook', None) is not None: |
4688 | - # Not available before PyGtk-2.10 |
4689 | - gtk.link_button_set_uri_hook(_open_link) |
4690 | |
4691 | -class BugsTab(gtk.VBox): |
4692 | +class BugsTab(Gtk.VBox): |
4693 | |
4694 | def __init__(self): |
4695 | - super(BugsTab, self).__init__(False, 6) |
4696 | + super(BugsTab, self).__init__(homogeneous=False, spacing=6) |
4697 | |
4698 | - table = gtk.Table(rows=2, columns=2) |
4699 | + table = Gtk.Table(rows=2, columns=2) |
4700 | |
4701 | table.set_row_spacings(6) |
4702 | table.set_col_spacing(0, 16) |
4703 | |
4704 | - image = gtk.Image() |
4705 | + image = Gtk.Image() |
4706 | image.set_from_file(icon_path("bug.png")) |
4707 | - table.attach(image, 0, 1, 0, 1, gtk.FILL) |
4708 | + table.attach(image, 0, 1, 0, 1, Gtk.AttachOptions.FILL) |
4709 | |
4710 | - align = gtk.Alignment(0.0, 0.1) |
4711 | - self.label = gtk.Label() |
4712 | + align = Gtk.Alignment.new(0.0, 0.1, 0, 0) |
4713 | + self.label = Gtk.Label() |
4714 | align.add(self.label) |
4715 | - table.attach(align, 1, 2, 0, 1, gtk.FILL) |
4716 | + table.attach(align, 1, 2, 0, 1, Gtk.AttachOptions.FILL) |
4717 | |
4718 | treeview = self.construct_treeview() |
4719 | - table.attach(treeview, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND) |
4720 | + table.attach(treeview, 1, 2, 1, 2, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND) |
4721 | |
4722 | self.set_border_width(6) |
4723 | - self.pack_start(table, expand=False) |
4724 | + self.pack_start(table, False, True, 0) |
4725 | |
4726 | self.clear() |
4727 | self.show_all() |
4728 | @@ -108,18 +103,18 @@ |
4729 | "%d %s." % (self.num_bugs, label)) |
4730 | |
4731 | def construct_treeview(self): |
4732 | - self.bugs = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) |
4733 | - self.treeview = gtk.TreeView(self.bugs) |
4734 | + self.bugs = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) |
4735 | + self.treeview = Gtk.TreeView(model=self.bugs) |
4736 | self.treeview.set_headers_visible(False) |
4737 | |
4738 | - uri_column = gtk.TreeViewColumn('Bug URI', gtk.CellRendererText(), text=0) |
4739 | + uri_column = Gtk.TreeViewColumn('Bug URI', Gtk.CellRendererText(), text=0) |
4740 | self.treeview.append_column(uri_column) |
4741 | |
4742 | self.treeview.connect('row-activated', self.on_row_activated) |
4743 | |
4744 | - win = gtk.ScrolledWindow() |
4745 | - win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
4746 | - win.set_shadow_type(gtk.SHADOW_IN) |
4747 | + win = Gtk.ScrolledWindow() |
4748 | + win.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) |
4749 | + win.set_shadow_type(Gtk.ShadowType.IN) |
4750 | win.add(self.treeview) |
4751 | |
4752 | return win |
4753 | @@ -144,65 +139,65 @@ |
4754 | _open_link(self, uri) |
4755 | |
4756 | |
4757 | -class SignatureTab(gtk.VBox): |
4758 | +class SignatureTab(Gtk.VBox): |
4759 | |
4760 | def __init__(self, repository): |
4761 | self.key = None |
4762 | self.revision = None |
4763 | self.repository = repository |
4764 | |
4765 | - super(SignatureTab, self).__init__(False, 6) |
4766 | - signature_box = gtk.Table(rows=3, columns=3) |
4767 | + super(SignatureTab, self).__init__(homogeneous=False, spacing=6) |
4768 | + signature_box = Gtk.Table(rows=3, columns=3) |
4769 | signature_box.set_col_spacing(0, 16) |
4770 | signature_box.set_col_spacing(1, 12) |
4771 | signature_box.set_row_spacings(6) |
4772 | |
4773 | - self.signature_image = gtk.Image() |
4774 | - signature_box.attach(self.signature_image, 0, 1, 0, 1, gtk.FILL) |
4775 | + self.signature_image = Gtk.Image() |
4776 | + signature_box.attach(self.signature_image, 0, 1, 0, 1, Gtk.AttachOptions.FILL) |
4777 | |
4778 | - align = gtk.Alignment(0.0, 0.1) |
4779 | - self.signature_label = gtk.Label() |
4780 | + align = Gtk.Alignment.new(0.0, 0.1, 0.0, 0.0) |
4781 | + self.signature_label = Gtk.Label() |
4782 | align.add(self.signature_label) |
4783 | - signature_box.attach(align, 1, 3, 0, 1, gtk.FILL) |
4784 | + signature_box.attach(align, 1, 3, 0, 1, Gtk.AttachOptions.FILL) |
4785 | |
4786 | - align = gtk.Alignment(0.0, 0.5) |
4787 | - self.signature_key_id_label = gtk.Label() |
4788 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4789 | + self.signature_key_id_label = Gtk.Label() |
4790 | self.signature_key_id_label.set_markup("<b>Key Id:</b>") |
4791 | align.add(self.signature_key_id_label) |
4792 | - signature_box.attach(align, 1, 2, 1, 2, gtk.FILL, gtk.FILL) |
4793 | + signature_box.attach(align, 1, 2, 1, 2, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4794 | |
4795 | - align = gtk.Alignment(0.0, 0.5) |
4796 | - self.signature_key_id = gtk.Label() |
4797 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4798 | + self.signature_key_id = Gtk.Label() |
4799 | self.signature_key_id.set_selectable(True) |
4800 | align.add(self.signature_key_id) |
4801 | - signature_box.attach(align, 2, 3, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4802 | + signature_box.attach(align, 2, 3, 1, 2, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4803 | |
4804 | - align = gtk.Alignment(0.0, 0.5) |
4805 | - self.signature_fingerprint_label = gtk.Label() |
4806 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4807 | + self.signature_fingerprint_label = Gtk.Label() |
4808 | self.signature_fingerprint_label.set_markup("<b>Fingerprint:</b>") |
4809 | align.add(self.signature_fingerprint_label) |
4810 | - signature_box.attach(align, 1, 2, 2, 3, gtk.FILL, gtk.FILL) |
4811 | + signature_box.attach(align, 1, 2, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4812 | |
4813 | - align = gtk.Alignment(0.0, 0.5) |
4814 | - self.signature_fingerprint = gtk.Label() |
4815 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4816 | + self.signature_fingerprint = Gtk.Label() |
4817 | self.signature_fingerprint.set_selectable(True) |
4818 | align.add(self.signature_fingerprint) |
4819 | - signature_box.attach(align, 2, 3, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4820 | + signature_box.attach(align, 2, 3, 2, 3, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4821 | |
4822 | - align = gtk.Alignment(0.0, 0.5) |
4823 | - self.signature_trust_label = gtk.Label() |
4824 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4825 | + self.signature_trust_label = Gtk.Label() |
4826 | self.signature_trust_label.set_markup("<b>Trust:</b>") |
4827 | align.add(self.signature_trust_label) |
4828 | - signature_box.attach(align, 1, 2, 3, 4, gtk.FILL, gtk.FILL) |
4829 | + signature_box.attach(align, 1, 2, 3, 4, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4830 | |
4831 | - align = gtk.Alignment(0.0, 0.5) |
4832 | - self.signature_trust = gtk.Label() |
4833 | + align = Gtk.Alignment.new(0.0, 0.5, 0.0, 0.0) |
4834 | + self.signature_trust = Gtk.Label() |
4835 | self.signature_trust.set_selectable(True) |
4836 | align.add(self.signature_trust) |
4837 | - signature_box.attach(align, 2, 3, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL) |
4838 | + signature_box.attach(align, 2, 3, 3, 4, Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4839 | |
4840 | self.set_border_width(6) |
4841 | - self.pack_start(signature_box, expand=False) |
4842 | + self.pack_start(signature_box, False, True, 0) |
4843 | self.show_all() |
4844 | |
4845 | def set_revision(self, revision): |
4846 | @@ -292,7 +287,7 @@ |
4847 | self.signature_trust.set_text('This key is ' + trust_text) |
4848 | |
4849 | |
4850 | -class RevisionView(gtk.Notebook): |
4851 | +class RevisionView(Gtk.Notebook): |
4852 | """ Custom widget for commit log details. |
4853 | |
4854 | A variety of bzr tools may need to implement such a thing. This is a |
4855 | @@ -301,36 +296,36 @@ |
4856 | |
4857 | __gproperties__ = { |
4858 | 'branch': ( |
4859 | - gobject.TYPE_PYOBJECT, |
4860 | + GObject.TYPE_PYOBJECT, |
4861 | 'Branch', |
4862 | 'The branch holding the revision being displayed', |
4863 | - gobject.PARAM_CONSTRUCT_ONLY | gobject.PARAM_WRITABLE |
4864 | + GObject.PARAM_CONSTRUCT_ONLY | GObject.PARAM_WRITABLE |
4865 | ), |
4866 | |
4867 | 'revision': ( |
4868 | - gobject.TYPE_PYOBJECT, |
4869 | + GObject.TYPE_PYOBJECT, |
4870 | 'Revision', |
4871 | 'The revision being displayed', |
4872 | - gobject.PARAM_READWRITE |
4873 | + GObject.PARAM_READWRITE |
4874 | ), |
4875 | |
4876 | 'children': ( |
4877 | - gobject.TYPE_PYOBJECT, |
4878 | + GObject.TYPE_PYOBJECT, |
4879 | 'Children', |
4880 | 'Child revisions', |
4881 | - gobject.PARAM_READWRITE |
4882 | + GObject.PARAM_READWRITE |
4883 | ), |
4884 | |
4885 | 'file-id': ( |
4886 | - gobject.TYPE_PYOBJECT, |
4887 | + GObject.TYPE_PYOBJECT, |
4888 | 'File Id', |
4889 | 'The file id', |
4890 | - gobject.PARAM_READWRITE |
4891 | + GObject.PARAM_READWRITE |
4892 | ) |
4893 | } |
4894 | |
4895 | def __init__(self, branch=None, repository=None): |
4896 | - gtk.Notebook.__init__(self) |
4897 | + super(RevisionView, self).__init__() |
4898 | |
4899 | self._revision = None |
4900 | self._branch = branch |
4901 | @@ -338,6 +333,7 @@ |
4902 | self._repository = branch.repository |
4903 | else: |
4904 | self._repository = repository |
4905 | + self.signature_table = None |
4906 | |
4907 | self._create_general() |
4908 | self._create_relations() |
4909 | @@ -477,6 +473,8 @@ |
4910 | self._add_tags() |
4911 | |
4912 | def _update_signature(self, widget, param): |
4913 | + if not has_seahorse: |
4914 | + return |
4915 | if self.get_current_page() == PAGE_SIGNATURE: |
4916 | self.signature_table.set_revision(self._revision) |
4917 | |
4918 | @@ -491,6 +489,8 @@ |
4919 | self.children_table) |
4920 | |
4921 | def _switch_page_cb(self, notebook, page, page_num): |
4922 | + if not has_seahorse: |
4923 | + return |
4924 | if page_num == PAGE_SIGNATURE: |
4925 | self.signature_table.set_revision(self._revision) |
4926 | |
4927 | @@ -530,212 +530,213 @@ |
4928 | table.resize(max(len(revids), 1), 2) |
4929 | |
4930 | for idx, revid in enumerate(revids): |
4931 | - align = gtk.Alignment(0.0, 0.0, 1, 1) |
4932 | + align = Gtk.Alignment.new(0.0, 0.0, 1, 1) |
4933 | widgets.append(align) |
4934 | table.attach(align, 1, 2, idx, idx + 1, |
4935 | - gtk.EXPAND | gtk.FILL, gtk.FILL) |
4936 | + Gtk.AttachOptions.EXPAND | Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL) |
4937 | align.show() |
4938 | |
4939 | - hbox = gtk.HBox(False, spacing=6) |
4940 | + hbox = Gtk.HBox(homogeneous=False, spacing=6) |
4941 | align.add(hbox) |
4942 | hbox.show() |
4943 | |
4944 | - image = gtk.Image() |
4945 | + image = Gtk.Image() |
4946 | image.set_from_stock( |
4947 | - gtk.STOCK_FIND, gtk.ICON_SIZE_SMALL_TOOLBAR) |
4948 | + Gtk.STOCK_FIND, Gtk.IconSize.SMALL_TOOLBAR) |
4949 | image.show() |
4950 | |
4951 | if self._show_callback is not None: |
4952 | - button = gtk.Button() |
4953 | + button = Gtk.Button() |
4954 | button.add(image) |
4955 | button.connect("clicked", self._show_clicked_cb, |
4956 | self._revision.revision_id, revid) |
4957 | - hbox.pack_start(button, expand=False, fill=True) |
4958 | + hbox.pack_start(button, False, True, 0) |
4959 | button.show() |
4960 | |
4961 | - button = gtk.Button() |
4962 | - revid_label = gtk.Label(str(revid)) |
4963 | - revid_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE) |
4964 | + button = Gtk.Button() |
4965 | + revid_label = Gtk.Label(label=str(revid)) |
4966 | + revid_label.set_ellipsize(Pango.EllipsizeMode.MIDDLE) |
4967 | revid_label.set_alignment(0.0, 0.5) |
4968 | button.add(revid_label) |
4969 | button.connect("clicked", |
4970 | - lambda w, r: self.set_revision(self._repository.get_revision(r)), revid) |
4971 | + lambda w, r: self.set_revision( |
4972 | + self._repository.get_revision(r)), revid) |
4973 | button.set_use_underline(False) |
4974 | - hbox.pack_start(button, expand=True, fill=True) |
4975 | + hbox.pack_start(button, True, True, 0) |
4976 | button.show_all() |
4977 | |
4978 | def _create_general(self): |
4979 | - vbox = gtk.VBox(False, 6) |
4980 | + vbox = Gtk.VBox(homogeneous=False, spacing=6) |
4981 | vbox.set_border_width(6) |
4982 | - vbox.pack_start(self._create_headers(), expand=False, fill=True) |
4983 | - vbox.pack_start(self._create_message_view()) |
4984 | - self.append_page(vbox, tab_label=gtk.Label("General")) |
4985 | + vbox.pack_start(self._create_headers(), False, True, 0) |
4986 | + vbox.pack_start(self._create_message_view(), True, True, 0) |
4987 | + self.append_page(vbox, Gtk.Label(label="General")) |
4988 | vbox.show() |
4989 | |
4990 | def _create_relations(self): |
4991 | - vbox = gtk.VBox(False, 6) |
4992 | + vbox = Gtk.VBox(homogeneous=False, spacing=6) |
4993 | vbox.set_border_width(6) |
4994 | - vbox.pack_start(self._create_parents(), expand=False, fill=True) |
4995 | - vbox.pack_start(self._create_children(), expand=False, fill=True) |
4996 | - self.append_page(vbox, tab_label=gtk.Label("Relations")) |
4997 | + vbox.pack_start(self._create_parents(), False, True, 0) |
4998 | + vbox.pack_start(self._create_children(), False, True, 0) |
4999 | + self.append_page(vbox, Gtk.Label(label="Relations")) |
5000 | vbox.show() |
Hi Curtis,
Thanks again for working on this, much appreciated. :)
Feel free to already push to lp:bzr-gtk/gtk3, which was a branch created earlier for gtk3 porting. I think we should create a lp:bzr-gtk/gtk2 once we merge your work into trunk, for people who are still using older versions of GNOME/GTK.
Trying out your branch on Oneiric I'm getting the following error on the terminal, and no visual graph in the "viz" window:
TypeError: Couldn't find conversion for foreign struct 'cairo.Context'
This seems like a Cairo bug to me - do I need a newer version or something?
Switching to a wide layout crashes here: jelmer/ src/bzr- gtk/gtk3/ viz/branchwin. py", line 571, in _vertical_layout construct_ paned() , True, True, True, 0) python2. 7/dist- packages/ gi/types. py", line 43, in function
Traceback (most recent call last):
File "/home/
self.
File "/usr/lib/
return info.invoke(*args, **kwargs)
TypeError: pack_start() takes exactly 5 arguments (6 given)
gloom crashes with another traceback: jelmer/ src/bzr- gtk/gtk3/ commands. py", line 117, in run jelmer/ src/bzr- gtk/gtk3/ loom.py" , line 42, in __init__ _construct( ) jelmer/ src/bzr- gtk/gtk3/ loom.py" , line 80, in _construct pack_end( self._diff) python2. 7/dist- packages/ gi/types. py", line 43, in function
File "/home/
dialog = LoomDialog(br, tree)
File "/home/
self.
File "/home/
hbox.
File "/usr/lib/
return info.invoke(*args, **kwargs)
TypeError: pack_end() takes exactly 5 arguments (2 given)