def detect_dependencies(): import gi # ZEROCONF try: import pybonjour # pylint: disable=unused-import _dependencies['PYBONJOUR'] = True except Exception: pass try: gi.require_version('Avahi', '0.6') from gi.repository import Avahi # pylint: disable=unused-import _dependencies['AVAHI'] = True except Exception: pass try: gi.require_version('Gst', '1.0') from gi.repository import Gst _dependencies['GST'] = True except Exception: pass try: gi.require_version('Farstream', '0.2') from gi.repository import Farstream _dependencies['FARSTREAM'] = True except Exception: pass try: if _dependencies['GST'] and _dependencies['FARSTREAM']: Gst.init(None) conference = Gst.ElementFactory.make('fsrtpconference', None) conference.new_session(Farstream.MediaType.AUDIO) _dependencies['AV'] = True except Exception as error: log('gajim').warning('AV dependency test failed: %s', error) # GEOCLUE try: gi.require_version('Geoclue', '2.0') from gi.repository import Geoclue # pylint: disable=unused-import _dependencies['GEOCLUE'] = True except (ImportError, ValueError): pass # UPNP try: gi.require_version('GUPnPIgd', '1.0') from gi.repository import GUPnPIgd global gupnp_igd gupnp_igd = GUPnPIgd.SimpleIgd() _dependencies['UPNP'] = True except ValueError: pass # IDLE try: from gajim.common import idle if idle.Monitor.is_available(): _dependencies['IDLE'] = True except Exception: pass # GSOUND try: gi.require_version('GSound', '1.0') from gi.repository import GLib from gi.repository import GSound global gsound_ctx gsound_ctx = GSound.Context() try: gsound_ctx.init() _dependencies['GSOUND'] = True except GLib.Error as error: log('gajim').warning('GSound init failed: %s', error) except (ImportError, ValueError): pass # GSPELL try: gi.require_version('Gspell', '1') from gi.repository import Gspell langs = Gspell.language_get_available() for lang in langs: log('gajim').info('%s (%s) dict available', lang.get_name(), lang.get_code()) if langs: _dependencies['GSPELL'] = True except (ImportError, ValueError): pass # Print results for dep, val in _dependencies.items(): log('gajim').info('%-13s %s', dep, val) log('gajim').info('Used language: %s', LANG)
def detect_dependencies(): import gi # ZEROCONF try: import pybonjour # pylint: disable=unused-import _dependencies['PYBONJOUR'] = True except Exception: pass try: gi.require_version('Avahi', '0.6') from gi.repository import Avahi # pylint: disable=unused-import _dependencies['AVAHI'] = True except Exception: pass # FARSTREAM try: if os.name == 'nt': root_path = Path(sys.executable).parents[1] fs_plugin_path = str(root_path / 'lib' / 'farstream-0.2') gst_plugin_path = str(root_path / 'lib' / 'gstreamer-1.0') os.environ['FS_PLUGIN_PATH'] = fs_plugin_path os.environ['GST_PLUGIN_PATH'] = gst_plugin_path gi.require_version('Farstream', '0.2') from gi.repository import Farstream gi.require_version('Gst', '1.0') from gi.repository import Gst try: Gst.init(None) conference = Gst.ElementFactory.make('fsrtpconference', None) conference.new_session(Farstream.MediaType.AUDIO) except Exception as error: log('gajim').info(error) _dependencies['FARSTREAM'] = True except (ImportError, ValueError): pass # GEOCLUE try: gi.require_version('Geoclue', '2.0') from gi.repository import Geoclue # pylint: disable=unused-import _dependencies['GEOCLUE'] = True except (ImportError, ValueError): pass # UPNP try: gi.require_version('GUPnPIgd', '1.0') from gi.repository import GUPnPIgd global gupnp_igd gupnp_igd = GUPnPIgd.SimpleIgd() _dependencies['UPNP'] = True except ValueError: pass # PYCURL try: import pycurl # pylint: disable=unused-import _dependencies['PYCURL'] = True except ImportError: pass # IDLE try: from gajim.common import idle if idle.Monitor.is_available(): _dependencies['IDLE'] = True except Exception: pass # GSPELL try: gi.require_version('Gspell', '1') from gi.repository import Gspell langs = Gspell.language_get_available() for lang in langs: log('gajim').info('%s (%s) dict available', lang.get_name(), lang.get_code()) if langs: _dependencies['GSPELL'] = True except (ImportError, ValueError): pass # Print results for dep, val in _dependencies.items(): log('gajim').info('%-13s %s', dep, val) log('gajim').info('Used language: %s', LANG)
def detect_dependencies(): import gi # ZEROCONF try: if os.name == 'nt': import pybonjour _dependencies['PYBONJOUR'] = True else: import dbus _dependencies['PYTHON-DBUS'] = True except Exception: pass # python-gnupg try: import gnupg ''' We need https://pypi.python.org/pypi/python-gnupg but https://pypi.python.org/pypi/gnupg shares the same package name. It cannot be used as a drop-in replacement. We test with a version check if python-gnupg is installed as it is on a much lower version number than gnupg Also we need at least python-gnupg 0.3.8 ''' v_gnupg = gnupg.__version__ if V(v_gnupg) < V('0.3.8') or V(v_gnupg) > V('1.0.0'): log('gajim').info('Gajim needs python-gnupg >= 0.3.8') raise ImportError _dependencies['PYGPG'] = True except ImportError: pass # GPG BINARY import subprocess def test_gpg(binary='gpg'): if os.name == 'nt': gpg_cmd = binary + ' -h >nul 2>&1' else: gpg_cmd = binary + ' -h >/dev/null 2>&1' if subprocess.call(gpg_cmd, shell=True): return False return True if test_gpg(binary='gpg2'): _dependencies['GPG_BINARY'] = 'gpg2' elif test_gpg(binary='gpg'): _dependencies['GPG_BINARY'] = 'gpg' # FARSTREAM try: if os.name == 'nt': os.environ['FS_PLUGIN_PATH'] = 'gtk\\lib\\farstream-0.1' os.environ['GST_PLUGIN_PATH'] = 'gtk\\lib\\gstreamer-0.10' gi.require_version('Farstream', '0.2') from gi.repository import Farstream gi.require_version('Gst', '1.0') from gi.repository import Gst try: Gst.init(None) conference = Gst.ElementFactory.make('fsrtpconference', None) session = conference.new_session(Farstream.MediaType.AUDIO) except Exception as error: log('gajim').info(error) _dependencies['FARSTREAM'] = True except (ImportError, ValueError): pass # GEOCLUE try: gi.require_version('Geoclue', '2.0') from gi.repository import Geoclue _dependencies['GEOCLUE'] = True except (ImportError, ValueError): pass # UPNP try: gi.require_version('GUPnPIgd', '1.0') from gi.repository import GUPnPIgd gupnp_igd = GUPnPIgd.SimpleIgd() _dependencies['UPNP'] = True except ValueError: pass # PYCURL try: import pycurl _dependencies['PYCURL'] = True except ImportError: pass # IDLE try: from gajim.common import idle if idle.Monitor.is_available(): _dependencies['IDLE'] = True except Exception: pass # GSPELL try: gi.require_version('Gspell', '1') from gi.repository import Gspell langs = Gspell.language_get_available() for lang in langs: log('gajim').info('%s (%s) dict available', lang.get_name(), lang.get_code()) if langs: _dependencies['GSPELL'] = True except (ImportError, ValueError): pass # Print results for dep, val in _dependencies.items(): log('gajim').info('%-13s %s', dep, val)
def __init__(self, transient_for, settings): super().__init__(transient_for=transient_for, modal=True) self.settings = settings self.set_default_size(340, 340) hints = Gdk.Geometry() hints.min_width = 340 hints.min_height = 340 self.set_geometry_hints(None, hints, Gdk.WindowHints.MIN_SIZE) self.set_border_width(5) self.set_deletable(False) self.set_title(_('Preferences')) langs_available: List[ Gspell.Language] = Gspell.language_get_available() langs_available_model = Gtk.ListStore(str, str) for lang in langs_available: langs_available_model.append((lang.get_code(), lang.get_name())) self.toast = Granite.WidgetsToast(title=_("Toast")) indent_width = Gtk.SpinButton.new_with_range(1, 24, 1) indent_width.set_value(self.settings.get_int('indent-width')) indent_width.connect('value-changed', self.on_indent_width) self.sort_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.sort_switch.set_state(self.settings.get_boolean('sort-desc')) self.sort_switch.connect("state-set", self.on_sort_desc) self.spellcheck_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.spellcheck_switch.set_state( self.settings.get_boolean('spellcheck')) self.spellcheck_switch.connect("state-set", self.on_spellcheck) self.spellcheck_language_chooser = Gtk.ComboBox() self.spellcheck_language_chooser.set_model(langs_available_model) self.spellcheck_language_chooser.set_id_column(0) self.spellcheck_language_chooser.set_entry_text_column(1) renderer_text = Gtk.CellRendererText() self.spellcheck_language_chooser.pack_start(renderer_text, True) self.spellcheck_language_chooser.add_attribute(renderer_text, "text", 1) self.spellcheck_language_chooser.set_active_id( self.settings.get_string('spellcheck-language')) self.spellcheck_language_chooser.connect('changed', self.on_spellcheck_language) self.autosave_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.autosave_switch.set_state(self.settings.get_boolean('autosave')) self.autosave_switch.connect("state-set", self.on_autosave) self.autoindent_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.autoindent_switch.set_state( self.settings.get_boolean('autoindent')) self.autoindent_switch.connect("state-set", self.on_autoindent) self.spaces_tabs_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.spaces_tabs_switch.set_state( self.settings.get_boolean('spaces-instead-of-tabs')) self.spaces_tabs_switch.connect("state-set", self.on_spaces_tabs) general_grid = Gtk.Grid(column_spacing=8, row_spacing=8) general_grid.attach(Granite.HeaderLabel(_("General")), 0, 0, 3, 1) general_grid.attach( Gtk.Label(_("Save files when changed:"), hexpand=True, halign=Gtk.Align.END), 0, 1, 2, 1) general_grid.attach(self.autosave_switch, 2, 1, 1, 1) general_grid.attach( Gtk.Label(_("Sort documents backwards:"), hexpand=True, halign=Gtk.Align.END), 0, 2, 2, 1) general_grid.attach(self.sort_switch, 2, 2, 1, 1) general_grid.attach( Gtk.Label(_("Spell checking:"), hexpand=True, halign=Gtk.Align.END), 0, 3, 2, 1) general_grid.attach(self.spellcheck_switch, 2, 3, 1, 1) general_grid.attach( Gtk.Label(_("Language:"), hexpand=True, halign=Gtk.Align.END), 0, 4, 2, 1) general_grid.attach(self.spellcheck_language_chooser, 2, 4, 1, 1) general_grid.attach(Granite.HeaderLabel(_("Tabs")), 0, 5, 3, 1) general_grid.attach( Gtk.Label(_("Automatic indentation:"), hexpand=True, halign=Gtk.Align.END), 0, 6, 2, 1) general_grid.attach(self.autoindent_switch, 2, 6, 1, 1) general_grid.attach( Gtk.Label(_("Insert spaces instead of tabs:"), hexpand=True, halign=Gtk.Align.END), 0, 7, 2, 1) general_grid.attach(self.spaces_tabs_switch, 2, 7, 1, 1) general_grid.attach( Gtk.Label(_("Tab width:"), hexpand=True, halign=Gtk.Align.END), 0, 8, 2, 1) general_grid.attach(indent_width, 2, 8, 2, 1) # Interface grid interface_grid = Gtk.Grid(column_spacing=8, row_spacing=8) scrolled = Gtk.ScrolledWindow(hexpand=True, vexpand=True) self.dark_theme_switch = Gtk.Switch(halign=Gtk.Align.START, valign=Gtk.Align.CENTER) self.dark_theme_switch.set_state( self.settings.get_boolean('prefer-dark-theme')) self.dark_theme_switch.connect("state-set", self.on_dark_theme) style_chooser = GtkSource.StyleSchemeChooserWidget(hexpand=True, vexpand=True) style_chooser.connect('notify::style-scheme', self.on_scheme_changed) scrolled.add(style_chooser) scheme = GtkSource.StyleSchemeManager.get_default().get_scheme( self.settings.get_string('stylescheme')) if not scheme: scheme = GtkSource.StyleSchemeManager().get_scheme("classic") style_chooser.set_style_scheme(scheme) interface_grid.attach(Granite.HeaderLabel(_("Appearance")), 0, 0, 3, 1) interface_grid.attach( Gtk.Label(_("Prefer dark theme:"), hexpand=True, halign=Gtk.Align.END), 0, 1, 2, 1) interface_grid.attach(self.dark_theme_switch, 2, 1, 1, 1) interface_grid.attach(Granite.HeaderLabel(_("Styles")), 0, 2, 3, 1) interface_grid.attach(scrolled, 0, 3, 3, 1) # Export grid export_grid = Gtk.Grid(column_spacing=8, row_spacing=8) self.render_medium(export_grid) self.render_writeas(export_grid) # Main Stack main_stack = Gtk.Stack(margin=6, margin_bottom=18, margin_top=8) main_stack.add_titled(general_grid, "behavior", _("Behavior")) main_stack.add_titled(interface_grid, "interface", _("Interface")) main_stack.add_titled(export_grid, "export", _("Export")) main_stackswitcher = Gtk.StackSwitcher(homogeneous=True) main_stackswitcher.set_stack(main_stack) main_stackswitcher.set_halign(Gtk.Align.CENTER) main_grid = Gtk.Grid() main_grid.attach(main_stackswitcher, 0, 0, 1, 1) main_grid.attach(main_stack, 0, 1, 1, 1) self.overlay = Gtk.Overlay() self.overlay.add(main_grid) self.overlay.add_overlay(self.toast) self.get_content_area().add(self.overlay) close_button = Gtk.Button(label=_("Close")) close_button.connect('clicked', self.on_close_activated) self.add_action_widget(close_button, 0)
HAVE_PYCURL = False try: from gajim.common import sleepy if sleepy.SUPPORTED: HAVE_IDLE = True except Exception: glog.info(_('Unable to load idle module')) HAVE_IDLE = False HAVE_SPELL = False try: spell_log = logging.getLogger('gajim.speller') gi.require_version('Gspell', '1') from gi.repository import Gspell langs = Gspell.language_get_available() for lang in langs: spell_log.info('%s (%s) dict available', lang.get_name(), lang.get_code()) if langs: HAVE_SPELL = True else: spell_log.info('No dicts available') except (ImportError, ValueError): pass gajim_identity = {'type': 'pc', 'category': 'client', 'name': 'Gajim'} gajim_common_features = [ nbxmpp.NS_BYTESTREAM, nbxmpp.NS_SI, nbxmpp.NS_FILE, nbxmpp.NS_MUC, nbxmpp.NS_MUC_USER, nbxmpp.NS_MUC_ADMIN, nbxmpp.NS_MUC_OWNER, nbxmpp.NS_MUC_CONFIG, nbxmpp.NS_COMMANDS, nbxmpp.NS_DISCO_INFO, 'ipv6',