Sun, 15 Jun 2008 14:23:40 +0200 <thp@perli.net>

Support tooltips for the episode list; improve tooltip appearance

	* src/gpodder/gui.py: Add tooltips to treeAvailable (episode list);
	avoid showing tooltips while the context menu of the treeChannels and
	treeAvailable is open, so the tooltip doesn't appear over the context
	menu; add Sebastian Krause to list of bug reporters
	* src/gpodder/util.py: Try to convert some HTML tags to text-only
	characters (<br> to newline, <li> to a "*", etc..) so the description
	of an episode is easier to read and looks more structured; also,
	convert more than two subsequent newlines to maximum two newlines
	(Closes: http://bugs.gpodder.org/show_bug.cgi?id=126)



git-svn-id: svn://svn.berlios.de/gpodder/trunk@742 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
Thomas Perl 2008-06-15 12:28:24 +00:00
parent f0f712d29c
commit c1bf2ceaf2
3 changed files with 81 additions and 3 deletions

View File

@ -1,3 +1,16 @@
Sun, 15 Jun 2008 14:23:40 +0200 <thp@perli.net>
Support tooltips for the episode list; improve tooltip appearance
* src/gpodder/gui.py: Add tooltips to treeAvailable (episode list);
avoid showing tooltips while the context menu of the treeChannels and
treeAvailable is open, so the tooltip doesn't appear over the context
menu; add Sebastian Krause to list of bug reporters
* src/gpodder/util.py: Try to convert some HTML tags to text-only
characters (<br> to newline, <li> to a "*", etc..) so the description
of an episode is easier to read and looks more structured; also,
convert more than two subsequent newlines to maximum two newlines
(Closes: http://bugs.gpodder.org/show_bug.cgi?id=126)
Sat, 14 Jun 2008 12:29:11 -0400 <me@nikosapi.org>
* src/gpodder/libpodcasts.py: make LocalDBReader and LocalDBWriter
read/save the episode mimetype attribute in the LocalDB. This

View File

@ -93,7 +93,7 @@ app_authors = [
'Pavel Mlčoch', 'Peter Hoffmann', 'Philippe Gouaillier', 'Pieter de Decker',
'Preben Randhol', 'Rafael Proença', 'red26wings', 'Richard Voigt',
'Robert Young', 'Roel Groeneveld',
'Scott Wegner', 'Seth Remington', 'Shane Donohoe', 'SPGoetze',
'Scott Wegner', 'Sebastian Krause', 'Seth Remington', 'Shane Donohoe', 'SPGoetze',
'Stefan Lohmaier', 'Stephan Buys', 'Stylianos Papanastasiou', 'Teo Ramirez',
'Thomas Matthijs', 'Thomas Mills Hinkle', 'Thomas Nilsson',
'Tim Michelsen', 'Tim Preetz', 'Todd Zullinger', 'Tomas Matheson', 'VladDrac',
@ -378,9 +378,14 @@ class gPodder(GladeWidget):
try:
self.treeChannels.set_property('has-tooltip', True)
self.treeChannels.connect('query-tooltip', self.treeview_channels_query_tooltip)
self.treeAvailable.set_property('has-tooltip', True)
self.treeAvailable.connect('query-tooltip', self.treeview_episodes_query_tooltip)
except:
log('No tooltips for channel navigator (need at least PyGTK 2.12)', sender = self)
log('I cannot set has-tooltip/query-tooltip (need at least PyGTK 2.12)', sender = self)
self.last_tooltip_channel = None
self.last_tooltip_episode = None
self.podcast_list_can_tooltip = True
self.episode_list_can_tooltip = True
# Add our context menu to treeAvailable
if gpodder.interface == gpodder.MAEMO:
@ -544,9 +549,49 @@ class gPodder(GladeWidget):
util.idle_add(self.user_apps_reader.get_applications_as_model, 'audio', False)
util.idle_add(self.user_apps_reader.get_applications_as_model, 'video', False)
def treeview_episodes_query_tooltip(self, treeview, x, y, keyboard_tooltip, tooltip):
# With get_bin_window, we get the window that contains the rows without
# the header. The Y coordinate of this window will be the height of the
# treeview header. This is the amount we have to subtract from the
# event's Y coordinate to get the coordinate to pass to get_path_at_pos
(x_bin, y_bin) = treeview.get_bin_window().get_position()
y -= x_bin
y -= y_bin
(path, column, rx, ry) = treeview.get_path_at_pos( x, y) or (None,)*4
if not self.episode_list_can_tooltip:
self.last_tooltip_episode = None
return False
if path is not None:
model = treeview.get_model()
iter = model.get_iter(path)
url = model.get_value(iter, 0)
description = model.get_value(iter, 7)
if self.last_tooltip_episode is not None and self.last_tooltip_episode != url:
self.last_tooltip_episode = None
return False
self.last_tooltip_episode = url
tooltip.set_text(description)
return True
self.last_tooltip_episode = None
return False
def podcast_list_allow_tooltips(self):
self.podcast_list_can_tooltip = True
def episode_list_allow_tooltips(self):
self.episode_list_can_tooltip = True
def treeview_channels_query_tooltip(self, treeview, x, y, keyboard_tooltip, tooltip):
(path, column, rx, ry) = treeview.get_path_at_pos( x, y) or (None,)*4
if not self.podcast_list_can_tooltip:
self.last_tooltip_channel = None
return False
if path is not None:
model = treeview.get_model()
iter = model.get_iter(path)
@ -670,6 +715,10 @@ class gPodder(GladeWidget):
menu.append( item)
menu.show_all()
# Disable tooltips while we are showing the menu, so
# the tooltip will not appear over the menu
self.podcast_list_can_tooltip = False
menu.connect('deactivate', lambda menushell: self.podcast_list_allow_tooltips())
menu.popup( None, None, None, event.button, event.time)
return True
@ -907,6 +956,10 @@ class gPodder(GladeWidget):
menu.append(self.set_finger_friendly(item))
menu.show_all()
# Disable tooltips while we are showing the menu, so
# the tooltip will not appear over the menu
self.episode_list_can_tooltip = False
menu.connect('deactivate', lambda menushell: self.episode_list_allow_tooltips())
menu.popup( None, None, None, event.button, event.time)
return True

View File

@ -364,15 +364,27 @@ def remove_html_tags(html):
re_strip_tags = re.compile('<[^>]*>')
re_unicode_entities = re.compile('&#(\d{2,4});')
re_html_entities = re.compile('&(.{2,8});')
re_newline_tags = re.compile('(<br[^>]*>|<[/]?ul[^>]*>|</li>)', re.I)
re_listing_tags = re.compile('<li[^>]*>', re.I)
result = html
# Convert common HTML elements to their text equivalent
result = re_newline_tags.sub('\n', result)
result = re_listing_tags.sub('\n * ', result)
result = re.sub('<[Pp]>', '\n\n', result)
# Remove all HTML/XML tags from the string
result = re_strip_tags.sub('', html)
result = re_strip_tags.sub('', result)
# Convert numeric XML entities to their unicode character
result = re_unicode_entities.sub(lambda x: unichr(int(x.group(1))), result)
# Convert named HTML entities to their unicode character
result = re_html_entities.sub(lambda x: unicode(entitydefs.get(x.group(1),''), 'iso-8859-1'), result)
# Convert more than two newlines to two newlines
result = re.sub('([\r\n]{2})([\r\n])+', '\\1', result)
return result.strip()