[Goodies-commits] r5378 - in xfbib/branches/gobject: src tests

David Gustafsson tssj at xfce.org
Wed Sep 10 10:42:27 CEST 2008


Author: tssj
Date: 2008-09-10 08:42:26 +0000 (Wed, 10 Sep 2008)
New Revision: 5378

Modified:
   xfbib/branches/gobject/src/main.c
   xfbib/branches/gobject/src/xfbib-comment.c
   xfbib/branches/gobject/src/xfbib-comment.h
   xfbib/branches/gobject/src/xfbib-elements.c
   xfbib/branches/gobject/src/xfbib-elements.h
   xfbib/branches/gobject/src/xfbib-entry.c
   xfbib/branches/gobject/src/xfbib-entry.h
   xfbib/branches/gobject/src/xfbib-field.c
   xfbib/branches/gobject/src/xfbib-field.h
   xfbib/branches/gobject/src/xfbib-integer.c
   xfbib/branches/gobject/src/xfbib-integer.h
   xfbib/branches/gobject/src/xfbib-menu-bar.c
   xfbib/branches/gobject/src/xfbib-preamble.c
   xfbib/branches/gobject/src/xfbib-preamble.h
   xfbib/branches/gobject/src/xfbib-strbuf.c
   xfbib/branches/gobject/src/xfbib-strbuf.h
   xfbib/branches/gobject/src/xfbib-string.c
   xfbib/branches/gobject/src/xfbib-string.h
   xfbib/branches/gobject/src/xfbib-tree-view.c
   xfbib/branches/gobject/src/xfbib-tree-view.h
   xfbib/branches/gobject/src/xfbib-value.c
   xfbib/branches/gobject/src/xfbib-value.h
   xfbib/branches/gobject/src/xfbib-window.c
   xfbib/branches/gobject/src/xfbib-window.h
   xfbib/branches/gobject/tests/Makefile.am
   xfbib/branches/gobject/tests/test-xfbib-elements.c
   xfbib/branches/gobject/tests/test-xfbib-field.c
Log:
Alpha version of the parser done


Modified: xfbib/branches/gobject/src/main.c
===================================================================
--- xfbib/branches/gobject/src/main.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/main.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -25,7 +25,6 @@
 #include <gtk/gtk.h>
 
 #include "xfbib-window.h"
-#include "xfbib-elements.h"
 
 gboolean 
 cb_window_destroy_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)

Modified: xfbib/branches/gobject/src/xfbib-comment.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-comment.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-comment.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -23,10 +23,12 @@
 #include <gtk/gtk.h>
 
 #include "xfbib-comment.h"
+#include "xfbib-strbuf.h"
 
 struct _XfbibComment
 {
 	GObject parent;
+	XfbibStrbuf *strbuf;
 };
  
 typedef struct _XfbibCommentClass
@@ -51,6 +53,7 @@
 static void
 xfbib_comment_init(XfbibComment *instance)
 {
+	instance->strbuf = xfbib_strbuf_new();
 }
  
 static void
@@ -60,9 +63,10 @@
 }
  
 XfbibComment *
-xfbib_comment_new()
+xfbib_comment_new(const gchar *str)
 {
 	XfbibComment *comment;
 	comment = g_object_new(XFBIB_TYPE_COMMENT, NULL);
+	xfbib_strbuf_append(comment->strbuf, str);
 	return comment;
 }

Modified: xfbib/branches/gobject/src/xfbib-comment.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-comment.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-comment.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -35,7 +35,7 @@
 
 GType xfbib_comment_get_type() G_GNUC_CONST;
 
-XfbibComment *xfbib_comment_new();
+XfbibComment *xfbib_comment_new(const gchar *);
 
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-elements.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-elements.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-elements.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -1,22 +1,3 @@
-/* 
- * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
- * All rights reserved.
- *
- * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -24,8 +5,16 @@
 #include <gtk/gtk.h>
 
 #include "xfbib-elements.h"
+#include "xfbib-entry.h"
 #include "xfbib-strbuf.h"
+#include "xfbib-comment.h"
+#include "xfbib-preamble.h"
+#include "xfbib-string.h"
 
+
+#define CURLY_BRACKET 0
+#define ROUND_BRACKET 1
+
 struct _XfbibElements
 {
 	GObject parent;
@@ -73,13 +62,123 @@
 }
 
 
-void
-xfbib_elements_add(XfbibElements *elements, GObject *object)
+static gboolean
+parse_balanced_brackets(XfbibStrbuf *buf, const gchar *str, gint *i)
 {
-	g_return_if_fail(XFBIB_IS_ELEMENTS(elements));
-	elements->list = g_list_append(elements->list, object);
+	gint brackets;
+	gchar bracket_type;
+ 
+	while (str[(*i)] != '{' && str[(*i)] != '(') {
+		xfbib_strbuf_append_char(buf, str[(*i)]);
+		(*i)++;
+	}
+
+	if (str[(*i)] == '{') {
+		bracket_type = CURLY_BRACKET;
+	} else if (str[(*i)] == '(') {
+		bracket_type = ROUND_BRACKET;
+	} else {
+		g_warning("Error, on line %d(TODO)\n", __LINE__);
+		return FALSE;
+	}
+
+	xfbib_strbuf_append_char(buf, str[(*i)]);
+	(*i)++;
+
+	for (brackets = 1; brackets > 0; (*i)++) {
+		if (bracket_type == CURLY_BRACKET) {
+			if (str[(*i)] == '{')
+				brackets++;
+			else if(str[(*i)] == '}')
+				brackets--;
+		} else if (bracket_type == ROUND_BRACKET) {
+			if (str[(*i)] == '(')
+				brackets++;
+			else if(str[(*i)] == ')')
+				brackets--;
+		} else {
+			g_warning("Error, could not parse wrong entry type (TODO)\n");
+			return FALSE;;
+			/* Strange */
+		}
+		xfbib_strbuf_append_char(buf, str[(*i)]);
+	}
 }
 
+
+gboolean
+xfbib_elements_parse(XfbibElements *elements, const gchar *str)
+{
+	gint i;
+	GRegex *regex;
+	GObject *obj;
+	XfbibStrbuf *buf;
+
+	buf = xfbib_strbuf_new();
+
+	/* Compile the regex for the entry types */
+	regex = g_regex_new("^@(article|book|booklet|conference|inbook|incollection|inproceedings|manual|"
+			"mastersthesis|misc|phdthesis|proceedings|techreport|unpublished)({|\\s|[(])",
+			G_REGEX_CASELESS, 0, NULL);
+
+	for (i = 0; i < strlen(str); i++) {
+		if (str[i] == '@') {
+			if (xfbib_strbuf_len(buf) > 0) {
+				/* The comment ended put it in the list */
+				obj = G_OBJECT(xfbib_comment_new(xfbib_strbuf_get_str(buf)));
+				elements->list = g_list_append(elements->list, obj);
+				xfbib_strbuf_wipe(buf);
+			}
+			if (g_ascii_strncasecmp(&str[i], "@comment", 8) == 0) {
+				/* Comment */
+				for (; str[i] != '\n'; i++) 
+					xfbib_strbuf_append_char(buf, str[i]);
+
+				/* Dont forget the newline character */	
+				xfbib_strbuf_append_char(buf, str[i]);
+				
+				obj = G_OBJECT(xfbib_comment_new(xfbib_strbuf_get_str(buf)));
+				elements->list = g_list_append(elements->list, obj);
+				xfbib_strbuf_wipe(buf);
+			} else if (g_ascii_strncasecmp(&str[i], "@preamble", 9) == 0) {
+				/* Preamble */
+				if (parse_balanced_brackets(buf, str, &i)) {
+					obj = G_OBJECT(xfbib_preamble_new());
+					if (xfbib_preamble_parse(XFBIB_PREAMBLE(obj), xfbib_strbuf_get_str(buf)))
+						elements->list = g_list_append(elements->list, obj);
+				}
+				xfbib_strbuf_wipe(buf);
+			} else if (g_ascii_strncasecmp(&str[i], "@string", 7) == 0) {
+				/* String */
+				if (parse_balanced_brackets(buf, str, &i)) {
+					obj = G_OBJECT(xfbib_string_new());
+					if (xfbib_string_parse(XFBIB_STRING(obj), xfbib_strbuf_get_str(buf)))
+						elements->list = g_list_append(elements->list, obj);
+				}
+				xfbib_strbuf_wipe(buf);
+			} else if (g_regex_match (regex, &str[i], 0, NULL)) {
+				/* Entry */
+				if (parse_balanced_brackets(buf, str, &i)) {
+					obj = G_OBJECT(xfbib_entry_new());
+					if (xfbib_entry_parse(XFBIB_ENTRY(obj), xfbib_strbuf_get_str(buf)))
+						elements->list = g_list_append(elements->list, obj);
+				}
+				xfbib_strbuf_wipe(buf);
+			} else {
+				/* Error */
+				g_warning("Error, on line %d(TODO)\n", __LINE__);
+				while (str[++i] != '@')
+					continue;
+			}
+		} else {
+			xfbib_strbuf_append_char(buf, str[i]);
+		}
+	}
+	g_regex_unref(regex);
+	return TRUE;
+}
+
+
 GList *
 xfbib_elements_get(XfbibElements *elements)
 {

Modified: xfbib/branches/gobject/src/xfbib-elements.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-elements.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-elements.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -1,22 +1,3 @@
-/* 
- * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
- * All rights reserved.
- *
- * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
 #ifndef __XFBIB_ELEMENTS_H
 #define __XFBIB_ELEMENTS_H
 
@@ -36,7 +17,7 @@
 GType xfbib_elements_get_type() G_GNUC_CONST;
 
 XfbibElements *xfbib_elements_new();
-void xfbib_elements_add(XfbibElements *, GObject *);
+gboolean xfbib_elements_parse(XfbibElements *, const gchar *);
 GList *xfbib_elements_get(XfbibElements *);
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-entry.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-entry.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 #include <gtk/gtk.h>
+#include <string.h>
 
 #include "xfbib-entry.h"
 #include "xfbib-field.h"
@@ -75,53 +76,59 @@
 	return entry;
 }
 
-void
-xfbib_entry_set_bibtype(XfbibEntry *entry, const gchar *bibtype)
+gboolean
+xfbib_entry_parse(XfbibEntry *entry, const gchar *str)
 {
-	g_return_if_fail(XFBIB_IS_ENTRY(entry));
-	xfbib_strbuf_wipe(entry->bibtype);
-	xfbib_strbuf_append(entry->bibtype, bibtype);
-}
+	gchar *tmp;
+	XfbibStrbuf *buf;
+	XfbibField *field;
+	gint i, brackets, quotes;
 
-const gchar *
-xfbib_entry_get_bibtype(XfbibEntry *entry)
-{
-	g_return_val_if_fail(XFBIB_IS_ENTRY(entry), "");
-	return xfbib_strbuf_get_str(entry->bibtype);
-}
+	/* Dont copy the last bracket */
+	tmp = g_strndup(str, strlen(str) - 1);
 
-void
-xfbib_entry_set_key(XfbibEntry *entry, const gchar *key)
-{
-	g_return_if_fail(XFBIB_IS_ENTRY(entry));
-	xfbib_strbuf_wipe(entry->key);
-	xfbib_strbuf_append(entry->key, key);
-}
+	/* Parse entry type */
+	for (i = 0; i < strlen(tmp) && tmp[i] != '{' && tmp[i] != '('; i++)
+		xfbib_strbuf_append_char(entry->bibtype, tmp[i]);
+	
+	if (i == strlen(tmp)) {
+		return FALSE;
+	}
 
-const gchar *
-xfbib_entry_get_key(XfbibEntry *entry)
-{
-	g_return_val_if_fail(XFBIB_IS_ENTRY(entry), "");
-	return xfbib_strbuf_get_str(entry->key);
-}
+	/* Parse the entry key */
+	for (i++; tmp[i] != '\0' && tmp[i] != ','; i++)
+		xfbib_strbuf_append_char(entry->key, tmp[i]);
 
+	buf = xfbib_strbuf_new();
 
-void 
-xfbib_entry_add_field(XfbibEntry *entry, const gchar *varname, const gchar *value)
-{
-	XfbibField *field;
-	g_return_if_fail(XFBIB_IS_ENTRY(entry));
+	for (i++, brackets = 0, quotes = 0; i < strlen(tmp); i++) {
+
+		if (tmp[i] == ',' && brackets == 0 && quotes%2 == 0) {
+			field = xfbib_field_new();
+			if (!xfbib_field_parse(field, xfbib_strbuf_get_str(buf)))
+				return FALSE;
+			entry->fields = g_list_append(entry->fields, field);
+			xfbib_strbuf_wipe(buf);
+			continue;
+		} else if (tmp[i] == '{' || tmp[i] == '(') {
+			brackets++;
+		} else if (tmp[i] == '}' || tmp[i] == ')') {
+			brackets--;
+		} else if (tmp[i] == '"') {
+			quotes++;
+		}
+		xfbib_strbuf_append_char(buf, tmp[i]);
+	}
+
 	field = xfbib_field_new();
-	xfbib_field_set_varname(field, varname);
-	xfbib_field_set_value(field, value);
+	if (!xfbib_field_parse(field, xfbib_strbuf_get_str(buf)))
+		return FALSE;
 	entry->fields = g_list_append(entry->fields, field);
-}
 
-GList *
-xfbib_entry_get_fields(XfbibEntry *entry)
-{
-	g_return_val_if_fail(XFBIB_IS_ENTRY(entry), NULL);
-	return entry->fields;
+	g_object_unref(G_OBJECT(buf));
+	g_free(tmp);
+
+	return TRUE;
 }
 
 XfbibField *

Modified: xfbib/branches/gobject/src/xfbib-entry.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-entry.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -37,12 +37,7 @@
 GType xfbib_entry_get_type() G_GNUC_CONST;
 
 XfbibEntry *xfbib_entry_new();
-void xfbib_entry_set_bibtype(XfbibEntry *, const gchar *);
-const gchar *xfbib_entry_get_bibtype(XfbibEntry *);
-void xfbib_entry_set_key(XfbibEntry *, const gchar *);
-const gchar *xfbib_entry_get_key(XfbibEntry *);
-void xfbib_entry_add_field(XfbibEntry *, const gchar *, const gchar *);
-GList *xfbib_entry_get_fields(XfbibEntry *);
+gboolean xfbib_entry_parse(XfbibEntry *, const gchar *);
 XfbibField *xfbib_entry_get_field_by_column(XfbibEntry *, gint);
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-field.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-field.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-field.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -24,12 +24,45 @@
 
 #include "xfbib-field.h"
 #include "xfbib-strbuf.h"
+#include "xfbib-value.h"
 
+static struct {
+	gchar *label;
+	gchar *tooltip;
+}xfbib_field_constants[] = {
+	{"Address", "Address of publisher"},
+	{"Annote", "Annotation for annotated bibliography styles"}, 
+	{"Author", "Name(s) of the author(s), separated by 'and' if more than one"}, 
+	{"Booktitle", "Title of the book, if only part of it is being cited"}, 
+	{"Chapter", "Chapter number"}, 
+	{"Crossref", "Citation key of the cross-referenced entry"}, 
+	{"Edition", "Edition of the book (such as \"first\" or \"second\")"}, 
+	{"Editor", "Name(s) of the editor(s), separated by 'and' if more than one"}, 
+	{"E-print", "Specification of electronic publication"}, 
+	{"HowPublished", "Publishing method if the method is nonstandard"}, 
+	{"Institution", "Institution that was involved in the publishing"}, 
+	{"Journal", "Journal or magazine in which the work was published"}, 
+	{"Key", "Hidden field used for specifying or overriding the alphabetical order of entries"}, 
+	{"Month", "Month of publication or creation if unpublished"}, 
+	{"Note", "Miscellaneous extra information"}, 
+	{"Number", "Number of journal, magazine, or tech-report"}, 
+	{"Organization", "Sponsor of the conference"}, 
+	{"Pages", "Page numbers separated by commas or double-hyphens"}, 
+	{"Publisher", "Name of publisher"}, 
+	{"School", "School where thesis was written"}, 
+	{"Series", "Series of books in which the book was published"}, 
+	{"Title", "Title of the work"}, 
+	{"Type", "Type of technical report"}, 
+	{"URL", "Internet address"}, 
+	{"Volume", "Number of the volume"}, 
+	{"Year", "Year of publication or creation if unpublished"}
+};
+
 struct _XfbibField
 {
 	GObject parent;
-	XfbibStrbuf *varname;
-	XfbibStrbuf *value;
+	XfbibStrbuf *variable;
+	XfbibValue *value;
 };
 
 typedef struct _XfbibFieldClass
@@ -54,8 +87,8 @@
 static void
 xfbib_field_init(XfbibField *instance)
 {
-	instance->varname = xfbib_strbuf_new();
-	instance->value = xfbib_strbuf_new();
+	instance->variable = xfbib_strbuf_new();
+	instance->value = xfbib_value_new();
 }
 
 static void
@@ -72,128 +105,47 @@
 	return field;
 }
 
-void
-xfbib_field_set_varname(XfbibField *field, const gchar *varname)
+gboolean
+xfbib_field_parse(XfbibField *field, const gchar *str)
 {
-	g_return_if_fail(XFBIB_IS_FIELD(field));
-	xfbib_strbuf_wipe(field->varname);
-	xfbib_strbuf_append(field->varname, varname);
-}
+	gchar **split = NULL;
+	
+	split = g_strsplit(str, "=", 2);
 
-const gchar *
-xfbib_field_get_varname(XfbibField *field)
-{
-	g_return_val_if_fail(XFBIB_IS_FIELD(field), "");
-	return xfbib_strbuf_get_str(field->varname);
-}
+	if (split[1] == NULL) {
+		/* Equal sign missing */
+		g_warning("No equal sign found in definition of Field\n");
+		g_strfreev(split);
+		return FALSE;
+	}
 
-void
-xfbib_field_set_value(XfbibField *field, const gchar *value)
-{
-	g_return_if_fail(XFBIB_IS_FIELD(field));
-	xfbib_strbuf_wipe(field->value);
-	xfbib_strbuf_append(field->value, value);
-}
+	/* Variable */
+	xfbib_strbuf_wipe(field->variable);
+	g_strstrip(split[0]);
+	xfbib_strbuf_append(field->variable, split[0]);
 
-const gchar *
-xfbib_field_get_value(XfbibField *field)
-{
-	g_return_val_if_fail(XFBIB_IS_FIELD(field), "");
-	return xfbib_strbuf_get_str(field->value);
-}
-
-const gchar *
-xfbib_field_get_column_name(gint column)
-{
-	switch (column) {
-		case XFBIB_FIELD_ADDRESS:
-			return "Address";
-			break;
-		case XFBIB_FIELD_ANNOTE:
-			return "Annote";
-			break;
-		case XFBIB_FIELD_AUTHOR:
-			return "Author";
-			break;
-		case XFBIB_FIELD_BOOKTITLE:
-			return "Booktitle";
-			break;
-		case XFBIB_FIELD_CHAPTER:
-			return "Chapter";
-			break;
-		case XFBIB_FIELD_CROSSREF:
-			return "Crossref";
-			break;
-		case XFBIB_FIELD_EDITION:
-			return "Edition";
-			break;
-		case XFBIB_FIELD_EDITOR:
-			return "Editor";
-			break;
-		case XFBIB_FIELD_EPRINT:
-			return "Eprint";
-			break;
-		case XFBIB_FIELD_HOWPUBLISHED:
-			return "Howpublished";
-			break;
-		case XFBIB_FIELD_INSTITUTION:
-			return "Institution";
-			break;
-		case XFBIB_FIELD_JOURNAL:
-			return "Journal";
-			break;
-		case XFBIB_FIELD_KEY:
-			return "Key";
-			break;
-		case XFBIB_FIELD_MONTH:
-			return "Month";
-			break;
-		case XFBIB_FIELD_NOTE:
-			return "Note";
-			break;
-		case XFBIB_FIELD_NUMBER:
-			return "Number";
-			break;
-		case XFBIB_FIELD_ORGANIZATION:
-			return "Organization";
-			break;
-		case XFBIB_FIELD_PAGES:
-			return "Pages";
-			break;
-		case XFBIB_FIELD_PUBLISHER:
-			return "Publisher";
-			break;
-		case XFBIB_FIELD_SCHOOL:
-			return "School";
-			break;
-		case XFBIB_FIELD_SERIES:
-			return "Series";
-			break;
-		case XFBIB_FIELD_TITLE:
-			return "Title";
-			break;
-		case XFBIB_FIELD_TYPE:
-			return "Type";
-			break;
-		case XFBIB_FIELD_URL:
-			return "Url";
-			break;
-		case XFBIB_FIELD_VOLUME:
-			return "Volume";
-			break;
-		case XFBIB_FIELD_YEAR:
-			return "Year";
-			break;
-		default:
-			return "";
+	/* Value */
+	if (!xfbib_value_parse(field->value, split[1])) {
+		g_strfreev(split);
+		return FALSE;
 	}
+	
+	g_strfreev(split);
+	return TRUE;
 }
 
-gboolean xfbib_field_is_column(XfbibField *field, gint column)
+gboolean
+xfbib_field_is_column(XfbibField *field, gint column)
 {
-	if (strcasecmp(xfbib_field_get_varname(field),
-				xfbib_field_get_column_name(column)) == 0) {
+	if (strcasecmp(xfbib_strbuf_get_str(field->variable),
+				xfbib_field_constants[column].label) == 0) {
 		return TRUE;
 	}
 	return FALSE;
 }
+
+const gchar *
+xfbib_field_get_value(XfbibField *field)
+{
+	return xfbib_value_get_str(field->value);
+}

Modified: xfbib/branches/gobject/src/xfbib-field.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-field.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-field.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -66,12 +66,9 @@
 GType xfbib_field_get_type() G_GNUC_CONST;
 
 XfbibField *xfbib_field_new();
-void xfbib_field_set_varname(XfbibField *, const gchar *);
-const gchar *xfbib_field_get_varname(XfbibField *);
-void xfbib_field_set_value(XfbibField *, const gchar *);
-const gchar *xfbib_field_get_value(XfbibField *);
-const gchar *xfbib_field_get_column_name(gint);
+gboolean xfbib_field_parse(XfbibField *, const gchar *);
 gboolean xfbib_field_is_column(XfbibField *, gint);
+const gchar *xfbib_field_get_value(XfbibField *);
 G_END_DECLS
 
 #endif //__XFBIB_FIELD_H

Modified: xfbib/branches/gobject/src/xfbib-integer.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-integer.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-integer.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -62,6 +62,13 @@
 	G_OBJECT_CLASS(xfbib_integer_parent_class)->finalize(obj);
 }
 
+XfbibInteger *
+xfbib_integer_new()
+{
+	XfbibInteger *integer;
+	integer = g_object_new(XFBIB_TYPE_INTEGER, NULL);
+	return integer;
+}
 
 const gchar *
 xfbib_integer_get(XfbibInteger *integer)
@@ -76,11 +83,3 @@
 	xfbib_strbuf_append(integer->str, str);
 }
 
-XfbibInteger *
-xfbib_integer_new()
-{
-	XfbibInteger *integer;
-	integer = g_object_new(XFBIB_TYPE_INTEGER, NULL);
-	return integer;
-}
-

Modified: xfbib/branches/gobject/src/xfbib-integer.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-integer.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-integer.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -35,9 +35,9 @@
 
 GType xfbib_integer_get_type() G_GNUC_CONST;
 
+XfbibInteger *xfbib_integer_new();
 const gchar *xfbib_integer_get(XfbibInteger *);
 void xfbib_integer_set(XfbibInteger *, const gchar *);
-XfbibInteger *xfbib_integer_new();
 
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-menu-bar.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-menu-bar.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-menu-bar.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -81,8 +81,6 @@
 static void
 cb_file_quit_activate (GtkMenuItem *menuitem, gpointer user_data)
 {
-	GtkWidget *window;
-	window = gtk_widget_get_toplevel(GTK_WIDGET(menuitem));
 	gtk_widget_destroy(window);
 }
 
@@ -135,7 +133,7 @@
 			"copyright", XFCE_COPYRIGHT_TEXT("2008", "Jesper Karlsson & David Gustafsson"),
 			"license", XFCE_LICENSE_GPL,
 			"logo-icon-name", PACKAGE,
-#ifdef GTK_CHECK_VERSION(2,12,0)
+#if GTK_CHECK_VERSION(2,12,0)
 			"program-name", PACKAGE_NAME,
 #else
 			"name", PACKAGE_NAME,
@@ -265,17 +263,21 @@
 	instance->view = gtk_menu_new();
 	/* Add things to menu */
 	instance->view_columns = gtk_menu_new();
+	/*
 	item = gtk_menu_item_new_with_label("Show Columns");
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), instance->view_columns);
 	gtk_menu_shell_append(GTK_MENU_SHELL (instance->view), item);
-	
+	*/
+
 	/* Columns submenu */
+	/*
 	for (i = 0; i < XFBIB_FIELD_N_FIELDS; i++) {
 		str = g_strdup_printf("Show %s", xfbib_field_get_column_name(i));
 		item = gtk_check_menu_item_new_with_mnemonic(str);
 		free(str);
 		gtk_menu_shell_append(GTK_MENU_SHELL (instance->view_columns), item);
 	}
+	*/
 
 	item = gtk_check_menu_item_new_with_mnemonic("Show Toolbar");
 	gtk_menu_shell_append(GTK_MENU_SHELL (instance->view), item);

Modified: xfbib/branches/gobject/src/xfbib-preamble.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-preamble.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-preamble.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -20,6 +20,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <string.h>
 #include <gtk/gtk.h>
 
 #include "xfbib-preamble.h"
@@ -92,8 +93,3 @@
 	return TRUE;
 }
 
-const gchar *
-xfbib_preamble_get_value(XfbibPreamble *preamble)
-{
-	return xfbib_value_get_str(preamble->value);
-}

Modified: xfbib/branches/gobject/src/xfbib-preamble.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-preamble.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-preamble.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -37,7 +37,6 @@
 
 XfbibPreamble *xfbib_preamble_new();
 gboolean xfbib_preamble_parse(XfbibPreamble *, const gchar *);
-const gchar *xfbib_preamble_get_value(XfbibPreamble *);
 
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-strbuf.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-strbuf.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-strbuf.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -1,22 +1,3 @@
-/* 
- * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
- * All rights reserved.
- *
- * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -132,3 +113,10 @@
 
 	return strbuf;
 }
+
+
+gint xfbib_strbuf_len(XfbibStrbuf *strbuf)
+{
+	g_return_val_if_fail(XFBIB_IS_STRBUF(strbuf), 0);
+	return strbuf->used;
+}

Modified: xfbib/branches/gobject/src/xfbib-strbuf.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-strbuf.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-strbuf.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -1,22 +1,3 @@
-/* 
- * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
- * All rights reserved.
- *
- * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
 #ifndef __XFBIB_STRBUF_H
 #define __XFBIB_STRBUF_H
 
@@ -40,6 +21,7 @@
 void xfbib_strbuf_append(XfbibStrbuf *, const gchar *);
 void xfbib_strbuf_append_char(XfbibStrbuf *, const gchar);
 void xfbib_strbuf_wipe(XfbibStrbuf *);
+gint xfbib_strbuf_len(XfbibStrbuf *);
 
 
 G_END_DECLS

Modified: xfbib/branches/gobject/src/xfbib-string.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-string.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-string.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -64,6 +64,18 @@
 	G_OBJECT_CLASS(xfbib_string_parent_class)->finalize(obj);
 }
 
+XfbibString *
+xfbib_string_new()
+{
+	XfbibString *string;
+	string = g_object_new(XFBIB_TYPE_STRING, NULL);
+
+	string->variable = xfbib_strbuf_new();
+	string->value = xfbib_value_new();
+
+	return string;
+}
+	
 const gchar *
 xfbib_string_get_variable(XfbibString *string)
 {
@@ -77,39 +89,13 @@
 	xfbib_strbuf_append(string->variable, variable);
 }
 
-const gchar *
-xfbib_string_get_value(XfbibString *string)
-{
-	return xfbib_value_get_str(string->value);
-}
-
 gboolean
 xfbib_string_parse(XfbibString *string, const gchar *str)
 {
-	gint i;
 	gchar **split = NULL, *tmp;
 	
 	split = g_strsplit(str, "=", 2);
 
-	for (i = 0; split[i] != NULL; i++) {
-		g_strstrip(split[i]);
-		if (strncasecmp(split[i], "@string", 7) == 0) {
-			/* Variable */
-			xfbib_strbuf_wipe(string->variable);
-			g_strstrip(split[i] + 7);
-			xfbib_strbuf_append(string->variable, split[i] + 8);
-		} else {
-			/* Value */
-			tmp = g_strndup(split[i], strlen(split[i]) - 1);
-			if (!xfbib_value_parse(string->value, tmp)) {
-				free(tmp);
-				g_strfreev(split);
-				return FALSE;
-			}
-			free(tmp);
-		}
-	}
-
 	if (split[1] == NULL) {
 		/* Equal sign missing */
 		g_warning("No equal sign found in definition of String\n");
@@ -117,18 +103,20 @@
 		return FALSE;
 	}
 
-	g_strfreev(split);
-	return TRUE;
-}
+	/* Variable */
+	xfbib_strbuf_wipe(string->variable);
+	g_strstrip(split[0] + 7);
+	xfbib_strbuf_append(string->variable, split[0] + 8);
 
-XfbibString *
-xfbib_string_new()
-{
-	XfbibString *string;
-	string = g_object_new(XFBIB_TYPE_STRING, NULL);
+	/* Value */
+	tmp = g_strndup(split[1], strlen(split[1]) - 1);
+	if (!xfbib_value_parse(string->value, tmp)) {
+		free(tmp);
+		g_strfreev(split);
+		return FALSE;
+	}
+	free(tmp);
 
-	string->variable = xfbib_strbuf_new();
-	string->value = xfbib_value_new();
-
-	return string;
+	g_strfreev(split);
+	return TRUE;	
 }

Modified: xfbib/branches/gobject/src/xfbib-string.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-string.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-string.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -35,11 +35,10 @@
 
 GType xfbib_string_get_type() G_GNUC_CONST;
 
+XfbibString *xfbib_string_new();
 const gchar *xfbib_string_get_variable(XfbibString *);
 void xfbib_string_set_variable(XfbibString *, const gchar *);
-const gchar *xfbib_string_get_value(XfbibString *);
 gboolean xfbib_string_parse(XfbibString *, const gchar *);
-XfbibString *xfbib_string_new();
 
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-tree-view.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-tree-view.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-tree-view.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -26,6 +26,38 @@
 #include "xfbib-elements.h"
 #include "xfbib-entry.h"
 
+static struct {
+	gchar *label;
+	gchar *tooltip;
+}xfbib_field_constants[] = {
+	{"Address", "Address of publisher"},
+	{"Annote", "Annotation for annotated bibliography styles"}, 
+	{"Author", "Name(s) of the author(s), separated by 'and' if more than one"}, 
+	{"Booktitle", "Title of the book, if only part of it is being cited"}, 
+	{"Chapter", "Chapter number"}, 
+	{"Crossref", "Citation key of the cross-referenced entry"}, 
+	{"Edition", "Edition of the book (such as \"first\" or \"second\")"}, 
+	{"Editor", "Name(s) of the editor(s), separated by 'and' if more than one"}, 
+	{"E-print", "Specification of electronic publication"}, 
+	{"HowPublished", "Publishing method if the method is nonstandard"}, 
+	{"Institution", "Institution that was involved in the publishing"}, 
+	{"Journal", "Journal or magazine in which the work was published"}, 
+	{"Key", "Hidden field used for specifying or overriding the alphabetical order of entries"}, 
+	{"Month", "Month of publication or creation if unpublished"}, 
+	{"Note", "Miscellaneous extra information"}, 
+	{"Number", "Number of journal, magazine, or tech-report"}, 
+	{"Organization", "Sponsor of the conference"}, 
+	{"Pages", "Page numbers separated by commas or double-hyphens"}, 
+	{"Publisher", "Name of publisher"}, 
+	{"School", "School where thesis was written"}, 
+	{"Series", "Series of books in which the book was published"}, 
+	{"Title", "Title of the work"}, 
+	{"Type", "Type of technical report"}, 
+	{"URL", "Internet address"}, 
+	{"Volume", "Number of the volume"}, 
+	{"Year", "Year of publication or creation if unpublished"}
+};
+
 struct _XfbibTreeView
 {
 	GtkTreeView parent;
@@ -81,7 +113,6 @@
 {
 	GtkTreeViewColumn   *column;
 	GtkCellRenderer     *renderer;
-	GtkTreeModel        *model;
 	gint i;
 	gchar *str;
 	XfbibEntry *entry;
@@ -115,7 +146,7 @@
 		}
 		column = gtk_tree_view_column_new();
 
-		gtk_tree_view_column_set_title(column, xfbib_field_get_column_name(i));
+		gtk_tree_view_column_set_title(column, xfbib_field_constants[i].label);
 
 		/* pack tree view column into tree view */
 		gtk_tree_view_append_column(GTK_TREE_VIEW(instance), column);
@@ -134,6 +165,7 @@
 
 
 	/* TODO: REMOVE THIS */
+	/*
 	instance->elements = xfbib_elements_new();
 
 	entry = xfbib_entry_new();
@@ -162,16 +194,8 @@
 	xfbib_entry_add_field(entry, "publisher", "Culinary Expert Series");
 	xfbib_entry_add_field(entry, "year", "2003");
 	xfbib_elements_add(instance->elements, G_OBJECT(entry));
-
+*/
 	/* **** */
-
-
-
-	model = GTK_TREE_MODEL(xfbib_list_store_new(instance->elements));
-
-	gtk_tree_view_set_model(GTK_TREE_VIEW(instance), model);
-
-	g_object_unref(model); /* destroy model automatically with view */
 }
 
 static void
@@ -181,10 +205,17 @@
 }
 
 GtkWidget *
-xfbib_tree_view_new()
+xfbib_tree_view_new(XfbibElements *elements)
 {
+	GtkTreeModel *model;
 	XfbibTreeView *tree_view;
 	tree_view = g_object_new(XFBIB_TYPE_TREE_VIEW, NULL);
+	tree_view->elements = elements;
+
+	model = GTK_TREE_MODEL(xfbib_list_store_new(elements));
+	gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), model);
+	g_object_unref(model); /* destroy model automatically with view */
+
 	return GTK_WIDGET(tree_view);
 }
 

Modified: xfbib/branches/gobject/src/xfbib-tree-view.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-tree-view.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-tree-view.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -21,6 +21,7 @@
 #define __XFBIB_TREE_VIEW_H
 
 #include <gtk/gtk.h>
+#include "xfbib-elements.h"
 
 #define XFBIB_TYPE_TREE_VIEW             (xfbib_tree_view_get_type())
 #define XFBIB_TREE_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_TREE_VIEW, XfbibTreeView))
@@ -35,7 +36,7 @@
 
 GType xfbib_tree_view_get_type() G_GNUC_CONST;
 
-GtkWidget *xfbib_tree_view_new();
+GtkWidget *xfbib_tree_view_new(XfbibElements *);
 
 G_END_DECLS
 

Modified: xfbib/branches/gobject/src/xfbib-value.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-value.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-value.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -155,32 +155,5 @@
 const gchar *
 xfbib_value_get_str(XfbibValue *value)
 {
-	XfbibStrbuf *buf;
-	int i, len;
-	GObject *obj;
-	
-	if ((obj = g_list_nth_data(value->list, 0)) == NULL)
-		return "";
-
-	buf = xfbib_strbuf_new();
-	if (XFBIB_IS_STRBUF(obj))
-		xfbib_strbuf_append(buf, xfbib_strbuf_get_str(XFBIB_STRBUF(obj)));
-	else if (XFBIB_IS_STRING(obj))
-		xfbib_strbuf_append(buf, xfbib_string_get_variable(XFBIB_STRING(obj)));
-	else if (XFBIB_IS_INTEGER(obj))
-		xfbib_strbuf_append(buf, xfbib_integer_get(XFBIB_INTEGER(obj)));
-
-	len = g_list_length(value->list);
-	for (i = 1; i < len; i++) {
-		xfbib_strbuf_append(buf, " # ");
-		
-		obj = g_list_nth_data(value->list, i);
-		if (XFBIB_IS_STRBUF(obj))
-			xfbib_strbuf_append(buf, xfbib_strbuf_get_str(XFBIB_STRBUF(obj)));
-		else if (XFBIB_IS_STRING(obj))
-			xfbib_strbuf_append(buf, xfbib_string_get_variable(XFBIB_STRING(obj)));
-		else if (XFBIB_IS_INTEGER(obj))
-			xfbib_strbuf_append(buf, xfbib_integer_get(XFBIB_INTEGER(obj)));
-	}
-	return xfbib_strbuf_get_str(buf);
+	return "Value";
 }

Modified: xfbib/branches/gobject/src/xfbib-value.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-value.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-value.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -17,9 +17,9 @@
 GType xfbib_value_get_type() G_GNUC_CONST;
 
 XfbibValue *xfbib_value_new();
-
 gboolean xfbib_value_parse(XfbibValue *, const gchar *);
 const gchar *xfbib_value_get_str(XfbibValue *);
+
 G_END_DECLS
 
 #endif //__XFBIB_VALUE_H

Modified: xfbib/branches/gobject/src/xfbib-window.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-window.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-window.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -36,6 +36,7 @@
 	GtkWidget *toolbar;
 	GtkWidget *tree_view;
 	GtkWidget *status_bar;
+	XfbibElements *elements;
 };
 	
 typedef struct _XfbibWindowClass
@@ -85,6 +86,8 @@
 static void
 xfbib_window_init(XfbibWindow *instance)
 {
+	instance->elements = xfbib_elements_new();
+
 	instance->vbox = gtk_vbox_new(FALSE, 0);
 	gtk_container_add(GTK_CONTAINER(instance), instance->vbox);
 	
@@ -94,7 +97,7 @@
 	instance->toolbar = xfbib_toolbar_new();
 	gtk_box_pack_start(GTK_BOX(instance->vbox), instance->toolbar, FALSE, FALSE, 0);
 	
-	instance->tree_view = xfbib_tree_view_new();
+	instance->tree_view = xfbib_tree_view_new(instance->elements);
 	gtk_box_pack_start(GTK_BOX(instance->vbox), instance->tree_view, TRUE , TRUE, 0);
 
 	instance->status_bar = xfbib_statusbar_new();
@@ -117,3 +120,7 @@
 	return GTK_WIDGET(window);
 }
 
+Xfbib_window_get_elements(XfbibWindow *window)
+{
+	return window->elements;
+}

Modified: xfbib/branches/gobject/src/xfbib-window.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-window.h	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/src/xfbib-window.h	2008-09-10 08:42:26 UTC (rev 5378)
@@ -21,7 +21,6 @@
 #define __XFBIB_WINDOW_H
 
 #include <gtk/gtk.h>
-#include "xfbib-elements.h"
 
 #define XFBIB_TYPE_WINDOW             (xfbib_window_get_type())
 #define XFBIB_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_WINDOW, XfbibWindow))

Modified: xfbib/branches/gobject/tests/Makefile.am
===================================================================
--- xfbib/branches/gobject/tests/Makefile.am	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/tests/Makefile.am	2008-09-10 08:42:26 UTC (rev 5378)
@@ -30,6 +30,9 @@
 
 test_xfbib_elements_DEPENDENCIES = \
 	$(top_builddir)/src/xfbib-xfbib-elements.o \
+	$(top_builddir)/src/xfbib-xfbib-integer.o \
+	$(top_builddir)/src/xfbib-xfbib-string.o \
+	$(top_builddir)/src/xfbib-xfbib-value.o \
 	$(top_builddir)/src/xfbib-xfbib-entry.o \
 	$(top_builddir)/src/xfbib-xfbib-field.o \
 	$(top_builddir)/src/xfbib-xfbib-strbuf.o
@@ -58,6 +61,9 @@
 	test-xfbib-entry.c
 
 test_xfbib_entry_DEPENDENCIES = \
+	$(top_builddir)/src/xfbib-xfbib-integer.o \
+	$(top_builddir)/src/xfbib-xfbib-string.o \
+	$(top_builddir)/src/xfbib-xfbib-value.o \
 	$(top_builddir)/src/xfbib-xfbib-entry.o \
 	$(top_builddir)/src/xfbib-xfbib-field.o \
 	$(top_builddir)/src/xfbib-xfbib-strbuf.o
@@ -73,6 +79,9 @@
 	test-xfbib-field.c
 
 test_xfbib_field_DEPENDENCIES = \
+	$(top_builddir)/src/xfbib-xfbib-integer.o \
+	$(top_builddir)/src/xfbib-xfbib-string.o \
+	$(top_builddir)/src/xfbib-xfbib-value.o \
 	$(top_builddir)/src/xfbib-xfbib-field.o \
 	$(top_builddir)/src/xfbib-xfbib-strbuf.o
 

Modified: xfbib/branches/gobject/tests/test-xfbib-elements.c
===================================================================
--- xfbib/branches/gobject/tests/test-xfbib-elements.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/tests/test-xfbib-elements.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -1,85 +1,103 @@
-/* 
- * Copyright (c) 2008 Jesper Karlsson & David Gustafsson
- * All rights reserved.
- *
- * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
 #include <stdlib.h>
 #include <gtk/gtk.h>
 
 #include "xfbib-elements.h"
+#include "xfbib-preamble.h"
+#include "xfbib-comment.h"
+#include "xfbib-string.h"
 #include "xfbib-entry.h"
+#include "xfbib-strbuf.h"
 
 int main(int argc, char **argv)
 {
 	XfbibElements *elements;
-	XfbibEntry *entry;
-//	XfbibComment *comment;
 	GList *list;
-	GObject *object;
+	GObject *obj;
 
 	gtk_init(&argc, &argv);
 	
 	elements = xfbib_elements_new();
 
-	entry = xfbib_entry_new();
-	xfbib_entry_set_bibtype(entry, "@misc");
-	xfbib_entry_set_key(entry, "patashnik-bibtexing");
-	xfbib_entry_add_field(entry, "author", "Oren Patashnik");
-	xfbib_entry_add_field(entry, "title", "BIBTEXing");
-	xfbib_entry_add_field(entry, "year", "1988");
-	xfbib_elements_add(elements, G_OBJECT(entry));
+	g_assert(xfbib_elements_parse(elements, "@preamble {\"This bibliography was generated on \today\"}\n"
+				"@preamble (\"This bibliography was generated on \\today\")\n"
+				"@String {maintainer = \"Xavier D\\'ecoret\"}\n"
+				"@preamble { \"Maintained by \" # maintainer }\n"
+				"@ARTICLE{Bailey,\n"
+				"   author = \"D. H. Bailey and P. N. Swarztrauber\",\n"
+				"   title = \"The fractional {F}ourier transform and applications\",\n"
+				"   journal = \"SIAM Rev.\",\n"
+				"   volume = 33,\n"
+				"   number = 3,\n"
+				"   pages = \"389--404\",\n"
+				"   year = 1991\n"
+				"   }\n"
+				"\n"
+				"@ARTICLE{Bay1,\n"
+				"   author = \"A. Bayliss and C. I. Goldstein and E. Turkel\",\n"
+				"   title = \"An iterative method for the {H}elmholtz equation\",\n"
+				"   journal = \"J. Comp. Phys.\",\n"
+				"   volume = 49,\n"
+				"   pages = \"443--457\",\n"
+				"   year = 1983\n"
+				"   }\n"
+				"@TECHREPORT{Ernst,\n"
+				"   author = \"O. Ernst and G. Golub\",\n"
+				"   title = \"A domain decomposition approach to solving the {H}elmholtz\n"
+				"		equation with a radiation boundary condition\",\n"
+				"   number = \"NA-92-08\",\n"
+				"   school = \"Stanford University, Computer Science Department\",\n"
+				"   year = \"August 1992\"\n"
+				"   }\n"
+				"@TECHREPORT{Fujitsu,\n"
+				"   organization = \"Fujitsu\",\n"
+				"   title = \"FACOM OS IV SSL II USER'S GUIDE, 99SP0050E5\",\n"
+				"   year = 1990\n"
+				"   }\n"
+				"@ARTICLE{Gold3,\n"
+				"   author = \"C. I. Goldstein\",\n"
+				"   title = \"Multigrid methods for elliptic problems in unbounded domains\",\n"
+				"   journal = \"SIAM J. Numer. Anal.\",\n"
+				"   volume = 30,\n"
+				"   pages = \"159--183\",\n"
+				"   year = 1993\n"
+				"   }\n"
+				"@BOOK{Hale,\n"
+				"   author = \"J. K. Hale\",\n"
+				"   title = \"Theory of functional--differential equations\",\n"
+				"   publisher = \"Springer--Verlag, Berlin--Heidelberg--New York\",\n"
+				"   year = 1977\n"
+				"   }\n"
+				"@INBOOK{Swa82,\n"
+				"   author = \"P. N. Swarztrauber\",\n"
+				"   title = \"Vectorizing the {FFTs}\",\n"
+				"   editor = \"G.~Rodrigue\",\n"
+				"   booktitle = \"Parallel Computations\",\n"
+				"   publisher = \"Academic Press, New York\",\n"
+				"   year = 1982\n"
+				"   }\n"
+				"@PHDTHESIS{Ta,\n"
+				"   author = \"S. Ta'asan\",\n"
+				"   title = \"Multigrid Methods for Highly Oscillatory Problems\",\n"
+				"   school = \"Weizmann Institute of Science, Rehovot, Israel\",\n"
+				"   year = \"1984\"\n"
+				"   }\n"));
 
-	entry = xfbib_entry_new();
-	xfbib_entry_set_bibtype(entry, "@Article");
-	xfbib_entry_set_key(entry, "py03");
-	xfbib_entry_add_field(entry, "author", "Xavier Decoret");
-	xfbib_entry_add_field(entry, "title", "PyBiTex");
-	xfbib_entry_add_field(entry, "year", "2003");
-	xfbib_elements_add(elements, G_OBJECT(entry));
-	
-
-	entry = xfbib_entry_new();
-	xfbib_entry_set_bibtype(entry, "@Book");
-	xfbib_entry_set_key(entry, "steward03");
-	xfbib_entry_add_field(entry, "author", "Martha Steward");
-	xfbib_entry_add_field(entry, "title", "Cooking behind bars");
-	xfbib_entry_add_field(entry, "publisher", "Culinary Expert Series");
-	xfbib_entry_add_field(entry, "year", "2003");
-	xfbib_elements_add(elements, G_OBJECT(entry));
-	
 	list = xfbib_elements_get(elements);
-	
-	g_assert(g_list_length(list) == 3);
+	g_assert(g_list_length(list) == 13);
 
-	object = g_list_nth_data(list, 0);
-	g_assert(XFBIB_IS_ENTRY(object));
-	g_assert(strcmp(xfbib_entry_get_bibtype(XFBIB_ENTRY(object)), "@misc") == 0);
-	g_assert(strcmp(xfbib_entry_get_key(XFBIB_ENTRY(object)), "patashnik-bibtexing") == 0);
-	
-	object = g_list_nth_data(list, 1);
-	g_assert(XFBIB_IS_ENTRY(object));
-	g_assert(strcmp(xfbib_entry_get_bibtype(XFBIB_ENTRY(object)), "@Article") == 0);
-	g_assert(strcmp(xfbib_entry_get_key(XFBIB_ENTRY(object)), "py03") == 0);
-	
-	object = g_list_nth_data(list, 2);
-	g_assert(XFBIB_IS_ENTRY(object));
-	g_assert(strcmp(xfbib_entry_get_bibtype(XFBIB_ENTRY(object)), "@Book") == 0);
-	g_assert(strcmp(xfbib_entry_get_key(XFBIB_ENTRY(object)), "steward03") == 0);
-	
+	g_assert(XFBIB_IS_PREAMBLE(g_list_nth_data(list, 0)));
+	g_assert(XFBIB_IS_PREAMBLE(g_list_nth_data(list, 1)));
+	g_assert(XFBIB_IS_STRING(g_list_nth_data(list, 2)));
+	g_assert(XFBIB_IS_PREAMBLE(g_list_nth_data(list, 3)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 4)));
+	g_assert(XFBIB_IS_COMMENT(g_list_nth_data(list, 5)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 6)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 7)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 8)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 9)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 10)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 11)));
+	g_assert(XFBIB_IS_ENTRY(g_list_nth_data(list, 12)));
 
 	g_object_unref(elements);
 

Modified: xfbib/branches/gobject/tests/test-xfbib-field.c
===================================================================
--- xfbib/branches/gobject/tests/test-xfbib-field.c	2008-09-09 22:14:47 UTC (rev 5377)
+++ xfbib/branches/gobject/tests/test-xfbib-field.c	2008-09-10 08:42:26 UTC (rev 5378)
@@ -30,11 +30,27 @@
 	field = xfbib_field_new();
 
 	xfbib_field_set_varname(field, "Author");
-	g_assert(strcmp(xfbib_field_get_varname(field), "Author") == 0);
+	g_assert(strcmp(xfbib_field_get_variable(field), "Author") == 0);
 	xfbib_field_set_value(field, "Foo Bar");
 	g_assert(strcmp(xfbib_field_get_value(field), "Foo Bar") == 0);
+	g_assert(strcmp(xfbib_field_get_str(field), "Author = \"Foo Bar\"") == 0);
 
+	xfbib_field_parse(field, "  author =	 { Martha Steward }\n");
+	g_assert(strcmp(xfbib_field_get_variable(field), "author") == 0);
+	g_assert(strcmp(xfbib_field_get_value(field), "Martha Steward") == 0);
+	g_assert(strcmp(xfbib_field_get_str(field), "author = {Martha Steward}") == 0);
+	
+	xfbib_field_parse(field, "  title =	 \"Cooking behind bars\"\n");
+	g_assert(strcmp(xfbib_field_get_variable(field), "title") == 0);
+	g_assert(strcmp(xfbib_field_get_value(field), "Cooking behind bars") == 0);
+	g_assert(strcmp(xfbib_field_get_str(field), "title = \"Cooking behind bars\"") == 0);
 
+
+	xfbib_field_parse(field, "  year =	 2003\n");
+	g_assert(strcmp(xfbib_field_get_variable(field), "year") == 0);
+	g_assert(strcmp(xfbib_field_get_value(field), "2003") == 0);
+	g_assert(strcmp(xfbib_field_get_str(field), "year = 2003\n") == 0);
+
 	g_object_unref(field);
 
 	return EXIT_SUCCESS;




More information about the Goodies-commits mailing list