Merge lp:~gary-lasker/software-center/show-technical-items-lp955030 into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 2944
Proposed branch: lp:~gary-lasker/software-center/show-technical-items-lp955030
Merge into: lp:software-center
Diff against target: 118 lines (+24/-38)
2 files modified
softwarecenter/ui/gtk3/panes/softwarepane.py (+2/-0)
softwarecenter/ui/gtk3/widgets/actionbar.py (+22/-38)
To merge this branch: bzr merge lp:~gary-lasker/software-center/show-technical-items-lp955030
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Kiwinote Approve
Review via email: mp+100544@code.launchpad.net

Description of the change

This branch makes the "Show N technical items" text at the bottom of a list view look clickable again by using the href markup capability that is now supported by GTK Label, per the suggestion from mvo in corresponding bug 955030, comment #6.

The code is not much simplified as it removes the former custom rendering code (which no longer worked correctly in GTK3 anyway).

To test, just grab a copy of the branch, open Software Center and enter "nfs" into the search bar. Notice that the "Show N technical items" link at the bottom left of the wondow is now colored orange, shows a hand cursor on a hover, and clicking it displays the full list of items (clicking a second time hides the technical items).

Thanks for your review!

To post a comment you must log in.
2944. By Gary Lasker on 2012-04-03

just add a comment to explain that we make every second label in the action bar activatable

Gary Lasker (gary-lasker) wrote :

I added a fix for the "Gtk-WARNING **: Unable to show '': Operation not supported" messages that were appearing in the log. Many thanks to kiwinote for suggesting the fix!

2945. By Gary Lasker on 2012-04-04

fix Gtk-WARNING for Operation not supported in the log output, thanks kiwinote

Kiwinote (kiwinote) wrote :

cool - thanks for this

review: Approve
Gary Lasker (gary-lasker) wrote :

Thanks kiwinote!!

Michael Vogt (mvo) wrote :

Thanks Gary, that looks great and is perfect for 12.04.

Once the string break is over we should probably go over this code again and remove the "_link_"
bits in set_label() and simply use strings with "<a href=>" instead of "_foo_" in the code that
calls set_label(). But as this is a string break we can not do it now :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/panes/softwarepane.py'
2--- softwarecenter/ui/gtk3/panes/softwarepane.py 2012-03-29 13:55:53 +0000
3+++ softwarecenter/ui/gtk3/panes/softwarepane.py 2012-04-04 14:44:26 +0000
4@@ -388,10 +388,12 @@
5 def _show_nonapp_pkgs(self):
6 self.nonapps_visible = NonAppVisibility.ALWAYS_VISIBLE
7 self.refresh_apps()
8+ return True
9
10 def _hide_nonapp_pkgs(self):
11 self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
12 self.refresh_apps()
13+ return True
14
15 def get_query(self):
16 channel_query = None
17
18=== modified file 'softwarecenter/ui/gtk3/widgets/actionbar.py'
19--- softwarecenter/ui/gtk3/widgets/actionbar.py 2012-03-13 17:13:27 +0000
20+++ softwarecenter/ui/gtk3/widgets/actionbar.py 2012-04-04 14:44:26 +0000
21@@ -50,19 +50,19 @@
22 super(ActionBar, self).__init__(spacing=self.PADDING)
23 self._btns = Gtk.HBox(spacing=self.PADDING)
24 self._btns.set_border_width(self.PADDING)
25- self._label = Gtk.HBox()
26- self._label.set_border_width(self.PADDING)
27+ self._label_hbox = Gtk.HBox()
28+ self._label_hbox.set_border_width(self.PADDING)
29 # So that all buttons children right align
30 self._btn_bin = Gtk.Alignment.new(1.0, 0.0, 1.0, 1.0)
31 self._btn_bin.set_padding(0, 0, 0, 10)
32 self._btn_bin.add(self._btns)
33 # Buttons go on the right, labels on the left (in LTR mode)
34- super(ActionBar, self).pack_start(self._label, False, False, 10)
35+ super(ActionBar, self).pack_start(self._label_hbox, False, False, 10)
36 super(ActionBar, self).pack_end(self._btn_bin, False, True, 0)
37
38 # Don't show_all() by default.
39 self.set_no_show_all(True)
40- self._label.show_all()
41+ self._label_hbox.show_all()
42 self._btn_bin.show_all()
43 self._visible = False
44
45@@ -107,7 +107,7 @@
46 # buttons are removed
47 self.set_size_request(-1, self.get_allocation().height)
48 self._btns.remove(child)
49- if len(children) == 1 and not len(self._label):
50+ if len(children) == 1 and not len(self._label_hbox):
51 # always animate with buttons
52 self._hide(animate=True)
53 return
54@@ -128,37 +128,21 @@
55 LOG.debug("got sections '%s'" % sections)
56 self._label_text = text
57
58- # Unfortunately, gtk has no native method for embedding a link
59- # in a Gtk.Label with non-link elements. To represent the label,
60- # this method makes an eventbox for each link and non-link
61- # section. If the section corresponds to a link, it hooks hover,
62- # unhover, and click behavior to the box.
63- while len(self._label) > len(sections):
64- last = self._label.get_children()[-1]
65- self._label.remove(last)
66- while len(self._label) < len(sections):
67- box = Gtk.EventBox()
68- self._label.pack_start(box, True, True, 0)
69- # Sections alternate between link and non-link types, so
70- # hook up link methods to even sections.
71- if not len(self._label) % 2:
72- box.connect("button-press-event",
73- self._callback(link_result, link_result_args))
74- box.connect("enter-notify-event", self._hover_link)
75- box.connect("leave-notify-event", self._unhover_link)
76+ for i, text_for_label in enumerate(sections):
77+ action_bar_item = Gtk.Label(text_for_label)
78+ # every second item in the bar is a clickable link, this is a
79+ # convention carried over from the past design
80+ if not i % 2:
81+ markup = sections[i]
82+ action_bar_item.set_markup(markup)
83+ else:
84+ markup = '<a href="">%s</a>' % text_for_label
85+ action_bar_item.set_markup(markup)
86+ action_bar_item.connect("activate-link",
87+ self._callback(link_result, link_result_args))
88+ self._label_hbox.pack_start(action_bar_item, True, True, 0)
89
90- # Finally, place the text segments in their respective event
91- # boxes. Use pango to underline link segments.
92- for i, box in enumerate(self._label):
93- label = Gtk.Label()
94- markup = sections[i]
95- if i % 2:
96- markup = "<u>%s</u>" % markup
97- label.set_markup(markup)
98- if box.get_child():
99- box.remove(box.get_child())
100- box.add(label)
101- box.show_all()
102+ self._label_hbox.show_all()
103 self._show(animate=False)
104
105 def unset_label(self):
106@@ -169,9 +153,9 @@
107 self._label_text = ""
108
109 # Destroy all event boxes holding text segments.
110- while len(self._label):
111- last = self._label.get_children()[-1]
112- self._label.remove(last)
113+ while len(self._label_hbox):
114+ last = self._label_hbox.get_children()[-1]
115+ self._label_hbox.remove(last)
116
117 window = self.get_window()
118 if window:

Subscribers

People subscribed via source and target branches