[Goodies-commits] r5500 - xfbib/branches/gobject/src
Jesper Karlsson
zarper at xfce.org
Wed Oct 1 20:43:40 CEST 2008
Author: zarper
Date: 2008-10-01 18:43:39 +0000 (Wed, 01 Oct 2008)
New Revision: 5500
Modified:
xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
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-multiple-input.c
xfbib/branches/gobject/src/xfbib-multiple-input.h
xfbib/branches/gobject/src/xfbib-value.c
xfbib/branches/gobject/src/xfbib-value.h
Log:
Added function so that changes to an entry can be retreived from the xfbib_entry_edit_dialog object.
Modified: xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-entry-edit-dialog.c 2008-10-01 18:43:39 UTC (rev 5500)
@@ -332,3 +332,44 @@
return GTK_WIDGET(entry_edit_dialog);
}
+XfbibEntry *
+xfbib_entry_edit_dialog_get_entry(XfbibEntryEditDialog *entry_edit_dialog)
+{
+ XfbibEntry *entry;
+ XfbibField *field;
+ GList *field_list;
+ XfbibValue *value;
+ int n;
+
+ entry = xfbib_entry_new();
+ xfbib_entry_set_key(entry, gtk_entry_get_text(entry_edit_dialog->key_entry));
+ xfbib_entry_set_bibtype(entry, gtk_combo_box_get_active_text(entry_edit_dialog->type_combo_box));
+ for (n = 0; n < XFBIB_FIELD_N_FIELDS; n++) {
+ if (n == XFBIB_FIELD_AUTHOR || n == XFBIB_FIELD_EDITOR) {
+ if(xfbib_multiple_input_get_str(entry_edit_dialog->inputs[n]) == "") {
+ continue;
+ }
+ /* TODO: check if they are integers or strings(variables), don't assume text */
+ field = xfbib_field_new();
+ xfbib_field_set_variable(field, xfbib_input_constants[n].label);
+ value = xfbib_value_new();
+ xfbib_value_set_str(value, xfbib_multiple_input_get_str(entry_edit_dialog->inputs[n]));
+ xfbib_field_set_value(field, value);
+ g_list_append(field_list, field);
+ } else {
+ if(xfbib_single_input_get_entry_text(entry_edit_dialog->inputs[n]) == "") {
+ continue;
+ }
+ /* TODO: check if they are integers or strings(variables), don't assume text */
+ field = xfbib_field_new();
+ xfbib_field_set_variable(field, xfbib_input_constants[n].label);
+ value = xfbib_value_new();
+ xfbib_value_set_str(value, xfbib_single_input_get_entry_text(entry_edit_dialog->inputs[n]));
+ xfbib_field_set_value(field, value);
+ g_list_append(field_list, field);
+ }
+ }
+ xfbib_entry_set_fields(entry, field_list);
+ return entry;
+}
+
Modified: xfbib/branches/gobject/src/xfbib-entry.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry.c 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-entry.c 2008-10-01 18:43:39 UTC (rev 5500)
@@ -163,22 +163,6 @@
return NULL;
}
-/*XfbibField *
-xfbib_entry_get_field_by_label(XfbibEntry *entry, const gchar *label)
-{
- XfbibField * field;
- gint n;
- g_return_val_if_fail(XFBIB_IS_ENTRY(entry), NULL);
-
- for (n = 0; n < g_list_length(entry->fields); n++) {
- field = g_list_nth_data(entry->fields, n);
- if (strcmp(field, label) == 0)
- return field;
- }
-
- return NULL;
-}*/
-
XfbibStrbuf *
xfbib_entry_get_bibtype(XfbibEntry *entry)
{
@@ -191,3 +175,21 @@
return entry->key;
}
+void
+xfbib_entry_set_key(XfbibEntry *entry, const gchar *key)
+{
+ xfbib_strbuf_append(entry->key, key);
+}
+
+void
+xfbib_entry_set_bibtype(XfbibEntry *entry, const gchar *bibtype)
+{
+ xfbib_strbuf_append(entry->bibtype, bibtype);
+}
+
+void
+xfbib_entry_set_fields(XfbibEntry *entry, GList *fields)
+{
+ entry->fields = fields;
+}
+
Modified: xfbib/branches/gobject/src/xfbib-entry.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-entry.h 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-entry.h 2008-10-01 18:43:39 UTC (rev 5500)
@@ -40,9 +40,11 @@
XfbibEntry *xfbib_entry_new();
gboolean xfbib_entry_parse(XfbibEntry *, const gchar *);
XfbibField *xfbib_entry_get_field_by_column(XfbibEntry *, gint);
-//XfbibField *xfbib_entry_get_field_by_label(XfbibEntry *, const gchar *);
XfbibStrbuf *xfbib_entry_get_bibtype(XfbibEntry *);
XfbibStrbuf *xfbib_entry_get_key(XfbibEntry *);
+void xfbib_entry_set_key(XfbibEntry *, const gchar *);
+void xfbib_entry_set_bibtype(XfbibEntry *, const gchar *);
+void xfbib_entry_set_fields(XfbibEntry *, GList *);
G_END_DECLS
#endif //__XFBIB_ENTRY_H
Modified: xfbib/branches/gobject/src/xfbib-field.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-field.c 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-field.c 2008-10-01 18:43:39 UTC (rev 5500)
@@ -149,3 +149,19 @@
{
return xfbib_value_get_str(field->value);
}
+
+void
+xfbib_field_set_variable(XfbibField *field, const gchar *str)
+{
+ xfbib_strbuf_append(field->variable,str);
+}
+
+void
+xfbib_field_set_value(XfbibField *field, XfbibValue *value)
+{
+ if(field->value != NULL) {
+ free(field->value);
+ }
+ field->value = value;
+}
+
Modified: xfbib/branches/gobject/src/xfbib-field.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-field.h 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-field.h 2008-10-01 18:43:39 UTC (rev 5500)
@@ -21,6 +21,7 @@
#define __XFBIB_FIELD_H
#include <glib-object.h>
+#include "xfbib-value.h"
#define XFBIB_TYPE_FIELD (xfbib_field_get_type())
#define XFBIB_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), XFBIB_TYPE_FIELD, XfbibField))
@@ -69,6 +70,8 @@
gboolean xfbib_field_parse(XfbibField *, const gchar *);
gboolean xfbib_field_is_column(XfbibField *, gint);
const gchar *xfbib_field_get_value_str(XfbibField *);
+void xfbib_field_set_variable(XfbibField *, const gchar *);
+void xfbib_field_set_value(XfbibField *, XfbibValue *);
G_END_DECLS
#endif //__XFBIB_FIELD_H
Modified: xfbib/branches/gobject/src/xfbib-multiple-input.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.c 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.c 2008-10-01 18:43:39 UTC (rev 5500)
@@ -24,6 +24,7 @@
#include "xfbib-multiple-input.h"
#include "xfbib-input-dialog.h"
+#include "xfbib-strbuf.h"
struct _XfbibMultipleInput
{
@@ -251,3 +252,21 @@
return NULL;
}
+const gchar *
+xfbib_multiple_input_get_str(XfbibMultipleInput *multiple_input)
+{
+ XfbibStrbuf *strbuf;
+ gchar *str;
+ int n = 0;
+
+ strbuf = xfbib_strbuf_new();
+ while((str = xfbib_multiple_input_get_nth_row(multiple_input, n)) != NULL) {
+ if(n != 0) {
+ xfbib_strbuf_append(strbuf, " and ");
+ }
+ xfbib_strbuf_append(strbuf, str);
+ n++;
+ }
+ return xfbib_strbuf_get_str(strbuf);
+}
+
Modified: xfbib/branches/gobject/src/xfbib-multiple-input.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-multiple-input.h 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-multiple-input.h 2008-10-01 18:43:39 UTC (rev 5500)
@@ -38,6 +38,7 @@
GtkWidget *xfbib_multiple_input_new(gchar *, gchar *);
void xfbib_multiple_input_set_text(XfbibMultipleInput *, const gchar *);
const gchar *xfbib_multiple_input_get_nth_row(XfbibMultipleInput *, gint);
+const gchar *xfbib_multiple_input_get_str(XfbibMultipleInput *);
G_END_DECLS
Modified: xfbib/branches/gobject/src/xfbib-value.c
===================================================================
--- xfbib/branches/gobject/src/xfbib-value.c 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-value.c 2008-10-01 18:43:39 UTC (rev 5500)
@@ -172,3 +172,34 @@
return "Compund string";
}
}
+
+void
+xfbib_value_set_str(XfbibValue *value, const gchar *str)
+{
+ GList *list;
+
+ g_list_append(list, G_OBJECT(str));
+ if(value->list != NULL) {
+ /* TODO: Free the list */
+ }
+ value->list = list;
+}
+
+void
+xfbib_value_set_int(XfbibValue *value)
+{
+ /* TODO */
+}
+
+void
+xfbib_value_set_string(XfbibValue *value)
+{
+ /* TODO */
+}
+
+void
+xfbib_value_set_comstr(XfbibValue *value)
+{
+ /* TODO */
+}
+
Modified: xfbib/branches/gobject/src/xfbib-value.h
===================================================================
--- xfbib/branches/gobject/src/xfbib-value.h 2008-10-01 18:22:01 UTC (rev 5499)
+++ xfbib/branches/gobject/src/xfbib-value.h 2008-10-01 18:43:39 UTC (rev 5500)
@@ -19,6 +19,7 @@
XfbibValue *xfbib_value_new();
gboolean xfbib_value_parse(XfbibValue *, const gchar *);
const gchar *xfbib_value_get_str(XfbibValue *);
+void xfbib_value_set_str(XfbibValue *, const gchar *);
G_END_DECLS
More information about the Goodies-commits
mailing list