gboolean biblio_detect_bibliography (GuBiblio* bc, GuEditor* ec) { gchar* content = NULL; gchar* bibfn = NULL; gchar** result = NULL; GMatchInfo *match_info; GRegex* bib_regex = NULL; gboolean state = FALSE; content = editor_grab_buffer (ec); bib_regex = g_regex_new ("^[^%]*\\\\bibliography{\\s*([^{}\\s]*)\\s*}", G_REGEX_MULTILINE, 0, NULL); if (g_regex_match (bib_regex, content, 0, &match_info)) { result = g_match_info_fetch_all (match_info); if (result[1]) { if (!STR_EQU (result[1] +strlen (result[1]) -4, ".bib")) bibfn = g_strconcat (result[1], ".bib", NULL); else bibfn = g_strdup (result[1]); state = editor_fileinfo_update_biblio (ec, bibfn); g_free (bibfn); } slog (L_INFO, "Detect bibliography file: %s\n", ec->bibfile); g_strfreev (result); } g_free (content); g_match_info_free (match_info); g_regex_unref (bib_regex); return state; }
gboolean iofunctions_autosave_cb (void *user) { gint tabtotal, i; GtkWidget *focus; GuTabContext* tab; GuEditor *ec; gchar *text; GList *tabs = gummi_get_all_tabs(); tabtotal = g_list_length(tabs); /* skip the autosave procedure when there are no tabs open */ if (tabtotal == 0) return TRUE; for (i=0; i < tabtotal; i++) { tab = g_list_nth_data (tabs, i); ec = tab->editor; if ((ec->filename) && editor_buffer_changed (ec)) { focus = gtk_window_get_focus (gummi_get_gui ()->mainwindow); text = editor_grab_buffer (ec); gtk_widget_grab_focus (focus); iofunctions_save_file (gummi->io, ec->filename, text); gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (ec->buffer), FALSE); slog (L_DEBUG, "Autosaving document: %s\n", ec->filename); gui_set_filename_display (tab, TRUE, TRUE); } } return TRUE; }
gchar* latex_update_workfile(GuLatex* lc, GuEditor* ec) { gchar *text; text = editor_grab_buffer(ec); // bit of a dirty hack, but only write the buffer content when // there is not a recovery in progress, otherwise the workfile // will be overwritten with empty text if (!STR_EQU(text, "")) { utils_set_file_contents(ec->workfile, text, -1); } return text; }