Expose system default video and audio player in UI

In addition to selecting audio and video players, we
now support "default" as a way of having a good default
that we can pass to a utility function that can later
be made cross-platform more easily.

Also cleaned up some UI issues with the video player,
so the label of the custom command is shown and the
combo box has the correct size.
This commit is contained in:
Thomas Perl 2008-11-06 18:06:12 +01:00
parent a83c253e22
commit 07fa96bf1b
6 changed files with 31 additions and 8 deletions

View File

@ -2592,7 +2592,7 @@
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
@ -2875,7 +2875,7 @@
</child>
<child>
<widget class="GtkLabel" id="label115">
<widget class="GtkLabel" id="labelCustomVideoCommand">
<property name="label" translatable="yes">Command line:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>

View File

@ -46,7 +46,7 @@ else:
gPodderSettings = {
# General settings
'player': ( str, 'xdg-open' ),
'player': (str, 'default'),
'videoplayer': (str, 'unspecified'),
'opml_url': ( str, 'http://www.gpodder.org/directory.opml' ),
'http_proxy': ( str, '' ),

View File

@ -2755,6 +2755,9 @@ class gPodderProperties(GladeWidget):
if not hasattr(self, 'user_apps_reader'):
self.user_apps_reader = UserAppsReader(['audio', 'video'])
self.comboAudioPlayerApp.set_row_separator_func(self.is_row_separator)
self.comboVideoPlayerApp.set_row_separator_func(self.is_row_separator)
if gpodder.interface == gpodder.GUI:
self.user_apps_reader.read()
@ -2767,6 +2770,9 @@ class gPodderProperties(GladeWidget):
self.ipodIcon.set_from_icon_name( 'gnome-dev-ipod', gtk.ICON_SIZE_BUTTON)
def is_row_separator(self, model, iter):
return model.get_value(iter, 0) == ''
def update_mountpoint( self, ipod):
if ipod is None or ipod.mount_point is None:
self.iPodMountpoint.set_label( '')
@ -2886,6 +2892,8 @@ class gPodderProperties(GladeWidget):
model = self.comboAudioPlayerApp.get_model()
command = model.get_value( iter, 1)
if command == '':
if self.openApp.get_text() == 'default':
self.openApp.set_text('')
self.openApp.set_sensitive( True)
self.openApp.show()
self.labelCustomCommand.show()
@ -2901,14 +2909,16 @@ class gPodderProperties(GladeWidget):
model = self.comboVideoPlayerApp.get_model()
command = model.get_value(iter, 1)
if command == '':
if self.openVideoApp.get_text() == 'default':
self.openVideoApp.set_text('')
self.openVideoApp.set_sensitive(True)
self.openVideoApp.show()
self.label115.show()
self.labelCustomVideoCommand.show()
else:
self.openVideoApp.set_text(command)
self.openVideoApp.set_sensitive(False)
self.openVideoApp.hide()
self.label115.hide()
self.labelCustomVideoCommand.hide()
def on_cbEnvironmentVariables_toggled(self, widget, *args):
sens = not self.cbEnvironmentVariables.get_active()

View File

@ -327,8 +327,11 @@ class gPodderLib(object):
elif file_type == 'audio':
player = self.config.player
else:
log('Non-audio or video file type, using xdg-open for %s', filename, sender=self)
player = 'xdg-open'
player = 'default'
# we should use the default player or no player is set
if player == 'default' or player == '':
return (util.gui_open(filename), player)
command_line = shlex.split(util.format_desktop_command(player, filename).encode('utf-8'))
log( 'Command line: [ %s ]', ', '.join( [ '"%s"' % p for p in command_line ]), sender = self)

View File

@ -73,6 +73,13 @@ class UserAppsReader(object):
self.__model_cache = {}
self.__has_read = False
self.__finished = threading.Event()
self.__has_sep = False
self.apps.append(UserApplication(_('Default application'), 'default', ';'.join((mime+'/*' for mime in self.mimetypes)), gtk.STOCK_OPEN))
self.apps.append(UserApplication(_('Custom command'), '', ';'.join((mime+'/*' for mime in self.mimetypes)), gtk.STOCK_EXECUTE))
def add_separator(self):
self.apps.append(UserApplication('', '', ';'.join((mime+'/*' for mime in self.mimetypes)), ''))
self.__has_sep = True
def read( self):
if self.__has_read:
@ -86,7 +93,6 @@ class UserAppsReader(object):
self.parse_and_append( file)
log('end reader', bench_end=True)
self.__finished.set()
self.apps.append(UserApplication('Shell command', '', ';'.join((mime+'/*' for mime in self.mimetypes)), gtk.STOCK_EXECUTE))
def parse_and_append( self, filename):
try:
@ -103,6 +109,8 @@ class UserAppsReader(object):
app_name = parser.get(sect, 'Name')
app_cmd = parser.get(sect, 'Exec')
app_icon = parser.get(sect, 'Icon')
if not self.__has_sep:
self.add_separator()
self.apps.append(UserApplication(app_name, app_cmd, app_mime, app_icon))
return
except:

View File

@ -930,8 +930,10 @@ def gui_open(filename):
subprocess.Popen(['xdg-open', filename])
# FIXME: Win32-specific "open" code needed here
# as fallback when xdg-open not available
return True
except:
log('Cannot open file/folder: "%s"', filename, sender=self, traceback=True)
return False
def open_website(url):