Skip to content

Commit

Permalink
Improvements to the extension system
Browse files Browse the repository at this point in the history
- Add category metadata in every extension
- Show this category in the extension list gui
- Add "mandatory_in" and "disable-in" configuration for an extension
- Add Ubuntu unity check to enable/disable unity specific extensions
- Move "gpodder.win32" and "gpodder.osx" setting to the "gpodder.ui" namespace to be able to use it in the extensions category settings
- Only show metadata information in the right-click dialog of an extension
  • Loading branch information
brot committed Dec 7, 2012
1 parent de0cae3 commit d5eae16
Show file tree
Hide file tree
Showing 26 changed files with 191 additions and 82 deletions.
2 changes: 1 addition & 1 deletion bin/gpo
Expand Up @@ -121,7 +121,7 @@ gpodder.ui.cli = True
# Platform detection (i.e. MeeGo 1.2 Harmattan, etc..)
gpodder.detect_platform()

have_ansi = sys.stdout.isatty() and not gpodder.win32
have_ansi = sys.stdout.isatty() and not gpodder.ui.win32
interactive_console = sys.stdin.isatty() and sys.stdout.isatty()
is_single_command = False

Expand Down
7 changes: 5 additions & 2 deletions bin/gpodder
Expand Up @@ -119,7 +119,7 @@ def main():
help=_('Subscribe to the given URL'))

# On Mac OS X, support the "psn" parameter for compatibility (bug 939)
if gpodder.osx:
if gpodder.ui.osx:
parser.add_option('-p', '--psn', dest='macpsn', metavar='PSN',
help=_('Mac OS X application process number'))

Expand All @@ -129,6 +129,9 @@ def main():
gpodder.ui.qml = True
else:
gpodder.ui.gtk = True

gpodder.ui.unity = (os.environ.get('DESKTOP_SESSION', 'unknown').lower() in
('ubuntu', 'ubuntu-2d'))

from gpodder import log
log.setup(options.verbose)
Expand Down Expand Up @@ -156,7 +159,7 @@ def main():
except dbus.exceptions.DBusException, dbus_exception:
logger.info('Cannot connect to remote object.', exc_info=True)

if not gpodder.win32 and os.environ.get('DISPLAY', '') == '':
if not gpodder.ui.win32 and os.environ.get('DISPLAY', '') == '':
logger.error('Cannot start gPodder: $DISPLAY is not set.')
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion share/gpodder/extensions/enqueue_in_mediaplayer.py
Expand Up @@ -16,6 +16,7 @@
__title__ = _('Enqueue in media players')
__description__ = _('Add a context menu item for enqueueing episodes in installed media players')
__author__ = 'Thomas Perl <thp@gpodder.org>, Bernd Schlapsi <brot@gmx.info>'
__category__ = 'interface'
__only_for__ = 'gtk'

AMAROK = (['amarok', '--play', '--append'], 'Enqueue in Amarok')
Expand All @@ -40,7 +41,6 @@ def _enqueue_episodes_cmd(self, episodes, cmd):
vlc = subprocess.Popen(cmd + filenames,
stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout, stderr = vlc.communicate()

def _enqueue_episodes_amarok(self, episodes):
self._enqueue_episodes_cmd(episodes, AMAROK[0])
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/flv2mp4.py
Expand Up @@ -23,6 +23,7 @@
__title__ = _('Convert .flv files from YouTube to .mp4')
__description__ = _('Useful for playing downloaded videos on hardware players')
__authors__ = 'Thomas Perl <thp@gpodder.org>, Bernd Schlapsi <brot@gmx.info>'
__category__ = 'post-download'

DefaultConfig = {
'context_menu': True, # Show the conversion option in the context menu
Expand Down
2 changes: 2 additions & 0 deletions share/gpodder/extensions/gtk_statusicon.py
Expand Up @@ -10,7 +10,9 @@

__title__ = _('Gtk Status Icon')
__description__ = _('Show a status icon for Gtk-based Desktops.')
__category__ = 'desktop-integration'
__only_for__ = 'gtk'
__disable_in__ = 'unity'

import gtk

Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/m4a_converter.py
Expand Up @@ -19,6 +19,7 @@
__title__ = _('Convert M4A audio to MP3 or OGG')
__description__ = _('Transcode .m4a files to .mp3 or .ogg using ffmpeg')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>, Thomas Perl <thp@gpodder.org>'
__category__ = 'post-download'


DefaultConfig = {
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/minimize_on_start.py
Expand Up @@ -9,6 +9,7 @@

__title__ = _('Minimize on start')
__description__ = _('Minimizes the gPodder window on startup.')
__category__ = 'interface'
__only_for__ = 'gtk'

class gPodderExtension:
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/normalize_audio.py
Expand Up @@ -21,6 +21,7 @@
__title__ = _('Normalize audio with re-encoding')
__description__ = _('Normalize the volume of audio files with normalize-audio')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>'
__category__ = 'post-download'


DefaultConfig = {
Expand Down
2 changes: 2 additions & 0 deletions share/gpodder/extensions/notification.py
Expand Up @@ -21,7 +21,9 @@

__title__ = 'Gtk+ Desktop Notifications'
__description__ = 'Display notification bubbles for different events.'
__category__ = 'desktop-integration'
__only_for__ = 'gtk'
__mandatory_in__ = 'gtk'

import gpodder

Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/rename_download.py
Expand Up @@ -16,6 +16,7 @@
__title__ = _('Rename episodes after download')
__description__ = _('Rename episodes to "<Episode Title>.<ext>" on download')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>, Thomas Perl <thp@gpodder.org>'
__category__ = 'post-download'


class gPodderExtension:
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/rm_ogg_cover.py
Expand Up @@ -37,6 +37,7 @@
__title__ = _('Remove cover art from OGG files')
__description__ = _('removes coverart from all downloaded ogg files')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>'
__category__ = 'post-download'


DefaultConfig = {
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/rockbox_convert2mp4.py
Expand Up @@ -26,6 +26,7 @@
__title__ = _('Convert video files to MP4 for Rockbox')
__description__ = _('Converts all videos to a Rockbox-compatible format')
__authors__ = 'Guy Sheffer <guysoft@gmail.com>, Thomas Perl <thp@gpodder.org>, Bernd Schlapsi <brot@gmx.info>'
__category__ = 'post-download'


DefaultConfig = {
Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/tagging.py
Expand Up @@ -38,6 +38,7 @@
__title__ = _('Tag downloaded files using Mutagen')
__description__ = _('Add episode and podcast titles to MP3/OGG tags')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>'
__category__ = 'post-download'


DefaultConfig = {
Expand Down
3 changes: 2 additions & 1 deletion share/gpodder/extensions/ted_subtitles.py
Expand Up @@ -15,8 +15,9 @@

__title__ = _('Subtitle Downloader for TED Talks')
__description__ = _('Downloads .srt subtitles for TED Talks Videos')
__only_for__ = 'gtk, cli, qml'
__authors__ = 'Danilo Shiga <daniloshiga@gmail.com>'
__category__ = 'post-download'
__only_for__ = 'gtk, cli, qml'


class gPodderExtension(object):
Expand Down
4 changes: 4 additions & 0 deletions share/gpodder/extensions/ubuntu_appindicator.py
Expand Up @@ -9,7 +9,11 @@

__title__ = _('Ubuntu App Indicator')
__description__ = _('Show a status indicator in the top bar.')
__authors__ = 'Thomas Perl <thp@gpodder.org>'
__category__ = 'desktop-integration'
__only_for__ = 'gtk'
__mandatory_in__ = 'unity'


import appindicator
import gtk
Expand Down
9 changes: 8 additions & 1 deletion share/gpodder/extensions/ubuntu_unity.py
Expand Up @@ -9,15 +9,21 @@

__title__ = _('Ubuntu Unity Integration')
__description__ = _('Show download progress in the Unity Launcher icon.')
__only_for__ = 'gtk'
__authors__ = 'Thomas Perl <thp@gpodder.org>'
__category__ = 'desktop-integration'
__only_for__ = 'unity'
__mandatory_in__ = 'unity'


# FIXME: Due to the fact that we do not yet use the GI-style bindings, we will
# have to run this module in its own interpreter and send commands to it using
# the subprocess module. Once we use GI-style bindings, we can get rid of all
# this and still expose the same "interface' (LauncherEntry and its methods)
# to our callers.

import os
import subprocess
import sys
import logging

if __name__ != '__main__':
Expand All @@ -32,6 +38,7 @@ def __init__(self, container):

def on_load(self):
logger.info('Starting Ubuntu Unity Integration.')
os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)
self.process = subprocess.Popen(['python', __file__],
stdin=subprocess.PIPE)

Expand Down
1 change: 1 addition & 0 deletions share/gpodder/extensions/update_feeds_on_startup.py
Expand Up @@ -14,6 +14,7 @@
__title__ = _('Search for new episodes on startup')
__description__ = _('Starts the search for new episodes on startup')
__authors__ = 'Bernd Schlapsi <brot@gmx.info>'
__category__ = 'interface'
__only_for__ = 'gtk'


Expand Down
2 changes: 1 addition & 1 deletion share/gpodder/ui/gtk/gpodderpreferences.ui
Expand Up @@ -189,7 +189,7 @@
<property name="reorderable">True</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<signal name="row-activated" handler="on_extensions_row_activated" swapped="no"/>
<signal name="button-press-event" handler="on_treeview_button_press_event" swapped="no"/>
</object>
</child>
</object>
Expand Down
6 changes: 3 additions & 3 deletions src/gpodder/__init__.py
Expand Up @@ -93,9 +93,9 @@ def __init__(self):
dbus_session_bus = None

# Set "win32" to True if we are on Windows
win32 = (platform.system() == 'Windows')
ui.win32 = (platform.system() == 'Windows')
# Set "osx" to True if we are on Mac OS X
osx = (platform.system() == 'Darwin')
ui.osx = (platform.system() == 'Darwin')

# i18n setup (will result in "gettext" to be available)
# Use _ = gpodder.gettext in modules to enable string translations
Expand All @@ -112,7 +112,7 @@ def __init__(self):
gettext = t.gettext
ngettext = t.ngettext

if win32:
if ui.win32:
try:
# Workaround for bug 650
from gtk.glade import bindtextdomain
Expand Down
2 changes: 1 addition & 1 deletion src/gpodder/config.py
Expand Up @@ -88,7 +88,7 @@

# Software updates from gpodder.org (primary audience: Windows users)
'software_update': {
'check_on_startup': gpodder.win32, # check for updates on start
'check_on_startup': gpodder.ui.win32, # check for updates on start
'last_check': 0, # unix timestamp of last update check
'interval': 5, # interval (in days) to check for updates
},
Expand Down

0 comments on commit d5eae16

Please sign in to comment.