Example #1
0
  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())
Example #2
0
 def on_delete_user_configuration_action_activate(self, action, data=None):
   cfgFile = autolatex_utils.get_autolatex_user_config_file()
   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 user configuration?"))
     answer = dialog.run()
     dialog.destroy()
     if answer == Gtk.ResponseType.YES:
       os.unlink(cfgFile)
       self.do_update_state()
  dialog = Gtk.MessageDialog(self.window, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _T("The program 'autolatex-backend' was not found.\nPlease fix the configuration of the AutoLaTeX plugin."))
  answer = dialog.run()
  dialog.destroy()

# Parsing the command line
parser = argparse.ArgumentParser()
parser.add_argument("--user", help=_T("change the user configuration"), action="store_true")
parser.add_argument("--document", help=_T("change the document configuration"), action="store_true")
parser.add_argument("--create", help=_T("create the configuration file"), action="store_true")
parser.add_argument("--directory", help=_T("directory where the TeX file is located"))
args = parser.parse_args()

# Open the dialogs
if (args.user):

  config_file = utils.get_autolatex_user_config_file()
  path = args.directory
  if not path or not os.path.isdir(path):
    path = os.path.expanduser("~")
  if not os.path.isfile(config_file):
    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, False, path)
Example #4
0
                    help=_T("change the user configuration"),
                    action="store_true")
parser.add_argument("--document",
                    help=_T("change the document configuration"),
                    action="store_true")
parser.add_argument("--create",
                    help=_T("create the configuration file"),
                    action="store_true")
parser.add_argument("--directory",
                    help=_T("directory where the TeX file is located"))
args = parser.parse_args()

# Open the dialogs
if (args.user):

    config_file = utils.get_autolatex_user_config_file()
    path = args.directory
    if not path or not os.path.isdir(path):
        path = os.path.expanduser("~")
    if not os.path.isfile(config_file):
        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(