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()
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()) self.options.append( TickOption( _('Close to system tray'), 'closeToTray', tooltip=_( 'Closing the window will send RedNotebook to the tray'))) able_to_spell_check = self.main_window.day_text_field.can_spell_check() tooltip = (_( 'Underline misspelled words' ) if able_to_spell_check else _('Requires gtkspell.') + ' ' + _( 'This is included in the python-gtkspell or python-gnome2-extras package' )) spell_check_option = TickOption(_('Check Spelling'), 'spellcheck', tooltip=tooltip) if not sys.platform == 'win32': self.options.append(spell_check_option) spell_check_option.set_sensitive(able_to_spell_check) # 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([ FontSizeOption(_('Font Size'), 'mainFontSize'), DateFormatOption(_('Date/Time format'), 'dateTimeString'), CsvTextOption( _('Exclude from clouds'), 'cloudIgnoreList', tooltip=_( 'Do not show those comma separated words in any cloud')), CsvTextOption( _('Allow small words in clouds'), 'cloudIncludeList', tooltip=_( 'Allow those words with 4 letters or less in the text cloud' )), ]) 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) spell_check_enabled = self.config.read('spellcheck', 0) self.main_window.day_text_field.enable_spell_check( spell_check_enabled) visible = (self.config.read('closeToTray', 0) == 1) self.main_window.tray_icon.set_visible(visible) else: # Reset some options self.main_window.set_font_size(self.config.read( 'mainFontSize', -1)) self.dialog.hide()