set transient for roster windows to error / warning dialogs. Fixes #6942
[gajim.git] / src / features_window.py
blob58c4a80afc92f1173de163d9e1c5a166bda1418c
1 # -*- coding:utf-8 -*-
2 ## src/features_window.py
3 ##
4 ## Copyright (C) 2007 Jean-Marie Traissard <jim AT lapin.org>
5 ## Julien Pivotto <roidelapluie AT gmail.com>
6 ## Stefan Bethge <stefan AT lanpartei.de>
7 ## Stephan Erb <steve-e AT h3c.de>
8 ## Copyright (C) 2007-2010 Yann Leboulanger <asterix AT lagaule.org>
9 ## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
11 ## This file is part of Gajim.
13 ## Gajim is free software; you can redistribute it and/or modify
14 ## it under the terms of the GNU General Public License as published
15 ## by the Free Software Foundation; version 3 only.
17 ## Gajim is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
26 import os
27 import sys
28 import gtk
29 import gtkgui_helpers
31 from common import gajim
32 from common import helpers
33 from common import kwalletbinding
34 from common.i18n import Q_
36 class FeaturesWindow:
37 """
38 Class for features window
39 """
41 def __init__(self):
42 self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui')
43 self.window = self.xml.get_object('features_window')
44 self.window.set_transient_for(gajim.interface.roster.window)
45 treeview = self.xml.get_object('features_treeview')
46 self.desc_label = self.xml.get_object('feature_desc_label')
48 # {name: (available_function, unix_text, windows_text)}
49 self.features = {
50 _('SSL certificate validation'): (self.pyopenssl_available,
51 _('A library used to validate server certificates to ensure a secure connection.'),
52 _('Requires python-pyopenssl.'),
53 _('Requires python-pyopenssl.')),
54 _('Bonjour / Zeroconf'): (self.zeroconf_available,
55 _('Serverless chatting with autodetected clients in a local network.'),
56 _('Requires python-avahi.'),
57 _('Requires pybonjour (http://o2s.csail.mit.edu/o2s-wiki/pybonjour).')),
58 _('Command line'): (self.dbus_available,
59 _('A script to control Gajim via commandline.'),
60 _('Requires python-dbus.'),
61 _('Feature not available under Windows.')),
62 _('OpenGPG message encryption'): (self.gpg_available,
63 _('Encrypting chat messages with gpg keys.'),
64 _('Requires gpg and python-gnupg (http://code.google.com/p/python-gnupg/).'),
65 _('Requires gpg.exe in PATH.')),
66 _('Network-manager'): (self.network_manager_available,
67 _('Autodetection of network status.'),
68 _('Requires gnome-network-manager and python-dbus.'),
69 _('Feature not available under Windows.')),
70 _('Session Management'): (self.session_management_available,
71 _('Gajim session is stored on logout and restored on login.'),
72 _('Requires python-gnome2.'),
73 _('Feature not available under Windows.')),
74 _('Password encryption'): (self.some_keyring_available,
75 _('Passwords can be stored securely and not just in plaintext.'),
76 _('Requires gnome-keyring and python-gnome2-desktop, or kwalletcli.'),
77 _('Feature not available under Windows.')),
78 _('SRV'): (self.srv_available,
79 _('Ability to connect to servers which are using SRV records.'),
80 _('Requires dnsutils.'),
81 _('Requires nslookup to use SRV records.')),
82 _('Spell Checker'): (self.speller_available,
83 _('Spellchecking of composed messages.'),
84 _('Requires libgtkspell.'),
85 _('Feature not available under Windows.')),
86 _('Notification'): (self.notification_available,
87 _('Passive popups notifying for new events.'),
88 _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.'),
89 _('Feature not available under Windows.')),
90 _('Automatic status'): (self.idle_available,
91 _('Ability to measure idle time, in order to set auto status.'),
92 _('Requires libxss library.'),
93 _('Requires python2.5.')),
94 _('LaTeX'): (self.latex_available,
95 _('Transform LaTeX expressions between $$ $$.'),
96 _('Requires texlive-latex-base and (dvipng or ImageMagick). You have to set \'use_latex\' to True in the Advanced Configuration Editor.'),
97 _('Requires texlive-latex-base and (dvipng or ImageMagick) (All is in MikTeX). You have to set \'use_latex\' to True in the Advanced Configuration Editor.')),
98 _('End to End message encryption'): (self.pycrypto_available,
99 _('Encrypting chat messages.'),
100 _('Requires python-crypto.'),
101 _('Requires python-crypto.')),
102 _('RST Generator'): (self.docutils_available,
103 _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).'),
104 _('Requires python-docutils.'),
105 _('Requires python-docutils.')),
106 _('Audio / Video'): (self.farsight_available,
107 _('Ability to start audio and video chat.'),
108 _('Requires python-farsight and gstreamer-plugins-bad.'),
109 _('Feature not available under Windows.')),
112 # name, supported
113 self.model = gtk.ListStore(str, bool)
114 treeview.set_model(self.model)
116 col = gtk.TreeViewColumn(Q_('?features:Available'))
117 treeview.append_column(col)
118 cell = gtk.CellRendererToggle()
119 cell.set_property('radio', True)
120 col.pack_start(cell)
121 col.set_attributes(cell, active = 1)
123 col = gtk.TreeViewColumn(_('Feature'))
124 treeview.append_column(col)
125 cell = gtk.CellRendererText()
126 col.pack_start(cell, expand = True)
127 col.add_attribute(cell, 'text', 0)
129 # Fill model
130 for feature in self.features:
131 func = self.features[feature][0]
132 rep = func()
133 self.model.append([feature, rep])
135 self.model.set_sort_column_id(0, gtk.SORT_ASCENDING)
137 self.xml.connect_signals(self)
138 self.window.show_all()
139 self.xml.get_object('close_button').grab_focus()
141 def on_close_button_clicked(self, widget):
142 self.window.destroy()
144 def on_features_treeview_cursor_changed(self, widget):
145 selection = widget.get_selection()
146 if not selection:
147 return
148 rows = selection.get_selected_rows()[1]
149 if not rows:
150 return
151 path = rows[0]
152 feature = self.model[path][0].decode('utf-8')
153 text = self.features[feature][1] + '\n'
154 if os.name == 'nt':
155 text = text + self.features[feature][3]
156 else:
157 text = text + self.features[feature][2]
158 self.desc_label.set_text(text)
160 def pyopenssl_available(self):
161 try:
162 import OpenSSL.SSL
163 import OpenSSL.crypto
164 except Exception:
165 return False
166 return True
168 def zeroconf_available(self):
169 return gajim.HAVE_ZEROCONF
171 def dbus_available(self):
172 if os.name == 'nt':
173 return False
174 from common import dbus_support
175 return dbus_support.supported
177 def gpg_available(self):
178 return gajim.HAVE_GPG
180 def network_manager_available(self):
181 if os.name == 'nt':
182 return False
183 import network_manager_listener
184 return network_manager_listener.supported
186 def session_management_available(self):
187 if os.name == 'nt':
188 return False
189 try:
190 __import__('gnome.ui')
191 except Exception:
192 return False
193 return True
195 def some_keyring_available(self):
196 if os.name == 'nt':
197 return False
198 if kwalletbinding.kwallet_available():
199 return True
200 try:
201 __import__('gnomekeyring')
202 except Exception:
203 return False
204 return True
206 def srv_available(self):
207 if os.name == 'nt':
208 return True
209 return helpers.is_in_path('nslookup')
211 def speller_available(self):
212 if os.name == 'nt':
213 return False
214 try:
215 __import__('gtkspell')
216 except ImportError:
217 return False
218 return True
220 def notification_available(self):
221 if os.name == 'nt':
222 return False
223 from common import dbus_support
224 if self.dbus_available() and dbus_support.get_notifications_interface():
225 return True
226 try:
227 __import__('pynotify')
228 except Exception:
229 return False
230 return True
232 def idle_available(self):
233 from common import sleepy
234 return sleepy.SUPPORTED
236 def latex_available(self):
237 from common import latex
238 return latex.check_for_latex_support()
240 def pycrypto_available(self):
241 return gajim.HAVE_PYCRYPTO
243 def docutils_available(self):
244 try:
245 __import__('docutils')
246 except Exception:
247 return False
248 return True
250 def farsight_available(self):
251 return gajim.HAVE_FARSIGHT