Skip to content

Commit

Permalink
Maemo 5: New episodes notification (Maemo bug 11130)
Browse files Browse the repository at this point in the history
Replace the focus-stealing method of opening the
new episodes window with a pynotify-based "yellow"
notification bubble that opens the new episodes list
when clicked.
  • Loading branch information
thp committed Aug 16, 2010
1 parent a4a37b8 commit bfd7100
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 4 deletions.
Binary file added data/icons/32/gpodder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions setup.py
Expand Up @@ -77,6 +77,7 @@
inst_icons = [ 'data/gpodder.png' ]
inst_icons_64 = [ 'data/icons/64/gpodder.png' ]
inst_icons_40 = [ 'data/icons/40/gpodder.png' ]
inst_icons_32 = [ 'data/icons/32/gpodder.png' ]
inst_icons_26 = [ 'data/icons/26/gpodder.png' ]
inst_icons_24 = [ 'data/icons/24/gpodder.png' ]
inst_icons_22 = [ 'data/icons/22/gpodder.png' ]
Expand Down Expand Up @@ -120,7 +121,9 @@
('share/applications/hildon', inst_desktop_maemo),
('share/icons/hicolor/scalable/apps', inst_icons_64),
('share/icons/hicolor/40x40/apps', inst_icons_40),
('share/icons/hicolor/32x32/apps', inst_icons_32),
('share/icons/hicolor/26x26/apps', inst_icons_26),
('share/icons/hicolor/16x16/apps', inst_icons_16),
]
packages += [
'gpodder.gtkui.maemo',
Expand Down
81 changes: 81 additions & 0 deletions src/gpodder/gtkui/frmntl/progress.py
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
#
# gPodder - A media aggregator and podcast client
# Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
#
# gPodder is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# gPodder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import gtk
import gobject
import hildon

import gpodder

_ = gpodder.gettext

class ProgressIndicator(object):
# Delayed time until window is shown (for short operations)
DELAY = 500

def __init__(self, title, subtitle=None, cancellable=False, parent=None):
self.title = title
self.subtitle = subtitle
self.cancellable = cancellable
self.parent = parent
self.dialog = None
self.indicator = None
self._progress_set = False
self._progress = 0.
self._message_set = False
self._message = ''
self.source_id = gobject.timeout_add(self.DELAY, self._create_progress)

def _create_progress(self):
self.dialog = hildon.hildon_banner_show_animation(self.parent, \
'qgn_indi_pball_a', self.title)
self._update_label()

gobject.source_remove(self.source_id)
self.source_id = None
return False

def _update_label(self):
if self.dialog is not None:
text = []
text.append(self.title)
if self._message_set:
text.append('\n')
text.append(self._message)
if self._progress_set:
text.append(' (%.0f%%)' % (self._progress*100.,))
self.dialog.set_text(''.join(text))

def on_message(self, message):
self._message_set = True
self._message = message
self._update_label()

def on_progress(self, progress):
self._progress_set = True
self._progress = progress
self._update_label()

def on_finished(self):
if self.dialog is not None:
self.dialog.destroy()

if self.source_id is not None:
gobject.source_remove(self.source_id)

27 changes: 23 additions & 4 deletions src/gpodder/gui.py
Expand Up @@ -102,6 +102,7 @@ def __init__(self, *args, **kwargs):
from gpodder.gtkui.desktop.episodeselector import gPodderEpisodeSelector
from gpodder.gtkui.desktop.podcastdirectory import gPodderPodcastDirectory
from gpodder.gtkui.desktop.dependencymanager import gPodderDependencyManager
from gpodder.gtkui.interface.progress import ProgressIndicator
try:
from gpodder.gtkui.desktop.trayicon import GPodderStatusIcon
have_trayicon = True
Expand All @@ -118,6 +119,7 @@ def __init__(self, *args, **kwargs):
from gpodder.gtkui.maemo.episodeselector import gPodderEpisodeSelector
from gpodder.gtkui.maemo.podcastdirectory import gPodderPodcastDirectory
from gpodder.gtkui.maemo.mygpodder import MygPodderSettings
from gpodder.gtkui.interface.progress import ProgressIndicator
have_trayicon = False
elif gpodder.ui.fremantle:
from gpodder.gtkui.frmntl.model import DownloadStatusModel
Expand All @@ -131,14 +133,14 @@ def __init__(self, *args, **kwargs):
from gpodder.gtkui.frmntl.podcastdirectory import gPodderPodcastDirectory
from gpodder.gtkui.frmntl.episodes import gPodderEpisodes
from gpodder.gtkui.frmntl.downloads import gPodderDownloads
from gpodder.gtkui.frmntl.progress import ProgressIndicator
have_trayicon = False

from gpodder.gtkui.frmntl.portrait import FremantleRotation

from gpodder.gtkui.interface.common import Orientation

from gpodder.gtkui.interface.welcome import gPodderWelcome
from gpodder.gtkui.interface.progress import ProgressIndicator

if gpodder.ui.maemo:
import hildon
Expand Down Expand Up @@ -2397,7 +2399,8 @@ def on_episode_list_model_updated():
threading.Thread(target=do_update_episode_list_model).start()
else:
self.episode_list_model.clear()


@dbus.service.method(gpodder.dbus_interface)
def offer_new_episodes(self, channels=None):
new_episodes = self.get_new_episodes(channels)
if new_episodes:
Expand Down Expand Up @@ -2669,7 +2672,22 @@ def update_feed_cache_finish_callback(self, updated_urls=None, select_url_afterw
self.show_message(_('New episodes have been added to the download list.'))
self.download_episode_list_paused(episodes)
else:
self.new_episodes_show(episodes)
try:
import pynotify
pynotify.init('gPodder')
n = pynotify.Notification('gPodder', _('New episodes available'), 'gpodder')
n.set_urgency(pynotify.URGENCY_CRITICAL)
n.set_hint('dbus-callback-default', ' '.join([
gpodder.dbus_bus_name,
gpodder.gui_object_path,
gpodder.dbus_interface,
'offer_new_episodes',
]))
n.set_hint('led-pattern', 'PatternCommunicationCall')
n.show()
except Exception, e:
log('Error: %s', str(e), sender=self, traceback=True)
self.new_episodes_show(episodes)
elif not self.config.auto_update_feeds:
self.show_message(_('No new episodes. Please check for new episodes later.'))
return
Expand Down Expand Up @@ -3905,7 +3923,8 @@ def update_podcasts_tab(self):

@dbus.service.method(gpodder.dbus_interface)
def show_gui_window(self):
self.gPodder.present()
parent = self.get_dialog_parent()
parent.present()

@dbus.service.method(gpodder.dbus_interface)
def subscribe_to_url(self, url):
Expand Down

0 comments on commit bfd7100

Please sign in to comment.