コード例 #1
0
vector < ustring > resource_get_resources(vector < ustring > &filenames, bool list_deleted_ones)
{
  // Storage.
  vector < ustring > resources;
  filenames.clear();

  // Read the user's templates.
  ReadDirectories rd(Directories->get_resources(), "", "");
  for (unsigned int i = 0; i < rd.directories.size(); i++) {
    ustring filename = gw_build_filename(Directories->get_resources(), rd.directories[i], resource_template_ini ());
    if (g_file_test(filename.c_str(), G_FILE_TEST_IS_REGULAR)) {
      filenames.push_back(filename);
      resources.push_back(resource_get_title(filename));
    }
  }

  // Make a list of "deleted" resources and add to it the unwanted ones.
  // Add the user's resources to these too in order that the user's resources
  // override any templates named the same.
  ustring deleted_filename;
  if (!list_deleted_ones)
    deleted_filename = gw_build_filename(Directories->get_resources(), "deleted");
  ReadText rt(deleted_filename, true, true);
  set < ustring > unwanted_ones(rt.lines.begin(), rt.lines.end());
  for (unsigned int i = 0; i < resources.size(); i++) {
    unwanted_ones.insert(resources[i]);
  }

  // Add some standard templates to the "deleted" resource. Reason:
  // Some standard templates have been added that come with Bibledit.
  // These templates reference material that is not available by default,
  // but requires user action to install that. To facilitate easy creation
  // if these resources by the user, some templates have been added. These
  // templates are not for display, but only to base a new template upon.
  // Therefore these templates should not normally be visible, only when used
  // to create a new resource based upon these.
  if (!list_deleted_ones) {
    unwanted_ones.insert("NetBible");
  }
  // Read the templates that come with Bibledit.
  ReadFiles rf(Directories->get_package_data(), "resource", ".ini");
  for (unsigned int i = 0; i < rf.files.size(); i++) {
    ustring filename = gw_build_filename(Directories->get_package_data(), rf.files[i]);
    ustring title = resource_get_title(filename);
    if (unwanted_ones.find(title) != unwanted_ones.end())
      continue;
    filenames.push_back(filename);
    resources.push_back(title);
  }

  // Sort them.
  quick_sort(resources, filenames, 0, resources.size());

  // Give resources.
  return resources;
}
コード例 #2
0
ファイル: kjv.cpp プロジェクト: postiffm/bibledit-gtk
void kjv_action_page (HtmlWriter2& htmlwriter)
{
  htmlwriter.heading_open (3);
  htmlwriter.text_add (_("Database creation from King James Bible exported from the Sword library"));
  htmlwriter.heading_close ();

  vector <ustring> messages;
  bool keep_going = true;

  // Locate the kjv.txt file.
  ustring kjv_txt_file = gw_build_filename (g_get_home_dir (), "kjv.txt");
  messages.push_back ("Looking for file " + kjv_txt_file);
  if (!g_file_test (kjv_txt_file.c_str(), G_FILE_TEST_IS_REGULAR)) {
    kjv_txt_file.clear();
  }
  if (kjv_txt_file.empty()) {
    messages.push_back (_("Can't find the input file"));
    keep_going = false;
  }
  if (keep_going) {
    messages.push_back (_("Using file ") + kjv_txt_file);
  }

  // The database.
  ustring kjv_sql_file = gw_build_filename (g_get_home_dir (), "kjv.sql");

  // Importing data into the database.
  if (keep_going) {
    messages.push_back (_("Importing data into the database at ") + kjv_sql_file);
    kjv_import_sword (kjv_txt_file, kjv_sql_file);
  }

  // Write accumulated messages.
  htmlwriter.heading_open (3);
  if (keep_going) {
    htmlwriter.text_add (_("Success! The database was created"));
  } else {
    htmlwriter.text_add (_("Error!"));
  }
  htmlwriter.heading_close ();
  if (keep_going) {
    htmlwriter.paragraph_open ();
    htmlwriter.text_add (_("To use the database, copy the file kjv.sql into the Bibledit-Desktop package and re-install."));
    htmlwriter.paragraph_close ();
  }
  for (unsigned int i = 0; i < messages.size(); i++) {
    htmlwriter.paragraph_open ();
    htmlwriter.text_add (messages[i]);
    htmlwriter.paragraph_close ();
  }  

  // Write OK.
  htmlwriter.paragraph_open ();
  htmlwriter.hyperlink_add ("ok", _("Ok"));
  htmlwriter.paragraph_close ();
}
コード例 #3
0
ファイル: xetex.cpp プロジェクト: alerque/bibledit
void XeTeX::place_ptx2pdf_macros ()
{
  GwSpawn spawn (Directories->get_tar());
  spawn.workingdirectory (working_directory);
  spawn.arg ("zxf");
  spawn.arg (gw_build_filename (Directories->get_package_data (), "ptx2pdf.tar.gz"));
  spawn.run ();
  ustring ptx2pdf_directory = "ptx2pdf";
  ReadFiles rf (gw_build_filename (working_directory, ptx2pdf_directory), "", "");
  for (unsigned int i = 0; i < rf.files.size(); i++) {
    unix_mv (gw_build_filename (working_directory, ptx2pdf_directory, rf.files[i]), gw_build_filename (working_directory, rf.files[i]));
  }
  unix_rmdir (gw_build_filename (working_directory, ptx2pdf_directory));
}
コード例 #4
0
ファイル: git.cpp プロジェクト: postiffm/bibledit-gtk
void git_upgrade ()
// Upgrades the git system.
{
  // Go through the projects that have their git repository enabled.
  extern Settings * settings;
  vector <ustring> projects = projects_get_all ();
  for (unsigned int i = 0; i < projects.size(); i++) {
    ProjectConfiguration * projectconfig = settings->projectconfig (projects[i]);
    ustring git_directory = gw_build_filename (project_data_directory_project (projects[i]), ".git");
    if (projectconfig->git_use_remote_repository_get()) {
      // At times there's a stale index.lock file that prevents any collaboration.
      // This is to be removed.
      ustring index_lock = gw_build_filename (git_directory, "index.lock");
      if (g_file_test (index_lock.c_str(), G_FILE_TEST_IS_REGULAR)) {
        gw_message (_("Cleaning out index lock ") + index_lock);
        unix_unlink (index_lock.c_str());
      }
      // Get the data directory for the project
      ustring datadirectory = tiny_project_data_directory_project(projects[i]);
      // On most machines git can determine the user's name from the system services. 
      // On the XO machine, it can't. It is set here manually. 
      // On more recent versions of git, like version 1.8.3 and younger,
      // although git may determine the user's name from the system, 
      // it still requires it to be set manually.
      ustring command;
      command = "git config user.email \"";
      command.append(g_get_user_name());
      command.append("@");
      command.append(g_get_host_name());
      command.append("\"");
      maintenance_register_shell_command (datadirectory, command);
      command = "git config user.name \"";
      command.append(g_get_real_name());
      command.append("\"");
      maintenance_register_shell_command (datadirectory, command);
      // (Re)initialize the repository. This can be done repeatedly without harm.
      // Note that this is done on shutdown.
      maintenance_register_shell_command (datadirectory, "git init");
    } else {
      if (g_file_test (git_directory.c_str(), G_FILE_TEST_IS_DIR)) {
        gw_message (_("Cleaning out folder ") + git_directory);
        ProgressWindow progresswindow (_("Tidying up project ") + projects[i], false);
        progresswindow.set_fraction (0.5);
        unix_rmdir (git_directory);
      }
    }
  }
}
コード例 #5
0
BulkSpellingDialog::BulkSpellingDialog(const vector <ustring> words)
{
  gtkbuilder = gtk_builder_new ();
  gtk_builder_add_from_file (gtkbuilder, gw_build_filename (Directories->get_package_data(), "gtkbuilder.bulkspellingdialog.xml").c_str(), NULL);

  Shortcuts shortcuts(0);

  dialog = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "dialog"));

  label = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label"));
  gtk_label_set_text (GTK_LABEL (label), _("All the words that are misspelled are visible below.\nClick on a word to approve the spelling."));

  vbox = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "vbox"));

  InDialogHelp * indialoghelp = new InDialogHelp(dialog, gtkbuilder, &shortcuts, NULL);
  cancelbutton = indialoghelp->cancelbutton;
  okbutton = indialoghelp->okbutton;
  gtk_widget_grab_default(okbutton);
  gtk_widget_grab_focus(okbutton);
  g_signal_connect((gpointer) okbutton, "clicked", G_CALLBACK(on_okbutton_clicked), gpointer(this));

  // Create a button for each misspelled word.
  GtkWidget * spellbutton;
  for (unsigned int i = 0; i < words.size(); i++) {
    spellbutton = gtk_button_new_with_label(words[i].c_str());
    gtk_widget_show(spellbutton);
    gtk_box_pack_start(GTK_BOX(vbox), spellbutton, false, false, 0);
    g_signal_connect((gpointer) spellbutton, "clicked", G_CALLBACK(on_spellbutton_clicked), gpointer(this));
  }  

  shortcuts.process();
  gtk_widget_show(dialog);
  
  new DialogAutoScaler (dialog, G_MAXINT);
}
コード例 #6
0
ファイル: dialogxetex.cpp プロジェクト: alerque/bibledit
XeTeXDialog::XeTeXDialog(int dummy)
{
  extern Settings *settings;
  ProjectConfiguration *projectconfig = settings->projectconfig(settings->genconfig.project_get());

  gtkbuilder = gtk_builder_new ();
  gtk_builder_add_from_file (gtkbuilder, gw_build_filename (Directories->get_package_data(), "gtkbuilder.xetexdialog.xml").c_str(), NULL);

  dialog = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "dialog"));

  label_portion = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_portion"));

  button_portion = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "button_portion"));
  g_signal_connect((gpointer) button_portion, "clicked", G_CALLBACK(on_button_portion_clicked), gpointer(this));

  expander = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "expander"));
  gtk_expander_set_expanded(GTK_EXPANDER(expander), settings->session.print_dialog_options_expanded);

  label_expander = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_expander"));

  notebook = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "notebook"));
  g_signal_connect_after((gpointer) notebook, "switch_page", G_CALLBACK(on_notebook_switch_page), gpointer(this));

  label_tab_notes = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_tab_notes"));
  checkbutton_full_references = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "checkbutton_full_references"));
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_full_references), settings->session.print_references_in_notes_in_full);
  // Set widget insensitive since is has not yet been implemented.
  gtk_widget_set_sensitive (checkbutton_full_references, false);

  label_tab_page = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_tab_page"));
  checkbutton_cropmarks = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "checkbutton_cropmarks"));
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_cropmarks), settings->session.print_crop_marks);

  label_tab_mapping = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_tab_mapping"));
  button_font_mapping_clear = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "button_font_mapping_clear"));
  filechooserbutton_font_mapping_file = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "filechooserbutton_font_mapping_file"));
  g_signal_connect((gpointer) button_font_mapping_clear, "clicked", G_CALLBACK(on_button_font_mapping_clear_clicked), gpointer(filechooserbutton_font_mapping_file));
  if (!projectconfig->xetex_font_mapping_file_get().empty()) {
    gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (filechooserbutton_font_mapping_file), projectconfig->xetex_font_mapping_file_get().c_str());
  }

  label_tab_engine = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label_tab_engine"));
  GSList *shaping_engine_group = NULL;
  radiobutton_shaping_engine_generic = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "radiobutton_shaping_engine_generic"));
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(radiobutton_shaping_engine_generic), shaping_engine_group);
  shaping_engine_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radiobutton_shaping_engine_generic));
  radiobutton_shaping_engine_arab = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "radiobutton_shaping_engine_arab"));
  gtk_radio_button_set_group(GTK_RADIO_BUTTON(radiobutton_shaping_engine_arab), shaping_engine_group);
  shaping_engine_group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radiobutton_shaping_engine_arab));
  shaping_engine_set (projectconfig->xetex_shaping_engine_get());

  InDialogHelp * indialoghelp = new InDialogHelp(dialog, gtkbuilder, NULL, "file/print/project");
  cancelbutton = indialoghelp->cancelbutton;
  okbutton = indialoghelp->okbutton;
  gtk_widget_grab_focus(okbutton);
  gtk_widget_grab_default(okbutton);
  g_signal_connect((gpointer) okbutton, "clicked", G_CALLBACK(on_okbutton_clicked), gpointer(this));

  set_gui();
}
コード例 #7
0
bool RemoteRepositoryAssistant::try_git_checkout_repository (const ustring& local, const ustring& remote)
// Checks the remote repository out into the local one.
{
  // Directory to run the cloning process in.
  ustring cloning_directory = git_testing_directory (local) + "clone";
  gw_mkdir_with_parents(cloning_directory);

  // Clone the remote repository.
  GwSpawn spawn("git");
  spawn.arg("clone");
  spawn.workingdirectory(cloning_directory);
  spawn.arg(git_testing_directory (remote));
  spawn.run();
  bool okay = (spawn.exitstatus == 0);

  // Message if things didn't work out.
  if (!okay) {
    gtk_label_set_text(GTK_LABEL(label_try_git), _("git clone fails to clone the repository"));
  }
  
  // Move the repository into place.
  ustring cloned_directory = gw_build_filename (cloning_directory, remote);
  ustring local_directory = git_testing_directory (local);
  unix_rmdir(local_directory);
  if (okay) {
    unix_mv(cloned_directory, local_directory);
  }
  unix_rmdir(cloning_directory);
  
  // Return result.
  return okay;
}
コード例 #8
0
void ResourceConverterDialog::on_write_anchors_button()
{
    // Remove old anchors.
    resource_conversion_remove_anchors(lines);

    // Flags.
    anchors_written = true;

    // Do the conversion.
    switch (resource_conversion_type) {
    case rctChapterStartsAtPatternVerseOneStartsAtChapterVerseStartsAtPattern:
    {
        resource_conversion_insert_anchors(lines, chapter_pattern_prefix, chapter_pattern_index, chapter_pattern_suffix, verse_pattern_prefix, verse_pattern_index, verse_pattern_suffix);
        break;
    }
    case rctEnd:
    {
        break;
    }
    }

    // Write text to file.
    write_lines(gw_build_filename(workingdirectory, filename), lines);

    // Update gui.
    if (write_anchors_gui()) {
        gui();
    }
}
コード例 #9
0
void stylesheets_upgrade()
// Upgrade older stylesheets to the currently used format.
{
  // Make the \r marker a section heading instead of a normal paragraph.
  {
    ReadFiles rf(Directories->get_stylesheets(), "", ".xml1");
    for (unsigned int i = 0; i < rf.files.size(); i++) {
      ustring filename = gw_build_filename(Directories->get_stylesheets(), rf.files[i]);
      gw_message(_("Updating stylesheet: ") + filename);
      ReadText rt (filename, true, false);
      stylesheet_upgrade_value (rt.lines, "r", "subtype", "2");
      unix_unlink (filename.c_str());
      ustring newfilename(filename);
      newfilename.replace(newfilename.length() - 1, 1, "2");
      write_lines (newfilename, rt.lines);
    }
  }

  // Note: The stylesheet.xml template has been updated thus far.
  // Every update listed below still needs to be entered into the template.

  // At the end of everything, check that we have at least one stylesheet.  
  {
    vector < ustring > stylesheets;
    stylesheet_get_ones_available(stylesheets);
    if (stylesheets.size() == 0) {
      stylesheet_create_new(STANDARDSHEET, stFull);
    }
  }
}
コード例 #10
0
ファイル: gwrappers.cpp プロジェクト: postiffm/bibledit-gtk
// Append an error message to the startup log file
void mkdir_info(const ustring & msg) 
{
	ustring errfilename = gw_build_filename(g_get_tmp_dir(), "bibledit.startup.txt");
	FILE *errfile = fopen(errfilename.c_str(), "a"); // always append to end
	fprintf(errfile, "%s\n", msg.c_str());
	fclose(errfile);
	DEBUG(msg)
}
コード例 #11
0
ファイル: xetex.cpp プロジェクト: alerque/bibledit
void XeTeX::write_stylesheet ()
// Writes the Paratext stylesheet to be used.
{
  ustring stylesheet = stylesheet_get_actual ();
  ustring filename = gw_build_filename (working_directory, "stylesheet.sty");
  stylesheet_export_paratext (stylesheet, filename);
  document_tex.push_back ("\\stylesheet{stylesheet.sty}");
  
}
コード例 #12
0
ファイル: notes_utils.cpp プロジェクト: postiffm/bibledit-gtk
void notes_convert_database_to_plain_files ()
{
    // Bail out if there's no database to convert.
    ustring database_filename = gw_build_filename(Directories->get_notes(), "notes.sql2");
    if (!g_file_test(database_filename.c_str(), G_FILE_TEST_IS_REGULAR)) {
        return;
    }

    // Progress window.
    ProgressWindow progresswindow (_("Converting project notes"), false);

    // Access the database.
    sqlite3 *db;
    int rc;
    char *error = NULL;
    try {
        rc = sqlite3_open(database_filename.c_str(), &db);
        if (rc) throw runtime_error(sqlite3_errmsg(db));
        sqlite3_busy_timeout(db, 1000);
        {
            // Read how many notes there are.
            SqliteReader reader(0);
            char *sql;
            sql = g_strdup_printf("select count(*) from notes;");
            rc = sqlite3_exec(db, sql, reader.callback, &reader, &error);
            g_free(sql);
            if (rc != SQLITE_OK) throw runtime_error(error);
            if (!reader.ustring0.empty()) {
                progresswindow.set_iterate (0, 1, convert_to_int (reader.ustring0[0]));
            }
        }
        {
            SqliteReader reader(0);
            rc = sqlite3_exec(db, "select id, ref_osis, project, category, note, created, modified, user, logbook from notes;", reader.callback, &reader, &error);
            if (rc != SQLITE_OK) throw runtime_error(error);
            for (unsigned int i = 0; i < reader.ustring0.size(); i++) {
                progresswindow.iterate ();
                notes_store_one_in_file(convert_to_int (reader.ustring0[i]), // ID.
                                        reader.ustring4[i],                  // Note.
                                        reader.ustring2[i],                  // Project.
                                        reader.ustring1[i],                  // References.
                                        reader.ustring3[i],                  // Category.
                                        convert_to_int (reader.ustring5[i]), // Date created.
                                        reader.ustring7[i],                  // User.
                                        convert_to_int (reader.ustring6[i]), // Date modified.
                                        reader.ustring8[i]);                 // Logbook.
            }
        }
        // Delete the notes database that was converted.
        unix_unlink (database_filename.c_str());
    }
    catch(exception & ex) {
        gw_critical(ex.what());
    }
    sqlite3_close(db);
}
コード例 #13
0
ファイル: opendocument.cpp プロジェクト: alerque/bibledit
void OpenDocument::unpack_template()
{
  // Clear working directory.
  unix_rmdir(workingdirectory);
  gw_mkdir_with_parents(workingdirectory);
  // Copy template there.
  // Note: To create the template use zip -r template.odt *
#ifdef WIN32
  ustring command = "unzip -o ";
  command.append(gw_build_filename(Directories->get_package_data(), "template.odt"));
  command.append(" -d ");
  command.append(shell_quote_space(workingdirectory));
#else
  ustring command = "cd";
  command.append(shell_quote_space(workingdirectory));
  command.append("; cp ");
  command.append(gw_build_filename(Directories->get_package_data(), "template.odt"));
  command.append(" .; unzip *; rm *.odt");
#endif
  if (system(command.c_str())) ; // This one does not work with GwSpawn because of the wildcards used.
}
コード例 #14
0
ファイル: paratext.cpp プロジェクト: postiffm/bibledit-gtk
ExportParatextStylesheet::ExportParatextStylesheet (int dummy)
{
  // Load the standard Paratext stylesheet.
  {
    ReadText rt (gw_build_filename (Directories->get_package_data(), "usfm.sty"), true, false);
    stylesheet_lines = rt.lines;
  }
  // Indicate it was exported from bibledit.
  if (!stylesheet_lines.empty()) {
    stylesheet_lines[0].append (_("# Exported from Bibledit-Desktop"));
  }
}
コード例 #15
0
ファイル: windowmerge.cpp プロジェクト: alerque/bibledit
void WindowMerge::approval_setup(const ustring & maindata, const ustring & mergedata)
{
  // Initialize the approval system's variables and gui.
  approve_master_project = current_master_project;
  approve_edited_project = current_edited_project;
  approve_book = book;
  approve_chapter = chapter;
  ustring label = _("Changes approval, ") + books_id_to_english(approve_book) + " " + convert_to_string(approve_chapter);
  gtk_label_set_text(GTK_LABEL(label_approve), label.c_str());
  gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook1), 1);
  approve_master_file = gw_build_filename(workingdirectory, "master");
  approve_merge_file = gw_build_filename(workingdirectory, "merged");

  // Save both sets of data to file.
  g_file_set_contents(approve_master_file.c_str(), merge_split_data(trim(maindata)).c_str(), -1, NULL);
  g_file_set_contents(approve_merge_file.c_str(), merge_split_data(trim(mergedata)).c_str(), -1, NULL);

  // Show differences in the GUI.
  approval_show_diff();

  // Info for user.
  gtkw_dialog_info(NULL, _("The chapters are ready for approving the individual changes"));
}
コード例 #16
0
bool resource_add_name_to_deleted_ones_if_standard_template(const ustring & filename)
/*
 If the filename given is a standard template, it adds the name of the resource
 to the list of deleted ones and then returns true.
 */
{
  ustring directory = gw_path_get_dirname(filename);
  if (directory == Directories->get_package_data()) {
    ustring deleted_filename = gw_build_filename(Directories->get_resources(), "deleted");
    ReadText rt(deleted_filename, true, true);
    ustring title = resource_get_title(filename);
    rt.lines.push_back(title);
    write_lines(deleted_filename, rt.lines);
    return true;
  }
  return false;
}
コード例 #17
0
ustring resource_url_get(const ustring& url, const ustring& templatefile)
/*
 Some urls are given as full ones, e.g. http://bibledit.org.
 These don't need any modification.
 Other urls are given as plain filenames only. It is assumed for these that 
 they are given relative to the resource directory where these reside. 
 These need to be modified so as to include the full path and the file:// prefix.
 */
{
  ustring modified_url(url);
  if (url.find ("http") != 0) {
    ustring path = gw_path_get_dirname(templatefile);
    modified_url = resource_file_prefix();
    modified_url.append(gw_build_filename(path, url));
  }
  return modified_url;
}
コード例 #18
0
void ResourceConverterDialog::on_open_file_button()
{
    // List all files in the working directory.
    ReadFiles rf(workingdirectory, "", "");
    // Select a file.
    ListviewDialog dialog(_("Select file"), rf.files, filename, true, NULL);
    if (dialog.run() == GTK_RESPONSE_OK) {
        // Store filename, read it.
        filename = dialog.focus;
        ReadText rt(gw_build_filename(workingdirectory, filename), true, false);
        lines = rt.lines;
        anchors_written = false;
    }
    if (open_file_gui()) {
        gui();
    }
}
コード例 #19
0
void RemoteRepositoryAssistant::on_button_clone ()
{
  // Progress.
  ProgressWindow progresswindow (_("Cloning repository"), false);
  progresswindow.set_fraction (0.5);
  
  // Clear out persistent clone directory.
  repository_unclone();
  
  // Create temporal clone directory.
  ustring temporal_clone_directory = git_testing_directory ("tempclone");
  unix_rmdir(temporal_clone_directory);
  gw_mkdir_with_parents(temporal_clone_directory);
  
  // Clone the remote repository
  GwSpawn spawn("git");
  spawn.workingdirectory(temporal_clone_directory);
  spawn.arg ("clone");
  spawn.arg(repository_url_get());
  spawn.run();

  if (spawn.exitstatus == 0) {
    // Move the cloned repository into the persistent clone directory.
    ReadDirectories rd (temporal_clone_directory, "", "");
    if (!rd.directories.empty()) {
      ustring subdirectory = rd.directories[0];
      subdirectory = gw_build_filename (temporal_clone_directory, subdirectory);
      unix_mv (subdirectory, persistent_clone_directory);
    }
    unix_rmdir(temporal_clone_directory);
  } else {
    // Clone failed, clear out any remains.
    repository_unclone();
  }  
  
  // Update structures.
  gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), vbox_clone, repository_was_cloned());
  if (repository_was_cloned()) {
    gtk_label_set_text (GTK_LABEL (label_clone), _("The data has been cloned, you can go forward"));
    previously_cloned_url = repository_url_get();
  } else {
    gtk_label_set_text (GTK_LABEL (label_clone), _("Cloning the data failed, please try again"));
    repository_unclone();
  }
}
コード例 #20
0
ファイル: utilities.cpp プロジェクト: postiffm/bibledit-gtk
ReadFiles::ReadFiles(const ustring & path, const ustring & prefix, const ustring & suffix)
{
  // Reads the regular files in directory "path" that end on "suffix".
  // It does not return directories.
  try {
    GDir *dir = g_dir_open(path.c_str(), 0, NULL);
    const gchar *s;
    vector < ustring > entries;
    while ((s = g_dir_read_name(dir)) != NULL)
      entries.push_back(s);
    g_dir_close(dir);
    for (unsigned int i = 0; i < entries.size(); i++) {
      if (g_str_has_suffix(entries[i].c_str(), suffix.c_str()))
        if (g_str_has_prefix(entries[i].c_str(), prefix.c_str()))
          if (!g_file_test(gw_build_filename(path, entries[i]).c_str(), G_FILE_TEST_IS_DIR))
            files.push_back(entries[i]);
    }
  }
  catch(...) {
  }
}
コード例 #21
0
YesNoAlwaysDialog::YesNoAlwaysDialog(const ustring& message, bool default_yes)
{
  gtkbuilder = gtk_builder_new ();
  gtk_builder_add_from_file (gtkbuilder, gw_build_filename (Directories->get_package_data(), "gtkbuilder.yesnoalwaysdialog.xml").c_str(), NULL);

  dialog = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "dialog"));

  label = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "label"));
  gtk_label_set_text (GTK_LABEL (label), message.c_str());

  checkbutton = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "checkbutton"));

  // Add the buttons. In the standard question dialog, the Yes is at the right, then the No following to the left.
  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_NO);
  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_YES);
  
  if (default_yes)
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
  else
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
}
コード例 #22
0
void RestoreAssistant::on_assistant_apply ()
{
  // Unpack the tarball.
  ustring unpack_directory = gw_build_filename (Directories->get_temp (), "restore");
  unix_rmdir (unpack_directory);
  gw_mkdir_with_parents (unpack_directory);
  if (uncompress (filename, unpack_directory)) {

    // Do specialized operations on the unpacked data.
    switch (get_type()) {
      case btBible:
      {
        restore_project (unpack_directory, bible_name, restore_feedback);
        break;
      }
      case btNotes:
      {
        restore_notes (unpack_directory, restore_feedback);
        break;
      }
      case btResource:
      {
        restore_resource (unpack_directory, restore_feedback);
        break;
      }
      case btAll:
      {
        restore_all_stage_one (unpack_directory, restore_feedback);
        break;
      }
    }
  } else {
    restore_feedback.push_back (_("Failed to unpack file ") + filename);
  }
 
  // Show summary.
  gtk_assistant_set_current_page (GTK_ASSISTANT (assistant), page_number_progress);
}
コード例 #23
0
ファイル: xetex.cpp プロジェクト: alerque/bibledit
ustring XeTeX::run ()
{
  write_document_tex_file ();
  ustring pdf_file;
  if (runtime_check (rtXeTeX)) {
    pdf_file = gw_build_filename (working_directory, "document.pdf");
    bool re_run = false;
    unsigned int run_count = 0;
    do {
      run_count++;
      GwSpawn spawn (runtime_program (rtXeTeX));
      spawn.workingdirectory (working_directory);
      spawn.arg ("document.tex");
      spawn.read ();
      spawn.progress ("Formatting run " + convert_to_string (run_count), true);
      spawn.run ();
      re_run = false;
      for (unsigned int i = 0; i < spawn.standardout.size(); i++) {
        gw_message (spawn.standardout[i]);
        if (spawn.standardout[i].find ("re-run") != string::npos) 
        re_run = true;
      }
      for (unsigned int i = 0; i < spawn.standarderr.size(); i++) {
        gw_critical (spawn.standarderr[i]);
        if (spawn.standarderr[i].find ("re-run") != string::npos) 
          re_run = true;
      }
      // If the formatting process was cancelled, bail out, with no pdf file.
      if (spawn.cancelled) {
        return "";
      }
    } while (re_run && (run_count < 10));
  }
  // Info for user in logfile.
  gw_message (_("All the data for this document is available in temporal folder ") + working_directory + ".");
  gw_message (_("You can tune the files by hand, then run \"xetex document.tex\" in this folder to convert it into a PDF file."));
  return pdf_file;
}
コード例 #24
0
ファイル: scripts.cpp プロジェクト: githubber/bibledit
ustring script_get_path(const ustring & script, ScriptType * scripttype, bool binary)
// Gets the full path to an existing "script".
// If "binary" is true, then, if possible, it gives the path, not to the original
// script, but to the binary form of it. Right now this is used for TECkit support
// which has the mapping file, which is the script, and the compiled file, which
// is the binary.
// The "scripttype" is filled with the right type of script.
{
  // Try the various types of scripts.
  for (unsigned int i = 0; i < stEnd; i++) {
    ScriptType script_type = ScriptType(i);
    ustring path = gw_build_filename(Directories->get_scripts(), script_prefix(script_type) + script + script_suffix(script_type, binary));
    if (g_file_test(path.c_str(), G_FILE_TEST_IS_REGULAR)) {
      if (scripttype)
        *scripttype = script_type;
      return path;
    }
  }
  // Failure.
  if (scripttype)
    *scripttype = stEnd;
  return "";
}
コード例 #25
0
PlanningEditDialog::PlanningEditDialog(unsigned int book, unsigned int chapter)
{
  // Initialize variables
  mybook = book;
  mychapter = chapter;

  // Build gui.
  gtkbuilder = gtk_builder_new ();
  gtk_builder_add_from_file (gtkbuilder, gw_build_filename (Directories->get_package_data(), "gtkbuilder.planningeditdialog.xml").c_str(), NULL);

  Shortcuts shortcuts(0);

  dialog = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "dialog"));

  button_status = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "button_status"));
  shortcuts.button (button_status);
  g_signal_connect((gpointer) button_status, "clicked", G_CALLBACK(on_button_status_clicked), gpointer(this));

  button_tasks = GTK_WIDGET (gtk_builder_get_object (gtkbuilder, "button_tasks"));
  shortcuts.button (button_tasks);
  g_signal_connect((gpointer) button_tasks, "clicked", G_CALLBACK(on_button_tasks_clicked), gpointer(this));

  InDialogHelp * indialoghelp = new InDialogHelp(dialog, gtkbuilder, &shortcuts, NULL);

  cancelbutton = indialoghelp->cancelbutton;
  shortcuts.stockbutton (cancelbutton);
  
  okbutton = indialoghelp->okbutton;
  shortcuts.stockbutton (okbutton);
  gtk_widget_grab_default(okbutton);
  gtk_widget_grab_focus(okbutton);
  g_signal_connect((gpointer) okbutton, "clicked", G_CALLBACK(on_okbutton_clicked), gpointer(this));

  shortcuts.process();

  gui();
}
コード例 #26
0
ファイル: notes_utils.cpp プロジェクト: postiffm/bibledit-gtk
ustring notes_file_name (gint32 id)
// The filename for a note with "id".
{
    return gw_build_filename (notes_shared_storage_folder (), convert_to_string (id));
}
コード例 #27
0
ファイル: notes_utils.cpp プロジェクト: postiffm/bibledit-gtk
ustring notes_categories_filename()
// Returns the filename of the notes database.
{
    return gw_build_filename(Directories->get_notes(), "categories");
}
コード例 #28
0
ファイル: notes_utils.cpp プロジェクト: postiffm/bibledit-gtk
ustring notes_index_filename ()
// Returns the filename of the notes index.
{
    return gw_build_filename(Directories->get_notes(), "index.sql");
}
コード例 #29
0
ファイル: notes_utils.cpp プロジェクト: postiffm/bibledit-gtk
ustring notes_shared_storage_folder ()
{
    return gw_build_filename (Directories->get_notes (), notes_shared_storage_base_name ());
}
コード例 #30
0
ファイル: scripts.cpp プロジェクト: githubber/bibledit
ustring script_temporal_error_file()
{
  return gw_build_filename(Directories->get_temp(), "script_filter_error");
}