[liorithiel] autodetect everytime browser/mailer by default
This commit is contained in:
parent
8521c7b8e3
commit
bae6755899
|
@ -24,6 +24,7 @@ import os
|
||||||
import common.config
|
import common.config
|
||||||
import common.sleepy
|
import common.sleepy
|
||||||
|
|
||||||
|
import gtkgui_helpers
|
||||||
import dialogs
|
import dialogs
|
||||||
import cell_renderer_image
|
import cell_renderer_image
|
||||||
import cell_renderer_image
|
import cell_renderer_image
|
||||||
|
@ -358,12 +359,17 @@ class PreferencesWindow:
|
||||||
self.links_frame.set_no_show_all(True)
|
self.links_frame.set_no_show_all(True)
|
||||||
else:
|
else:
|
||||||
self.links_open_with_combobox = self.xml.get_widget('links_open_with_combobox')
|
self.links_open_with_combobox = self.xml.get_widget('links_open_with_combobox')
|
||||||
if gajim.config.get('openwith') == 'gnome-open':
|
if gajim.config.get('autodetect_browser_mailer'):
|
||||||
self.links_open_with_combobox.set_active(0)
|
self.links_open_with_combobox.set_active(0)
|
||||||
|
gtkgui_helpers.plugin.autodetect_browser_mailer()
|
||||||
|
# autodetect_browser_mailer is now False.
|
||||||
|
# so user has 'Always Use GNOME/KDE' or Custom
|
||||||
|
elif gajim.config.get('openwith') == 'gnome-open':
|
||||||
|
self.links_open_with_combobox.set_active(1)
|
||||||
elif gajim.config.get('openwith') == 'kfmclient exec':
|
elif gajim.config.get('openwith') == 'kfmclient exec':
|
||||||
self.links_open_with_combobox.set_active(True)
|
|
||||||
elif gajim.config.get('openwith') == 'custom':
|
|
||||||
self.links_open_with_combobox.set_active(2)
|
self.links_open_with_combobox.set_active(2)
|
||||||
|
elif gajim.config.get('openwith') == 'custom':
|
||||||
|
self.links_open_with_combobox.set_active(3)
|
||||||
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
||||||
self.xml.get_widget('custom_browser_entry').set_text(
|
self.xml.get_widget('custom_browser_entry').set_text(
|
||||||
gajim.config.get('custombrowser'))
|
gajim.config.get('custombrowser'))
|
||||||
|
@ -779,13 +785,16 @@ class PreferencesWindow:
|
||||||
self.save_status_messages(model)
|
self.save_status_messages(model)
|
||||||
|
|
||||||
def on_links_open_with_combobox_changed(self, widget):
|
def on_links_open_with_combobox_changed(self, widget):
|
||||||
|
gajim.config.set('autodetect_browser_mailer', False)
|
||||||
if widget.get_active() == 2:
|
if widget.get_active() == 2:
|
||||||
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
self.xml.get_widget('custom_apps_frame').set_sensitive(True)
|
||||||
gajim.config.set('openwith', 'custom')
|
gajim.config.set('openwith', 'custom')
|
||||||
else:
|
else:
|
||||||
if widget.get_active() == 0:
|
if widget.get_active() == 0:
|
||||||
|
gajim.config.set('autodetect_browser_mailer', True)
|
||||||
|
elif widget.get_active() == 1:
|
||||||
gajim.config.set('openwith', 'gnome-open')
|
gajim.config.set('openwith', 'gnome-open')
|
||||||
if widget.get_active() == 1:
|
elif widget.get_active() == 2:
|
||||||
gajim.config.set('openwith', 'kfmclient exec')
|
gajim.config.set('openwith', 'kfmclient exec')
|
||||||
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
|
self.xml.get_widget('custom_apps_frame').set_sensitive(False)
|
||||||
self.plugin.save_config()
|
self.plugin.save_config()
|
||||||
|
|
|
@ -30,6 +30,7 @@ except RuntimeError, msg:
|
||||||
if str(msg) == 'could not open display':
|
if str(msg) == 'could not open display':
|
||||||
print 'Gajim needs Xserver to run. Exiting...'
|
print 'Gajim needs Xserver to run. Exiting...'
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
import os
|
import os
|
||||||
|
@ -37,6 +38,7 @@ import sre
|
||||||
import signal
|
import signal
|
||||||
import getopt
|
import getopt
|
||||||
import time
|
import time
|
||||||
|
import gtkgui_helpers
|
||||||
|
|
||||||
from common import i18n
|
from common import i18n
|
||||||
i18n.init()
|
i18n.init()
|
||||||
|
@ -937,6 +939,10 @@ class Interface:
|
||||||
gajim.config.set_per('themes', theme, o,
|
gajim.config.set_per('themes', theme, o,
|
||||||
default[theme][d.index(o)])
|
default[theme][d.index(o)])
|
||||||
|
|
||||||
|
|
||||||
|
if gajim.config.get('autodetect_browser_mailer'):
|
||||||
|
gtkgui_helpers.plugin.autodetect_browser_mailer()
|
||||||
|
|
||||||
if gajim.verbose:
|
if gajim.verbose:
|
||||||
gajim.log.setLevel(gajim.logging.DEBUG)
|
gajim.log.setLevel(gajim.logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -5169,8 +5169,9 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkComboBox" id="links_open_with_combobox">
|
<widget class="GtkComboBox" id="links_open_with_combobox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="items" translatable="yes">GNOME default applications
|
<property name="items" translatable="yes">Autodetect
|
||||||
KDE default applications
|
Always use GNOME default applications
|
||||||
|
Always use KDE default applications
|
||||||
Custom</property>
|
Custom</property>
|
||||||
<signal name="changed" handler="on_links_open_with_combobox_changed" last_modification_time="Sat, 05 Mar 2005 16:44:57 GMT"/>
|
<signal name="changed" handler="on_links_open_with_combobox_changed" last_modification_time="Sat, 05 Mar 2005 16:44:57 GMT"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -35,3 +35,41 @@ def escape_for_pango_markup(string):
|
||||||
'"': '"'})
|
'"': '"'})
|
||||||
|
|
||||||
return escaped_str
|
return escaped_str
|
||||||
|
|
||||||
|
def autodetect_browser_mailer(self):
|
||||||
|
#recognize the environment for appropriate browser/mailer
|
||||||
|
if os.path.isdir('/proc'):
|
||||||
|
# under Linux: checking if 'gnome-session' or
|
||||||
|
# 'startkde' programs were run before gajim, by
|
||||||
|
# checking /proc (if it exists)
|
||||||
|
#
|
||||||
|
# if something is unclear, read `man proc`;
|
||||||
|
# if /proc exists, directories that have only numbers
|
||||||
|
# in their names contain data about processes.
|
||||||
|
# /proc/[xxx]/exe is a symlink to executable started
|
||||||
|
# as process number [xxx].
|
||||||
|
# filter out everything that we are not interested in:
|
||||||
|
files = os.listdir('/proc')
|
||||||
|
|
||||||
|
# files that doesn't have only digits in names...
|
||||||
|
files = filter(str.isdigit, files)
|
||||||
|
|
||||||
|
# files that aren't directories...
|
||||||
|
files = filter(lambda f:os.path.isdir('/proc/' + f), files)
|
||||||
|
|
||||||
|
# processes owned by somebody not running gajim...
|
||||||
|
# (we check if we have access to that file)
|
||||||
|
files = filter(lambda f:os.access('/proc/' + f +'/exe', os.F_OK), files)
|
||||||
|
|
||||||
|
# be sure that /proc/[number]/exe is really a symlink
|
||||||
|
# to avoid TBs in incorrectly configured systems
|
||||||
|
files = filter(lambda f:os.path.islink('/proc/' + f + '/exe'), files)
|
||||||
|
|
||||||
|
# list of processes
|
||||||
|
processes = [os.path.basename(os.readlink('/proc/' + f +'/exe')) for f in files]
|
||||||
|
if 'gnome-session' in processes:
|
||||||
|
gajim.config.set('openwith', 'gnome-open')
|
||||||
|
elif 'startkde' in processes:
|
||||||
|
gajim.config.set('openwith', 'kfmclient exec')
|
||||||
|
else:
|
||||||
|
gajim.config.set('openwith', 'custom')
|
||||||
|
|
Loading…
Reference in New Issue