Example #1
0
    def _detect_dbus_caps(self):
        if sys.platform in ('win32', 'darwin'):
            return

        if app.is_flatpak():
            self._dbus_available = True
            return

        def on_proxy_ready(_source, res, _data=None):
            try:
                proxy = Gio.DBusProxy.new_finish(res)
                self._daemon_capabilities = proxy.GetCapabilities()
            except GLib.Error as error:
                log.warning('Notifications D-Bus not available: %s', error)
            else:
                self._dbus_available = True
                log.info('Notifications D-Bus connected')

        log.info('Connecting to Notifications D-Bus')
        Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION,
                                  Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS,
                                  None, 'org.freedesktop.Notifications',
                                  '/org/freedesktop/Notifications',
                                  'org.freedesktop.Notifications', None,
                                  on_proxy_ready)
Example #2
0
    def on_install_plugin_button_clicked(self, widget):
        if app.is_flatpak():
            open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/flathub')
            return

        def show_warn_dialog():
            text = _('Archive is malformed')
            dialog = WarningDialog(text, '', transient_for=self.window)
            dialog.set_modal(False)
            dialog.popup()

        def _on_plugin_exists(zip_filename):
            def _on_yes():
                plugin = app.plugin_manager.install_from_zip(
                    zip_filename, True)
                if not plugin:
                    show_warn_dialog()
                    return

            NewConfirmationDialog(
                _('Overwrite Plugin?'),
                _('Plugin already exists'),
                _('Do you want to overwrite the currently installed version?'),
                [
                    DialogButton.make('Cancel'),
                    DialogButton.make(
                        'Remove', text=_('_Overwrite'), callback=_on_yes)
                ],
                transient_for=self.window).show()

        def _try_install(zip_filename):
            try:
                plugin = app.plugin_manager.install_from_zip(zip_filename)
            except PluginsystemError as er_type:
                error_text = str(er_type)
                if error_text == _('Plugin already exists'):
                    _on_plugin_exists(zip_filename)
                    return

                WarningDialog(error_text, '"%s"' % zip_filename, self.window)
                return
            if not plugin:
                show_warn_dialog()
                return

        ArchiveChooserDialog(_try_install, transient_for=self.window)
Example #3
0
def _require_native() -> bool:
    if app.is_flatpak():
        return True
    if sys.platform in ('win32', 'darwin'):
        return True
    return False
Example #4
0
File: gui.py Project: bj-h/gajim
    def __init__(self):
        '''Initialize Plugins window'''
        builder = get_builder('plugins_window.ui')
        self.window = builder.get_object('plugins_window')
        self.window.set_transient_for(app.interface.roster.window)

        widgets_to_extract = ('plugins_notebook', 'plugin_name_label',
                              'plugin_version_label', 'plugin_authors_label',
                              'plugin_homepage_linkbutton',
                              'install_plugin_button',
                              'uninstall_plugin_button',
                              'configure_plugin_button',
                              'installed_plugins_treeview', 'available_text',
                              'available_text_label')

        for widget_name in widgets_to_extract:
            setattr(self, widget_name, builder.get_object(widget_name))

        self.plugin_description_textview = builder.get_object('description')

        # Disable 'Install from ZIP' for Flatpak installs
        if app.is_flatpak():
            self.install_plugin_button.set_tooltip_text(
                _('Click to view Gajim\'s wiki page on how to install plugins in Flatpak.'
                  ))

        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
                                                     GdkPixbuf.Pixbuf)
        self.installed_plugins_treeview.set_model(self.installed_plugins_model)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))  #, renderer, text=Column.NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', Column.ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.NAME)
        col.set_property('expand', True)
        self.installed_plugins_treeview.append_column(col)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.installed_plugins_toggled_cb)
        col = Gtk.TreeViewColumn(_('Active'),
                                 renderer,
                                 active=Column.ACTIVE,
                                 activatable=Column.ACTIVATABLE)
        self.installed_plugins_treeview.append_column(col)

        self.def_icon = load_icon('preferences-desktop',
                                  self.window,
                                  pixbuf=True)

        # connect signal for selection change
        selection = self.installed_plugins_treeview.get_selection()
        selection.connect('changed',
                          self.installed_plugins_treeview_selection_changed)
        selection.set_mode(Gtk.SelectionMode.SINGLE)

        self._clear_installed_plugin_info()

        self.fill_installed_plugins_model()
        root_iter = self.installed_plugins_model.get_iter_first()
        if root_iter:
            selection.select_iter(root_iter)

        builder.connect_signals(self)

        self.plugins_notebook.set_current_page(0)

        # Adding GUI extension point for Plugins that want to hook the Plugin Window
        app.plugin_manager.gui_extension_point('plugin_window', self)

        self.window.show_all()
Example #5
0
File: gui.py Project: bj-h/gajim
    def on_install_plugin_button_clicked(self, widget):
        if app.is_flatpak():
            open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/flathub')
            return

        def show_warn_dialog():
            text = _('Archive is malformed')
            dialog = WarningDialog(text, '', transient_for=self.window)
            dialog.set_modal(False)
            dialog.popup()

        def _on_plugin_exists(zip_filename):
            def _on_yes():
                plugin = app.plugin_manager.install_from_zip(
                    zip_filename, True)
                if not plugin:
                    show_warn_dialog()
                    return
                model = self.installed_plugins_model

                for _index, row in enumerate(model):
                    if plugin == row[Column.PLUGIN]:
                        model.remove(row.iter)
                        break

                iter_ = model.append([
                    plugin, plugin.name, False, plugin.activatable,
                    self.get_plugin_icon(plugin)
                ])
                sel = self.installed_plugins_treeview.get_selection()
                sel.select_iter(iter_)

            NewConfirmationDialog(
                _('Overwrite Plugin?'),
                _('Plugin already exists'),
                _('Do you want to overwrite the currently installed version?'),
                [
                    DialogButton.make('Cancel'),
                    DialogButton.make(
                        'Remove', text=_('_Overwrite'), callback=_on_yes)
                ],
                transient_for=self.window).show()

        def _try_install(zip_filename):
            try:
                plugin = app.plugin_manager.install_from_zip(zip_filename)
            except PluginsystemError as er_type:
                error_text = str(er_type)
                if error_text == _('Plugin already exists'):
                    _on_plugin_exists(zip_filename)
                    return

                WarningDialog(error_text, '"%s"' % zip_filename, self.window)
                return
            if not plugin:
                show_warn_dialog()
                return
            model = self.installed_plugins_model
            iter_ = model.append([
                plugin, plugin.name, False, plugin.activatable,
                self.get_plugin_icon(plugin)
            ])
            sel = self.installed_plugins_treeview.get_selection()
            sel.select_iter(iter_)

        ArchiveChooserDialog(_try_install, transient_for=self.window)
Example #6
0
    def __init__(self):
        Gtk.ApplicationWindow.__init__(self)
        EventHelper.__init__(self)

        self.set_application(app.app)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_default_size(650, 500)
        self.set_show_menubar(False)
        self.set_title(_('Plugins'))

        self._ui = get_builder('plugins_window.ui')
        self.add(self._ui.plugins_notebook)

        # Disable 'Install from ZIP' for Flatpak installs
        if app.is_flatpak():
            self._ui.install_plugin_button.set_tooltip_text(
                _('Click to view Gajim\'s wiki page on how to install plugins '
                  'in Flatpak.'))

        self.installed_plugins_model = Gtk.ListStore(object, str, bool, bool,
                                                     GdkPixbuf.Pixbuf)
        self._ui.installed_plugins_treeview.set_model(
            self.installed_plugins_model)

        renderer = Gtk.CellRendererText()
        col = Gtk.TreeViewColumn(_('Plugin'))  # , renderer, text=Column.NAME)
        cell = Gtk.CellRendererPixbuf()
        col.pack_start(cell, False)
        col.add_attribute(cell, 'pixbuf', Column.ICON)
        col.pack_start(renderer, True)
        col.add_attribute(renderer, 'text', Column.NAME)
        col.set_property('expand', True)
        self._ui.installed_plugins_treeview.append_column(col)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self._installed_plugin_toggled)
        col = Gtk.TreeViewColumn(_('Active'), renderer, active=Column.ACTIVE,
                                 activatable=Column.ACTIVATABLE)
        self._ui.installed_plugins_treeview.append_column(col)

        self.def_icon = load_icon('preferences-desktop', self, pixbuf=True)

        # connect signal for selection change
        selection = self._ui.installed_plugins_treeview.get_selection()
        selection.connect(
            'changed', self._installed_plugins_treeview_selection_changed)
        selection.set_mode(Gtk.SelectionMode.SINGLE)

        self._clear_installed_plugin_info()

        self._fill_installed_plugins_model()
        root_iter = self.installed_plugins_model.get_iter_first()
        if root_iter:
            selection.select_iter(root_iter)

        self.connect('destroy', self._on_destroy)
        self.connect('key-press-event', self._on_key_press)
        self._ui.connect_signals(self)

        self._ui.plugins_notebook.set_current_page(0)

        # Adding GUI extension point for Plugins that want to hook
        # the Plugin Window
        app.plugin_manager.gui_extension_point('plugin_window', self)

        self.register_events([
            ('plugin-removed', ged.GUI1, self._on_plugin_removed),
            ('plugin-added', ged.GUI1, self._on_plugin_added),
        ])

        self.show_all()