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.
Revision: 378
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=378&view=rev
Author: frlan
Date: 2009-01-14 22:08:50 +0000 (Wed, 14 Jan 2009)
Log Message:
-----------
GeanyLaTeX: Moved some strings to seperate C file
Modified Paths:
--------------
trunk/geanylatex/po/POTFILES.in
trunk/geanylatex/src/Makefile.am
trunk/geanylatex/src/bibtex.c
trunk/geanylatex/src/bibtex.h
Added Paths:
-----------
trunk/geanylatex/src/bibtexlabels.c
Modified: trunk/geanylatex/po/POTFILES.in
===================================================================
--- trunk/geanylatex/po/POTFILES.in 2009-01-14 22:07:38 UTC (rev 377)
+++ trunk/geanylatex/po/POTFILES.in 2009-01-14 22:08:50 UTC (rev 378)
@@ -2,3 +2,4 @@
src/latexencodings.c
src/letters.c
src/bibtex.c
+src/bibtexlabels.c
Modified: trunk/geanylatex/src/Makefile.am
===================================================================
--- trunk/geanylatex/src/Makefile.am 2009-01-14 22:07:38 UTC (rev 377)
+++ trunk/geanylatex/src/Makefile.am 2009-01-14 22:08:50 UTC (rev 378)
@@ -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
+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_LDFLAGS = -module -avoid-version
geanylatex_la_LIBADD = @GEANY_LIBS@ $(INTLLIBS)
Modified: trunk/geanylatex/src/bibtex.c
===================================================================
--- trunk/geanylatex/src/bibtex.c 2009-01-14 22:07:38 UTC (rev 377)
+++ trunk/geanylatex/src/bibtex.c 2009-01-14 22:08:50 UTC (rev 378)
@@ -1,7 +1,7 @@
/*
* bibtex.c
*
- * Copyright 2008 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
+ * Copyright 2008-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
@@ -25,108 +25,6 @@
fields[entry_number] = flag;
-gchar *label_types[] = {
- N_("Article"),
- N_("Book"),
- N_("Booklet"),
- N_("Conference"),
- N_("Inbook"),
- N_("Incollection"),
- N_("Inproceedings"),
- N_("Manual"),
- N_("Mastersthesis"),
- N_("Misc"),
- N_("PhdThesis"),
- N_("Proceedings"),
- N_("Techreport"),
- N_("Unpublished")};
-
-
-const gchar *label_entry[] = {
- N_("Address"),
- N_("Annote"),
- N_("Author"),
- N_("Booktitle"),
- N_("Chapter"),
- N_("Crossref"),
- N_("Edition"),
- N_("Editor"),
- N_("E-print"),
- N_("HowPublished"),
- N_("Institution"),
- N_("Journal"),
- N_("Key"),
- N_("Month"),
- N_("Note"),
- N_("Number"),
- N_("Organization"),
- N_("Pages"),
- N_("Publisher"),
- N_("School"),
- N_("Series"),
- N_("Title"),
- N_("Type"),
- N_("URL"),
- N_("Volume"),
- N_("Year")};
-
-const gchar *label_entry_keywords[] = {
- ("Address"),
- ("Annote"),
- ("Author"),
- ("Booktitle"),
- ("Chapter"),
- ("Crossref"),
- ("Edition"),
- ("Editor"),
- ("E-print"),
- ("HowPublished"),
- ("Institution"),
- ("Journal"),
- ("Key"),
- ("Month"),
- ("Note"),
- ("Number"),
- ("Organization"),
- ("Pages"),
- ("Publisher"),
- ("School"),
- ("Series"),
- ("Title"),
- ("Type"),
- ("URL"),
- ("Volume"),
- ("Year")};
-
-const gchar *tooltips[] = {
- N_("Address of publisher"),
- N_("Annotation for annotated bibliography styles"),
- N_("Name(s) of the author(s), separated by 'and' if more than one"),
- N_("Title of the book, if only part of it is being cited"),
- N_("Chapter number"),
- N_("Citation key of the cross-referenced entry"),
- N_("Edition of the book (such as \"first\" or \"second\")"),
- N_("Name(s) of the editor(s), separated by 'and' if more than one"),
- N_("Specification of electronic publication"),
- N_("Publishing method if the method is nonstandard"),
- N_("Institution that was involved in the publishing"),
- N_("Journal or magazine in which the work was published"),
- N_("Hidden field used for specifying or overriding the alphabetical order of entries"),
- N_("Month of publication or creation if unpublished"),
- N_("Miscellaneous extra information"),
- N_("Number of journal, magazine, or tech-report"),
- N_("Sponsor of the conference"),
- N_("Page numbers separated by commas or double-hyphens"),
- N_("Name of publisher"),
- N_("School where thesis was written"),
- N_("Series of books in which the book was published"),
- N_("Title of the work"),
- N_("Type of technical report"),
- N_("Internet address"),
- N_("Number of the volume"),
- N_("Year of publication or creation if unpublished")};
-
-
static int get_entry_pos(char *str)
{
int i;
Modified: trunk/geanylatex/src/bibtex.h
===================================================================
--- trunk/geanylatex/src/bibtex.h 2009-01-14 22:07:38 UTC (rev 377)
+++ trunk/geanylatex/src/bibtex.h 2009-01-14 22:08:50 UTC (rev 378)
@@ -75,8 +75,14 @@
N_ENTRIES
};
-extern gchar *label_types[N_TYPES];
+extern gchar *label_types[];
+extern const gchar *label_tooltips[];
+
+extern const gchar *label_entry_keywords[];
+
+extern const gchar *label_entry[];
+
int push_bibtex_entry(int style, GeanyDocument *doc);
void insert_bibtex_entry(G_GNUC_UNUSED GtkMenuItem * menuitem, G_GNUC_UNUSED gpointer gdata);
Added: trunk/geanylatex/src/bibtexlabels.c
===================================================================
--- trunk/geanylatex/src/bibtexlabels.c (rev 0)
+++ trunk/geanylatex/src/bibtexlabels.c 2009-01-14 22:08:50 UTC (rev 378)
@@ -0,0 +1,126 @@
+ /*
+ * bibtexlabels.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 "geanylatex.h"
+#include "bibtex.h"
+
+gchar *label_types[] = {
+ N_("Article"),
+ N_("Book"),
+ N_("Booklet"),
+ N_("Conference"),
+ N_("Inbook"),
+ N_("Incollection"),
+ N_("Inproceedings"),
+ N_("Manual"),
+ N_("Mastersthesis"),
+ N_("Misc"),
+ N_("PhdThesis"),
+ N_("Proceedings"),
+ N_("Techreport"),
+ N_("Unpublished")};
+
+
+const gchar *label_entry[] = {
+ N_("Address"),
+ N_("Annote"),
+ N_("Author"),
+ N_("Booktitle"),
+ N_("Chapter"),
+ N_("Crossref"),
+ N_("Edition"),
+ N_("Editor"),
+ N_("E-print"),
+ N_("HowPublished"),
+ N_("Institution"),
+ N_("Journal"),
+ N_("Key"),
+ N_("Month"),
+ N_("Note"),
+ N_("Number"),
+ N_("Organization"),
+ N_("Pages"),
+ N_("Publisher"),
+ N_("School"),
+ N_("Series"),
+ N_("Title"),
+ N_("Type"),
+ N_("URL"),
+ N_("Volume"),
+ N_("Year")};
+
+const gchar *label_entry_keywords[] = {
+ ("Address"),
+ ("Annote"),
+ ("Author"),
+ ("Booktitle"),
+ ("Chapter"),
+ ("Crossref"),
+ ("Edition"),
+ ("Editor"),
+ ("E-print"),
+ ("HowPublished"),
+ ("Institution"),
+ ("Journal"),
+ ("Key"),
+ ("Month"),
+ ("Note"),
+ ("Number"),
+ ("Organization"),
+ ("Pages"),
+ ("Publisher"),
+ ("School"),
+ ("Series"),
+ ("Title"),
+ ("Type"),
+ ("URL"),
+ ("Volume"),
+ ("Year")};
+
+const gchar *label_tooltips[] = {
+ N_("Address of publisher"),
+ N_("Annotation for annotated bibliography styles"),
+ N_("Name(s) of the author(s), separated by 'and' if more than one"),
+ N_("Title of the book, if only part of it is being cited"),
+ N_("Chapter number"),
+ N_("Citation key of the cross-referenced entry"),
+ N_("Edition of the book (such as \"first\" or \"second\")"),
+ N_("Name(s) of the editor(s), separated by 'and' if more than one"),
+ N_("Specification of electronic publication"),
+ N_("Publishing method if the method is nonstandard"),
+ N_("Institution that was involved in the publishing"),
+ N_("Journal or magazine in which the work was published"),
+ N_("Hidden field used for specifying or overriding the alphabetical order of entries"),
+ N_("Month of publication or creation if unpublished"),
+ N_("Miscellaneous extra information"),
+ N_("Number of journal, magazine, or tech-report"),
+ N_("Sponsor of the conference"),
+ N_("Page numbers separated by commas or double-hyphens"),
+ N_("Name of publisher"),
+ N_("School where thesis was written"),
+ N_("Series of books in which the book was published"),
+ N_("Title of the work"),
+ N_("Type of technical report"),
+ N_("Internet address"),
+ N_("Number of the volume"),
+ N_("Year of publication or creation if unpublished")};
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.