def do_update_state(self): directory = self._find_AutoLaTeX_dir() hasTeXDocument = self._is_TeX_document() hasAutoLaTeXDocument = (directory is not None) isInTeXContext = (hasTeXDocument or hasAutoLaTeXDocument) # Display or hide the menus self._menu.set_visible(isInTeXContext) self._document_actions.set_visible(isInTeXContext) self._texsensitive_actions.set_visible(isInTeXContext) self._general_actions.set_visible(isInTeXContext) if directory: cfgFile = autolatex_utils.get_autolatex_document_config_file(directory) hasDocConfFile = os.path.exists(cfgFile) else: hasDocConfFile = False hasUserConfFile = os.path.exists(autolatex_utils.get_autolatex_user_config_file()) # Change the sensitivity if self._document_actions: self._document_actions.set_sensitive(hasAutoLaTeXDocument and not self._compilation_under_progress) if self._texsensitive_actions: self._texsensitive_actions.set_sensitive(hasTeXDocument and not self._compilation_under_progress) if self._docconfsensitive_actions: self._docconfsensitive_actions.set_sensitive(hasDocConfFile and not self._compilation_under_progress) if self._userconfsensitive_actions: self._userconfsensitive_actions.set_sensitive(hasUserConfFile and not self._compilation_under_progress) action = self._document_actions.get_action('AutoLaTeXNextError') assert action is not None action.set_sensitive(self._latex_console.has_next_error()) action = self._document_actions.get_action('AutoLaTeXPreviousError') assert action is not None action.set_sensitive(self._latex_console.has_previous_error())
def on_delete_document_configuration_action_activate(self, action, data=None): directory = self._find_AutoLaTeX_dir() if directory: cfgFile = autolatex_utils.get_autolatex_document_config_file(directory) if os.path.exists(cfgFile): dialog = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, _T("Do you want to delete the document configuration?")) answer = dialog.run() dialog.destroy() if answer == Gtk.ResponseType.YES: os.unlink(cfgFile) self.do_update_state()
fid.close() else: sys.stderr.write(_T("Unable to create the configuration file: %s\n") % config_file) exit(255) else: sys.stderr.write(_T("Unable to find a document, file not found: %s\n") % config_file) exit(255) cli_config.open_configuration_dialog(None, False, path) else: path = args.directory if not path or not os.path.isdir(path): path = os.getcwd() directory = utils.find_AutoLaTeX_directory(path) if not directory: config_file = utils.get_autolatex_document_config_file(path) if (args.create): fid = open(config_file, "a") if fid: fid.close() else: sys.stderr.write(_T("Unable to create the configuration file: %s\n") % config_file) exit(255) else: sys.stderr.write(_T("Unable to find a document, file not found: %s\n") % config_file) exit(255) cli_config.open_configuration_dialog(None, True, directory) exit(0)
exit(255) else: sys.stderr.write( _T("Unable to find a document, file not found: %s\n") % config_file) exit(255) cli_config.open_configuration_dialog(None, False, path) else: path = args.directory if not path or not os.path.isdir(path): path = os.getcwd() directory = utils.find_AutoLaTeX_directory(path) if not directory: config_file = utils.get_autolatex_document_config_file(path) if (args.create): fid = open(config_file, "a") if fid: fid.close() else: sys.stderr.write( _T("Unable to create the configuration file: %s\n") % config_file) exit(255) else: sys.stderr.write( _T("Unable to find a document, file not found: %s\n") % config_file) exit(255) cli_config.open_configuration_dialog(None, True, directory)