Beispiel #1
0
def _info(type_, value, tb):
    if not _exception_in_progress.acquire(False):
        # Exceptions have piled up, so we use the default exception
        # handler for such exceptions
        _excepthook_save(type_, value, tb)
        return

    dialog = HigDialog(
        None, Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
        _('A programming error has been detected'),
        _('It probably is not fatal, but should be reported '
          'to the developers nonetheless.'))

    dialog.set_modal(False)
    #FIXME: add icon to this button
    RESPONSE_REPORT_BUG = 42
    dialog.add_buttons(Gtk.STOCK_CLOSE, Gtk.ButtonsType.CLOSE,
                       _('_Report Bug'), RESPONSE_REPORT_BUG)
    report_button = dialog.action_area.get_children()[0]  # right to left
    report_button.grab_focus()

    # Details
    textview = Gtk.TextView()
    textview.set_editable(False)
    textview.override_font(Pango.FontDescription('Monospace'))
    sw = Gtk.ScrolledWindow()
    sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    sw.add(textview)
    frame = Gtk.Frame()
    frame.set_shadow_type(Gtk.ShadowType.IN)
    frame.add(sw)
    frame.set_border_width(6)
    textbuffer = textview.get_buffer()
    trace = StringIO()
    traceback.print_exception(type_, value, tb, None, trace)
    textbuffer.set_text(trace.getvalue())
    textview.set_size_request(Gdk.Screen.width() / 3, Gdk.Screen.height() / 4)
    expander = Gtk.Expander(label=_('Details'))
    expander.add(frame)
    dialog.vbox.pack_start(expander, True, True, 0)

    dialog.set_resizable(True)
    # on expand the details the dialog remains centered on screen
    dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

    def on_dialog_response(dialog, response):
        if response == RESPONSE_REPORT_BUG:
            url = 'http://trac.gajim.org/wiki/HowToCreateATicket'
            helpers.launch_browser_mailer('url', url)
        else:
            dialog.destroy()

    dialog.connect('response', on_dialog_response)
    dialog.show_all()

    _exception_in_progress.release()
Beispiel #2
0
def _info(type_, value, tb):
    if not _exception_in_progress.acquire(False):
        # Exceptions have piled up, so we use the default exception
        # handler for such exceptions
        _excepthook_save(type_, value, tb)
        return

    dialog = HigDialog(None, Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
                            _('A programming error has been detected'),
                            _('It probably is not fatal, but should be reported '
                            'to the developers nonetheless.'))

    dialog.set_modal(False)
    #FIXME: add icon to this button
    RESPONSE_REPORT_BUG = 42
    dialog.add_buttons(Gtk.STOCK_CLOSE, Gtk.ButtonsType.CLOSE,
            _('_Report Bug'), RESPONSE_REPORT_BUG)
    report_button = dialog.action_area.get_children()[0] # right to left
    report_button.grab_focus()

    # Details
    textview = Gtk.TextView()
    textview.set_editable(False)
    textview.override_font(Pango.FontDescription('Monospace'))
    sw = Gtk.ScrolledWindow()
    sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    sw.add(textview)
    frame = Gtk.Frame()
    frame.set_shadow_type(Gtk.ShadowType.IN)
    frame.add(sw)
    frame.set_border_width(6)
    textbuffer = textview.get_buffer()
    trace = StringIO()
    traceback.print_exception(type_, value, tb, None, trace)
    textbuffer.set_text(trace.getvalue())
    textview.set_size_request(
            Gdk.Screen.width() / 3,
            Gdk.Screen.height() / 4)
    expander = Gtk.Expander(label=_('Details'))
    expander.add(frame)
    dialog.vbox.pack_start(expander, True, True, 0)

    dialog.set_resizable(True)
    # on expand the details the dialog remains centered on screen
    dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

    def on_dialog_response(dialog, response):
        if response == RESPONSE_REPORT_BUG:
            url = 'http://trac.gajim.org/wiki/HowToCreateATicket'
            helpers.launch_browser_mailer('url', url)
        else:
            dialog.destroy()
    dialog.connect('response', on_dialog_response)
    dialog.show_all()

    _exception_in_progress.release()
Beispiel #3
0
    def on_plugin_downloaded(self, widget, plugin_dirs):
        dialog = HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
            '', _('All selected plugins downloaded'))
        dialog.set_modal(False)
        dialog.set_transient_for(self.window)

        for _dir in plugin_dirs:
            is_active = False
            plugins = None
            plugin_dir = os.path.join(gajim.PLUGINS_DIRS[1], _dir)
            plugin = gajim.plugin_manager.get_plugin_by_path(plugin_dir)
            if plugin:
                if plugin.active:
                    is_active = True
                    gobject.idle_add(gajim.plugin_manager.deactivate_plugin,
                        plugin)
                gajim.plugin_manager.plugins.remove(plugin)

                model = self.installed_plugins_model
                for row in xrange(len(model)):
                    if plugin == model[row][0]:
                        model.remove(model.get_iter((row, 0)))
                        break

            plugins = self.scan_dir_for_plugin(plugin_dir)
            if not plugins:
                continue
            gajim.plugin_manager.add_plugin(plugins[0])
            plugin = gajim.plugin_manager.plugins[-1]
            for row in xrange(len(self.available_plugins_model)):
                if plugin.name == self.available_plugins_model[row][C_NAME]:
                    self.available_plugins_model[row][C_LOCAL_VERSION] = \
                        plugin.version
                    self.available_plugins_model[row][C_UPGRADE] = False
            if is_active:
                gobject.idle_add(gajim.plugin_manager.activate_plugin, plugin)
            # get plugin icon
            icon_file = os.path.join(plugin.__path__, os.path.split(
                plugin.__path__)[1]) + '.png'
            icon = self.def_icon
            if os.path.isfile(icon_file):
                icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_file, 16, 16)
            if not hasattr(plugin, 'activatable'):
                # version 0.15
                plugin.activatable = False
            max_row = [plugin, plugin.name, is_active, plugin.activatable, icon]
            # support old plugin system
            if len(self.installed_plugins_model):
                row_len = len(self.installed_plugins_model[0])
            else:
                row_len = 5
            row = max_row[0: row_len]
            self.installed_plugins_model.append(row)

        dialog.popup()
Beispiel #4
0
    def on_inslall_upgrade_clicked(self, widget):
        self.inslall_upgrade_button.set_property('sensitive', False)
        self.errors = ''

        def on_error(func, path, error):
            if func == os.path.islink:
            # if symlink
                os.unlink(path)
                return
            # access is denied or other
            # WarningDialog(_('Can\'t remove dir'), error[1], self.window)
            self.errors += str(error[1])

        name_list = []
        for i in range(len(self.model)):
            if self.model[i][C_UPGRADE]:
                name_list.append(self.model[i][C_NAME])
        for name in name_list:
            # remove dirs
            target_dir = os.path.join(gajim.MY_EMOTS_PATH, name)
            if os.path.isdir(target_dir):
                rmtree(target_dir, False, on_error)

            # unzip new files
            zip_file = os.path.join(self.__path__, 'emoticons_pack.zip')
            with zipfile.ZipFile(zip_file, 'r') as myzip:
                namelist = myzip.namelist()
                for n in namelist:
                    if not n.startswith(name):
                        continue
                    try:
                        icon_file = myzip.extract(n, path=gajim.MY_EMOTS_PATH)
                    except Exception as e:
                        self.errors += str(e)
        # unset all checkbattons
        for i in range(len(self.model)):
            self.model[i][C_UPGRADE] = False

        if self.errors:
            WarningDialog(
                _('Not fully installed'),
                'Access is denied or other', self.window)
        else:
            # show dialog
            dialog = HigDialog(
                None,  gtk.MESSAGE_INFO, gtk.BUTTONS_OK, '',
                _('All selected emoticons installed(upgraded)'))
            dialog.set_modal(False)
            dialog.set_transient_for(self.window)
            dialog.popup()
Beispiel #5
0
    def on_inslall_upgrade_clicked(self, widget):
        self.inslall_upgrade_button.set_property('sensitive', False)
        self.errors = ''

        def on_error(func, path, error):
            if func == os.path.islink:
                # if symlink
                os.unlink(path)
                return
            # access is denied or other
            # WarningDialog(_('Can\'t remove dir'), error[1], self.window)
            self.errors += str(error[1])

        name_list = []
        for i in range(len(self.model)):
            if self.model[i][C_UPGRADE]:
                name_list.append(self.model[i][C_NAME])
        for name in name_list:
            # remove dirs
            target_dir = os.path.join(gajim.MY_EMOTS_PATH, name)
            if os.path.isdir(target_dir):
                rmtree(target_dir, False, on_error)

            # unzip new files
            zip_file = os.path.join(self.__path__, 'emoticons_pack.zip')
            with zipfile.ZipFile(zip_file, 'r') as myzip:
                namelist = myzip.namelist()
                for n in namelist:
                    if not n.startswith(name):
                        continue
                    try:
                        icon_file = myzip.extract(n, path=gajim.MY_EMOTS_PATH)
                    except Exception as e:
                        self.errors += str(e)
        # unset all checkbattons
        for i in range(len(self.model)):
            self.model[i][C_UPGRADE] = False

        if self.errors:
            WarningDialog(_('Not fully installed'),
                          'Access is denied or other', self.window)
        else:
            # show dialog
            dialog = HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, '',
                               _('All selected emoticons installed(upgraded)'))
            dialog.set_modal(False)
            dialog.set_transient_for(self.window)
            dialog.popup()