SF.net SVN: geany-plugins:[382] trunk/geanylatex/src

frlan at users.sourceforge.net frlan at xxxxx
Mon Jan 19 20:19:57 UTC 2009


Revision: 382
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=382&view=rev
Author:   frlan
Date:     2009-01-19 20:19:56 +0000 (Mon, 19 Jan 2009)

Log Message:
-----------
GeanyLaTeX: Added a first version for support of finding allready definded labels inside insert \ref{} menu

Merge branch 'Reftex_start'

Modified Paths:
--------------
    trunk/geanylatex/src/Makefile.am
    trunk/geanylatex/src/bibtex.c
    trunk/geanylatex/src/geanylatex.c
    trunk/geanylatex/src/geanylatex.h

Added Paths:
-----------
    trunk/geanylatex/src/latexutils.c
    trunk/geanylatex/src/latexutils.h
    trunk/geanylatex/src/reftex.c
    trunk/geanylatex/src/reftex.h

Modified: trunk/geanylatex/src/Makefile.am
===================================================================
--- trunk/geanylatex/src/Makefile.am	2009-01-18 18:28:20 UTC (rev 381)
+++ trunk/geanylatex/src/Makefile.am	2009-01-19 20:19:56 UTC (rev 382)
@@ -1,5 +1,5 @@
 lib_LTLIBRARIES = geanylatex.la
-geanylatex_la_SOURCES = geanylatex.c geanylatex.h datatypes.h latexencodings.c latexencodings.h letters.c letters.h bibtex.h bibtex.c bibtexlabels.c
+geanylatex_la_SOURCES = geanylatex.c geanylatex.h datatypes.h latexencodings.c latexencodings.h letters.c letters.h bibtex.h bibtex.c bibtexlabels.c reftex.c reftex.h latexutils.c latexutils.h
 
 geanylatex_la_LDFLAGS = -module -avoid-version
 geanylatex_la_LIBADD  = @GEANY_LIBS@  $(INTLLIBS)

Modified: trunk/geanylatex/src/bibtex.c
===================================================================
--- trunk/geanylatex/src/bibtex.c	2009-01-18 18:28:20 UTC (rev 381)
+++ trunk/geanylatex/src/bibtex.c	2009-01-19 20:19:56 UTC (rev 382)
@@ -20,6 +20,7 @@
  */
 
 #include "bibtex.h"
+#include "reftex.h"
 
 #define set_status(entry_number, flag) \
 	fields[entry_number] = flag;

Modified: trunk/geanylatex/src/geanylatex.c
===================================================================
--- trunk/geanylatex/src/geanylatex.c	2009-01-18 18:28:20 UTC (rev 381)
+++ trunk/geanylatex/src/geanylatex.c	2009-01-19 20:19:56 UTC (rev 382)
@@ -138,6 +138,7 @@
 	GtkWidget *radio1 = NULL;
 	GtkWidget *radio2 = NULL;
 
+
 	dialog = gtk_dialog_new_with_buttons(_("Insert reference"),
 					     GTK_WINDOW(geany->main_widgets->window),
 					     GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL,
@@ -152,7 +153,8 @@
 	gtk_table_set_row_spacings(GTK_TABLE(table), 6);
 
 	label_ref = gtk_label_new(_("Ref name:"));
-	textbox_ref = gtk_entry_new();
+	textbox_ref = gtk_combo_box_entry_new_text();
+	add_Labels(textbox_ref, get_aux_file());
 
 	gtk_misc_set_alignment(GTK_MISC(label_ref), 0, 0.5);
 
@@ -178,7 +180,7 @@
 	{
 		gchar *ref_string = NULL;
 
-		ref_string = g_strdup(gtk_entry_get_text(GTK_ENTRY(textbox_ref)));
+		ref_string = g_strdup(gtk_combo_box_get_active_text(GTK_COMBO_BOX(textbox_ref)));
 
 		if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio2)) == FALSE)
 		{

Modified: trunk/geanylatex/src/geanylatex.h
===================================================================
--- trunk/geanylatex/src/geanylatex.h	2009-01-18 18:28:20 UTC (rev 381)
+++ trunk/geanylatex/src/geanylatex.h	2009-01-19 20:19:56 UTC (rev 382)
@@ -42,6 +42,7 @@
 #include "letters.h"
 #include "latexencodings.h"
 #include "bibtex.h"
+#include "reftex.h"
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>

Added: trunk/geanylatex/src/latexutils.c
===================================================================
--- trunk/geanylatex/src/latexutils.c	                        (rev 0)
+++ trunk/geanylatex/src/latexutils.c	2009-01-19 20:19:56 UTC (rev 382)
@@ -0,0 +1,89 @@
+/*
+ *      utils.c
+ *
+ *      Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#include "latexutils.h"
+#include "document.h"
+
+gchar **geanylatex_read_file_in_array(const gchar *filename)
+{
+	gchar **result = NULL;
+	gchar *data;
+
+	if (filename == NULL) return NULL;
+
+	g_file_get_contents(filename, &data, NULL, NULL);
+
+	if (data != NULL)
+	{
+		result = g_strsplit_set(data, "\r\n", -1);
+	}
+
+	g_free(data);
+
+	return result;
+}
+
+const gchar *get_aux_file()
+{
+	GeanyDocument *doc = NULL;
+	gchar *locale_filename = NULL;
+	GString *tmp = NULL;
+
+	doc = document_get_current();
+
+	if (doc != NULL)
+	{
+		if (doc->file_name != NULL)
+		{
+			locale_filename = utils_get_locale_from_utf8(doc->file_name);
+			tmp = g_string_new(locale_filename);
+			utils_string_replace_all(tmp, ".tex", ".aux");
+
+			return g_string_free(tmp, FALSE);
+		}
+	}
+
+	return NULL;
+}
+
+LaTeXLabel parseLine(const gchar *line)
+{
+	LaTeXLabel label;
+
+	gchar *t = NULL;
+	const gchar *x = NULL;
+	gint l = 0;
+
+	line += 10;
+	x = line;
+	t = strchr(line, '}');
+	if (t != NULL)
+	{
+		while (*x != '\0' && x < t && *x != '}')
+		{
+			l++;
+			x++;
+		}
+	}
+	label.label_name = g_strndup(line, l);
+
+	return label;
+}

Added: trunk/geanylatex/src/latexutils.h
===================================================================
--- trunk/geanylatex/src/latexutils.h	                        (rev 0)
+++ trunk/geanylatex/src/latexutils.h	2009-01-19 20:19:56 UTC (rev 382)
@@ -0,0 +1,33 @@
+/*
+ *      latexutils.h
+ *
+ *      Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+#ifndef LATEXUTILS_H
+#define LATEXUTILS_H
+
+#include "geanylatex.h"
+#include "reftex.h"
+
+gchar **geanylatex_read_file_in_array(const gchar *filename);
+
+LaTeXLabel parseLine(const gchar *line);
+
+const gchar *get_aux_file();
+
+#endif

Added: trunk/geanylatex/src/reftex.c
===================================================================
--- trunk/geanylatex/src/reftex.c	                        (rev 0)
+++ trunk/geanylatex/src/reftex.c	2009-01-19 20:19:56 UTC (rev 382)
@@ -0,0 +1,46 @@
+/*
+ *      reftex.c
+ *
+ *      Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#include "reftex.h"
+#include "latexutils.h"
+
+void add_Labels(GtkWidget *combobox, gchar *file)
+{
+	gchar **aux_entries = NULL;
+	int i = 0;
+	LaTeXLabel tmp;
+	if (file != NULL)
+	{
+		aux_entries = geanylatex_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 = parseLine(aux_entries[i]);
+					gtk_combo_box_append_text(GTK_COMBO_BOX(combobox), tmp.label_name);
+					//insert_string(aux_entries[i]);
+				}
+			}
+		}
+	}
+}

Added: trunk/geanylatex/src/reftex.h
===================================================================
--- trunk/geanylatex/src/reftex.h	                        (rev 0)
+++ trunk/geanylatex/src/reftex.h	2009-01-19 20:19:56 UTC (rev 382)
@@ -0,0 +1,35 @@
+/*
+ *      reftex.h
+ *
+ *      Copyright 2009 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#ifndef REFTEX_H
+#define REFTEX_H
+
+#include "geanylatex.h"
+
+typedef struct
+{
+	gchar *label_name;
+	gint page;
+	gchar *chapter;
+} LaTeXLabel;
+
+void add_Labels(GtkWidget *combobox, gchar *file);
+#endif


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list