void ShowNotesDialog::on_ok() { extern Settings *settings; // Reference selection. settings->genconfig.notes_selection_reference_set(get_reference_selection ()); // Edited selection. settings->genconfig.notes_selection_edited_set(get_edited_selection ()); settings->genconfig.notes_selection_date_from_set(from_day); settings->genconfig.notes_selection_date_to_set(to_day); // Category. ustring category = combobox_get_active_string(combobox_category); if (category == all_categories()) category.clear(); settings->genconfig.notes_selection_category_set(category); // Project selection. settings->genconfig.notes_selection_current_project_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_current_project))); // Title and inclusions. settings->session.project_notes_show_title = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_title)); settings->genconfig.notes_display_project_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_project))); settings->genconfig.notes_display_category_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_category))); settings->genconfig.notes_display_date_created_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_date_created))); settings->genconfig.notes_display_created_by_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_created_by))); // Notes text display. settings->genconfig.notes_display_summary_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_summary))); settings->genconfig.notes_display_reference_text_set(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_add_ref_text))); }
void ShowNotesDialog::timeout() { // Clear the event id. event_id = 0; // Get the parameters from the dialog, not from the Settings object, since these have not yet been stored. extern Settings * settings; ustring currentreference = books_id_to_english(settings->genconfig.book_get()) + " " + settings->genconfig.chapter_get() + ":" + settings->genconfig.verse_get(); NotesSelectionReferenceType refselection = get_reference_selection (); NotesSelectionEditedType editedselection = get_edited_selection (); ustring category = combobox_get_active_string(combobox_category); if (category == all_categories()) category.clear(); bool currentprojectselection = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_current_project)); // Get notes count. vector <unsigned int> ids; unsigned int id_cursor; notes_select (ids, id_cursor, currentreference, category, refselection, editedselection, currentprojectselection, from_day, to_day); // Update GUI. ustring message = _("This selection would display ") + convert_to_string ((unsigned int)ids.size()) + " "; if (ids.size() == 1) message.append (_("note")); else message.append (_("notes")); gtk_label_set_text (GTK_LABEL (label_result), message.c_str()); }
void FiltersDialog::on_button_delete() { ustring filter = combobox_get_active_string(combobox_filters); ustring filename = script_get_path(filter, NULL); unix_unlink(filename.c_str()); load_filters(""); }
void FiltersDialog::on_combobox_filters() { // Clear rules buffer. gtk_text_buffer_set_text(rulesbuffer, "", -1); // Get the name of the script. ustring filter = combobox_get_active_string(combobox_filters); // Set the type of the script. ScriptType scripttype; script_get_path(filter, &scripttype); gtk_label_set_text(GTK_LABEL(label_type), script_get_named_type(scripttype).c_str()); // Set sensitivity of widgets. bool editable = true; if (filter == scripts_straight_through()) editable = false; gtk_widget_set_sensitive(textview_rules, editable); gtk_widget_set_sensitive(button_delete, editable); // If not sensitive, bail out. if (!editable) return; // Load the script rules or code. ustring filename = script_get_path(filter, NULL); gchar *contents; g_file_get_contents(filename.c_str(), &contents, NULL, NULL); if (contents) { gtk_text_buffer_set_text(rulesbuffer, contents, -1); g_free(contents); } gtk_text_buffer_set_modified(rulesbuffer, false); }
void WindowMerge::on_combobox_edited() { current_edited_project = combobox_get_active_string(combobox_edited); if (!current_edited_project.empty()) { previous_edited_project = current_edited_project; if (current_edited_project == current_master_project) { combobox_set_index(combobox_master, -1); } } // Simulate editors changed, so it would load the differences. editors_changed(); }
void FiltersDialog::on_button_try() { // Iterators. GtkTextIter startiter, enditer; // Input text. GtkTextBuffer *inputbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview_input)); gtk_text_buffer_get_start_iter(inputbuffer, &startiter); gtk_text_buffer_get_end_iter(inputbuffer, &enditer); ustring inputfile = script_temporal_input_file(); gchar *txt = gtk_text_buffer_get_text(inputbuffer, &startiter, &enditer, false); g_file_set_contents(inputfile.c_str(), txt, -1, NULL); g_free(txt); // Postiff: plug memory leak // Filter. ustring scriptname = combobox_get_active_string(combobox_filters); bool straightthrough = scriptname == scripts_straight_through(); // Output file. ustring outputfile = script_temporal_output_file(); // Run filter. ustring error = script_filter(scriptname, straightthrough, inputfile, outputfile); // Show output in textview. gchar *outputtext; g_file_get_contents(outputfile.c_str(), &outputtext, NULL, NULL); GtkTextBuffer *outputbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview_output)); if (outputtext) { gtk_text_buffer_set_text(outputbuffer, outputtext, -1); g_free(outputtext); } else { gtk_text_buffer_set_text(outputbuffer, "", -1); } // If script failed, give the error for debugging purposes. if (!error.empty()) { gtk_text_buffer_set_text(outputbuffer, error.c_str(), -1); } // If there were compile errors before, show these. if (!compile_errors.empty()) { gtk_text_buffer_set_text(outputbuffer, "", -1); for (unsigned int i = 0; i < compile_errors.size(); i++) { gtk_text_buffer_insert_at_cursor(outputbuffer, compile_errors[i].c_str(), -1); gtk_text_buffer_insert_at_cursor(outputbuffer, "\n", -1); } } }
void FiltersDialog::on_rulesbuffer_changed_execute() { // Bail out if there's no change in the rules buffer. if (!gtk_text_buffer_get_modified(rulesbuffer)) return; // Get the name of the script. Bail out if straight throug. ustring scriptname = combobox_get_active_string(combobox_filters); if (scriptname == scripts_straight_through()) return; // Get the filename and type of the script. ScriptType scripttype; ustring scriptfile = script_get_path(scriptname, &scripttype); // Save the rules to the script file. GtkTextIter startiter, enditer; gtk_text_buffer_get_start_iter(rulesbuffer, &startiter); gtk_text_buffer_get_end_iter(rulesbuffer, &enditer); gchar *txt = gtk_text_buffer_get_text(rulesbuffer, &startiter, &enditer, false); g_file_set_contents(scriptfile.c_str(), txt, -1, NULL); g_free(txt); // Postiff: plug memory leak // If it is a TECkit mapping, compile it. if (scripttype == stTECkit) { compile_errors.clear(); GwSpawn spawn("teckit_compile"); spawn.workingdirectory(Directories->get_scripts()); spawn.arg(scriptfile); // To compile UTF-8 source that lacks an encoding signature, the -u flag must be specified on the compiler command line. spawn.arg("-u"); spawn.run(); if (spawn.exitstatus != 0) { ustring tecfile = script_get_path(scriptname, scripttype, true); unix_unlink(tecfile.c_str()); spawn.read(); spawn.run(); compile_errors = spawn.standarderr; } } }
void NotesTransferDialog::on_okbutton() { // Get the project. extern Settings *settings; ustring project = settings->genconfig.project_get(); // Progress. ProgressWindow progresswindow(_("Transferring text to notes"), false); // Get the category into which to insert notes. ustring category = combobox_get_active_string(combobox1); // Go through the books in the project. vector < unsigned int >books = project_get_books(project); for (unsigned int bk = 0; bk < books.size(); bk++) { // Progress. progresswindow.set_text(books_id_to_english(books[bk])); // Go through the chapters in this book. Progress. vector < unsigned int >chapters = project_get_chapters(project, books[bk]); progresswindow.set_iterate(0, 1, chapters.size()); for (unsigned int ch = 0; ch < chapters.size(); ch++) { progresswindow.iterate(); // Go through the verses in this chapter. vector < ustring > verses = project_get_verses(project, books[bk], chapters[ch]); for (unsigned int vs = 0; vs < verses.size(); vs++) { // Retrieve each verse and insert it into the notes. ustring text = project_retrieve_verse(project, books[bk], chapters[ch], verses[vs]); clean_note(text); if (!text.empty()) { transfer_note(project, books[bk], chapters[ch], verses[vs], text, category); } } } } }
unsigned int RevertDialog::chapter_get() { ustring uchapter = combobox_get_active_string(comboboxchapter); unsigned int chapter = convert_to_int(uchapter); return chapter; }
unsigned int RevertDialog::book_get() { ustring localbook = combobox_get_active_string(comboboxbook); unsigned int book = books_name_to_id(language, localbook); return book; }
ustring WindowCheckKeyterms::collection () { return combobox_get_active_string(combobox_collection); }
void ProjectNoteDialog::on_okbutton1() { project = combobox_get_active_string(combobox_note_project); }
void ImportAssistant::on_assistant_apply () { // Take action depending on the type of import. switch (get_type()) { case itBible: { switch (get_bible_type()) { case ibtUsfm: { ProgressWindow progresswindow(_("Importing files"), false); progresswindow.set_iterate(0, 1, files_names.size()); for (unsigned int i = 0; i < files_names.size(); i++) { progresswindow.iterate(); import_usfm_file (files_names[i], files_book_ids[i], bible_name, summary_messages); } break; } case ibtBibleWorks: { import_bibleworks_text_file (files_names[0], bible_name, summary_messages); break; } case ibtOnlineBible: { import_online_bible (my_windows_outpost, combobox_get_active_string (combobox_online_bible_bible), bible_name, summary_messages); break; } case ibtRawText: { summary_messages.push_back (_("Importing raw text is a manual process. The online help provides more information on that.")); break; } } break; } case itReferences: { summary_messages.push_back (_("Importing references is done in the references window.")); summary_messages.push_back (_("In that window, click on [actions], then click on \"Import a list of references\".")); break; } case itStylesheet: { if (my_styles_window) { my_styles_window->on_stylesheet_import(); } break; } case itNotes: { summary_messages.push_back (_("After this window closes an opportunity will be offered to import notes.")); import_notes = true; break; } case itKeyterms: { summary_messages.push_back (_("After this window closes an opportunity will be offered to import keyterms.")); import_keyterms = true; break; } } }