[Goodies-commits] r6366 - xfbib/branches/gobject/src
David Gustafsson
tssj at xfce.org
Tue Dec 23 01:53:24 CET 2008
Author: tssj
Date: 2008-12-23 00:53:24 +0000 (Tue, 23 Dec 2008)
New Revision: 6366
Modified:
xfbib/branches/gobject/src/xfbib-bibtex-comment.c
xfbib/branches/gobject/src/xfbib-bibtex-comment.h
xfbib/branches/gobject/src/xfbib-bibtex-entry.c
xfbib/branches/gobject/src/xfbib-bibtex-entry.h
xfbib/branches/gobject/src/xfbib-bibtex-field.c
xfbib/branches/gobject/src/xfbib-bibtex-field.h
xfbib/branches/gobject/src/xfbib-bibtex-preamble.c
xfbib/branches/gobject/src/xfbib-bibtex-preamble.h
xfbib/branches/gobject/src/xfbib-bibtex-string.c
xfbib/branches/gobject/src/xfbib-bibtex-string.h
xfbib/branches/gobject/src/xfbib-bibtex-value.c
xfbib/branches/gobject/src/xfbib-bibtex-value.h
xfbib/branches/gobject/src/xfbib-bibtex.c
xfbib/branches/gobject/src/xfbib-bibtex.h
xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
xfbib/branches/gobject/src/xfbib-input-dialog.c
xfbib/branches/gobject/src/xfbib-menu-bar.c
xfbib/branches/gobject/src/xfbib-multiple-input.c
xfbib/branches/gobject/src/xfbib-string-tree-view.c
Log:
Changed so that bibtex values handles bibtex strings correctly and fixed a few compilation warnings.
Modified: xfbib/branches/gobject/src/xfbib-bibtex-comment.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-comment.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-comment.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -27,6 +27,7 @@
struct _XfbibBibtexComment
{
GObject parent;
+ GObject *owner;
gchar *str;
};
@@ -63,14 +64,23 @@
}
XfbibBibtexComment *
-xfbib_bibtex_comment_new(const gchar *str)
+xfbib_bibtex_comment_new(GObject *obj, const gchar *str)
{
XfbibBibtexComment *comment;
comment = g_object_new(XFBIB_TYPE_BIBTEX_COMMENT, NULL);
+ comment->owner = obj;
comment->str = g_strdup(str);
return comment;
}
+GObject *
+xfbib_bibtex_comment_get_owner(XfbibBibtexComment *comment)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_COMMENT(comment), NULL);
+ return comment->owner;
+}
+
+
gchar *
xfbib_bibtex_comment_get(XfbibBibtexComment *comment)
{
Modified: xfbib/branches/gobject/src/xfbib-bibtex-comment.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-comment.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-comment.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -35,7 +35,8 @@
GType xfbib_bibtex_comment_get_type() G_GNUC_CONST;
-XfbibBibtexComment *xfbib_bibtex_comment_new(const gchar *);
+XfbibBibtexComment *xfbib_bibtex_comment_new(GObject *, const gchar *);
+GObject *xfbib_bibtex_comment_get_owner(XfbibBibtexComment *);
gchar *xfbib_bibtex_comment_get(XfbibBibtexComment *);
G_END_DECLS
Modified: xfbib/branches/gobject/src/xfbib-bibtex-entry.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-entry.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-entry.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -30,6 +30,7 @@
struct _XfbibBibtexEntry
{
GObject parent;
+ GObject *owner;
gchar *bibtype;
gchar separator;
gchar *key;
@@ -75,13 +76,22 @@
}
XfbibBibtexEntry *
-xfbib_bibtex_entry_new()
+xfbib_bibtex_entry_new(GObject *obj)
{
XfbibBibtexEntry *entry;
entry = g_object_new(XFBIB_TYPE_BIBTEX_ENTRY, NULL);
+ entry->owner = obj;
return entry;
}
+
+GObject *
+xfbib_bibtex_entry_get_owner(XfbibBibtexEntry *entry)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_ENTRY(entry), NULL);
+ return entry->owner;
+}
+
gboolean
xfbib_bibtex_entry_parse(XfbibBibtexEntry *entry, const gchar *str)
{
@@ -121,7 +131,7 @@
for (i++, brackets = 0, quotes = 0; i < len; i++) {
if (tmp[i] == ',' && ((entry->separator == '{' && brackets == 0) ||
(entry->separator == '"' && quotes%2 == 0))) {
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
if (!xfbib_bibtex_field_parse(field, buf->str))
return FALSE;
entry->fields = g_list_append(entry->fields, field);
@@ -144,7 +154,7 @@
}
if (i < buf->len) {
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
if (!xfbib_bibtex_field_parse(field, buf->str))
return FALSE;
entry->fields = g_list_append(entry->fields, field);
Modified: xfbib/branches/gobject/src/xfbib-bibtex-entry.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-entry.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-entry.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -36,7 +36,8 @@
GType xfbib_bibtex_entry_get_type() G_GNUC_CONST;
-XfbibBibtexEntry *xfbib_bibtex_entry_new();
+XfbibBibtexEntry *xfbib_bibtex_entry_new(GObject *);
+GObject *xfbib_bibtex_entry_get_owner(XfbibBibtexEntry *);
gboolean xfbib_bibtex_entry_parse(XfbibBibtexEntry *, const gchar *);
GList *xfbib_bibtex_entry_get_fields(XfbibBibtexEntry *);
void xfbib_bibtex_entry_set_fields(XfbibBibtexEntry *, GList *);
Modified: xfbib/branches/gobject/src/xfbib-bibtex-field.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-field.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-field.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -28,6 +28,7 @@
struct _XfbibBibtexField
{
GObject parent;
+ GObject *owner;
gchar *variable;
XfbibBibtexValue *value;
};
@@ -55,7 +56,7 @@
xfbib_bibtex_field_init(XfbibBibtexField *instance)
{
instance->variable = NULL;
- instance->value = xfbib_bibtex_value_new();
+ instance->value = xfbib_bibtex_value_new(G_OBJECT(instance));
}
static void
@@ -66,13 +67,22 @@
}
XfbibBibtexField *
-xfbib_bibtex_field_new()
+xfbib_bibtex_field_new(GObject *obj)
{
XfbibBibtexField *field;
field = g_object_new(XFBIB_TYPE_BIBTEX_FIELD, NULL);
+ field->owner = obj;
return field;
}
+
+GObject *
+xfbib_bibtex_field_get_owner(XfbibBibtexField *field)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_FIELD(field), NULL);
+ return field->owner;
+}
+
gboolean
xfbib_bibtex_field_parse(XfbibBibtexField *field, const gchar *str)
{
Modified: xfbib/branches/gobject/src/xfbib-bibtex-field.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-field.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-field.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -98,7 +98,8 @@
GType xfbib_field_get_type() G_GNUC_CONST;
-XfbibBibtexField *xfbib_bibtex_field_new();
+XfbibBibtexField *xfbib_bibtex_field_new(GObject *);
+GObject *xfbib_bibtex_field_get_owner(XfbibBibtexField *);
gboolean xfbib_bibtex_field_parse(XfbibBibtexField *, const gchar *);
const gchar *xfbib_bibtex_field_get_variable(XfbibBibtexField *);
void xfbib_bibtex_field_set_variable(XfbibBibtexField *, const gchar *);
Modified: xfbib/branches/gobject/src/xfbib-bibtex-preamble.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-preamble.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-preamble.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -29,6 +29,7 @@
struct _XfbibBibtexPreamble
{
GObject parent;
+ GObject *owner;
gchar separator;
XfbibBibtexValue *value;
};
@@ -55,7 +56,7 @@
static void
xfbib_bibtex_preamble_init(XfbibBibtexPreamble *instance)
{
- instance->value = xfbib_bibtex_value_new();
+ instance->value = xfbib_bibtex_value_new(G_OBJECT(instance));
}
static void
@@ -65,13 +66,22 @@
}
XfbibBibtexPreamble *
-xfbib_bibtex_preamble_new()
+xfbib_bibtex_preamble_new(GObject *obj)
{
XfbibBibtexPreamble *preamble;
preamble = g_object_new(XFBIB_TYPE_BIBTEX_PREAMBLE, NULL);
+ preamble->owner = obj;
return preamble;
}
+
+GObject *
+xfbib_bibtex_preamble_get_owner(XfbibBibtexPreamble *preamble)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_PREAMBLE(preamble), NULL);
+ return preamble->owner;
+}
+
gboolean
xfbib_bibtex_preamble_parse(XfbibBibtexPreamble *preamble, const gchar *s)
{
Modified: xfbib/branches/gobject/src/xfbib-bibtex-preamble.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-preamble.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-preamble.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -36,7 +36,8 @@
GType xfbib_bibtex_preamble_get_type() G_GNUC_CONST;
-XfbibBibtexPreamble *xfbib_bibtex_preamble_new();
+XfbibBibtexPreamble *xfbib_bibtex_preamble_new(GObject *);
+GObject *xfbib_bibtex_preamble_get_owner(XfbibBibtexPreamble *);
gboolean xfbib_bibtex_preamble_parse(XfbibBibtexPreamble *, const gchar *);
gchar xfbib_bibtex_preamble_get_separator(XfbibBibtexPreamble *);
XfbibBibtexValue *xfbib_bibtex_preamble_get_value(XfbibBibtexPreamble *);
Modified: xfbib/branches/gobject/src/xfbib-bibtex-string.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-string.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-string.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -29,6 +29,7 @@
struct _XfbibBibtexString
{
GObject parent;
+ GObject *owner;
gchar separator;
gchar *variable;
XfbibBibtexValue *value;
@@ -58,7 +59,7 @@
{
instance->separator = '\0';
instance->variable = NULL;
- instance->value = xfbib_bibtex_value_new();
+ instance->value = xfbib_bibtex_value_new(G_OBJECT(instance));
}
static void
@@ -68,13 +69,22 @@
}
XfbibBibtexString *
-xfbib_bibtex_string_new()
+xfbib_bibtex_string_new(GObject *obj)
{
XfbibBibtexString *string;
string = g_object_new(XFBIB_TYPE_BIBTEX_STRING, NULL);
+ string->owner = obj;
return string;
}
+
+GObject *
+xfbib_bibtex_string_get_owner(XfbibBibtexString *string)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(string), NULL);
+ return string->owner;
+}
+
const gchar *
xfbib_bibtex_string_get_variable(XfbibBibtexString *string)
{
Modified: xfbib/branches/gobject/src/xfbib-bibtex-string.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-string.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-string.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -42,7 +42,8 @@
GType xfbib_bibtex_string_get_type() G_GNUC_CONST;
-XfbibBibtexString *xfbib_bibtex_string_new();
+XfbibBibtexString *xfbib_bibtex_string_new(GObject *);
+GObject *xfbib_bibtex_string_get_owner(XfbibBibtexString *);
const gchar *xfbib_bibtex_string_get_variable(XfbibBibtexString *);
void xfbib_bibtex_string_set_variable(XfbibBibtexString *, const gchar *);
XfbibBibtexValue *xfbib_bibtex_string_get_value(XfbibBibtexString *);
Modified: xfbib/branches/gobject/src/xfbib-bibtex-value.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-value.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-value.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -6,13 +6,17 @@
#include "xfbib-bibtex-value.h"
#include "xfbib-bibtex-string.h"
+#include "xfbib-bibtex-preamble.h"
+#include "xfbib-bibtex.h"
#include "xfbib-string.h"
#include "xfbib-integer.h"
+static gint bibtex_string_cmp(gconstpointer, gconstpointer);
struct _XfbibBibtexValue
{
GObject parent;
+ GObject *owner;
GList *list;
};
@@ -55,21 +59,38 @@
}
XfbibBibtexValue *
-xfbib_bibtex_value_new()
+xfbib_bibtex_value_new(GObject *obj)
{
XfbibBibtexValue *value;
value = g_object_new(XFBIB_TYPE_BIBTEX_VALUE, NULL);
-
+ value->owner = obj;
return value;
}
+GObject *
+xfbib_bibtex_value_get_owner(XfbibBibtexValue *value)
+{
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
+ return value->owner;
+}
+
gboolean
xfbib_bibtex_value_parse(XfbibBibtexValue *value, const gchar *str)
{
gint i, j, len, braces;
gchar **split = NULL;
GObject *obj;
+ XfbibBibtex *elements;
+ if (XFBIB_IS_BIBTEX_STRING(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_string_get_owner(XFBIB_BIBTEX_STRING(value->owner)));
+ } else if (XFBIB_IS_BIBTEX_FIELD(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_entry_get_owner(
+ XFBIB_BIBTEX_ENTRY(xfbib_bibtex_field_get_owner(XFBIB_BIBTEX_FIELD(value->owner)))));
+ } else if (XFBIB_IS_BIBTEX_PREAMBLE(value->owner)) {
+ elements = XFBIB_BIBTEX(xfbib_bibtex_preamble_get_owner(XFBIB_BIBTEX_PREAMBLE(value->owner)));
+ }
+
/* TODO: Free all elements of the list */
value->list = NULL;
@@ -121,19 +142,17 @@
return FALSE;
}
- obj = G_OBJECT(xfbib_string_new());
+ obj = G_OBJECT(xfbib_string_new(G_OBJECT(value)));
xfbib_string_parse(XFBIB_STRING(obj), split[i]);
value->list = g_list_prepend(value->list, obj);
} else if(g_ascii_isalpha(split[i][0])) {
/* Variable */
-
if (strstr(split[i], "\"") != NULL) {
g_warning("Variable contains double quote\n");
return FALSE;
}
- obj = G_OBJECT(xfbib_bibtex_string_new());
- xfbib_bibtex_string_set_variable(XFBIB_BIBTEX_STRING(obj), split[i]);
+ obj = xfbib_bibtex_find(elements, bibtex_string_cmp, split[i]);
value->list = g_list_prepend(value->list, obj);
} else {
len = strlen(split[i]);
@@ -145,7 +164,7 @@
}
}
/* Integer */
- obj = G_OBJECT(xfbib_integer_new());
+ obj = G_OBJECT(xfbib_integer_new(G_OBJECT(value)));
xfbib_integer_set(XFBIB_INTEGER(obj), split[i]);
value->list = g_list_prepend(value->list, obj);
}
@@ -179,26 +198,36 @@
value->list = list;
}
+/*
+ * Returned string must be freed
+ */
gchar *
xfbib_bibtex_value_get_str(XfbibBibtexValue *value)
{
- GObject *obj;
+ XfbibBibtexValue *val;
+ GString *str;
+ GList *list;
+ gchar *tmp;
g_return_val_if_fail(XFBIB_IS_BIBTEX_VALUE(value), NULL);
- if (g_list_length(value->list) == 1) {
- obj = g_list_nth_data(value->list, 0);
- if (XFBIB_IS_STRING(obj)) {
+ str = g_string_new(NULL);
+
+ for (list = value->list; list != NULL; list = g_list_next(list)) {
+ if (XFBIB_IS_STRING(list->data)) {
/* regular string */
- return xfbib_string_get(XFBIB_STRING(obj));
- } else if (XFBIB_IS_INTEGER(obj)) {
+ g_string_append(str, xfbib_string_get(XFBIB_STRING(list->data)));
+ } else if (XFBIB_IS_INTEGER(list->data)) {
/* integer value */
- return xfbib_integer_get(XFBIB_INTEGER(obj));
- } else if (XFBIB_IS_BIBTEX_STRING(obj)) {
+ g_string_append(str, xfbib_integer_get(XFBIB_INTEGER(list->data)));
+ } else if (XFBIB_IS_BIBTEX_STRING(list->data)) {
/* variable */
- return "todo: variable";
+ val = xfbib_bibtex_string_get_value(XFBIB_BIBTEX_STRING(list->data));
+ tmp = xfbib_bibtex_value_get_str(val);
+ g_string_append(str, tmp);
+ g_free(tmp);
}
}
- return NULL;
+ return g_string_free(str, FALSE);
}
/*
@@ -215,8 +244,19 @@
g_list_free (value->list);
value->list = NULL;
- string = xfbib_string_new();
+ string = xfbib_string_new(G_OBJECT(value));
xfbib_string_set(string, str);
value->list = g_list_append(value->list, G_OBJECT(string));
}
+static gint
+bibtex_string_cmp(gconstpointer a, gconstpointer b)
+{
+ gchar *aa = a;
+ XfbibBibtexString *bb = b;
+ g_return_val_if_fail(a != NULL, -1);
+ g_return_val_if_fail(XFBIB_IS_BIBTEX_STRING(b), 1);
+
+ return strcmp(aa, xfbib_bibtex_string_get_variable(bb));
+}
+
Modified: xfbib/branches/gobject/src/xfbib-bibtex-value.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex-value.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex-value.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -16,7 +16,8 @@
GType xfbib_bibtex_value_get_type() G_GNUC_CONST;
-XfbibBibtexValue *xfbib_bibtex_value_new();
+XfbibBibtexValue *xfbib_bibtex_value_new(GObject *);
+GObject *xfbib_bibtex_value_get_owner(XfbibBibtexValue *);
gboolean xfbib_bibtex_value_parse(XfbibBibtexValue *, const gchar *);
GList *xfbib_bibtex_value_get(XfbibBibtexValue *);
void xfbib_bibtex_value_set(XfbibBibtexValue *, GList *);
Modified: xfbib/branches/gobject/src/xfbib-bibtex.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -145,7 +145,7 @@
if (str[i] == '@') {
if (buf->len > 0) {
/* The comment ended put it in the list */
- obj = G_OBJECT(xfbib_bibtex_comment_new(buf->str));
+ obj = G_OBJECT(xfbib_bibtex_comment_new(G_OBJECT(elements), buf->str));
#if G_SEQUENCE
g_sequence_append(elements->seq, obj);
#else
@@ -161,7 +161,7 @@
/* Dont forget the newline character */
buf = g_string_append_c(buf, str[i]);
- obj = G_OBJECT(xfbib_bibtex_comment_new(buf->str));
+ obj = G_OBJECT(xfbib_bibtex_comment_new(G_OBJECT(elements), buf->str));
#if G_SEQUENCE
g_sequence_append(elements->seq, obj);
#else
@@ -171,7 +171,7 @@
} else if (g_ascii_strncasecmp(&str[i], "@preamble", 9) == 0) {
/* Preamble */
if (parse_balanced_brackets(buf, str, &i)) {
- obj = G_OBJECT(xfbib_bibtex_preamble_new());
+ obj = G_OBJECT(xfbib_bibtex_preamble_new(G_OBJECT(elements)));
if (xfbib_bibtex_preamble_parse(XFBIB_BIBTEX_PREAMBLE(obj), buf->str)) {
#if G_SEQUENCE
g_sequence_append(elements->seq, obj);
@@ -184,7 +184,7 @@
} else if (g_ascii_strncasecmp(&str[i], "@string", 7) == 0) {
/* String */
if (parse_balanced_brackets(buf, str, &i)) {
- obj = G_OBJECT(xfbib_bibtex_string_new());
+ obj = G_OBJECT(xfbib_bibtex_string_new(G_OBJECT(elements)));
if (xfbib_bibtex_string_parse(XFBIB_BIBTEX_STRING(obj), buf->str)) {
elements->n_strings++;
#if G_SEQUENCE
@@ -198,7 +198,7 @@
} else if (g_regex_match (regex, &str[i], 0, NULL)) {
/* Entry */
if (parse_balanced_brackets(buf, str, &i)) {
- obj = G_OBJECT(xfbib_bibtex_entry_new());
+ obj = G_OBJECT(xfbib_bibtex_entry_new(G_OBJECT(elements)));
if (xfbib_bibtex_entry_parse(XFBIB_BIBTEX_ENTRY(obj), buf->str)) {
elements->n_entries++;
#if G_SEQUENCE
@@ -497,3 +497,26 @@
return -1;
}
+GObject *
+xfbib_bibtex_find(XfbibBibtex *elements, GCompareFunc func, gconstpointer ptr)
+{
+ GObject *tmp;
+ g_return_val_if_fail(XFBIB_IS_BIBTEX(elements), NULL);
+
+#if G_SEQUENCE
+ GSequenceIter *iter;
+ for (iter = g_sequence_get_begin_iter(elements->seq);
+ !g_sequence_iter_is_end(iter); iter = g_sequence_iter_next(iter)) {
+ tmp = g_sequence_get(iter);
+#else
+ gint i, len;
+ len = g_list_length(elements->list);
+ for (i = 0, n = -1; i < len; i++) {
+ tmp = g_list_nth_data(elements->list, i);
+#endif
+ if (!func(ptr, tmp)) {
+ return tmp;
+ }
+ }
+ return NULL;
+}
Modified: xfbib/branches/gobject/src/xfbib-bibtex.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-bibtex.h 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-bibtex.h 2008-12-23 00:53:24 UTC (rev 6366)
@@ -34,6 +34,7 @@
void xfbib_bibtex_remove_all(XfbibBibtex *);
void xfbib_bibtex_add(XfbibBibtex *, GObject *);
gint xfbib_bibtex_replace(XfbibBibtex *, GObject *, GObject *);
+GObject *xfbib_bibtex_find(XfbibBibtex *, GCompareFunc, gconstpointer);
G_END_DECLS
Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -29,6 +29,7 @@
#include "xfbib-multiple-input.h"
#include "xfbib-bibtex-field.h"
#include "xfbib-bibtex-entry.h"
+#include "xfbib-state.h"
static struct {
gchar *text;
@@ -421,10 +422,13 @@
XfbibBibtexField *field;
GList *field_list = NULL;
XfbibBibtexValue *value;
+ XfbibState *state;
int n;
const gchar *str;
- entry = xfbib_bibtex_entry_new();
+ state = xfbib_state_new();
+
+ entry = xfbib_bibtex_entry_new(G_OBJECT(xfbib_state_get_bibtex_elements(state))/* TODO: Elements */);
xfbib_bibtex_entry_set_key(entry, gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->key_entry)));
xfbib_bibtex_entry_set_bibtype(entry, gtk_combo_box_get_active_text(GTK_COMBO_BOX(entry_edit_dialog->type_combo_box)));
for (n = 0; n < XFBIB_BIBTEX_FIELD_N_FIELDS; n++) {
@@ -434,14 +438,14 @@
if(strcmp(str, "") == 0) {
continue;
}
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
- value = xfbib_bibtex_value_new();
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
xfbib_bibtex_value_set_str(value, str);
} else {
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
- value = xfbib_bibtex_value_new();
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
xfbib_bibtex_value_set(value, xfbib_multiple_input_get(XFBIB_MULTIPLE_INPUT(entry_edit_dialog->inputs[n].input)));
}
field_list = g_list_append(field_list, field);
@@ -452,16 +456,16 @@
continue;
}
/* TODO: check if they are integers or strings(variables), don't assume text */
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
- value = xfbib_bibtex_value_new();
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
xfbib_bibtex_value_set_str(value, gtk_entry_get_text(GTK_ENTRY(entry_edit_dialog->inputs[n].input)));
xfbib_bibtex_field_set_value(field, value);
field_list = g_list_append(field_list, field);
} else {
- field = xfbib_bibtex_field_new();
+ field = xfbib_bibtex_field_new(G_OBJECT(entry));
xfbib_bibtex_field_set_variable(field, xfbib_bibtex_field_constants[n].label);
- value = xfbib_bibtex_value_new();
+ value = xfbib_bibtex_value_new(G_OBJECT(field));
xfbib_bibtex_value_set(value, entry_edit_dialog->inputs[n].gl);
xfbib_bibtex_field_set_value(field, value);
field_list = g_list_append(field_list, field);
Modified: xfbib/branches/gobject/src/xfbib-input-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-input-dialog.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-input-dialog.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -138,7 +138,7 @@
const gchar *xfbib_input_dialog_get_string_key(XfbibInputDialog *instance)
{
- return gtk_combo_box_get_active_text(GTK_COMBO_BOX_ENTRY(instance->string_key_entry));
+ return gtk_combo_box_get_active_text(GTK_COMBO_BOX(instance->string_key_entry));
}
const gchar *xfbib_input_dialog_get_text(XfbibInputDialog *instance)
Modified: xfbib/branches/gobject/src/xfbib-menu-bar.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-menu-bar.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-menu-bar.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -252,7 +252,7 @@
/* This will only work in single or browse selection mode! */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- string = XFBIB_BIBTEX_ENTRY(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+ string = XFBIB_BIBTEX_STRING(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
#if 0
dialog = xfbib_entry_edit_dialog_new(string);
Modified: xfbib/branches/gobject/src/xfbib-multiple-input.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -29,6 +29,7 @@
#include "xfbib-bibtex-value.h"
#include "xfbib-string.h"
#include "xfbib-integer.h"
+#include "xfbib-state.h"
struct _XfbibMultipleInput
{
@@ -320,16 +321,19 @@
{
GList *list = NULL;
XfbibString *str;
+ XfbibState *state;
XfbibBibtexString *string;
XfbibBibtexValue *value;
const gchar *bibstr, *text;
gint n;
+ state = xfbib_state_new();
+
for(n = 0; (text = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 0)) != NULL; n++) {
bibstr = xfbib_multiple_input_get_nth_row_ith_column(multiple_input, n, 1);
if(bibstr != NULL) {
- string = xfbib_bibtex_string_new();
- value = xfbib_bibtex_value_new();
+ string = xfbib_bibtex_string_new(G_OBJECT(xfbib_state_get_bibtex_elements(state)));
+ value = xfbib_bibtex_value_new(G_OBJECT(string));
xfbib_bibtex_string_set_variable(string, bibstr);
xfbib_bibtex_value_set_str(value, text);
@@ -337,7 +341,7 @@
list = g_list_append(list, G_OBJECT(string));
} else {
- str = xfbib_string_new();
+ str = xfbib_string_new(G_OBJECT(xfbib_state_get_bibtex_elements(state)));
xfbib_string_set(str, text);
list = g_list_append(list, G_OBJECT(str));
}
Modified: xfbib/branches/gobject/src/xfbib-string-tree-view.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-string-tree-view.c 2008-12-22 01:16:55 UTC (rev 6365)
+++ xfbib/branches/gobject/src/xfbib-string-tree-view.c 2008-12-23 00:53:24 UTC (rev 6366)
@@ -92,7 +92,7 @@
model = gtk_tree_view_get_model(tree_view);
if (gtk_tree_model_get_iter(model, &iter, path)) {
- string = XFBIB_BIBTEX_ENTRY(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
+ string = XFBIB_BIBTEX_STRING(xfbib_list_store_get(XFBIB_LIST_STORE(model), &iter));
#if 0
dialog = xfbib_string_edit_dialog_new(string);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
More information about the Goodies-commits
mailing list