Ejemplo n.º 1
0
    def on_options_dialog(self):
        self.dialog.clear()

        # Make the config globally available
        Option.config = self.config
        Option.main_window = self.main_window

        self.options = []

        if platform.system() == "Linux" and os.path.exists("/usr/bin/rednotebook"):
            logging.debug("Running on Linux. Is installed. Adding autostart option")
            self.options.insert(0, AutostartOption())

        # Most modern Linux distributions do not have a systray anymore.
        # If this option is activated on a system without a systray, the
        # application keeps on running in the background after it has been
        # closed. The option can still be activated in the configuration file.
        if filesystem.has_system_tray():
            self.options.append(
                TickOption(
                    _("Close to system tray"),
                    "closeToTray",
                    tooltip=_("Closing the window will send RedNotebook to the tray"),
                )
            )

        # Automatic switching between preview and edit mode.
        self.options.append(
            TickOption(_("Switch between edit and preview mode automatically"), "autoSwitchMode", default=0)
        )

        # Check for new version
        check_version_option = TickOption(_("Check for new version at startup"), "checkForNewVersion")

        def check_version_action(widget):
            utils.check_new_version(self.main_window.journal, info.version)
            # Apply changes from dialog to options window
            check = bool(self.journal.config.get("checkForNewVersion"))
            check_version_option.check_button.set_active(check)

        check_version_button = ActionButton(_("Check now"), check_version_action)
        check_version_option.pack_start(check_version_button, False, False)
        self.options.append(check_version_option)

        self.options.extend(
            [
                # Use separate fonts since the preview often doesn't support the edit font.
                FontOption(_("Edit font:"), "mainFont"),
                TextOption(
                    _("Preview font:"),
                    "previewFont",
                    default=Config.defaults["previewFont"],
                    tooltip=_("Comma-separated font names"),
                ),
                DateFormatOption(_("Date/Time format"), "dateTimeString"),
                TextOption(
                    _("Exclude from cloud"),
                    "cloudIgnoreList",
                    tooltip=_("Do not show these comma separated words and #tags in the clouds"),
                ),
                TextOption(
                    _("Include small words in cloud"),
                    "cloudIncludeList",
                    tooltip=_("Allow these words with 4 letters or less"),
                ),
            ]
        )

        self.add_all_options()

        response = self.dialog.run()

        if response == gtk.RESPONSE_OK:
            self.save_options()

            # Apply some options
            self.main_window.cloud.update_lists()
            self.main_window.cloud.update(force_update=True)

            visible = self.config.read("closeToTray") == 1
            self.main_window.tray_icon.set_visible(visible)
        else:
            # Reset some options
            self.main_window.set_font(self.config.read("mainFont"))

        self.dialog.hide()
Ejemplo n.º 2
0
    def on_options_dialog(self):
        self.dialog.clear()

        # Make the config globally available
        Option.config = self.config
        Option.main_window = self.main_window

        self.options = []

        if platform.system() == 'Linux' and os.path.exists(
                '/usr/bin/rednotebook'):
            logging.debug(
                'Running on Linux. Is installed. Adding autostart option')
            self.options.insert(0, AutostartOption())

        # Most modern Linux distributions do not have a systray anymore.
        # If this option is activated on a system without a systray, the
        # application keeps on running in the background after it has been
        # closed. The option can still be activated in the configuration file.
        if filesystem.has_system_tray():
            self.options.append(
                TickOption(
                    _('Close to system tray'),
                    'closeToTray',
                    tooltip=_(
                        'Closing the window will send RedNotebook to the tray')
                ))

        # Automatic switching between preview and edit mode.
        self.options.append(
            TickOption(_('Switch between edit and preview mode automatically'),
                       'autoSwitchMode'))

        # Check for new version
        check_version_option = TickOption(
            _('Check for new version at startup'), 'checkForNewVersion')

        self.options.append(
            TickOption(_('Search as you type'), 'instantSearch'))

        def check_version_action(widget):
            utils.check_new_version(self.main_window.journal,
                                    info.version,
                                    startup=False)
            # Apply changes from dialog to options window
            check = bool(self.journal.config.read('checkForNewVersion'))
            check_version_option.check_button.set_active(check)

        check_version_button = ActionButton(_('Check now'),
                                            check_version_action)
        check_version_option.pack_start(check_version_button, False, False, 0)
        self.options.append(check_version_option)

        self.options.extend([
            # Use separate fonts since the preview often doesn't support the edit font.
            FontOption(_('Edit font:'), 'mainFont'),
            TextOption(_('Preview font:'),
                       'previewFont',
                       default=Config.defaults['previewFont'],
                       tooltip=_('Comma-separated font names')),
            DateFormatOption(
                _('Date/Time format'),
                'dateTimeString',
                tooltip=_(
                    'Used by Date/Time button and $date$ template macro.')),
            DateFormatOption(
                _('Date format'),
                'exportDateFormat',
                tooltip=_('Used for dates in titlebar and exports.')),
            TextOption(
                _('Exclude from cloud'),
                'cloudIgnoreList',
                tooltip=
                _('Do not show these comma separated words and #tags in the clouds'
                  )),
            TextOption(_('Include small words in cloud'),
                       'cloudIncludeList',
                       tooltip=_('Allow these words with 4 letters or less')),
        ])

        self.add_all_options()

        response = self.dialog.run()

        if response == Gtk.ResponseType.OK:
            self.save_options()

            # Apply some options
            self.main_window.cloud.update_lists()
            self.main_window.cloud.update(force_update=True)

            visible = (self.config.read('closeToTray') == 1)
            self.main_window.tray_icon.set_visible(visible)
        else:
            # Reset some options
            self.main_window.set_font(
                self.config.read('mainFont', editor.DEFAULT_FONT))

        self.dialog.hide()
Ejemplo n.º 3
0
    def on_options_dialog(self):
        self.dialog.clear()

        # Make the config globally available
        Option.config = self.config
        Option.main_window = self.main_window

        self.options = []

        if platform.system() == 'Linux' and os.path.exists('/usr/bin/rednotebook'):
            logging.debug('Running on Linux. Is installed. Adding autostart option')
            self.options.insert(0, AutostartOption())

        # Most modern Linux distributions do not have a systray anymore.
        # If this option is activated on a system without a systray, the
        # application keeps on running in the background after it has been
        # closed. The option can still be activated in the configuration file.
        if filesystem.has_system_tray():
            self.options.append(TickOption(
                _('Close to system tray'), 'closeToTray',
                tooltip=_('Closing the window will send RedNotebook to the tray')))

        # Automatic switching between preview and edit mode.
        self.options.append(TickOption(_('Switch between edit and preview mode automatically'),
                                       'autoSwitchMode', default=0))

        # Check for new version
        check_version_option = TickOption(_('Check for new version at startup'), 'checkForNewVersion')

        # Enable/Disable right-hand pane
        self.options.append(TickOption(_('Show right-side tags pane'),'showTagsPane'))

        def check_version_action(widget):
            utils.check_new_version(self.main_window.journal, info.version)
            # Apply changes from dialog to options window
            check = bool(self.journal.config.get('checkForNewVersion'))
            check_version_option.check_button.set_active(check)

        check_version_button = ActionButton(_('Check now'), check_version_action)
        check_version_option.pack_start(check_version_button, False, False)
        self.options.append(check_version_option)

        self.options.extend([
            # Use separate fonts since the preview often doesn't support the edit font.
            FontOption(_('Edit font:'), 'mainFont'),
            TextOption(_('Preview font:'), 'previewFont',
                       default=Config.defaults['previewFont'],
                       tooltip=_('Comma-separated font names')),
            DateFormatOption(_('Date/Time format'), 'dateTimeString'),
            TextOption(_('Exclude from cloud'), 'cloudIgnoreList',
                       tooltip=_('Do not show these comma separated words and #tags in the clouds')),
            TextOption(_('Include small words in cloud'), 'cloudIncludeList',
                       tooltip=_('Allow these words with 4 letters or less')),
        ])

        self.add_all_options()

        response = self.dialog.run()

        if response == gtk.RESPONSE_OK:
            self.save_options()

            # Apply some options
            self.main_window.cloud.update_lists()
            self.main_window.cloud.update(force_update=True)

            visible = (self.config.read('closeToTray') == 1)
            self.main_window.tray_icon.set_visible(visible)

            # Enable/disable the "tags" pane on the right
            if self.config.read('showTagsPane') == 1:
                self.main_window.annotations_pane.show()
            else:
                self.main_window.annotations_pane.hide()

        else:
            # Reset some options
            self.main_window.set_font(self.config.read('mainFont', editor.DEFAULT_FONT))

        self.dialog.hide()