Merge lp:~smartgpx/bzr-gtk/workaround_for_lp494140 into lp:bzr-gtk/gtk2

Proposed by David Roberts on 2009-12-09
Status: Merged
Merged at revision: 709
Proposed branch: lp:~smartgpx/bzr-gtk/workaround_for_lp494140
Merge into: lp:bzr-gtk/gtk2
Diff against target: 69 lines (+12/-7)
2 files modified
revisionview.py (+4/-2)
viz/branchwin.py (+8/-5)
To merge this branch: bzr merge lp:~smartgpx/bzr-gtk/workaround_for_lp494140
Reviewer Review Type Date Requested Status
Vincent Ladeuil 2009-12-09 Needs Information on 2010-02-24
Review via email: mp+15855@code.launchpad.net
To post a comment you must log in.
David Roberts (smartgpx) wrote :

This demonstrates a workaround (not truely a 'solution') to lp:494140. With this patch, all gtk tools can be run under xandros, a debian-etch based OS supplied by asus.

It is not clear whether any vital functionality is lost by this patch: the author does not have access to a recent debian install for comparison purposes.

Rejection of this merge proposal in favour of a solution understood and supported by the developers will be a satisfactory outcome.

Vincent Ladeuil (vila) wrote :

With your patch, brz viz issues a warning:

Traceback (most recent call last):
  File "/home/vila/.bazaar/plugins/gtk/viz/branchwin.py", line 416, in _treeselection_changed_cb
    self.prev_button.set_menu(prev_menu)
AttributeError: 'gtk.ToolButton' object has no attribute 'set_menu'

I added some getattr() calls so that the code is still active for PyGtk-2.10, can you merge it and check it still works for you ?

The branch is: lp:~vila/bzr-gtk/494140-xandros-compat

You can push your branch again when you've got a working version.

review: Needs Fixing
673. By David Roberts on 2009-12-09

Further consequential changes for PyGtk-2.8

David Roberts (smartgpx) wrote :

Thank you for your attempt to 'mentor' by giving me the opportunity to
explore this.

I thought it was beyond my gtk/python skills at present. But I've got
a proposal.

My thinking is as follows. 'self.prev_button.set_menu' expects self to
be a MenuToolButton, which we should have established by calling
set_tool_item_type.
But for PyGtk < 2.10 we haven't done that.

But to avoid the runtime error we can at least inspect whether we can
call set_menu
on the button we actually have...

And we need to do this twice, for prev_button and next_button.

Seems to run Visualize cleanly now.

Did I merge your changes correctly and following correct etiquette/attribution?

2009/12/9 Vincent Ladeuil <email address hidden>:
> Review: Needs Fixing
> With your patch, brz viz issues a warning:
>
> Traceback (most recent call last):
>  File "/home/vila/.bazaar/plugins/gtk/viz/branchwin.py", line 416, in _treeselection_changed_cb
>    self.prev_button.set_menu(prev_menu)
> AttributeError: 'gtk.ToolButton' object has no attribute 'set_menu'
>
> I added some getattr() calls so that the code is still active for PyGtk-2.10, can you merge it and check it still works for you ?
>
> The branch is: lp:~vila/bzr-gtk/494140-xandros-compat
>
> You can push your branch again when you've got a working version.
> --
> https://code.edge.launchpad.net/~smartgpx/bzr-gtk/workaround_for_lp494140/+merge/15855
> You are the owner of lp:~smartgpx/bzr-gtk/workaround_for_lp494140.
>

Vincent Ladeuil (vila) wrote :

> Thank you for your attempt to 'mentor' by giving me the opportunity to
> explore this.
>
> I thought it was beyond my gtk/python skills at present. But I've got
> a proposal.

Hehe, obviously you're too humble here since you demonstrate your understanding of the issue below :)

>
> My thinking is as follows. 'self.prev_button.set_menu' expects self to
> be a MenuToolButton, which we should have established by calling
> set_tool_item_type.
> But for PyGtk < 2.10 we haven't done that.

But if you don't encounter the issue, does it matter ?
I mentioned the warning only to give you feedback about why my changes were needed.
If the behavior is fine on your side with them, no need to do *more* changes :)

>
> But to avoid the runtime error we can at least inspect whether we can
> call set_menu
> on the button we actually have...

That's sound, but not needed because we did that earlier.

>
> And we need to do this twice, for prev_button and next_button.
>
> Seems to run Visualize cleanly now.
>

Good. AIUI you may not have the history associated with the 'next' and 'previous' buttons, but that's the price to pay for running an older PyGtk version I'm afraid.

> Did I merge your changes correctly and following correct
> etiquette/attribution?

I have no idea since you didn't push :)

The diff below is still your original one and the associated branch is still at revno 672.

Vincent Ladeuil (vila) wrote :

@David: Any progress to report ?
Can you at least push your current branch here so we continue the discussion ?

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'revisionview.py'
2--- revisionview.py 2009-06-10 18:07:35 +0000
3+++ revisionview.py 2009-12-11 09:04:12 +0000
4@@ -51,13 +51,15 @@
5 webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
6 webbrowser.open(uri)
7
8-gtk.link_button_set_uri_hook(_open_link)
9+if getattr(gtk, 'link_button_set_uri_hook', None) is not None:
10+ # Not available before PyGtk-2.10
11+ gtk.link_button_set_uri_hook(_open_link)
12
13 class BugsTab(gtk.VBox):
14
15 def __init__(self):
16 super(BugsTab, self).__init__(False, 6)
17-
18+
19 table = gtk.Table(rows=2, columns=2)
20
21 table.set_row_spacings(6)
22
23=== modified file 'viz/branchwin.py'
24--- viz/branchwin.py 2009-05-25 15:57:23 +0000
25+++ viz/branchwin.py 2009-12-11 09:04:12 +0000
26@@ -1,11 +1,10 @@
27-# -*- coding: UTF-8 -*-
28 """Branch window.
29
30 This module contains the code to manage the branch information window,
31 which contains both the revision graph and details panes.
32 """
33
34-__copyright__ = "Copyright © 2005 Canonical Ltd."
35+__copyright__ = "Copyright (c) 2005 Canonical Ltd."
36 __author__ = "Scott James Remnant <scott@ubuntu.com>"
37
38
39@@ -80,7 +79,9 @@
40 self.accel_group = gtk.AccelGroup()
41 self.add_accel_group(self.accel_group)
42
43- gtk.Action.set_tool_item_type(gtk.MenuToolButton)
44+ if getattr(gtk.Action, 'set_tool_item_type', None) is not None:
45+ # Not available before PyGtk-2.10
46+ gtk.Action.set_tool_item_type(gtk.MenuToolButton)
47
48 self.prev_rev_action = gtk.Action("prev-rev", "_Previous Revision", "Go to the previous revision", gtk.STOCK_GO_DOWN)
49 self.prev_rev_action.set_accel_path("<viz>/Go/Previous Revision")
50@@ -413,7 +414,8 @@
51 self.prev_rev_action.set_sensitive(False)
52 prev_menu.hide()
53
54- self.prev_button.set_menu(prev_menu)
55+ if getattr(self.prev_button, 'set_menu', None) is not None:
56+ self.prev_button.set_menu(prev_menu)
57
58 next_menu = gtk.Menu()
59 if len(children) > 0:
60@@ -433,7 +435,8 @@
61 self.next_rev_action.set_sensitive(False)
62 next_menu.hide()
63
64- self.next_button.set_menu(next_menu)
65+ if getattr(self.next_button, 'set_menu', None) is not None:
66+ self.next_button.set_menu(next_menu)
67
68 self.revisionview.set_revision(revision)
69 self.revisionview.set_children(children)

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: