Fixed a bug with forcing autodetection of browser/mail during startup when the

config file already existed and had a different option choosen. Added in an
'Always use OS/X default applications' option for when running on OS/X. Changed
the custom defaults to use OS/X native applications.
This commit is contained in:
James Newton 2007-11-17 15:03:02 +00:00
parent 95a46ff9f9
commit f1d3f85037
6 changed files with 29 additions and 9 deletions

View File

@ -53,9 +53,9 @@ class Config:
DEFAULT_ICONSET = 'dcraven'
if sys.platform == 'darwin':
DEFAULT_OPENWITH = 'open'
DEFAULT_BROWSER = 'open -a firefox'
DEFAULT_MAILAPP = 'open -a thunderbird'
DEFAULT_FILE_MANAGER = 'open'
DEFAULT_BROWSER = 'open -a Safari'
DEFAULT_MAILAPP = 'open -a Mail'
DEFAULT_FILE_MANAGER = 'open -a Finder'
else:
DEFAULT_OPENWITH = 'gnome-open'
DEFAULT_BROWSER = 'firefox'

View File

@ -429,6 +429,9 @@ def launch_browser_mailer(kind, uri):
command = 'kfmclient exec'
elif gajim.config.get('openwith') == 'exo-open':
command = 'exo-open'
elif ((sys.platform == 'darwin') and
(gajim.config.get('openwith') == 'open')):
command = 'open'
elif gajim.config.get('openwith') == 'custom':
if kind == 'url':
command = gajim.config.get('custombrowser')
@ -456,6 +459,9 @@ def launch_file_manager(path_to_open):
command = 'kfmclient exec'
elif gajim.config.get('openwith') == 'exo-open':
command = 'exo-open'
elif ((sys.platform == 'darwin') and
(gajim.config.get('openwith') == 'open')):
command = 'open'
elif gajim.config.get('openwith') == 'custom':
command = gajim.config.get('custom_file_manager')
if command == '': # if no app is configured

View File

@ -63,7 +63,7 @@ class OptionsParser:
if os.path.exists(self.__filename):
#we talk about a file
print _('error: cannot open %s for reading') % self.__filename
return
return False
new_version = gajim.config.get('version')
new_version = new_version.split('-', 1)[0]
@ -80,6 +80,7 @@ class OptionsParser:
self.old_values = {} # clean mem
fd.close()
return True
def write_line(self, fd, opt, parents, value):
if value == None:

View File

@ -399,9 +399,12 @@ class PreferencesWindow:
self.xml.get_widget('custom_apps_frame').set_no_show_all(True)
if sys.platform == 'darwin':
self.applications_combobox.remove_text(4)
self.applications_combobox.remove_text(3)
self.applications_combobox.remove_text(2)
self.applications_combobox.remove_text(1)
self.applications_combobox.append_text("Always use OS/X default applications")
self.applications_combobox.append_text("Custom")
if gajim.config.get('autodetect_browser_mailer'):
self.applications_combobox.set_active(0)
@ -412,10 +415,13 @@ class PreferencesWindow:
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)
self.applications_combobox.set_active(3)
elif ((sys.platform == 'darwin') and
(gajim.config.get('openwith') == 'open')):
self.applications_combobox.set_active(1)
elif gajim.config.get('openwith') == 'custom':
if sys.platform == 'darwin':
self.applications_combobox.set_active(1)
self.applications_combobox.set_active(2)
else:
self.applications_combobox.set_active(4)
self.xml.get_widget('custom_apps_frame').show()
@ -912,6 +918,9 @@ class PreferencesWindow:
gajim.config.set('autodetect_browser_mailer', True)
self.xml.get_widget('custom_apps_frame').hide()
elif widget.get_active() == 1:
self.xml.get_widget('custom_apps_frame').hide()
gajim.config.set('openwith', 'open')
elif widget.get_active() == 2:
self.xml.get_widget('custom_apps_frame').show()
gajim.config.set('openwith', 'custom')
else:

View File

@ -2585,7 +2585,7 @@ class Interface:
'urlmsgcolor': gajim.config.get('urlmsgcolor'),
}
parser.read()
cfg_was_read = parser.read()
# Do not set gajim.verbose to False if -v option was given
if gajim.config.get('verbose'):
gajim.verbose = True
@ -2629,8 +2629,7 @@ class Interface:
gajim.config.set_per('themes', theme_name, o,
theme[d.index(o)])
if gajim.config.get('autodetect_browser_mailer') or \
len(gajim.connections) == 0:
if gajim.config.get('autodetect_browser_mailer') or not cfg_was_read:
gtkgui_helpers.autodetect_browser_mailer()
if gajim.verbose:

View File

@ -186,6 +186,8 @@ def autodetect_browser_mailer():
gajim.config.set('openwith', 'kfmclient exec')
elif user_runs_xfce():
gajim.config.set('openwith', 'exo-open')
elif user_runs_osx():
gajim.config.set('openwith', 'open')
else:
gajim.config.set('openwith', 'custom')
@ -201,6 +203,9 @@ def user_runs_xfce():
return True
return False
def user_runs_osx():
return sys.platform == 'darwin'
def get_running_processes():
'''returns running processes or None (if not /proc exists)'''
if os.path.isdir('/proc'):