use xdg-open if available. Thanks to polymorphm forthe initial patch. Fixes #5874

This commit is contained in:
Yann Leboulanger 2010-09-08 15:25:36 +02:00
parent 2a941132b1
commit 3e2bfd67a3
8 changed files with 35 additions and 46 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
gajimversion="0.13.90.1"
gajimversion="0.14.0.1"
if [ -d ".hg" ]; then
node=$(hg tip --template "{node}")
hgversion="-${node:0:12}"

View File

@ -9,16 +9,7 @@
</columns>
<data>
<row>
<col id="0" translatable="yes">Autodetect on every Gajim startup</col>
</row>
<row>
<col id="0" translatable="yes">Always use GNOME default applications</col>
</row>
<row>
<col id="0" translatable="yes">Always use KDE default applications</col>
</row>
<row>
<col id="0" translatable="yes">Always use Xfce default applications</col>
<col id="0" translatable="yes">Use default applications</col>
</row>
<row>
<col id="0" translatable="yes">Custom</col>

View File

@ -59,7 +59,7 @@ class Config:
DEFAULT_ICONSET = 'dcraven'
DEFAULT_MOOD_ICONSET = 'default'
DEFAULT_ACTIVITY_ICONSET = 'default'
DEFAULT_OPENWITH = 'gnome-open'
DEFAULT_OPENWITH = 'xdg-open'
DEFAULT_BROWSER = 'firefox'
DEFAULT_MAILAPP = 'mozilla-thunderbird -compose'
DEFAULT_FILE_MANAGER = 'xffm'

View File

@ -27,7 +27,7 @@ docdir = '../'
basedir = '../'
localedir = '../po'
version = '0.13.90.1'
version = '0.14.0.1'
import subprocess
try:
node = subprocess.Popen('hg tip --template {node}', shell=True,

View File

@ -683,12 +683,9 @@ def launch_browser_mailer(kind, uri):
if kind == 'url' and uri.startswith('www.'):
uri = 'http://' + uri
if gajim.config.get('openwith') == 'gnome-open':
command = 'gnome-open'
elif gajim.config.get('openwith') == 'kfmclient exec':
command = 'kfmclient exec'
elif gajim.config.get('openwith') == 'exo-open':
command = 'exo-open'
if gajim.config.get('openwith') in ('xdg-open', 'gnome-open',
'kfmclient exec', 'exo-open'):
command = gajim.config.get('openwith')
elif gajim.config.get('openwith') == 'custom':
if kind == 'url':
command = gajim.config.get('custombrowser')
@ -710,12 +707,9 @@ def launch_file_manager(path_to_open):
except Exception:
pass
else:
if gajim.config.get('openwith') == 'gnome-open':
command = 'gnome-open'
elif gajim.config.get('openwith') == 'kfmclient exec':
command = 'kfmclient exec'
elif gajim.config.get('openwith') == 'exo-open':
command = 'exo-open'
if gajim.config.get('openwith') in ('xdg-open', 'gnome-open',
'kfmclient exec', 'exo-open'):
command = gajim.config.get('openwith')
elif gajim.config.get('openwith') == 'custom':
command = gajim.config.get('custom_file_manager')
if command == '': # if no app is configured

View File

@ -222,6 +222,8 @@ class OptionsParser:
self.update_config_to_013101()
if old < [0, 13, 90, 1] and new >= [0, 13, 90, 1]:
self.update_config_to_013901()
if old < [0, 14, 0, 1] and new >= [0, 14, 0, 1]:
self.update_config_to_01401()
gajim.logger.init_vars()
gajim.logger.attach_cache_database()
@ -892,4 +894,13 @@ class OptionsParser:
def update_config_to_013901(self):
schemes = 'aaa:// aaas:// acap:// cap:// cid: crid:// data: dav: dict:// dns: fax: file:/ ftp:// geo: go: gopher:// h323: http:// https:// iax: icap:// im: imap:// info: ipp:// iris: iris.beep: iris.xpc: iris.xpcs: iris.lwz: ldap:// mid: modem: msrp:// msrps:// mtqp:// mupdate:// news: nfs:// nntp:// opaquelocktoken: pop:// pres: prospero:// rtsp:// service: shttp:// sip: sips: sms: snmp:// soap.beep:// soap.beeps:// tag: tel: telnet:// tftp:// thismessage:/ tip:// tv: urn:// vemmi:// xmlrpc.beep:// xmlrpc.beeps:// z39.50r:// z39.50s:// about: apt: cvs:// daap:// ed2k:// feed: fish:// git:// iax2: irc:// ircs:// ldaps:// magnet: mms:// rsync:// ssh:// svn:// sftp:// smb:// webcal://'
gajim.config.set('uri_schemes', schemes)
gajim.config.set('version', '0.13.90.1')
gajim.config.set('version', '0.13.90.1')
def update_config_to_01401(self):
if 'autodetect_browser_mailer' not in self.old_values or 'openwith' \
not in self.old_values or \
(self.old_values['autodetect_browser_mailer'] == 'False' and \
self.old_values['openwith'] != 'custom'):
gajim.config.set('autodetect_browser_mailer', True)
gajim.config.set('openwith', gajim.config.DEFAULT_OPENWITH)
gajim.config.set('version', '0.14.0.1')

View File

@ -497,14 +497,8 @@ class PreferencesWindow:
self.applications_combobox.set_active(0)
# else autodetect_browser_mailer is False.
# so user has 'Always Use GNOME/KDE/Xfce' or Custom
elif gajim.config.get('openwith') == 'gnome-open':
self.applications_combobox.set_active(1)
elif gajim.config.get('openwith') == 'kfmclient exec':
self.applications_combobox.set_active(2)
elif gajim.config.get('openwith') == 'exo-open':
self.applications_combobox.set_active(3)
elif gajim.config.get('openwith') == 'custom':
self.applications_combobox.set_active(4)
self.applications_combobox.set_active(1)
self.xml.get_object('custom_apps_frame').show()
self.xml.get_object('custom_browser_entry').set_text(
@ -1133,20 +1127,13 @@ class PreferencesWindow:
gajim.config.set('stun_server', widget.get_text().decode('utf-8'))
def on_applications_combobox_changed(self, widget):
gajim.config.set('autodetect_browser_mailer', False)
if widget.get_active() == 4:
if widget.get_active() == 0:
gajim.config.set('autodetect_browser_mailer', True)
self.xml.get_object('custom_apps_frame').hide()
elif widget.get_active() == 1:
gajim.config.set('autodetect_browser_mailer', False)
self.xml.get_object('custom_apps_frame').show()
gajim.config.set('openwith', 'custom')
else:
if widget.get_active() == 0:
gajim.config.set('autodetect_browser_mailer', True)
elif widget.get_active() == 1:
gajim.config.set('openwith', 'gnome-open')
elif widget.get_active() == 2:
gajim.config.set('openwith', 'kfmclient exec')
elif widget.get_active() == 3:
gajim.config.set('openwith', 'exo-open')
self.xml.get_object('custom_apps_frame').hide()
gajim.interface.save_config()
def on_custom_browser_entry_changed(self, widget):

View File

@ -223,7 +223,9 @@ def get_default_font():
def autodetect_browser_mailer():
# recognize the environment and set appropriate browser/mailer
if user_runs_gnome():
if user_supports_xdg_open():
gajim.config.set('openwith', 'xdg-open')
elif user_runs_gnome():
gajim.config.set('openwith', 'gnome-open')
elif user_runs_kde():
gajim.config.set('openwith', 'kfmclient exec')
@ -232,6 +234,10 @@ def autodetect_browser_mailer():
else:
gajim.config.set('openwith', 'custom')
def user_supports_xdg_open():
import os.path
return os.path.isfile('/usr/bin/xdg-open')
def user_runs_gnome():
return 'gnome-session' in get_running_processes()