Exemple #1
0
/* Parses a given bib file and inserting found references into a given comboboy */
void glatex_parse_bib_file(const gchar* file, gpointer combobox)
{
	gchar **bib_entries = NULL;
	int i = 0;
	LaTeXLabel *tmp;
	gchar *tmp_label_name = NULL;
	
	if (file != NULL)
	{
		/*  Return if its not an bib file */
		if (!g_str_has_suffix(file, ".bib"))
		{
			return;
		}

		bib_entries = glatex_read_file_in_array(file);

		if (bib_entries != NULL)
		{
			for (i = 0; bib_entries[i] != NULL ; i++)
			{
				if  (g_str_has_prefix(bib_entries[i], "@"))
				{
					tmp = glatex_parseLine_bib(bib_entries[i]);
					tmp_label_name = g_strdup(tmp->label_name);
					gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), tmp_label_name);
					g_free(tmp);
					g_free(tmp_label_name);
				}
			}
			g_free(bib_entries);
		}
	}
}
Exemple #2
0
void glatex_parse_aux_file(gchar *file, gpointer combobox)
{
	gchar **aux_entries = NULL;
	int i = 0;
	LaTeXLabel *tmp;
	gchar *tmp_label_name = NULL;

	if (file != NULL)
	{
		/*  Return if its not an aux file */
		if (!g_str_has_suffix(file, ".aux"))
			return;

		aux_entries = glatex_read_file_in_array(file);

		if (aux_entries != NULL)
		{
			for (i = 0; aux_entries[i] != NULL ; i++)
			{
				if  (g_str_has_prefix(aux_entries[i], "\\newlabel"))
				{
					tmp = glatex_parseLine(aux_entries[i]);
					tmp_label_name = g_strdup(tmp->label_name);
					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox), tmp_label_name);
					g_free(tmp);
					g_free(tmp_label_name);
				}
			}
			g_free(aux_entries);
		}
	}
}