]> git.sur5r.net Git - glabels/commitdiff
New document merge API.
authorJim Evins <evins@snaught.com>
Tue, 3 Dec 2002 02:53:54 +0000 (02:53 +0000)
committerJim Evins <evins@snaught.com>
Tue, 3 Dec 2002 02:53:54 +0000 (02:53 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@198 f5e0f49d-192f-0410-a22d-a8d8700d0965

30 files changed:
glabels2/po/POTFILES.in
glabels2/src/Makefile.am
glabels2/src/glabels-batch.c
glabels2/src/glabels.c
glabels2/src/label.c
glabels2/src/merge-init.c [new file with mode: 0644]
glabels2/src/merge-init.h [new file with mode: 0644]
glabels2/src/merge-properties-dialog.c [new file with mode: 0644]
glabels2/src/merge-properties-dialog.h [new file with mode: 0644]
glabels2/src/merge-properties.c [deleted file]
glabels2/src/merge-properties.h [deleted file]
glabels2/src/merge-text.c
glabels2/src/merge-text.h
glabels2/src/merge-ui-text.c [deleted file]
glabels2/src/merge-ui-text.h [deleted file]
glabels2/src/merge-ui.c [deleted file]
glabels2/src/merge-ui.h [deleted file]
glabels2/src/merge.c
glabels2/src/merge.h
glabels2/src/print-dialog.c
glabels2/src/print.c
glabels2/src/tools.c
glabels2/src/view-barcode.c
glabels2/src/view-text.c
glabels2/src/wdgt-bc-data.c
glabels2/src/wdgt-bc-data.h
glabels2/src/wdgt-text-entry.c
glabels2/src/wdgt-text-entry.h
glabels2/src/xml-label-04.c
glabels2/src/xml-label.c

index e9b6b800ad9ca7c93541a056ac6422de8cbaa08f..8f48dcaa9fa8a1e1ab8d2ad3ba822aeea6ed341b 100644 (file)
@@ -43,8 +43,8 @@ src/view-barcode.c
 src/view-barcode.h
 src/view-highlight.c
 src/view-highlight.h
-src/merge-properties.c
-src/merge-properties.h
+src/merge-properties-dialog.c
+src/merge-properties-dialog.h
 src/print.c
 src/print.h
 src/print-dialog.c
@@ -79,12 +79,10 @@ src/xml-label-04.c
 src/xml-label-04.h
 src/merge.c
 src/merge.h
+src/merge-init.c                       \
+src/merge-init.h                       \
 src/merge-text.c
 src/merge-text.h
-src/merge-ui.c
-src/merge-ui.h
-src/merge-ui-text.c
-src/merge-ui-text.h
 src/text-node.c
 src/text-node.h
 src/wdgt-text-props.c
index 0b033b1b078c090558fc6b77741215f1d0f92e60..20d6c7bce16cdb48ce26dc7907a2cd6eb8c14ded 100644 (file)
@@ -84,8 +84,8 @@ glabels_SOURCES =                     \
        view-barcode.h                  \
        view-highlight.c                \
        view-highlight.h                \
-       merge-properties.c              \
-       merge-properties.h              \
+       merge-properties-dialog.c       \
+       merge-properties-dialog.h       \
        print.c                         \
        print.h                         \
        print-dialog.c                  \
@@ -120,12 +120,10 @@ glabels_SOURCES =                         \
        xml-label-04.h                  \
        merge.c                         \
        merge.h                         \
+       merge-init.c                    \
+       merge-init.h                    \
        merge-text.c                    \
        merge-text.h                    \
-       merge-ui.c                      \
-       merge-ui.h                      \
-       merge-ui-text.c                 \
-       merge-ui-text.h                 \
        text-node.c                     \
        text-node.h                     \
        wdgt-text-props.c               \
@@ -210,6 +208,8 @@ glabels_batch_SOURCES =             \
        xml-label-04.h                  \
        merge.c                         \
        merge.h                         \
+       merge-init.c                    \
+       merge-init.h                    \
        merge-text.c                    \
        merge-text.h                    \
        text-node.c                     \
index 1bad5d6e1d41216f27a7a834a3adef0a4fff7115..63fed9620e56b4a7bd056dee674ce858606527da 100644 (file)
@@ -25,7 +25,7 @@
 #include <gnome.h>
 #include <libgnomeprint/gnome-print-master.h>
 
-#include "merge.h"
+#include "merge-init.h"
 #include "xml-label.h"
 #include "template.h"
 #include "print.h"
index bc25158c90a43e759bfe168a98308b9d59d3887c..d64a80532cabe885f15369ba045df1a30eec14e8 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "splash.h"
 #include "stock.h"
-#include "merge.h"
+#include "merge-init.h"
 #include "template.h"
 #include "prefs.h"
 #include "debug.h"
@@ -165,7 +165,6 @@ main (int argc, char **argv)
 
        gl_template_init();
        gl_merge_init();
-       gl_merge_ui_init();
        gl_recent_init();
 
        if (bonobo_ui_init ("glabels", VERSION, &argc, argv) == FALSE) {
index 498dc5261c2238ee45b20b459ccfaea6413bdd18..cd776ecdac43d0d71f989cc609f2c1a7c363a547 100644 (file)
@@ -178,7 +178,7 @@ gl_label_instance_init (glLabel *label)
        gl_debug (DEBUG_LABEL, "START");
 
        label->private = g_new0 (glLabelPrivate, 1);
-       label->private->merge = gl_merge_new();
+       label->private->merge = NULL;
 
        gl_debug (DEBUG_LABEL, "END");
 }
@@ -202,7 +202,7 @@ gl_label_finalize (GObject *object)
                g_object_unref (G_OBJECT(p->data));
        }
 
-       gl_merge_free (&label->private->merge);
+       g_object_unref (G_OBJECT(label->private->merge));
 
        g_free (label->private);
 
@@ -506,7 +506,7 @@ gl_label_set_merge (glLabel *label,
 
        g_return_if_fail (label && GL_IS_LABEL (label));
 
-       gl_merge_free (&label->private->merge);
+       g_object_unref (G_OBJECT(label->private->merge));
        label->private->merge = gl_merge_dup (merge);
 
        label->private->modified_flag = TRUE;
diff --git a/glabels2/src/merge-init.c b/glabels2/src/merge-init.c
new file mode 100644 (file)
index 0000000..251769c
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  merge.c:  document merge initialization
+ *
+ *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *
+ *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#include <config.h>
+
+#include <gnome.h>
+
+#include "merge-init.h"
+#include "merge-text.h"
+
+#include "debug.h"
+
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+/*========================================================*/
+/* Private globals.                                       */
+/*========================================================*/
+
+/*========================================================*/
+/* Private function prototypes.                           */
+/*========================================================*/
+
+\f
+/*****************************************************************************/
+/* Initailize document merge module, by registering all available backends.  */
+/*****************************************************************************/
+void
+gl_merge_init (void)
+{
+
+       gl_merge_register_backend (GL_TYPE_MERGE_TEXT,
+                                  "Text/Comma",
+                                  _("Text file with comma delimeters (CSV)"),
+                                  GL_MERGE_SRC_IS_FILE,
+                                  "delim", ',',
+                                  NULL);
+
+       gl_merge_register_backend (GL_TYPE_MERGE_TEXT,
+                                  "Text/Colon",
+                                  _("Text file with colon delimeters"),
+                                  GL_MERGE_SRC_IS_FILE,
+                                  "delim", ',',
+                                  NULL);
+
+       gl_merge_register_backend (GL_TYPE_MERGE_TEXT,
+                                  "Text/Tab",
+                                  _("Text file with tab delimeters (CSV)"),
+                                  GL_MERGE_SRC_IS_FILE,
+                                  "delim", ',',
+                                  NULL);
+
+}
diff --git a/glabels2/src/merge-init.h b/glabels2/src/merge-init.h
new file mode 100644 (file)
index 0000000..33d48ec
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  merge-init.h:  document merge initialization header file
+ *
+ *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
+ *
+ *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#ifndef __MERGE_INIT_H__
+#define __MERGE_INIT_H__
+
+#include "merge.h"
+
+G_BEGIN_DECLS
+
+void gl_merge_init (void);
+
+G_END_DECLS
+
+#endif
diff --git a/glabels2/src/merge-properties-dialog.c b/glabels2/src/merge-properties-dialog.c
new file mode 100644 (file)
index 0000000..ede3779
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  merge-properties-dialog.c:  document merge properties dialog module
+ *
+ *  Copyright (C) 2001  Jim Evins <evins@snaught.com>.
+ *
+ *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#include <config.h>
+
+#include "view.h"
+#include "merge.h"
+#include "merge-properties-dialog.h"
+#include "hig.h"
+
+#include "debug.h"
+
+/*===========================================*/
+/* Private data types                        */
+/*===========================================*/
+
+typedef struct {
+       GtkWidget *dialog;
+
+       glView  *view;
+       glLabel *label;
+       glMerge *merge;
+
+       GtkWidget *type_entry;
+       GtkWidget *src_entry;
+       GtkWidget *sample;
+
+       glMergeSrcType  src_type;
+       gchar          *sample_src;
+
+} PropertyDialogPassback;
+
+/*===========================================*/
+/* Private globals                           */
+/*===========================================*/
+
+/*===========================================*/
+/* Local function prototypes                 */
+/*===========================================*/
+
+static void create_merge_dialog_widgets (glHigDialog            *dialog,
+                                        PropertyDialogPassback *data);
+
+static void type_changed_cb             (GtkWidget              *widget,
+                                        PropertyDialogPassback *data);
+
+static void src_changed_cb              (GtkWidget              *widget,
+                                        PropertyDialogPassback *data);
+
+static void response_cb                 (glHigDialog            *dialog,
+                                        gint                    response,
+                                        PropertyDialogPassback *data);
+\f
+/****************************************************************************/
+/* Launch merge properties dialog.                                          */
+/****************************************************************************/
+void
+gl_merge_properties_dialog (glView *view)
+{
+       PropertyDialogPassback *data;
+       GtkWidget *dialog;
+
+       data = g_new0 (PropertyDialogPassback, 1);
+
+       dialog = gl_hig_dialog_new_with_buttons (
+               _("Edit document-merge properties"),
+               NULL,
+               GTK_DIALOG_DESTROY_WITH_PARENT,
+               GTK_STOCK_OK, GTK_RESPONSE_OK,
+               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+               NULL);
+
+       data->dialog = dialog;
+       data->view = view;
+       data->label = view->label;
+
+       create_merge_dialog_widgets (GL_HIG_DIALOG (dialog), data);
+
+       g_signal_connect (G_OBJECT(dialog), "response",
+                         G_CALLBACK(response_cb), data);
+
+       gtk_widget_show_all (GTK_WIDGET (dialog));
+
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Create merge widgets.                                          */
+/*--------------------------------------------------------------------------*/
+static void
+create_merge_dialog_widgets (glHigDialog * dialog,
+                            PropertyDialogPassback * data)
+{
+       GtkWidget         *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll, *wentry;
+       GList             *texts;
+       gchar             *description;
+       glMergeSrcType     src_type;
+       gchar             *src;
+       GtkSizeGroup      *label_size_group;
+
+       data->merge = gl_label_get_merge (data->label);
+       description = gl_merge_get_description (data->merge);
+       src_type    = gl_merge_get_src_type (data->merge);
+       src         = gl_merge_get_src (data->merge);
+
+       /* ---- Source section ---- */
+       wframe = gl_hig_category_new (_("Source"));
+       gl_hig_dialog_add_widget (dialog, wframe);
+       label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+       /* Format line */
+       whbox = gl_hig_hbox_new();
+       gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox);
+
+       wlabel = gtk_label_new (_("Format:"));
+       gtk_size_group_add_widget (label_size_group, wlabel);
+       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
+       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
+
+       wcombo = gtk_combo_new ();
+       texts = gl_merge_get_descriptions ();
+       gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts);
+       gl_merge_free_descriptions (&texts);
+       data->type_entry = GTK_COMBO (wcombo)->entry;
+       gtk_entry_set_editable (GTK_ENTRY (data->type_entry), FALSE);
+       gtk_entry_set_text (GTK_ENTRY (data->type_entry), description);
+       gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), wcombo);
+       g_signal_connect (G_OBJECT (data->type_entry), "changed",
+                         G_CALLBACK (type_changed_cb), data);
+
+       whbox = gl_hig_hbox_new();
+       gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox);
+
+       /* Location line */
+       wlabel = gtk_label_new (_("Location:"));
+       gtk_size_group_add_widget (label_size_group, wlabel);
+       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
+       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
+
+       switch (src_type) {
+       case GL_MERGE_SRC_IS_FILE:
+               data->src_entry =
+                       gnome_file_entry_new (NULL, _("Select merge-database source"));
+               wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY(data->src_entry));
+               gtk_entry_set_text (GTK_ENTRY(wentry), src);
+               g_signal_connect (G_OBJECT (wentry), "changed",
+                                 G_CALLBACK (src_changed_cb), data);
+               break;
+       default:
+               data->src_entry = gtk_label_new (_("N/A"));
+               break;
+       }
+       gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), data->src_entry);
+
+       /* ---- Sample Fields section ---- */
+       wframe = gl_hig_category_new (_("Sample fields"));
+       gl_hig_dialog_add_widget (dialog, wframe);
+
+#if 0
+       wscroll = gtk_scrolled_window_new (NULL, NULL);
+       gtk_container_set_border_width (GTK_CONTAINER (wscroll), 5);
+       gtk_widget_set_usize (wscroll, 400, 250);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll),
+                                       GTK_POLICY_AUTOMATIC,
+                                       GTK_POLICY_AUTOMATIC);
+       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), wscroll);
+
+       data->sample = gl_merge_ui_field_ws_new ();
+       gtk_container_set_border_width (GTK_CONTAINER (data->sample), 10);
+       gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
+                                          (data->field_ws), type, src);
+       gl_merge_ui_field_ws_set_field_defs (GL_MERGE_UI_FIELD_WS
+                                            (data->sample), fields);
+       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll),
+                                              data->sample);
+#endif
+
+       g_free (src);
+       g_free (description);
+
+        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  type "changed" callback.                                       */
+/*--------------------------------------------------------------------------*/
+static void
+type_changed_cb (GtkWidget * widget,
+                PropertyDialogPassback * data)
+{
+       gchar             *description;
+       gchar             *name;
+       gchar             *src;
+       glMergeSrcType     src_type;
+       GtkWidget         *wentry;
+
+       description = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
+                                             0, -1);
+       name = gl_merge_description_to_name (description);
+
+       src = gl_merge_get_src (data->merge); /* keep current source if possible */
+
+       g_object_unref (G_OBJECT(data->merge));
+       data->merge = gl_merge_new (name);
+
+       gtk_widget_destroy (data->src_entry);
+       src_type = gl_merge_get_src_type (data->merge);
+       switch (src_type) {
+       case GL_MERGE_SRC_IS_FILE:
+               data->src_entry =
+                       gnome_file_entry_new (NULL, _("Select merge-database source"));
+               wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY(data->src_entry));
+               gtk_entry_set_text (GTK_ENTRY(wentry), src);
+               g_signal_connect (G_OBJECT (wentry), "changed",
+                                 G_CALLBACK (src_changed_cb), data);
+               break;
+       default:
+               data->src_entry = gtk_label_new (_("N/A"));
+               break;
+       }
+
+       g_free (description);
+       g_free (name);
+       g_free (src);
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  source "changed" callback.                                     */
+/*--------------------------------------------------------------------------*/
+static void
+src_changed_cb (GtkWidget * widget,
+               PropertyDialogPassback * data)
+{
+       gchar     *src;
+       GtkWidget *wentry;
+
+       wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY(data->src_entry));
+       src = gtk_editable_get_chars (GTK_EDITABLE (wentry), 0, -1);
+
+#if 0
+       gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
+                                          (data->sample), type, src);
+#endif
+}
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  response callback.                                             */
+/*--------------------------------------------------------------------------*/
+static void
+response_cb (glHigDialog * dialog,
+            gint response,
+            PropertyDialogPassback * data)
+{
+       switch (response) {
+
+       case GTK_RESPONSE_OK:
+
+               gl_label_set_merge (data->label, data->merge);
+               break;
+       }
+
+
+       g_object_unref (G_OBJECT(data->merge));
+       g_free (data);
+       gtk_widget_destroy (GTK_WIDGET(dialog));
+}
diff --git a/glabels2/src/merge-properties-dialog.h b/glabels2/src/merge-properties-dialog.h
new file mode 100644 (file)
index 0000000..4f516ec
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  merge-properties-dialog.h:  document merge properties dialog module header file
+ *
+ *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
+ *
+ *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+#ifndef __MERGE_PROPERTIES_DIALOG_H__
+#define __MERGE_PROPERTIES_DIALOG_H__
+
+#include "view.h"
+
+G_BEGIN_DECLS
+
+extern void gl_merge_properties_dialog (glView *view);
+
+G_END_DECLS
+
+#endif
diff --git a/glabels2/src/merge-properties.c b/glabels2/src/merge-properties.c
deleted file mode 100644 (file)
index c82e433..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_properties.c:  document merge properties dialog module
- *
- *  Copyright (C) 2001  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#include <config.h>
-
-#include "view.h"
-#include "merge.h"
-#include "merge-ui.h"
-#include "merge-properties.h"
-#include "hig.h"
-
-#include "debug.h"
-
-/*===========================================*/
-/* Private data types                        */
-/*===========================================*/
-
-typedef struct {
-       GtkWidget *dialog;
-
-       glView *view;
-       glLabel *label;
-
-       GtkWidget *type_entry;
-       GtkWidget *src_entry;
-       GtkWidget *field_ws;
-
-       glMergeType src_type;
-       gchar *field_ws_src;
-
-} PropertyDialogPassback;
-
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
-
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
-
-static void create_merge_dialog_widgets (glHigDialog            *dialog,
-                                        PropertyDialogPassback *data);
-
-static void type_changed_cb             (GtkWidget              *widget,
-                                        PropertyDialogPassback *data);
-
-static void src_changed_cb              (GtkWidget              *widget,
-                                        PropertyDialogPassback *data);
-
-static void response_cb                 (glHigDialog            *dialog,
-                                        gint                    response,
-                                        PropertyDialogPassback *data);
-\f
-/****************************************************************************/
-/* Launch merge properties dialog.                                          */
-/****************************************************************************/
-void
-gl_merge_properties_dialog (glView *view)
-{
-       static PropertyDialogPassback *data = NULL;
-       GtkWidget *dialog;
-
-       if (data == NULL) {
-               data = g_new0 (PropertyDialogPassback, 1);
-       }
-
-       dialog = gl_hig_dialog_new_with_buttons (
-               _("Edit document-merge properties"),
-               NULL,
-               GTK_DIALOG_DESTROY_WITH_PARENT,
-               GTK_STOCK_OK, GTK_RESPONSE_OK,
-               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-               NULL);
-
-       data->dialog = dialog;
-       data->view = view;
-       data->label = view->label;
-
-       data->type_entry = NULL;
-       data->src_entry = NULL;
-       data->field_ws = NULL;
-
-       create_merge_dialog_widgets (GL_HIG_DIALOG (dialog), data);
-
-       g_signal_connect (G_OBJECT(dialog), "response",
-                         G_CALLBACK(response_cb), data);
-
-       gtk_widget_show_all (GTK_WIDGET (dialog));
-
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Create merge widgets.                                          */
-/*--------------------------------------------------------------------------*/
-static void
-create_merge_dialog_widgets (glHigDialog * dialog,
-                            PropertyDialogPassback * data)
-{
-       GtkWidget *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll;
-       GList *texts;
-       glMerge *merge;
-       glMergeType type;
-       gchar *src;
-       GList *fields;
-       GtkSizeGroup *label_size_group;
-
-       merge = gl_label_get_merge (data->label);
-       type = merge->type;
-       src  = merge->src;
-       fields = merge->field_defs;
-
-       /* ---- Source section ---- */
-       wframe = gl_hig_category_new (_("Source"));
-       gl_hig_dialog_add_widget (dialog, wframe);
-       label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-
-       /* Format line */
-       whbox = gl_hig_hbox_new();
-       gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox);
-
-       wlabel = gtk_label_new (_("Format:"));
-       gtk_size_group_add_widget (label_size_group, wlabel);
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
-
-       wcombo = gtk_combo_new ();
-       texts = gl_merge_get_long_texts_list ();
-       gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts);
-       gl_merge_free_long_texts_list (&texts);
-       data->type_entry = GTK_COMBO (wcombo)->entry;
-       gtk_entry_set_editable (GTK_ENTRY (data->type_entry), FALSE);
-       gtk_entry_set_text (GTK_ENTRY (data->type_entry),
-                           gl_merge_type_to_long_text (type));
-       gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), wcombo);
-
-       whbox = gl_hig_hbox_new();
-       gl_hig_category_add_widget (GL_HIG_CATEGORY (wframe), whbox);
-
-       /* Location line */
-       wlabel = gtk_label_new (_("Location:"));
-       gtk_size_group_add_widget (label_size_group, wlabel);
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-       gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
-
-       data->src_entry = gl_merge_ui_src_new ();
-       gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type);
-       gl_merge_ui_src_set_value (GL_MERGE_UI_SRC (data->src_entry), src);
-       gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), data->src_entry);
-
-       /* ---- Fields section ---- */
-       wframe = gl_hig_category_new (_("Fields"));
-       gl_hig_dialog_add_widget (dialog, wframe);
-
-       wscroll = gtk_scrolled_window_new (NULL, NULL);
-       gtk_container_set_border_width (GTK_CONTAINER (wscroll), 5);
-       gtk_widget_set_usize (wscroll, 400, 250);
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll),
-                                       GTK_POLICY_AUTOMATIC,
-                                       GTK_POLICY_AUTOMATIC);
-       gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), wscroll);
-
-       data->field_ws = gl_merge_ui_field_ws_new ();
-       gtk_container_set_border_width (GTK_CONTAINER (data->field_ws), 10);
-       gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
-                                          (data->field_ws), type, src);
-       gl_merge_ui_field_ws_set_field_defs (GL_MERGE_UI_FIELD_WS
-                                            (data->field_ws), fields);
-       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll),
-                                              data->field_ws);
-
-       g_signal_connect (G_OBJECT (data->type_entry), "changed",
-                         G_CALLBACK (type_changed_cb), data);
-       g_signal_connect (G_OBJECT (data->src_entry), "changed",
-                         G_CALLBACK (src_changed_cb), data);
-
-       gl_merge_free (&merge);
-
-        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  type "changed" callback.                                       */
-/*--------------------------------------------------------------------------*/
-static void
-type_changed_cb (GtkWidget * widget,
-                PropertyDialogPassback * data)
-{
-       glMergeType type;
-       gchar *type_text;
-
-       type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
-                                           0, -1);
-       type = gl_merge_long_text_to_type (type_text);
-       g_free (type_text);
-
-       gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  source "changed" callback.                                     */
-/*--------------------------------------------------------------------------*/
-static void
-src_changed_cb (GtkWidget * widget,
-               PropertyDialogPassback * data)
-{
-       glMergeType type;
-       gchar *type_text, *src;
-
-       type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
-                                           0, -1);
-       type = gl_merge_long_text_to_type (type_text);
-       g_free (type_text);
-
-       src = gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry));
-       gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
-                                          (data->field_ws), type, src);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  response callback.                                             */
-/*--------------------------------------------------------------------------*/
-static void
-response_cb (glHigDialog * dialog,
-            gint response,
-            PropertyDialogPassback * data)
-{
-       gchar *type_text;
-       glMerge *merge;
-
-       switch (response) {
-
-       case GTK_RESPONSE_OK:
-
-               merge = gl_merge_new();
-
-               type_text =
-                      gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
-                                                   0, -1);
-               merge->type = gl_merge_long_text_to_type (type_text);
-               g_free (type_text);
-
-               merge->src =
-                       gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry));
-
-               merge->field_defs =
-                       gl_merge_ui_field_ws_get_field_defs (GL_MERGE_UI_FIELD_WS
-                                                            (data->field_ws));
-
-               gl_label_set_merge (data->label, merge);
-
-               gl_merge_free (&merge);
-
-               break;
-       }
-
-       gtk_widget_destroy (data->dialog);
-}
diff --git a/glabels2/src/merge-properties.h b/glabels2/src/merge-properties.h
deleted file mode 100644 (file)
index 7af2679..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_properties.h:  document merge properties dialog module header file
- *
- *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#ifndef __MERGE_PROPERTIES_H__
-#define __MERGE_PROPERTIES_H__
-
-#include "view.h"
-
-extern void gl_merge_properties_dialog (glView *view);
-
-#endif
index 50852e515008484a4a23faeee188684630e4c481..7259c3fc7832256e9198541afe0b90cb3ffadd8f 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <config.h>
 
-#include <gnome.h>
+#include <stdio.h>
 
 #include "merge-text.h"
 
 /* Private types                             */
 /*===========================================*/
 
+struct _glMergeTextPrivate {
+       gchar             delim;
+       FILE             *fp;
+};
+
+enum {
+       LAST_SIGNAL
+};
+
+enum {
+       ARG_0,
+       ARG_DELIM,
+};
+
 /*===========================================*/
 /* Private globals                           */
 /*===========================================*/
 
+static glMergeClass *parent_class = NULL;
+
+static guint signals[LAST_SIGNAL] = {0};
+
+
 /*===========================================*/
 /* Local function prototypes                 */
 /*===========================================*/
-static GList * split_fields( gchar *line, gchar delim );
-static void free_fields( GList **fields );
+
+static void           gl_merge_text_class_init     (glMergeTextClass *klass);
+static void           gl_merge_text_instance_init  (glMergeText      *object);
+static void           gl_merge_text_finalize       (GObject          *object);
+
+static void           gl_merge_text_set_property   (GObject          *object,
+                                                   guint             param_id,
+                                                   const GValue     *value,
+                                                   GParamSpec       *pspec);
+
+static void           gl_merge_text_get_property   (GObject          *object,
+                                                   guint             param_id,
+                                                   GValue           *value,
+                                                   GParamSpec       *pspec);
+
+static GList         *gl_merge_text_get_key_list   (glMerge          *merge);
+static void           gl_merge_text_open           (glMerge          *merge);
+static void           gl_merge_text_close          (glMerge          *merge);
+static glMergeRecord *gl_merge_text_get_record     (glMerge          *merge);
+static void           gl_merge_text_copy           (glMerge          *dst_merge,
+                                                   glMerge          *src_merge);
+
+static GList         *split_fields                 (gchar            *line,
+                                                   gchar             delim);
+static void           free_fields                  (GList           **fields);
 
 \f
-/****************************************************************************/
-/* Open merge source.                                                       */
-/****************************************************************************/
-glMergeInput *
-gl_merge_text_open (glMergeType type,
-                   GList * field_defs,
-                   gchar * src)
+/*****************************************************************************/
+/* Boilerplate object stuff.                                                 */
+/*****************************************************************************/
+GType
+gl_merge_text_get_type (void)
+{
+       static GType type = 0;
+
+       if (!type) {
+               GTypeInfo info = {
+                       sizeof (glMergeTextClass),
+                       NULL,
+                       NULL,
+                       (GClassInitFunc) gl_merge_text_class_init,
+                       NULL,
+                       NULL,
+                       sizeof (glMergeText),
+                       0,
+                       (GInstanceInitFunc) gl_merge_text_instance_init,
+               };
+
+               type = g_type_register_static (GL_TYPE_MERGE,
+                                              "glMergeText", &info, 0);
+       }
+
+       return type;
+}
+
+static void
+gl_merge_text_class_init (glMergeTextClass *klass)
+{
+       GObjectClass *object_class = (GObjectClass *) klass;
+       glMergeClass *merge_class  = (glMergeClass *) klass;
+
+       gl_debug (DEBUG_MERGE, "START");
+
+       parent_class = g_type_class_peek_parent (klass);
+
+       object_class->set_property = gl_merge_text_set_property;
+       object_class->get_property = gl_merge_text_get_property;
+
+       g_object_class_install_property
+                (object_class,
+                 ARG_DELIM,
+                 g_param_spec_char ("delim", NULL, NULL,
+                                   0, 0x7F, ',',
+                                   (G_PARAM_READABLE | G_PARAM_WRITABLE)));
+
+       object_class->finalize = gl_merge_text_finalize;
+
+       merge_class->get_key_list = gl_merge_text_get_key_list;
+       merge_class->open         = gl_merge_text_open;
+       merge_class->close        = gl_merge_text_close;
+       merge_class->get_record   = gl_merge_text_get_record;
+       merge_class->copy         = gl_merge_text_copy;
+
+       gl_debug (DEBUG_MERGE, "END");
+}
+
+static void
+gl_merge_text_instance_init (glMergeText *merge_text)
+{
+       gl_debug (DEBUG_MERGE, "START");
+
+       merge_text->private = g_new0 (glMergeTextPrivate, 1);
+
+       gl_debug (DEBUG_MERGE, "END");
+}
+
+static void
+gl_merge_text_finalize (GObject *object)
+{
+       gl_debug (DEBUG_MERGE, "START");
+
+       g_return_if_fail (object && GL_IS_MERGE_TEXT (object));
+
+       G_OBJECT_CLASS (parent_class)->finalize (object);
+
+       gl_debug (DEBUG_MERGE, "END");
+}
+
+/*--------------------------------------------------------------------------*/
+/* Set argument.                                                            */
+/*--------------------------------------------------------------------------*/
+static void
+gl_merge_text_set_property (GObject      *object,
+                           guint         param_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+       glMergeText *merge_text;
+
+       merge_text = GL_MERGE_TEXT (object);
+
+       switch (param_id) {
+
+       case ARG_DELIM:
+               merge_text->private->delim = g_value_get_char (value);
+               gl_debug (DEBUG_MERGE, "ARG \"delim\" = \"%c\"",
+                         merge_text->private->delim);
+               break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+                break;
+
+        }
+
+}
+
+/*--------------------------------------------------------------------------*/
+/* Get argument.                                                            */
+/*--------------------------------------------------------------------------*/
+static void
+gl_merge_text_get_property (GObject     *object,
+                           guint        param_id,
+                           GValue      *value,
+                           GParamSpec  *pspec)
+{
+       glMergeText *merge_text;
+
+       merge_text = GL_MERGE_TEXT (object);
+
+       switch (param_id) {
+
+       case ARG_DELIM:
+               g_value_set_char (value, merge_text->private->delim);
+               break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+                break;
+
+        }
+
+}
+
+/*--------------------------------------------------------------------------*/
+/* Get key list.                                                            */
+/*--------------------------------------------------------------------------*/
+static GList *
+gl_merge_text_get_key_list (glMerge *merge)
 {
-       FILE *fp;
-       glMergeInput *input;
+       glMergeText *merge_text;
+       gchar       *src;
+       FILE        *fp;
+       gchar        delim;
+       gchar        line[LINE_BUF_LEN];
+       GList       *fields, *p;
+       gint         i_field, n_fields, n_fields_max = 0;
+       GList       *key_list;
+       
+       /* Fields are simply column numbers. */
+       /* FIXME:  the key_list should probably be cached, and only re-evaluated */
+       /*         if the source has changed. */
+
+       merge_text = GL_MERGE_TEXT (merge);
+
+       src = gl_merge_get_src (merge);
+       delim = merge_text->private->delim;
 
        fp = fopen (src, "r");
-       if (fp == NULL) {
+       if ( fp == NULL ) {
                return NULL;
        }
 
-       input = g_new0 (glMergeInput, 1);
-       input->type = type;
-       input->field_defs = field_defs;
-       input->handle = fp;
+       while ( fgets (line, LINE_BUF_LEN, fp) != NULL ) {
 
-       return input;
+               if (TRUE /* TODO: skip blank lines or comments */ ) {
+                       g_strchomp (line);
+                       fields = split_fields (line, delim);
+                       n_fields = 0;
+                       for (p=fields; p != NULL; p=p->next) {
+                               n_fields++;
+                       }
+                       free_fields (&fields);
+                       if ( n_fields > n_fields_max ) n_fields = n_fields_max;
+               }
+
+       }
+
+       key_list = NULL;
+       for (i_field=1; i_field <= n_fields; i_field++) {
+               key_list = g_list_append (key_list, g_strdup_printf ("%d", i_field));
+       }
+
+       return key_list;
+}
+
+/*--------------------------------------------------------------------------*/
+/* Open merge source.                                                       */
+/*--------------------------------------------------------------------------*/
+static void
+gl_merge_text_open (glMerge *merge)
+{
+       glMergeText *merge_text;
+       gchar       *src;
+
+       merge_text = GL_MERGE_TEXT (merge);
+
+       src = gl_merge_get_src (merge);
+
+       if (src != NULL) {
+               merge_text->private->fp = fopen (src, "r");
+       }
+
+       g_free (src);
 }
 
-/****************************************************************************/
+/*--------------------------------------------------------------------------*/
 /* Close merge source.                                                      */
-/****************************************************************************/
-void
-gl_merge_text_close (glMergeInput * input)
+/*--------------------------------------------------------------------------*/
+static void
+gl_merge_text_close (glMerge *merge)
 {
-       if (input != NULL) {
+       glMergeText *merge_text;
+
+       merge_text = GL_MERGE_TEXT (merge);
 
-               fclose ((FILE *) input->handle);
-               g_free (input);
+       if (merge_text->private->fp != NULL) {
+
+               fclose (merge_text->private->fp);
+               merge_text->private->fp = NULL;
 
        }
 }
 
-/****************************************************************************/
+/*--------------------------------------------------------------------------*/
 /* Get next record from merge source, NULL if no records left (i.e EOF)     */
-/****************************************************************************/
-glMergeRecord *
-gl_merge_text_get_record (glMergeInput * input)
+/*--------------------------------------------------------------------------*/
+static glMergeRecord *
+gl_merge_text_get_record (glMerge *merge)
 {
-       gchar delim, *loc;
-       GList *fields, *p;
-       gint  i_field;
+       glMergeText   *merge_text;
+       gchar          delim;
+       FILE          *fp;
+       gchar          line[LINE_BUF_LEN];
        glMergeRecord *record = NULL;
-       glMergeField *field;
-       gchar line[LINE_BUF_LEN];
+       GList         *fields, *p;
+       gint           i_field;
+       glMergeField  *field;
 
-       if (input != NULL) {
+       merge_text = GL_MERGE_TEXT (merge);
 
-               switch (input->type) {
-               case GL_MERGE_TEXT_TAB:
-                       delim = '\t';
-                       break;
-               case GL_MERGE_TEXT_COLON:
-                       delim = ':';
-                       break;
-               case GL_MERGE_TEXT_COMMA:
-                       delim = ',';
-                       break;
-               default:
-                       g_warning ("Unexpected merge type");
-                       return NULL;
-               }
+       delim = merge_text->private->delim;
+       fp    = merge_text->private->fp;
 
-               while (fgets (line, LINE_BUF_LEN, (FILE *) input->handle) !=
-                      NULL) {
-                       if (TRUE /* TODO: skip blank lines or comments */ ) {
-                               g_strchomp (line);
-                               record = g_new0 (glMergeRecord, 1);
-                               record->select_flag = TRUE;
-                               fields = split_fields (line, delim);
-                               i_field = 1;
-                               for (p=fields; p != NULL; p=p->next) {
-                                       loc =
-                                           g_strdup_printf ("%d", i_field++);
-                                       field = g_new0 (glMergeField, 1);
-                                       field->value = g_strdup (p->data);
-                                       field->key =
-                                           gl_merge_find_key (input->
-                                                              field_defs, loc);
-                                       record->field_list =
-                                               g_list_append (record->field_list, field);
-                                       g_free (loc);
-                               }
-                               free_fields (&fields);
-                               return record;
+       if (fp == NULL) {
+               return NULL;
+       }
+              
+       while ( fgets (line, LINE_BUF_LEN, fp) != NULL ) {
+
+               if (TRUE /* TODO: skip blank lines or comments */ ) {
+                       g_strchomp (line);
+                       record = g_new0 (glMergeRecord, 1);
+                       record->select_flag = TRUE;
+                       fields = split_fields (line, delim);
+                       i_field = 1;
+                       for (p=fields; p != NULL; p=p->next) {
+                               
+                               field = g_new0 (glMergeField, 1);
+                               field->key = g_strdup_printf ("%d", i_field++);
+                               field->value = g_strdup (p->data);
+
+                               record->field_list =
+                                       g_list_append (record->field_list, field);
                        }
+                       free_fields (&fields);
+                       return record;
                }
 
        }
+
        return NULL;
 }
 
-/****************************************************************************/
-/* Retrieve a list of raw fields (columns in this case)                     */
-/****************************************************************************/
-GList *
-gl_merge_text_get_raw_record (glMergeInput * input)
+/*---------------------------------------------------------------------------*/
+/* Copy merge_text specific fields.                                          */
+/*---------------------------------------------------------------------------*/
+static void
+gl_merge_text_copy (glMerge *dst_merge,
+                   glMerge *src_merge)
 {
-       GList *list = NULL;
-       gchar line[LINE_BUF_LEN], delim;
-       GList *fields, *p;
-       gint i_field;
-       glMergeRawField *raw_field;
+       glMergeText *dst_merge_text;
+       glMergeText *src_merge_text;
 
-       if (input != NULL) {
+       dst_merge_text = GL_MERGE_TEXT (dst_merge);
+       src_merge_text = GL_MERGE_TEXT (src_merge);
 
-               switch (input->type) {
-               case GL_MERGE_TEXT_TAB:
-                       delim = '\t';
-                       break;
-               case GL_MERGE_TEXT_COLON:
-                       delim = ':';
-                       break;
-               case GL_MERGE_TEXT_COMMA:
-                       delim = ',';
-                       break;
-               default:
-                       g_warning ("Unexpected merge type");
-                       return NULL;
-               }
-
-               while (fgets (line, LINE_BUF_LEN, (FILE *) input->handle)
-                      != NULL) {
-                       if (TRUE /* TODO: skip blank lines or comments */ ) {
-                               g_strchomp (line);
-                               fields = split_fields (line, delim);
-                               i_field = 1;
-                               for (p=fields; p != NULL; p=p->next) {
-                                       raw_field =
-                                               g_new0 (glMergeRawField, 1);
-                                       raw_field->loc =
-                                               g_strdup_printf ("%d",
-                                                                i_field++);
-                                       raw_field->value = g_strdup (p->data);
-                                       list = g_list_append (list, raw_field);
-                               }
-                               free_fields (&fields);
-                               break;
-                       }
-               }
-
-       }
-       return list;
+       dst_merge_text->private->delim = src_merge_text->private->delim;
 }
 
 /*---------------------------------------------------------------------------*/
index b1dddef7d9866ed5aa08999a8f6ee7e016c59d94..f642600a7bd7e823c71de4e00c60d5413fa5bbac 100644 (file)
 #ifndef __MERGE_TEXT_H__
 #define __MERGE_TEXT_H__
 
-#include <gtk/gtk.h>
-
 #include "merge.h"
 
-extern glMergeInput *gl_merge_text_open (glMergeType type, GList * field_defs,
-                                        gchar * src);
-extern void gl_merge_text_close (glMergeInput * input);
-extern glMergeRecord *gl_merge_text_get_record (glMergeInput * input);
-extern GList *gl_merge_text_get_raw_record (glMergeInput * input);
+G_BEGIN_DECLS
+
+/* The following object arguments are available:
+ *
+ * name               type             description
+ * --------------------------------------------------------------------------------
+ * delim              gchar            Field delimiter.
+ *
+ */
+
+#define GL_TYPE_MERGE_TEXT              (gl_merge_text_get_type ())
+#define GL_MERGE_TEXT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_MERGE_TEXT, glMergeText))
+#define GL_MERGE_TEXT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_TEXT, glMergeTextClass))
+#define GL_IS_MERGE_TEXT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_MERGE_TEXT))
+#define GL_IS_MERGE_TEXT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_TEXT))
+#define GL_MERGE_TEXT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GL_TYPE_MERGE_TEXT, glMergeTextClass))
+
+
+typedef struct _glMergeText          glMergeText;
+typedef struct _glMergeTextClass     glMergeTextClass;
+
+typedef struct _glMergeTextPrivate   glMergeTextPrivate;
+
+
+struct _glMergeText {
+       glMerge              object;
+
+       glMergeTextPrivate  *private;
+};
+
+struct _glMergeTextClass {
+       glMergeClass         parent_class;
+};
+
+
+GType             gl_merge_text_get_type            (void);
+
+G_END_DECLS
 
 #endif
diff --git a/glabels2/src/merge-ui-text.c b/glabels2/src/merge-ui-text.c
deleted file mode 100644 (file)
index ba280a3..0000000
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_ui_text.c:  text-file document merge user interface backend module
- *
- *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#include <config.h>
-
-#include "merge-ui-text.h"
-#include "merge-text.h"
-#include "marshal.h"
-
-#include "debug.h"
-
-/*===========================================*/
-/* Private types                             */
-/*===========================================*/
-
-enum {
-       CHANGED,
-       LAST_SIGNAL
-};
-
-typedef struct {
-       gchar *loc;
-       GtkWidget *entry;
-} EntryNode;
-
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
-
-static GtkContainerClass *parent_class;
-
-static gint merge_ui_text_src_signals[LAST_SIGNAL] = { 0 };
-static gint merge_ui_text_field_ws_signals[LAST_SIGNAL] = { 0 };
-
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
-
-static void gl_merge_ui_text_src_class_init (glMergeUITextSrcClass * class);
-static void gl_merge_ui_text_src_instance_init (glMergeUITextSrc * src);
-static void gl_merge_ui_text_src_finalize (GObject * object);
-static void gl_merge_ui_text_src_construct (glMergeUITextSrc * src,
-                                           glMergeType type);
-
-static void src_changed_cb (glMergeUITextSrc * src);
-
-static void gl_merge_ui_text_field_ws_class_init (glMergeUITextFieldWSClass * class);
-static void gl_merge_ui_text_field_ws_instance_init (glMergeUITextFieldWS * field_ws);
-static void gl_merge_ui_text_field_ws_finalize (GObject * object);
-static void gl_merge_ui_text_field_ws_construct (glMergeUITextFieldWS * field_ws,
-                                                glMergeType type,
-                                                gchar * src);
-
-static void field_ws_changed_cb (glMergeUITextFieldWS * field_ws);
-\f
-/*****************************************************************************/
-/* Boilerplate Object stuff.                                                 */
-/*****************************************************************************/
-guint
-gl_merge_ui_text_src_get_type (void)
-{
-       static guint merge_ui_text_src_type = 0;
-
-       if (!merge_ui_text_src_type) {
-               GTypeInfo merge_ui_text_src_info = {
-                       sizeof (glMergeUITextSrcClass),
-                       NULL,
-                       NULL,
-                       (GClassInitFunc) gl_merge_ui_text_src_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (glMergeUITextSrc),
-                       0,
-                       (GInstanceInitFunc) gl_merge_ui_text_src_instance_init,
-               };
-
-               merge_ui_text_src_type =
-                       g_type_register_static (gtk_vbox_get_type (),
-                                               "glMergeUITextSrc",
-                                               &merge_ui_text_src_info, 0);
-       }
-
-       return merge_ui_text_src_type;
-}
-
-static void
-gl_merge_ui_text_src_class_init (glMergeUITextSrcClass * class)
-{
-       GObjectClass *object_class;
-
-       object_class = (GObjectClass *) class;
-
-       parent_class = gtk_type_class (gtk_vbox_get_type ());
-
-       object_class->finalize = gl_merge_ui_text_src_finalize;
-
-       merge_ui_text_src_signals[CHANGED] =
-           g_signal_new ("changed",
-                         G_OBJECT_CLASS_TYPE(object_class),
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET (glMergeUITextSrcClass, changed),
-                         NULL, NULL,
-                         gl_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0);
-}
-
-static void
-gl_merge_ui_text_src_instance_init (glMergeUITextSrc * src)
-{
-       src->type = GL_MERGE_NONE;
-       src->entry = NULL;
-}
-
-static void
-gl_merge_ui_text_src_finalize (GObject * object)
-{
-       glMergeUITextSrc *src;
-       glMergeUITextSrcClass *class;
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GL_IS_MERGE_UI_TEXT_SRC (object));
-
-       src = GL_MERGE_UI_TEXT_SRC (object);
-
-       G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GtkWidget *
-gl_merge_ui_text_src_new (glMergeType type)
-{
-       glMergeUITextSrc *src;
-
-       src = g_object_new (gl_merge_ui_text_src_get_type (), NULL);
-
-       gl_merge_ui_text_src_construct (src, type);
-
-       return GTK_WIDGET (src);
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Construct composite widget.                                     */
-/*---------------------------------------------------------------------------*/
-static void
-gl_merge_ui_text_src_construct (glMergeUITextSrc * src,
-                               glMergeType type)
-{
-       GtkWidget *wvbox, *wentry;
-
-       wvbox = GTK_WIDGET (src);
-
-       src->type = type;
-
-       src->entry =
-           gnome_file_entry_new (NULL, _("Select merge-database source"));
-       gtk_box_pack_start (GTK_BOX (wvbox), src->entry, TRUE, TRUE, 0);
-
-       wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (src->entry));
-       g_signal_connect_swapped (G_OBJECT (wentry), "changed",
-                                 G_CALLBACK (src_changed_cb),
-                                 G_OBJECT (src));
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Callback for when our backend widget has changed.              */
-/*--------------------------------------------------------------------------*/
-static void
-src_changed_cb (glMergeUITextSrc * src)
-{
-       /* Emit our "changed" signal */
-       g_signal_emit (G_OBJECT (src), merge_ui_text_src_signals[CHANGED], 0);
-}
-
-/*****************************************************************************/
-/* Set src name.                                                             */
-/*****************************************************************************/
-void
-gl_merge_ui_text_src_set_value (glMergeUITextSrc * src,
-                               gchar * text)
-{
-       GtkWidget *wentry;
-
-       wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (src->entry));
-
-       gtk_entry_set_text (GTK_ENTRY (wentry), text);
-}
-
-/*****************************************************************************/
-/* Get src name.                                                             */
-/*****************************************************************************/
-gchar *
-gl_merge_ui_text_src_get_value (glMergeUITextSrc * src)
-{
-       return gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (src->entry),
-                                              TRUE);
-}
-
-/*****************************************************************************/
-/* Boilerplate Object stuff.                                                 */
-/*****************************************************************************/
-guint
-gl_merge_ui_text_field_ws_get_type (void)
-{
-       static guint merge_ui_text_field_ws_type = 0;
-
-       if (!merge_ui_text_field_ws_type) {
-               GTypeInfo merge_ui_text_field_ws_info = {
-                       sizeof (glMergeUITextFieldWSClass),
-                       NULL,
-                       NULL,
-                       (GClassInitFunc) gl_merge_ui_text_field_ws_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (glMergeUITextFieldWS),
-                       0,
-                       (GInstanceInitFunc) gl_merge_ui_text_field_ws_instance_init,
-               };
-
-               merge_ui_text_field_ws_type =
-                   g_type_register_static (gtk_hbox_get_type (),
-                                           "glMergeUITextFieldWS",
-                                           &merge_ui_text_field_ws_info, 0);
-       }
-
-       return merge_ui_text_field_ws_type;
-}
-
-static void
-gl_merge_ui_text_field_ws_class_init (glMergeUITextFieldWSClass * class)
-{
-       GObjectClass *object_class;
-
-       object_class = (GObjectClass *) class;
-
-       parent_class = gtk_type_class (gtk_hbox_get_type ());
-
-       object_class->finalize = gl_merge_ui_text_field_ws_finalize;
-
-       merge_ui_text_field_ws_signals[CHANGED] =
-           g_signal_new ("changed",
-                         G_OBJECT_CLASS_TYPE(object_class),
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET (glMergeUITextFieldWSClass, changed),
-                         NULL, NULL,
-                         gl_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0);
-}
-
-static void
-gl_merge_ui_text_field_ws_instance_init (glMergeUITextFieldWS * field_ws)
-{
-       field_ws->type = GL_MERGE_NONE;
-       field_ws->entry_list = NULL;
-}
-
-static void
-gl_merge_ui_text_field_ws_finalize (GObject * object)
-{
-       glMergeUITextFieldWS *field_ws;
-       glMergeUITextFieldWSClass *class;
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GL_IS_MERGE_UI_TEXT_FIELD_WS (object));
-
-       field_ws = GL_MERGE_UI_TEXT_FIELD_WS (object);
-
-       G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-GtkWidget *
-gl_merge_ui_text_field_ws_new (glMergeType type,
-                              gchar * src)
-{
-       glMergeUITextFieldWS *field_ws;
-
-       field_ws = g_object_new (gl_merge_ui_text_field_ws_get_type (), NULL);
-
-       gl_merge_ui_text_field_ws_construct (field_ws, type, src);
-
-       return GTK_WIDGET (field_ws);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Construct composite widget.                                    */
-/*--------------------------------------------------------------------------*/
-static void
-gl_merge_ui_text_field_ws_construct (glMergeUITextFieldWS * field_ws,
-                                    glMergeType type,
-                                    gchar * src)
-{
-       GtkWidget *whbox, *wtable, *wlabel, *whline, *wentry;
-       glMergeInput *mp;
-       glMergeRawField *sample_field;
-       GList *sample_field_list=NULL, *p;
-       gint n_fields, i;
-       EntryNode *entry_node;
-
-       field_ws->type = type;
-       field_ws->entry_list = NULL;
-
-       mp = gl_merge_open( type, NULL, src );
-       sample_field_list = gl_merge_get_raw_record (mp);
-       gl_merge_close(mp);
-       n_fields = g_list_length( sample_field_list );
-
-       whbox = GTK_WIDGET (field_ws);
-
-       wtable = gtk_table_new (n_fields + 2, 3, FALSE);
-       gtk_table_set_col_spacings (GTK_TABLE (wtable), 20);
-       gtk_table_set_row_spacings (GTK_TABLE (wtable), 10);
-       gtk_box_pack_start (GTK_BOX (whbox), wtable, FALSE, FALSE, GNOME_PAD);
-
-       wlabel = gtk_label_new (_("Column"));
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 1, 0.5);
-       gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1);
-
-       wlabel = gtk_label_new (_("Custom field key"));
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-       gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 1, 2, 0, 1);
-
-       wlabel = gtk_label_new (_("Sample data"));
-       gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-       gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 2, 3, 0, 1);
-
-       whline = gtk_hseparator_new ();
-       gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 0, 1, 1, 2);
-       whline = gtk_hseparator_new ();
-       gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 1, 2, 1, 2);
-       whline = gtk_hseparator_new ();
-       gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 2, 3, 1, 2);
-
-       for (p = sample_field_list, i = 0; p != NULL; p = p->next, i++) {
-               sample_field = p->data;
-
-               wlabel = gtk_label_new (sample_field->loc);
-               gtk_misc_set_alignment (GTK_MISC (wlabel), 1, 0.5);
-               gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel,
-                                          0, 1, i + 2, i + 3);
-
-               wentry = gtk_entry_new ();
-               gtk_entry_set_text (GTK_ENTRY (wentry), sample_field->loc);
-               gtk_widget_set_usize (wentry, 100, 0);
-               gtk_table_attach_defaults (GTK_TABLE (wtable), wentry,
-                                          1, 2, i + 2, i + 3);
-
-               g_signal_connect_swapped (G_OBJECT (wentry), "changed",
-                                         G_CALLBACK(field_ws_changed_cb),
-                                         G_OBJECT (field_ws));
-
-               wlabel = gtk_label_new (sample_field->value);
-               gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
-               gtk_label_set_justify (GTK_LABEL(wlabel), GTK_JUSTIFY_LEFT);
-               gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel,
-                                          2, 3, i + 2, i + 3);
-
-               entry_node = g_new0 (EntryNode, 1);
-               entry_node->loc = g_strdup (sample_field->loc);
-               entry_node->entry = wentry;
-               field_ws->entry_list =
-                   g_list_append (field_ws->entry_list, entry_node);
-
-       }
-
-       gl_merge_free_raw_record (&sample_field_list);
-
-}
-
-/*****************************************************************************/
-/* Set field definitions.  (associate key with locator)                      */
-/*****************************************************************************/
-void
-gl_merge_ui_text_field_ws_set_field_defs (glMergeUITextFieldWS * field_ws,
-                                         GList * field_defs)
-{
-       GList *p_entry, *p_defs;
-       EntryNode *entry;
-       glMergeFieldDefinition *def;
-
-       for (p_entry = field_ws->entry_list; p_entry != NULL;
-            p_entry = p_entry->next) {
-               entry = (EntryNode *) p_entry->data;
-
-               for (p_defs = field_defs; p_defs != NULL; p_defs = p_defs->next) {
-                       def = (glMergeFieldDefinition *) p_defs->data;
-
-                       if (strcmp (entry->loc, def->loc) == 0) {
-                               gtk_entry_set_text (GTK_ENTRY (entry->entry),
-                                                   def->key);
-                       }
-               }
-       }
-
-}
-
-/*****************************************************************************/
-/* Get field definitions.  (associate key with locator)                      */
-/*****************************************************************************/
-GList *
-gl_merge_ui_text_field_ws_get_field_defs (glMergeUITextFieldWS * field_ws)
-{
-       GList *p_entry, *defs_list = NULL;
-       EntryNode *entry;
-       glMergeFieldDefinition *def;
-
-       for (p_entry = field_ws->entry_list; p_entry != NULL;
-            p_entry = p_entry->next) {
-               entry = (EntryNode *) p_entry->data;
-
-               def = g_new0 (glMergeFieldDefinition, 1);
-
-               def->loc = g_strdup (entry->loc);
-               def->key =
-                   gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1);
-
-               defs_list = g_list_append (defs_list, def);
-
-       }
-
-       return defs_list;
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Callback for when our backend widget has changed.              */
-/*--------------------------------------------------------------------------*/
-static void
-field_ws_changed_cb (glMergeUITextFieldWS * field_ws)
-{
-       /* Emit our "changed" signal */
-       g_signal_emit (G_OBJECT (field_ws),
-                      merge_ui_text_field_ws_signals[CHANGED], 0);
-}
diff --git a/glabels2/src/merge-ui-text.h b/glabels2/src/merge-ui-text.h
deleted file mode 100644 (file)
index 42006f2..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_ui_text.h:  text-file merge user interface backend header
- *
- *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#ifndef __MERGE_UI_TEXT_H__
-#define __MERGE_UI_TEXT_H__
-
-#include <gnome.h>
-
-#include "merge.h"
-
-/*======================================================*/
-/* Merge source selection widget                        */
-/*======================================================*/
-#define GL_TYPE_MERGE_UI_TEXT_SRC (gl_merge_ui_text_src_get_type ())
-#define GL_MERGE_UI_TEXT_SRC(obj) \
-        (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_TEXT_SRC, glMergeUITextSrc ))
-#define GL_MERGE_UI_TEXT_SRC_CLASS(klass) \
-        (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_TEXT_SRC, glMergeUITextSrcClass))
-#define GL_IS_MERGE_UI_TEXT_SRC(obj) \
-        (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_TEXT_SRC))
-#define GL_IS_MERGE_UI_TEXT_SRC_CLASS(klass) \
-        (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_TEXT_SRC))
-
-typedef struct _glMergeUITextSrc glMergeUITextSrc;
-typedef struct _glMergeUITextSrcClass glMergeUITextSrcClass;
-
-struct _glMergeUITextSrc {
-       GtkVBox parent_widget;
-
-       glMergeType type;
-       GtkWidget *entry;
-};
-
-struct _glMergeUITextSrcClass {
-       GtkVBoxClass parent_class;
-
-       void (*changed) (glMergeUITextSrc * src, gpointer user_data);
-};
-
-extern guint gl_merge_ui_text_src_get_type (void);
-extern GtkWidget *gl_merge_ui_text_src_new (glMergeType type);
-extern void gl_merge_ui_text_src_set_value (glMergeUITextSrc * src,
-                                           gchar * text);
-extern gchar *gl_merge_ui_text_src_get_value (glMergeUITextSrc * src);
-
-/*======================================================*/
-/* Merge field selection/definition widget.             */
-/*======================================================*/
-#define GL_TYPE_MERGE_UI_TEXT_FIELD_WS (gl_merge_ui_text_field_ws_get_type ())
-#define GL_MERGE_UI_TEXT_FIELD_WS(obj) \
-        (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_TEXT_FIELD_WS, glMergeUITextFieldWS ))
-#define GL_MERGE_UI_TEXT_FIELD_WS_CLASS(klass) \
-        (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_TEXT_FIELD_WS, glMergeUITextFieldWSClass))
-#define GL_IS_MERGE_UI_TEXT_FIELD_WS(obj) \
-        (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_TEXT_FIELD_WS))
-#define GL_IS_MERGE_UI_TEXT_FIELD_WS_CLASS(klass) \
-        (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_TEXT_FIELD_WS))
-
-typedef struct _glMergeUITextFieldWS glMergeUITextFieldWS;
-typedef struct _glMergeUITextFieldWSClass glMergeUITextFieldWSClass;
-
-struct _glMergeUITextFieldWS {
-       GtkHBox parent_widget;
-
-       glMergeType type;
-       GList *entry_list;
-};
-
-struct _glMergeUITextFieldWSClass {
-       GtkHBoxClass parent_class;
-
-       void (*changed) (glMergeUITextFieldWS * field_ws, gpointer user_data);
-};
-
-extern guint gl_merge_ui_text_field_ws_get_type (void);
-extern GtkWidget *gl_merge_ui_text_field_ws_new (glMergeType type,
-                                                gchar * src);
-extern void gl_merge_ui_text_field_ws_set_field_defs (glMergeUITextFieldWS * field_ws,
-                                                     GList * field_defs);
-extern GList *gl_merge_ui_text_field_ws_get_field_defs (glMergeUITextFieldWS *
-                                                       field_ws);
-
-#endif
diff --git a/glabels2/src/merge-ui.c b/glabels2/src/merge-ui.c
deleted file mode 100644 (file)
index 7e6f6b8..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_ui.c:  document merge user interface module
- *
- *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#include <config.h>
-
-#include "merge-ui.h"
-#include "marshal.h"
-
-/* Backends */
-#include "merge-ui-text.h"
-
-#include "debug.h"
-
-/*===========================================*/
-/* Private types                             */
-/*===========================================*/
-
-enum {
-       CHANGED,
-       LAST_SIGNAL
-};
-
-typedef struct {
-
-       GtkWidget * (*src_new) (glMergeType);
-       void (*src_set_value) ();
-       gchar * (*src_get_value) ();
-
-       GtkWidget * (*field_ws_new) (glMergeType, gchar *);
-       void (*field_ws_set_field_defs) ();
-       GList * (*field_ws_get_field_defs) ();
-
-} BackendFunctions;
-
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
-
-static GtkContainerClass *parent_class;
-
-static gint merge_ui_src_signals[LAST_SIGNAL] = { 0 };
-static gint merge_ui_field_ws_signals[LAST_SIGNAL] = { 0 };
-
-static BackendFunctions func[GL_MERGE_N_TYPES];
-
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
-
-static void gl_merge_ui_src_class_init (glMergeUISrcClass * class);
-static void gl_merge_ui_src_instance_init (glMergeUISrc * src);
-static void gl_merge_ui_src_finalize (GObject * object);
-
-static void src_changed_cb (glMergeUISrc * src);
-
-static void gl_merge_ui_field_ws_class_init (glMergeUIFieldWSClass * class);
-static void gl_merge_ui_field_ws_instance_init (glMergeUIFieldWS * field_ws);
-static void gl_merge_ui_field_ws_finalize (GObject * object);
-
-static void field_ws_changed_cb (glMergeUIFieldWS * field_ws);
-\f
-/*****************************************************************************/
-/* Initialize module.                                                        */
-/*****************************************************************************/
-void
-gl_merge_ui_init (void)
-{
-       gint i;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       /* Register backend functions. */
-
-       i = GL_MERGE_NONE;
-       func[i].src_new = NULL;
-       func[i].src_set_value = NULL;
-       func[i].src_get_value = NULL;
-       func[i].field_ws_new = NULL;
-       func[i].field_ws_set_field_defs = NULL;
-       func[i].field_ws_get_field_defs = NULL;
-
-       i = GL_MERGE_TEXT_TAB;
-       func[i].src_new = gl_merge_ui_text_src_new;
-       func[i].src_set_value = gl_merge_ui_text_src_set_value;
-       func[i].src_get_value = gl_merge_ui_text_src_get_value;
-       func[i].field_ws_new = gl_merge_ui_text_field_ws_new;
-       func[i].field_ws_set_field_defs =
-               gl_merge_ui_text_field_ws_set_field_defs;
-       func[i].field_ws_get_field_defs =
-               gl_merge_ui_text_field_ws_get_field_defs;
-
-       i = GL_MERGE_TEXT_COMMA;
-       func[i].src_new = gl_merge_ui_text_src_new;
-       func[i].src_set_value = gl_merge_ui_text_src_set_value;
-       func[i].src_get_value = gl_merge_ui_text_src_get_value;
-       func[i].field_ws_new = gl_merge_ui_text_field_ws_new;
-       func[i].field_ws_set_field_defs =
-               gl_merge_ui_text_field_ws_set_field_defs;
-       func[i].field_ws_get_field_defs =
-               gl_merge_ui_text_field_ws_get_field_defs;
-
-       i = GL_MERGE_TEXT_COLON;
-       func[i].src_new = gl_merge_ui_text_src_new;
-       func[i].src_set_value = gl_merge_ui_text_src_set_value;
-       func[i].src_get_value = gl_merge_ui_text_src_get_value;
-       func[i].field_ws_new = gl_merge_ui_text_field_ws_new;
-       func[i].field_ws_set_field_defs =
-               gl_merge_ui_text_field_ws_set_field_defs;
-       func[i].field_ws_get_field_defs =
-               gl_merge_ui_text_field_ws_get_field_defs;
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Boilerplate Object stuff.                                                 */
-/*****************************************************************************/
-guint
-gl_merge_ui_src_get_type (void)
-{
-       static guint merge_ui_src_type = 0;
-
-       if (!merge_ui_src_type) {
-               GTypeInfo merge_ui_src_info = {
-                       sizeof (glMergeUISrcClass),
-                       NULL,
-                       NULL,
-                       (GClassInitFunc) gl_merge_ui_src_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (glMergeUISrc),
-                       0,
-                       (GInstanceInitFunc) gl_merge_ui_src_instance_init,
-               };
-
-               merge_ui_src_type =
-                       g_type_register_static (gtk_vbox_get_type (),
-                                               "glMergeUISrc",
-                                               &merge_ui_src_info, 0);
-       }
-
-       return merge_ui_src_type;
-}
-
-static void
-gl_merge_ui_src_class_init (glMergeUISrcClass * class)
-{
-       GObjectClass *object_class;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       object_class = (GObjectClass *) class;
-
-       parent_class = gtk_type_class (gtk_vbox_get_type ());
-
-       object_class->finalize = gl_merge_ui_src_finalize;
-
-       merge_ui_src_signals[CHANGED] =
-           g_signal_new ("changed",
-                         G_OBJECT_CLASS_TYPE(object_class),
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET (glMergeUISrcClass, changed),
-                         NULL, NULL,
-                         gl_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-static void
-gl_merge_ui_src_instance_init (glMergeUISrc * src)
-{
-       gl_debug (DEBUG_MERGE, "START");
-       src->backend_widget = NULL;
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-static void
-gl_merge_ui_src_finalize (GObject * object)
-{
-       glMergeUISrc *src;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GL_IS_MERGE_UI_SRC (object));
-
-       src = GL_MERGE_UI_SRC (object);
-
-       G_OBJECT_CLASS (parent_class)->finalize (object);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-GtkWidget *
-gl_merge_ui_src_new (void)
-{
-       glMergeUISrc *src;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       src = g_object_new (gl_merge_ui_src_get_type (), NULL);
-
-       src->type = GL_MERGE_NONE;
-       src->backend_widget = gtk_label_new (_("N/A"));
-       gtk_misc_set_alignment (GTK_MISC (src->backend_widget), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (src), src->backend_widget, TRUE, TRUE,
-                           0);
-
-       gl_debug (DEBUG_MERGE, "END");
-
-       return GTK_WIDGET (src);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Callback for when our backend widget has changed.              */
-/*--------------------------------------------------------------------------*/
-static void
-src_changed_cb (glMergeUISrc * src)
-{
-       gl_debug (DEBUG_MERGE, "START");
-
-       /* Emit our "changed" signal */
-       g_signal_emit (G_OBJECT (src), merge_ui_src_signals[CHANGED], 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Set type.                                                                 */
-/*****************************************************************************/
-void
-gl_merge_ui_src_set_type (glMergeUISrc * src,
-                         glMergeType type)
-{
-       gl_debug (DEBUG_MERGE, "START");
-
-       if (type != src->type) {
-
-               gtk_widget_destroy (src->backend_widget);
-
-               src->type = type;
-
-               if (type != GL_MERGE_NONE) {
-                       src->backend_widget = (func[type].src_new) (type);
-               } else {
-                       src->backend_widget = gtk_label_new (_("N/A"));
-                       gtk_misc_set_alignment (GTK_MISC (src->backend_widget),
-                                               0, 0.5);
-               }
-
-               gtk_box_pack_start (GTK_BOX (src), src->backend_widget,
-                                   TRUE, TRUE, 0);
-
-               if (GTK_WIDGET_VISIBLE (src)) {
-                       gtk_widget_show_all (src->backend_widget);
-               }
-
-               if (type != GL_MERGE_NONE) {
-                       g_signal_connect_swapped (G_OBJECT(src->backend_widget),
-                                                 "changed",
-                                                 G_CALLBACK(src_changed_cb),
-                                                 G_OBJECT (src));
-               }
-
-               /* Emit our "changed" signal */
-               g_signal_emit (G_OBJECT (src),
-                              merge_ui_src_signals[CHANGED], 0);
-       }
-
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Set src.                                                                  */
-/*****************************************************************************/
-void
-gl_merge_ui_src_set_value (glMergeUISrc * src,
-                          gchar * text)
-{
-       glMergeType type;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       type = src->type;
-
-       if (type != GL_MERGE_NONE) {
-               func[type].src_set_value (src->backend_widget, text);
-       } else {
-               gl_debug (DEBUG_MERGE, "END");
-               return;
-       }
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Get src name.                                                             */
-/*****************************************************************************/
-gchar *
-gl_merge_ui_src_get_value (glMergeUISrc * src)
-{
-       glMergeType type;
-
-       gl_debug (DEBUG_MERGE, "");
-
-       type = src->type;
-
-       if (type != GL_MERGE_NONE) {
-               return func[type].src_get_value (src->backend_widget);
-       } else {
-               return NULL;
-       }
-
-}
-
-/*****************************************************************************/
-/* Boilerplate Object stuff.                                                 */
-/*****************************************************************************/
-guint
-gl_merge_ui_field_ws_get_type (void)
-{
-       static guint merge_ui_field_ws_type = 0;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       if (!merge_ui_field_ws_type) {
-               GTypeInfo merge_ui_field_ws_info = {
-                       sizeof (glMergeUIFieldWSClass),
-                       NULL,
-                       NULL,
-                       (GClassInitFunc) gl_merge_ui_field_ws_class_init,
-                       NULL,
-                       NULL,
-                       sizeof (glMergeUIFieldWS),
-                       0,
-                       (GInstanceInitFunc) gl_merge_ui_field_ws_instance_init,
-               };
-
-               merge_ui_field_ws_type =
-                       g_type_register_static (gtk_vbox_get_type (),
-                                               "glMergeUIFieldWS",
-                                               &merge_ui_field_ws_info, 0);
-       }
-
-       gl_debug (DEBUG_MERGE, "END");
-
-       return merge_ui_field_ws_type;
-}
-
-static void
-gl_merge_ui_field_ws_class_init (glMergeUIFieldWSClass * class)
-{
-       GObjectClass *object_class;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       object_class = (GObjectClass *) class;
-
-       parent_class = gtk_type_class (gtk_vbox_get_type ());
-
-       object_class->finalize = gl_merge_ui_field_ws_finalize;
-
-       merge_ui_field_ws_signals[CHANGED] =
-           g_signal_new ("changed",
-                         G_OBJECT_CLASS_TYPE(object_class),
-                         G_SIGNAL_RUN_LAST,
-                         G_STRUCT_OFFSET (glMergeUIFieldWSClass, changed),
-                         NULL, NULL,
-                         gl_marshal_VOID__VOID,
-                         G_TYPE_NONE, 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-static void
-gl_merge_ui_field_ws_instance_init (glMergeUIFieldWS * field_ws)
-{
-       gl_debug (DEBUG_MERGE, "START");
-
-       field_ws->type = GL_MERGE_NONE;
-       field_ws->src = NULL;
-       field_ws->backend_widget = NULL;
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-static void
-gl_merge_ui_field_ws_finalize (GObject * object)
-{
-       glMergeUIFieldWS *field_ws;
-       glMergeUIFieldWSClass *class;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       g_return_if_fail (object != NULL);
-       g_return_if_fail (GL_IS_MERGE_UI_FIELD_WS (object));
-
-       field_ws = GL_MERGE_UI_FIELD_WS (object);
-
-       G_OBJECT_CLASS (parent_class)->finalize (object);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-GtkWidget *
-gl_merge_ui_field_ws_new (void)
-{
-       glMergeUIFieldWS *field_ws;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       field_ws = g_object_new (gl_merge_ui_field_ws_get_type (), NULL);
-
-       field_ws->type = GL_MERGE_NONE;
-       field_ws->backend_widget = gtk_label_new (_("N/A"));
-       gtk_misc_set_alignment (GTK_MISC (field_ws->backend_widget), 0, 0.5);
-       gtk_box_pack_start (GTK_BOX (field_ws), field_ws->backend_widget,
-                           FALSE, FALSE, 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-
-       return GTK_WIDGET (field_ws);
-}
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Callback for when our backend widget has changed.              */
-/*--------------------------------------------------------------------------*/
-static void
-field_ws_changed_cb (glMergeUIFieldWS * field_ws)
-{
-       gl_debug (DEBUG_MERGE, "START");
-
-       /* Emit our "changed" signal */
-       g_signal_emit (G_OBJECT (field_ws),
-                      merge_ui_field_ws_signals[CHANGED], 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* set type and src data, create appropriate backend widget.                 */
-/*****************************************************************************/
-void
-gl_merge_ui_field_ws_set_type_src (glMergeUIFieldWS * field_ws,
-                                  glMergeType type,
-                                  gchar * src)
-{
-       gl_debug (DEBUG_MERGE, "START");
-
-       if (field_ws->src != NULL)
-               g_free (field_ws->src);
-       if (field_ws->backend_widget != NULL) {
-               gtk_widget_destroy (field_ws->backend_widget);
-       }
-
-       field_ws->type = type;
-       field_ws->src = g_strdup (src);
-
-       if (type != GL_MERGE_NONE) {
-               field_ws->backend_widget =
-                   (func[type].field_ws_new) (type, src);
-       } else {
-               field_ws->backend_widget = gtk_label_new (_("N/A"));
-               gtk_misc_set_alignment (GTK_MISC (field_ws->backend_widget), 0,
-                                       0.5);
-       }
-
-       gtk_box_pack_start (GTK_BOX (field_ws), field_ws->backend_widget,
-                           FALSE, FALSE, 0);
-
-       if (type != GL_MERGE_NONE) {
-               g_signal_connect_swapped (G_OBJECT(field_ws->backend_widget),
-                                         "changed",
-                                         G_CALLBACK(field_ws_changed_cb),
-                                         G_OBJECT (field_ws));
-       }
-
-       if (GTK_WIDGET_VISIBLE (field_ws)) {
-               gtk_widget_show_all (field_ws->backend_widget);
-       }
-       /* Emit our "changed" signal */
-       g_signal_emit (G_OBJECT (field_ws),
-                      merge_ui_field_ws_signals[CHANGED], 0);
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Set field definitions (associate ids with raw fields).                    */
-/*****************************************************************************/
-void
-gl_merge_ui_field_ws_set_field_defs (glMergeUIFieldWS * field_ws,
-                                    GList * field_defs)
-{
-       glMergeType type;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       type = field_ws->type;
-
-       if (type != GL_MERGE_NONE) {
-
-               (func[type].field_ws_set_field_defs) (field_ws->backend_widget,
-                                                     field_defs);
-
-               /* Emit our "changed" signal */
-               g_signal_emit (G_OBJECT (field_ws),
-                              merge_ui_field_ws_signals[CHANGED], 0);
-
-       }
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
-/*****************************************************************************/
-/* Get field definitions (associate ids with raw fields).                    */
-/*****************************************************************************/
-GList *
-gl_merge_ui_field_ws_get_field_defs (glMergeUIFieldWS * field_ws)
-{
-       glMergeType type;
-
-       gl_debug (DEBUG_MERGE, "");
-
-       type = field_ws->type;
-
-       if (type != GL_MERGE_NONE) {
-
-               return (func[type].field_ws_get_field_defs) (field_ws->
-                                                            backend_widget);
-       } else {
-
-               return NULL;
-
-       }
-
-}
diff --git a/glabels2/src/merge-ui.h b/glabels2/src/merge-ui.h
deleted file mode 100644 (file)
index e5a7e71..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  merge_ui.h:  document merge user interface module header file
- *
- *  Copyright (C) 2002  Jim Evins <evins@snaught.com>.
- *
- *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- */
-#ifndef __MERGE_UI_H__
-#define __MERGE_UI_H__
-
-#include <gnome.h>
-
-#include "merge.h"
-
-extern void
- gl_merge_ui_init (void);
-
-/*======================================================*/
-/* Merge source selection widget                        */
-/*======================================================*/
-#define GL_TYPE_MERGE_UI_SRC (gl_merge_ui_src_get_type ())
-#define GL_MERGE_UI_SRC(obj) \
-        (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_SRC, glMergeUISrc ))
-#define GL_MERGE_UI_SRC_CLASS(klass) \
-        (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_SRC, glMergeUISrcClass))
-#define GL_IS_MERGE_UI_SRC(obj) \
-        (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_SRC))
-#define GL_IS_MERGE_UI_SRC_CLASS(klass) \
-        (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_SRC))
-
-typedef struct _glMergeUISrc glMergeUISrc;
-typedef struct _glMergeUISrcClass glMergeUISrcClass;
-
-struct _glMergeUISrc {
-       GtkVBox parent_widget;
-
-       glMergeType type;
-       GtkWidget *backend_widget;
-};
-
-struct _glMergeUISrcClass {
-       GtkVBoxClass parent_class;
-
-       void (*changed) (glMergeUISrc * src, gpointer user_data);
-};
-
-extern guint gl_merge_ui_src_get_type (void);
-extern GtkWidget *gl_merge_ui_src_new (void);
-extern void gl_merge_ui_src_set_type (glMergeUISrc * src, glMergeType type);
-extern void gl_merge_ui_src_set_value (glMergeUISrc * src, gchar * text);
-extern gchar *gl_merge_ui_src_get_value (glMergeUISrc * src);
-
-/*======================================================*/
-/* Merge field selection/definition widget.             */
-/*======================================================*/
-#define GL_TYPE_MERGE_UI_FIELD_WS (gl_merge_ui_field_ws_get_type ())
-#define GL_MERGE_UI_FIELD_WS(obj) \
-        (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_FIELD_WS, glMergeUIFieldWS ))
-#define GL_MERGE_UI_FIELD_WS_CLASS(klass) \
-        (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_FIELD_WS, glMergeUIFieldWSClass))
-#define GL_IS_MERGE_UI_FIELD_WS(obj) \
-        (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_FIELD_WS))
-#define GL_IS_MERGE_UI_FIELD_WS_CLASS(klass) \
-        (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_FIELD_WS))
-
-typedef struct _glMergeUIFieldWS glMergeUIFieldWS;
-typedef struct _glMergeUIFieldWSClass glMergeUIFieldWSClass;
-
-struct _glMergeUIFieldWS {
-       GtkVBox parent_widget;
-
-       glMergeType type;
-       gchar *src;
-       GtkWidget *backend_widget;
-};
-
-struct _glMergeUIFieldWSClass {
-       GtkVBoxClass parent_class;
-
-       void (*changed) (glMergeUIFieldWS * field_ws, gpointer user_data);
-};
-
-extern guint gl_merge_ui_field_ws_get_type (void);
-extern GtkWidget *gl_merge_ui_field_ws_new (void);
-extern void gl_merge_ui_field_ws_set_type_src (glMergeUIFieldWS * field_ws,
-                                              glMergeType type,
-                                              gchar * src);
-extern void gl_merge_ui_field_ws_set_field_defs (glMergeUIFieldWS * field_ws,
-                                                GList * field_defs);
-extern GList *gl_merge_ui_field_ws_get_field_defs (glMergeUIFieldWS * field_ws);
-
-#endif
index ed8133220805caa0f9907f833b16269819c9a83b..5d6a7feed707c2f231239bc04238bea3c4f2126d 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  merge.c:  document merge module
  *
- *  Copyright (C) 2001  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
  *
  *  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
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
-
 #include <config.h>
 
 #include <gnome.h>
+#include <string.h>
 
 #include "merge.h"
-#include "merge-text.h"
 
 #include "debug.h"
 
-/*===========================================*/
-/* Private types                             */
-/*===========================================*/
-typedef struct {
-       gchar *short_text;
-       gchar *long_text;
-} TypeTexts;
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+struct _glMergePrivate {
+       gchar             *name;
+       gchar             *description;
+       gchar             *src;
+       glMergeSrcType     src_type;
+};
+
+enum {
+       LAST_SIGNAL
+};
 
 typedef struct {
 
-       glMergeInput * (*open) (glMergeType, GList *, gchar *);
-       void (*close) (glMergeInput *);
-       glMergeRecord * (*get_record) (glMergeInput *);
-       GList * (*get_raw_record) (glMergeInput *);
+       GType              type;
+       gchar             *name;
+       gchar             *description;
+       glMergeSrcType     src_type;
+
+       const gchar       *first_arg_name;
+       va_list            args;
+
+} Backend;
 
-} BackendFunctions;
+/*========================================================*/
+/* Private globals.                                       */
+/*========================================================*/
 
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
+static GObjectClass *parent_class = NULL;
 
-static TypeTexts type_text[GL_MERGE_N_TYPES];
+static guint signals[LAST_SIGNAL] = {0};
 
-static BackendFunctions func[GL_MERGE_N_TYPES];
+static GList *backends = NULL;
+
+/*========================================================*/
+/* Private function prototypes.                           */
+/*========================================================*/
+
+static void gl_merge_class_init    (glMergeClass *klass);
+static void gl_merge_instance_init (glMerge      *object);
+static void gl_merge_finalize      (GObject      *object);
 
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
 
 \f
 /*****************************************************************************/
-/* Initialize module.                                                        */
+/* Register a new merge backend.                                             */
 /*****************************************************************************/
 void
-gl_merge_init (void)
+gl_merge_register_backend (GType              type,
+                          gchar             *name,
+                          gchar             *description,
+                          glMergeSrcType     src_type,
+                          const gchar       *first_arg_name,
+                          ...)
 {
-       gint i;
+       Backend *backend;
+       va_list  args;
+       gchar   *a_nam;
+       gpointer a_val;
 
-       gl_debug (DEBUG_MERGE, "START");
+       backend = g_new0 (Backend, 1);
 
-       /* Register backend functions and data. */
-
-       i = GL_MERGE_NONE;
-       func[i].open = NULL;
-       func[i].close = NULL;
-       func[i].get_record = NULL;
-       func[i].get_raw_record = NULL;
-       type_text[i].short_text = "None";
-       type_text[i].long_text = _("None");
-
-       i = GL_MERGE_TEXT_TAB;
-       func[i].open = gl_merge_text_open;
-       func[i].close = gl_merge_text_close;
-       func[i].get_record = gl_merge_text_get_record;
-       func[i].get_raw_record = gl_merge_text_get_raw_record;
-       type_text[i].short_text = "Text/Tab";
-       type_text[i].long_text = _("Text with tab separators");
-
-       i = GL_MERGE_TEXT_COMMA;
-       func[i].open = gl_merge_text_open;
-       func[i].close = gl_merge_text_close;
-       func[i].get_record = gl_merge_text_get_record;
-       func[i].get_raw_record = gl_merge_text_get_raw_record;
-       type_text[i].short_text = "Text/Comma";
-       type_text[i].long_text = _("Text with comma separators");
-
-       i = GL_MERGE_TEXT_COLON;
-       func[i].open = gl_merge_text_open;
-       func[i].close = gl_merge_text_close;
-       func[i].get_record = gl_merge_text_get_record;
-       func[i].get_raw_record = gl_merge_text_get_raw_record;
-       type_text[i].short_text = "Text/Colon";
-       type_text[i].long_text = _("Text with colon separators");
+       backend->type = type;
+       backend->name = g_strdup (name);
+       backend->description = g_strdup (description);
+
+       backend->first_arg_name = first_arg_name;
+       va_start (args, first_arg_name);
+       G_VA_COPY (backend->args, args);
+       va_end (args);
+
+       backends = g_list_append (backends, backend);
 
-       gl_debug (DEBUG_MERGE, "END");
 }
 
 /*****************************************************************************/
-/* Create new merge information structure.                                   */
+/* Get list of registered backend descriptions.                              */
 /*****************************************************************************/
-glMerge *gl_merge_new (void)
+GList *
+gl_merge_get_descriptions (void)
 {
-       gl_debug (DEBUG_MERGE, "");
+       GList   *descriptions = NULL;
+       GList   *p;
+       Backend *backend;
+
+       descriptions = g_list_append (descriptions, g_strdup(_("None")));
+
+       for ( p=backends; p!=NULL; p=p->next) {
+               backend = (Backend *)p->data;
+               descriptions = g_list_append (descriptions,
+                                             g_strdup(backend->description));
+       }
 
-       return g_new0 (glMerge, 1);
+       return descriptions;
 }
 
 /*****************************************************************************/
-/* Duplicate merge information structure.                                    */
+/* Free list of descriptions.                                                */
 /*****************************************************************************/
-glMerge *gl_merge_dup (glMerge *orig)
+void
+gl_merge_free_descriptions (GList **descriptions)
 {
-       glMerge *new;
+       GList *p;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       new = gl_merge_new ();
+       for (p = *descriptions; p != NULL; p = p->next) {
+               g_free (p->data);
+               p->data = NULL;
+       }
 
-       new->type       = orig->type;
-       new->src        = g_strdup (orig->src);
-       new->field_defs = gl_merge_dup_field_def_list (orig->field_defs);
+       g_list_free (*descriptions);
+       *descriptions = NULL;
 
        gl_debug (DEBUG_MERGE, "END");
-       return new;
 }
 
 /*****************************************************************************/
-/* Free existing merge information structure.                                */
+/* Lookup name of backend from description.                                  */
 /*****************************************************************************/
-void    gl_merge_free (glMerge **merge)
+gchar *
+gl_merge_description_to_name (gchar *description)
 {
-       gl_debug (DEBUG_MERGE, "START");
+       GList   *p;
+       Backend *backend;
 
-       g_free ((*merge)->src);
-       (*merge)->src = NULL;
-       gl_merge_free_field_def_list (&(*merge)->field_defs);
+       if (g_strcasecmp(description, _("None")) == 0) {
+               return g_strdup("None");
+       }
 
-       *merge = NULL;
+       for ( p=backends; p!=NULL; p=p->next) {
+               backend = (Backend *)p->data;
+               if (g_strcasecmp(description, backend->description) == 0) {
+                       return g_strdup(backend->name);
+               }
+       }
 
-       gl_debug (DEBUG_MERGE, "END");
+       return g_strdup("None");
 }
 
 /*****************************************************************************/
-/* Lookup type from short text.                                              */
+/* Boilerplate object stuff.                                                 */
 /*****************************************************************************/
-glMergeType
-gl_merge_text_to_type (gchar * text)
+GType
+gl_merge_get_type (void)
+{
+       static GType type = 0;
+
+       if (!type) {
+               GTypeInfo info = {
+                       sizeof (glMergeClass),
+                       NULL,
+                       NULL,
+                       (GClassInitFunc) gl_merge_class_init,
+                       NULL,
+                       NULL,
+                       sizeof (glMerge),
+                       0,
+                       (GInstanceInitFunc) gl_merge_instance_init,
+               };
+
+               type = g_type_register_static (G_TYPE_OBJECT,
+                                              "glMerge", &info, 0);
+       }
+
+       return type;
+}
+
+static void
+gl_merge_class_init (glMergeClass *klass)
 {
-       glMergeType type;
+       GObjectClass *object_class = (GObjectClass *) klass;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       for (type = 0; type < GL_MERGE_N_TYPES; type++) {
-               if (g_strcasecmp (text, type_text[type].short_text) == 0) {
-                       gl_debug (DEBUG_MERGE, "END");
-                       return type;
-               }
-       }
+       parent_class = g_type_class_peek_parent (klass);
+
+       object_class->finalize = gl_merge_finalize;
 
        gl_debug (DEBUG_MERGE, "END");
+}
+
+static void
+gl_merge_instance_init (glMerge *merge)
+{
+       gl_debug (DEBUG_MERGE, "START");
+
+       merge->private = g_new0 (glMergePrivate, 1);
 
-       return GL_MERGE_NONE;
+       gl_debug (DEBUG_MERGE, "END");
 }
 
-/*****************************************************************************/
-/* Lookup short text for given type.                                         */
-/*****************************************************************************/
-gchar *
-gl_merge_type_to_text (glMergeType type)
+static void
+gl_merge_finalize (GObject *object)
 {
-       gl_debug (DEBUG_MERGE, "");
+       gl_debug (DEBUG_MERGE, "START");
+
+       g_return_if_fail (object && GL_IS_MERGE (object));
+
+       g_free (GL_MERGE(object)->private->name);
+       g_free (GL_MERGE(object)->private->description);
+       g_free (GL_MERGE(object)->private->src);
+       g_free (GL_MERGE(object)->private);
 
-       return g_strdup (type_text[type].short_text);
+       G_OBJECT_CLASS (parent_class)->finalize (object);
+
+       gl_debug (DEBUG_MERGE, "END");
 }
 
 /*****************************************************************************/
-/* Lookup type from long descriptive text.                                   */
+/* New merge object.                                                         */
 /*****************************************************************************/
-glMergeType
-gl_merge_long_text_to_type (gchar * text)
+glMerge *
+gl_merge_new (gchar *name)
 {
-       glMergeType type;
+       glMerge *merge = NULL;
+       GList   *p;
+       Backend *backend;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       for (type = 0; type < GL_MERGE_N_TYPES; type++) {
-               if (g_strcasecmp (text, type_text[type].long_text) == 0) {
-                       gl_debug (DEBUG_MERGE, "END");
-                       return type;
+       for (p=backends; p!=NULL; p=p->next) {
+               backend = (Backend *)p->data;
+
+               if (g_strcasecmp(name, backend->name) == 0) {
+
+                       merge = GL_MERGE (g_object_new_valist (backend->type,
+                                                              backend->first_arg_name,
+                                                              backend->args));
+
+                       merge->private->name        = name;
+                       merge->private->description = backend->description;
+                       merge->private->src_type    = backend->src_type;
+
+                       break;
                }
        }
 
-       gl_debug (DEBUG_MERGE, "END");
-       return GL_MERGE_NONE;
-}
+       if ( (merge == NULL) && (g_strcasecmp (name, "None") != 0)) {
+               g_warning ("Unknown merge backend \"%s\"", name);
+       }
 
-/*****************************************************************************/
-/* Lookup longer, more descriptive text for given type.                      */
-/*****************************************************************************/
-gchar *
-gl_merge_type_to_long_text (glMergeType type)
-{
-       gl_debug (DEBUG_MERGE, "");
+       gl_debug (DEBUG_MERGE, "END");
 
-       return g_strdup (type_text[type].long_text);
+       return merge;
 }
 
 /*****************************************************************************/
-/* Retrieve a list of descriptive texts for all available types.             */
+/* Duplicate merge.                                                         */
 /*****************************************************************************/
-GList *
-gl_merge_get_long_texts_list (void)
+glMerge *
+gl_merge_dup (glMerge *src_merge)
 {
-       glMergeType type;
-       GList *list = NULL;
+       glMerge    *dst_merge;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       for (type = 0; type < GL_MERGE_N_TYPES; type++) {
+       if (src_merge == NULL) {
+               gl_debug (DEBUG_MERGE, "END (NULL)");
+               return NULL;
+       }
+
+       g_return_val_if_fail (GL_IS_MERGE (src_merge), NULL);
+
+       dst_merge = g_object_new (G_OBJECT_TYPE(src_merge), NULL);
+       dst_merge->private->name        = g_strdup (src_merge->private->name);
+       dst_merge->private->description = g_strdup (src_merge->private->description);
+       dst_merge->private->src         = g_strdup (src_merge->private->src);
+
+       if ( GL_MERGE_GET_CLASS(src_merge)->copy != NULL ) {
 
-               list = g_list_append (list, gl_merge_type_to_long_text (type));
+               /* We have an object specific method, use it */
+               GL_MERGE_GET_CLASS(src_merge)->copy (dst_merge, src_merge);
 
        }
 
        gl_debug (DEBUG_MERGE, "END");
-       return list;
+
+       return dst_merge;
 }
 
 /*****************************************************************************/
-/* Free list of descriptive texts.                                           */
+/* Get name of merge.                                                        */
 /*****************************************************************************/
-void
-gl_merge_free_long_texts_list (GList ** list)
+gchar *
+gl_merge_get_name (glMerge *merge)
 {
-       GList *p;
-
-       gl_debug (DEBUG_MERGE, "START");
+       gl_debug (DEBUG_MERGE, "");
 
-       for (p = *list; p != NULL; p = p->next) {
-               g_free (p->data);
-               p->data = NULL;
+       if (merge == NULL) {
+               return g_strdup("None");
        }
 
-       g_list_free (*list);
-       *list = NULL;
+       g_return_val_if_fail (GL_IS_MERGE (merge), g_strdup("None"));
 
-       gl_debug (DEBUG_MERGE, "END");
+       return g_strdup(merge->private->name);
 }
 
 /*****************************************************************************/
-/* Duplicate field definitions.                                              */
+/* Get description of merge.                                                 */
 /*****************************************************************************/
-GList *gl_merge_dup_field_def_list (GList * orig)
+gchar *
+gl_merge_get_description (glMerge *merge)
 {
-       GList *new, *p_orig;
-       glMergeFieldDefinition *fd_new, *fd_orig;
+       gl_debug (DEBUG_MERGE, "");
 
-       gl_debug (DEBUG_MERGE, "START");
+       if (merge == NULL) {
+               return g_strdup(_("None"));
+       }
+
+       g_return_val_if_fail (GL_IS_MERGE (merge), g_strdup(_("None")));
 
-       new = NULL;
-       for (p_orig = orig; p_orig != NULL; p_orig = p_orig->next) {
-               fd_orig = (glMergeFieldDefinition *) p_orig->data;
-               fd_new  = g_new0 (glMergeFieldDefinition, 1);
+       return g_strdup(merge->private->description);
+}
 
-               fd_new->key = g_strdup (fd_orig->key);
-               fd_new->loc = g_strdup (fd_orig->loc);
+/*****************************************************************************/
+/* Get source type of merge.                                                 */
+/*****************************************************************************/
+glMergeSrcType
+gl_merge_get_src_type (glMerge *merge)
+{
+       gl_debug (DEBUG_MERGE, "");
 
-               new = g_list_append (new, fd_new);
+       if (merge == NULL) {
+               return GL_MERGE_SRC_IS_FIXED;
        }
 
-       gl_debug (DEBUG_MERGE, "END");
-       return new;
+       g_return_val_if_fail (GL_IS_MERGE (merge), GL_MERGE_SRC_IS_FIXED);
+
+       return merge->private->src_type;
 }
 
 /*****************************************************************************/
-/* Free list of field definitions.                                           */
+/* Set src of merge.                                                         */
 /*****************************************************************************/
 void
-gl_merge_free_field_def_list (GList ** list)
+gl_merge_set_src (glMerge *merge,
+                 gchar   *src)
 {
-       GList *p;
-       glMergeFieldDefinition *field_def;
-
        gl_debug (DEBUG_MERGE, "START");
 
-       for (p = *list; p != NULL; p = p->next) {
-               field_def = (glMergeFieldDefinition *) p->data;
+       g_return_if_fail (merge && GL_IS_MERGE (merge));
 
-               g_free (field_def->key);
-               field_def->key = NULL;
-               g_free (field_def->loc);
-               field_def->loc = NULL;
+       g_free(merge->private->src);
+       merge->private->src = src;
 
-               g_free (p->data);
-               p->data = NULL;
+       gl_debug (DEBUG_MERGE, "END");
+}
+
+/*****************************************************************************/
+/* Get src of merge.                                                         */
+/*****************************************************************************/
+gchar *
+gl_merge_get_src (glMerge *merge)
+{
+       gl_debug (DEBUG_MERGE, "");
+
+       if (merge == NULL) {
+               return NULL;
        }
 
-       g_list_free (*list);
-       *list = NULL;
+       g_return_val_if_fail (GL_IS_MERGE (merge), NULL);
 
-       gl_debug (DEBUG_MERGE, "END");
+       return g_strdup(merge->private->src);
 }
 
 /*****************************************************************************/
-/* Extract a list of valid keys from field definitions list                  */
+/* Get Key List.                                                             */
 /*****************************************************************************/
 GList *
-gl_merge_get_key_list (GList * field_defs)
+gl_merge_get_key_list (glMerge *merge)
 {
-       GList *p, *keys;
-       glMergeFieldDefinition *field_def;
+       GList *key_list = NULL;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       keys = NULL;
-       for (p = field_defs; p != NULL; p = p->next) {
-               field_def = (glMergeFieldDefinition *) p->data;
+       if (merge == NULL) {
+               return NULL;
+       }
+
+       g_return_val_if_fail (GL_IS_MERGE (merge), NULL);
+
+       if ( GL_MERGE_GET_CLASS(merge)->get_key_list != NULL ) {
+
+               key_list = GL_MERGE_GET_CLASS(merge)->get_key_list (merge);
 
-               keys = g_list_append (keys, g_strdup (field_def->key));
        }
 
        gl_debug (DEBUG_MERGE, "END");
 
-       return keys;
+       return key_list;
 }
 
 /*****************************************************************************/
 /* Free a list of keys.                                                      */
 /*****************************************************************************/
 void
-gl_merge_free_key_list (GList ** keys)
+gl_merge_free_key_list (GList **key_list)
 {
        GList *p;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       for (p = *keys; p != NULL; p = p->next) {
+       for (p = *key_list; p != NULL; p = p->next) {
                g_free (p->data);
                p->data = NULL;
        }
 
-       g_list_free (*keys);
-       *keys = NULL;
+       g_list_free (*key_list);
+       *key_list = NULL;
 
        gl_debug (DEBUG_MERGE, "END");
 }
 
 /*****************************************************************************/
-/* Lookup key for given locator.                                             */
+/* Open merge source.                                                        */
 /*****************************************************************************/
-gchar *
-gl_merge_find_key (GList * field_defs,
-                  gchar * loc)
+void
+gl_merge_open (glMerge *merge)
 {
-       GList *p;
-       glMergeFieldDefinition *field_def;
-
        gl_debug (DEBUG_MERGE, "START");
 
-       for (p = field_defs; p != NULL; p = p->next) {
-               field_def = (glMergeFieldDefinition *) p->data;
+       g_return_if_fail (merge && GL_IS_MERGE (merge));
 
-               if (strcmp (loc, field_def->loc) == 0) {
-                       gl_debug (DEBUG_MERGE, "END");
-                       return g_strdup (field_def->key);
-               }
+       if ( GL_MERGE_GET_CLASS(merge)->open != NULL ) {
+
+               GL_MERGE_GET_CLASS(merge)->open (merge);
 
        }
 
        gl_debug (DEBUG_MERGE, "END");
-
-       return NULL;
-}
-
-/*****************************************************************************/
-/* Open merge source front-end.                                              */
-/*****************************************************************************/
-glMergeInput *
-gl_merge_open (glMergeType type,
-              GList * field_defs,
-              gchar * src)
-{
-       gl_debug (DEBUG_MERGE, "");
-
-       return func[type].open (type, field_defs, src);
 }
 
 /*****************************************************************************/
-/* Close merge source front-end.                                             */
+/* Close merge source.                                                       */
 /*****************************************************************************/
 void
-gl_merge_close (glMergeInput * input)
+gl_merge_close (glMerge *merge)
 {
        gl_debug (DEBUG_MERGE, "START");
 
-       if ( input != NULL ) {
-               func[input->type].close (input);
+       g_return_if_fail (merge && GL_IS_MERGE (merge));
+
+       if ( GL_MERGE_GET_CLASS(merge)->close != NULL ) {
+
+               GL_MERGE_GET_CLASS(merge)->close (merge);
+
        }
 
        gl_debug (DEBUG_MERGE, "END");
 }
 
 /*****************************************************************************/
-/* Get next record from merge source, NULL if exhausted (front-end).         */
+/* Get next record (list of fields) from opened merge source.                */
 /*****************************************************************************/
 glMergeRecord *
-gl_merge_get_record (glMergeInput * input)
+gl_merge_get_record (glMerge *merge)
 {
-       gl_debug (DEBUG_MERGE, "");
+       glMergeRecord *record = NULL;
 
-       if ( input == NULL ) {
-               return NULL;
-       }
-       return func[input->type].get_record (input);
-}
+       gl_debug (DEBUG_MERGE, "START");
 
-/*****************************************************************************/
-/* Get next record (raw) from merge source, NULL if exhausted (front-end).   */
-/*****************************************************************************/
-GList *
-gl_merge_get_raw_record (glMergeInput * input)
-{
-       gl_debug (DEBUG_MERGE, "");
+       g_return_val_if_fail (merge && GL_IS_MERGE (merge), NULL);
+
+       if ( GL_MERGE_GET_CLASS(merge)->get_record != NULL ) {
+
+               record = GL_MERGE_GET_CLASS(merge)->get_record (merge);
 
-       if ( input == NULL ) {
-               return NULL;
        }
-       return func[input->type].get_raw_record (input);
+
+       gl_debug (DEBUG_MERGE, "END");
+
+       return record;
 }
 
 /*****************************************************************************/
 /* Free a merge record (list of fields)                                      */
 /*****************************************************************************/
 void
-gl_merge_free_record (glMergeRecord ** record)
+gl_merge_free_record (glMergeRecord **record)
 {
        GList *p;
        glMergeField *field;
@@ -471,55 +538,26 @@ gl_merge_free_record (glMergeRecord ** record)
        gl_debug (DEBUG_MERGE, "END");
 }
 
-/*****************************************************************************/
-/* Free a merge record (list of fields)                                      */
-/*****************************************************************************/
-void
-gl_merge_free_raw_record (GList ** record)
-{
-       GList *p;
-       glMergeRawField *field;
-
-       gl_debug (DEBUG_MERGE, "START");
-
-       for (p = *record; p != NULL; p = p->next) {
-               field = (glMergeRawField *) p->data;
-
-               g_free (field->loc);
-               field->loc = NULL;
-               g_free (field->value);
-               field->value = NULL;
-
-               g_free (p->data);
-               p->data = NULL;
-
-       }
-
-       g_list_free (*record);
-       *record = NULL;
-
-       gl_debug (DEBUG_MERGE, "END");
-}
-
 /*****************************************************************************/
 /* Find key in given record and evaluate.                                    */
 /*****************************************************************************/
 extern gchar *
-gl_merge_eval_key (gchar * key,
-                  glMergeRecord * record)
+gl_merge_eval_key (glMergeRecord *record,
+                  gchar         *key)
+                  
 {
-       GList *p;
+       GList        *p;
        glMergeField *field;
+       gchar        *val = NULL;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       if ( record != NULL ) {
+       if ( (record != NULL) && record->select_flag  ) {
                for (p = record->field_list; p != NULL; p = p->next) {
                        field = (glMergeField *) p->data;
 
                        if (strcmp (key, field->key) == 0) {
-                               gl_debug (DEBUG_MERGE, "END");
-                               return g_strdup (field->value);
+                               val = g_strdup (field->value);
                        }
 
                }
@@ -527,28 +565,25 @@ gl_merge_eval_key (gchar * key,
 
        gl_debug (DEBUG_MERGE, "END");
 
-       return NULL;
+       return val;
 }
 
 /*****************************************************************************/
 /* Read all records from merge source.                                       */
 /*****************************************************************************/
 GList *
-gl_merge_read_data(glMergeType type,
-                  GList *field_defs,
-                  gchar *src)
+gl_merge_read_record_list (glMerge *merge)
 {
-       glMergeInput *mp;
        glMergeRecord *record;
        GList *record_list = NULL;
 
        gl_debug (DEBUG_MERGE, "START");
 
-       mp = gl_merge_open (type, field_defs, src);
-       while ( (record = gl_merge_get_record (mp)) != NULL ) {
+       gl_merge_open (merge);
+       while ( (record = gl_merge_get_record (merge)) != NULL ) {
                record_list = g_list_append( record_list, record );
        }
-       gl_merge_close(mp);
+       gl_merge_close (merge);
              
        gl_debug (DEBUG_MERGE, "END");
 
@@ -559,7 +594,7 @@ gl_merge_read_data(glMergeType type,
 /* Free a list of records.                                                   */
 /*****************************************************************************/
 void
-gl_merge_free_data (GList ** record_list)
+gl_merge_free_record_list (GList **record_list)
 {
        GList *p;
        glMergeRecord *record;
@@ -603,3 +638,4 @@ gl_merge_count_records (GList *record_list)
        return count;
 }
 
+
index 3c8497b6346741ac975fbc54519e2b7006798b55..5028e6ff6687610dcc2bf34b1b71026557cd1bb5 100644 (file)
 #ifndef __MERGE_H__
 #define __MERGE_H__
 
-#include <glib.h>
+#include <glib-object.h>
 
-typedef enum {
-
-       GL_MERGE_NONE,
-       GL_MERGE_TEXT_TAB,
-       GL_MERGE_TEXT_COMMA,
-       GL_MERGE_TEXT_COLON,
+G_BEGIN_DECLS
 
-       GL_MERGE_N_TYPES
-} glMergeType;
-
-typedef struct {
-       glMergeType  type;
-       gchar       *src;
-       GList       *field_defs;
-} glMerge;
-
-typedef struct {
-       gchar *key;
-       gchar *loc;
-} glMergeFieldDefinition;
-
-typedef struct {
-       gchar *loc;
-       gchar *value;
-} glMergeRawField;
+typedef enum {
+       GL_MERGE_SRC_IS_FIXED,
+       GL_MERGE_SRC_IS_FILE,
+} glMergeSrcType;
 
 typedef struct {
        gchar *key;
@@ -60,46 +41,94 @@ typedef struct {
        GList    *field_list;  /* List of glMergeFields */
 } glMergeRecord;
 
-typedef struct {
-       glMergeType type;
-       GList *field_defs;
-       gpointer handle;
-} glMergeInput;
-
-extern void
- gl_merge_init (void);
-
-extern glMerge *gl_merge_new (void);
-extern glMerge *gl_merge_dup (glMerge *orig);
-extern void    gl_merge_free (glMerge **merge);
-
-extern glMergeType gl_merge_text_to_type (gchar * text);
-extern gchar *gl_merge_type_to_text (glMergeType type);
-extern glMergeType gl_merge_long_text_to_type (gchar * text);
-extern gchar *gl_merge_type_to_long_text (glMergeType type);
-extern GList *gl_merge_get_long_texts_list (void);
-extern void gl_merge_free_long_texts_list (GList ** list);
-
-extern GList *gl_merge_dup_field_def_list (GList * field_defs);
-extern void   gl_merge_free_field_def_list (GList ** field_defs);
-
-extern GList *gl_merge_get_key_list (GList * field_defs);
-extern void gl_merge_free_key_list (GList ** keys);
-
-extern gchar *gl_merge_find_key (GList * field_defs, gchar * loc);
-
-extern glMergeInput *gl_merge_open (glMergeType type, GList * field_defs,
-                                   gchar * src);
-extern void gl_merge_close (glMergeInput * input);
-extern glMergeRecord *gl_merge_get_record (glMergeInput * input);
-extern GList *gl_merge_get_raw_record (glMergeInput * input);
-extern void gl_merge_free_record (glMergeRecord ** record);
-extern void gl_merge_free_raw_record (GList ** record);
-extern gchar *gl_merge_eval_key (gchar * key, glMergeRecord * record);
-
-extern GList *gl_merge_read_data (glMergeType type, GList * field_defs,
-                                 gchar * src);
-extern void gl_merge_free_data (GList **record_list);
-extern gint gl_merge_count_records (GList *record_list);
+
+#define GL_TYPE_MERGE              (gl_merge_get_type ())
+#define GL_MERGE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_MERGE, glMerge))
+#define GL_MERGE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE, glMergeClass))
+#define GL_IS_MERGE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_MERGE))
+#define GL_IS_MERGE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE))
+#define GL_MERGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), GL_TYPE_MERGE, glMergeClass))
+
+
+typedef struct _glMerge          glMerge;
+typedef struct _glMergeClass     glMergeClass;
+
+typedef struct _glMergePrivate   glMergePrivate;
+
+
+struct _glMerge {
+       GObject          object;
+
+       glMergePrivate  *private;
+};
+
+struct _glMergeClass {
+       GObjectClass     parent_class;
+
+        GList         *(*get_key_list)   (glMerge *merge);
+
+       void           (*open)           (glMerge *merge);
+
+       void           (*close)          (glMerge *merge);
+
+       glMergeRecord *(*get_record)     (glMerge *merge);
+
+       void           (*copy)           (glMerge *dst_merge,
+                                         glMerge *src_merge);
+};
+
+
+void              gl_merge_register_backend    (GType              type,
+                                               gchar             *name,
+                                               gchar             *description,
+                                               glMergeSrcType     src_type,
+                                               const gchar       *first_arg_name,
+                                               ...);
+
+GList            *gl_merge_get_descriptions    (void);
+
+void              gl_merge_free_descriptions   (GList **descriptions);
+
+gchar            *gl_merge_description_to_name (gchar *description);
+
+GType             gl_merge_get_type            (void);
+
+glMerge          *gl_merge_new                 (gchar             *name);
+
+glMerge          *gl_merge_dup                 (glMerge           *orig);
+
+gchar            *gl_merge_get_name            (glMerge           *merge);
+
+gchar            *gl_merge_get_description     (glMerge           *merge);
+
+glMergeSrcType    gl_merge_get_src_type        (glMerge           *merge);
+
+void              gl_merge_set_src             (glMerge           *merge,
+                                               gchar             *src);
+
+gchar            *gl_merge_get_src             (glMerge           *merge);
+
+GList            *gl_merge_get_key_list        (glMerge           *merge);
+
+void              gl_merge_free_key_list       (GList            **keys);
+
+void              gl_merge_open                (glMerge           *merge);
+
+void              gl_merge_close               (glMerge           *merge);
+
+glMergeRecord    *gl_merge_get_record          (glMerge           *merge);
+
+void              gl_merge_free_record         (glMergeRecord    **record);
+
+gchar            *gl_merge_eval_key            (glMergeRecord     *record,
+                                               gchar             *key);
+
+GList            *gl_merge_read_record_list    (glMerge           *merge);
+
+void              gl_merge_free_record_list    (GList            **record_list);
+
+gint              gl_merge_count_records       (GList             *record_list);
+
+G_END_DECLS
 
 #endif
index 05bca590a1859f53ea3d2fe754f3b173234c33ff..b2226e6013e13f4909bfb05a15bbf2966285c2e6 100644 (file)
@@ -144,7 +144,7 @@ job_page_new (GtkWidget *dlg,
        vbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER);
 
        merge = gl_label_get_merge (label);
-       if (merge->type == GL_MERGE_NONE) {
+       if (merge == NULL) {
 
                /* ----------- Add simple-copies widget ------------ */
                wframe = gl_hig_category_new (_("Copies"));
@@ -167,13 +167,13 @@ job_page_new (GtkWidget *dlg,
                prmerge = gl_wdgt_print_merge_new (label);
                gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), prmerge);
 
-               record_list = gl_merge_read_data (merge->type,
-                                                 merge->field_defs,
-                                                 merge->src);
+               record_list = gl_merge_read_record_list (merge);
+
                n_records = gl_merge_count_records( record_list );
                gl_wdgt_print_merge_set_copies (GL_WDGT_PRINT_MERGE(prmerge),
                                           n_copies, first, n_records,
                                           collate_flag);
+               g_object_unref (G_OBJECT(merge));
        }
        gtk_widget_show_all (wframe);
        g_object_set_data (G_OBJECT(dlg), "copies", copies);
@@ -267,7 +267,7 @@ print_response (GtkDialog *dlg,
 
                merge = gl_label_get_merge (label);
 
-               if (merge->type == GL_MERGE_NONE) {
+               if (merge == NULL) {
 
                        gl_wdgt_print_copies_get_range (GL_WDGT_PRINT_COPIES (copies),
                                                        &n_sheets, &first, &last);
@@ -278,9 +278,7 @@ print_response (GtkDialog *dlg,
 
                } else {
 
-                       record_list = gl_merge_read_data (merge->type,
-                                                         merge->field_defs,
-                                                         merge->src);
+                       record_list = gl_merge_read_record_list (merge);
                        gl_wdgt_print_merge_get_copies (GL_WDGT_PRINT_MERGE (prmerge),
                                                        &n_copies, &first,
                                                        &collate_flag);
@@ -290,9 +288,8 @@ print_response (GtkDialog *dlg,
                                            collate_flag,
                                            outline_flag,
                                            reverse_flag);
+                       g_object_unref (G_OBJECT(merge));
                }
-
-               gl_merge_free (&merge);
                break;
 
        default:
index e6fcd1099f3659b090a7b76424a695ae1bf8d476..80cb4886378d88cd0758f0e566e40f1eed38b7c6 100644 (file)
@@ -339,23 +339,22 @@ gl_print_batch (GnomePrintMaster *master,
        merge = gl_label_get_merge (label);
        template = gl_label_get_template (label);
 
-       if ( merge->type == GL_MERGE_NONE ) {
+       if ( merge == NULL ) {
                n_per_page = gl_template_get_n_labels(template);
 
                gl_print_simple (master, label, n_sheets, 1, n_per_page,
                                 outline_flag, reverse_flag);
        } else {
-               record_list = gl_merge_read_data (merge->type,
-                                                 merge->field_defs,
-                                                 merge->src);
+               record_list = gl_merge_read_record_list (merge);
 
                gl_print_merge_collated (master, label, record_list,
                                         n_copies, 1,
                                         outline_flag, reverse_flag);
        }
-       gl_merge_free (&merge);
        gl_template_free (&template);
 
+       g_object_unref (G_OBJECT(merge));
+
        gl_debug (DEBUG_PRINT, "END");
 }
 
index 1b2716ffb9ed606e43d9e6f425b2dee306cf3f4d..e964f55baa320832a4df12bc5ec003a264d4ebff 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "tools.h"
 #include "window.h"
-#include "merge-properties.h"
+#include "merge-properties-dialog.h"
 
 /*===========================================*/
 /* Private types.                            */
index 70048b9143ae143801c99e642a1fcfda8f6b69ee..e22bfc5a49e13e88c52deddf4a9a9c3704edbc92 100644 (file)
@@ -287,12 +287,11 @@ construct_properties_dialog (glViewObject *view_object)
        gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
 
        /* barcode data */
-       view_barcode->private->bc_data =
-               gl_wdgt_bc_data_new (merge->field_defs);
+       view_barcode->private->bc_data = gl_wdgt_bc_data_new (merge);
        gl_wdgt_bc_data_set_label_size_group (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
                                              label_size_group);
        gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
-                                 (merge->type != GL_MERGE_NONE),
+                                 (merge != NULL),
                                  text_node);
        gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
                                    view_barcode->private->bc_data);
@@ -556,10 +555,10 @@ update_dialog_cb (glLabelObject  *object,
        /* Update widgets in property dialog */
 
        gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
-                                 (merge->type != GL_MERGE_NONE),
+                                 (merge != NULL),
                                  text_node);
        gl_wdgt_bc_data_set_field_defs (GL_WDGT_BC_DATA(view_barcode->private->bc_data),
-                                       merge->field_defs);
+                                       merge);
        gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props),
                                     scale, color);
        gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style),
index 4e60eda6a070eb521d9d50a795499b5db3630fcf..f3601a53c93759cbc4e51e1543be5e0c370adbdf 100644 (file)
@@ -279,11 +279,11 @@ construct_properties_dialog (glViewObject *view_object)
        wsection = gl_hig_category_new (_("Text"));
        gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection);
        view_text->private->text_entry =
-               gl_wdgt_text_entry_new (merge->field_defs);
+               gl_wdgt_text_entry_new (merge);
        gl_wdgt_text_entry_set_label_size_group (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
                                                 label_size_group);
        gl_wdgt_text_entry_set_text (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
-                                    (merge->type != GL_MERGE_NONE),
+                                    (merge != NULL),
                                     lines);
        gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection),
                                    view_text->private->text_entry);
@@ -507,10 +507,10 @@ update_dialog_cb (glLabelObject  *object,
        /* Update widgets in property dialog */
 
        gl_wdgt_text_entry_set_text (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
-                                    (merge->type != GL_MERGE_NONE),
+                                    (merge != NULL),
                                     lines);
        gl_wdgt_text_entry_set_field_defs (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry),
-                                          merge->field_defs);
+                                          merge);
        gl_wdgt_text_props_set_params (GL_WDGT_TEXT_PROPS(view_text->private->text_props),
                                       font_family, font_size, font_weight,
                                       font_italic_flag, color, just);
index 58f6a0ea792d499dfb08927f585baa7e64e980f5..9da7abec492e76e9605c12f34b4961d8165a4072 100644 (file)
@@ -55,7 +55,7 @@ static void gl_wdgt_bc_data_class_init    (glWdgtBCDataClass *class);
 static void gl_wdgt_bc_data_instance_init (glWdgtBCData      *bc_data);
 static void gl_wdgt_bc_data_finalize      (GObject           *object);
 static void gl_wdgt_bc_data_construct     (glWdgtBCData      *bc_data,
-                                          GList             *field_defs);
+                                          glMerge           *merge);
 
 static void changed_cb                    (glWdgtBCData      *bc_data);
 static void radio_toggled_cb              (GtkToggleButton   *togglebutton,
@@ -154,7 +154,7 @@ gl_wdgt_bc_data_finalize (GObject *object)
 /* New widget.                                                              */
 /****************************************************************************/
 GtkWidget *
-gl_wdgt_bc_data_new (GList *field_defs)
+gl_wdgt_bc_data_new (glMerge *merge)
 {
        glWdgtBCData *bc_data;
 
@@ -162,7 +162,7 @@ gl_wdgt_bc_data_new (GList *field_defs)
 
        bc_data = g_object_new (gl_wdgt_bc_data_get_type (), NULL);
 
-       gl_wdgt_bc_data_construct (bc_data, field_defs);
+       gl_wdgt_bc_data_construct (bc_data, merge);
 
        gl_debug (DEBUG_WDGT, "END");
 
@@ -174,7 +174,7 @@ gl_wdgt_bc_data_new (GList *field_defs)
 /*--------------------------------------------------------------------------*/
 static void
 gl_wdgt_bc_data_construct (glWdgtBCData *bc_data,
-                          GList        *field_defs)
+                          glMerge      *merge)
 {
        GtkWidget *wvbox, *whbox;
        GSList *radio_group = NULL;
@@ -221,7 +221,7 @@ gl_wdgt_bc_data_construct (glWdgtBCData *bc_data,
 
        /* Key entry widget */
        bc_data->key_combo = gtk_combo_new ();
-       keys = gl_merge_get_key_list (field_defs);
+       keys = gl_merge_get_key_list (merge);
        if (keys != NULL)
                gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo),
                                               keys);
@@ -280,13 +280,13 @@ radio_toggled_cb (GtkToggleButton *togglebutton,
 /****************************************************************************/
 void
 gl_wdgt_bc_data_set_field_defs  (glWdgtBCData *bc_data,
-                                GList        *field_defs)
+                                glMerge      *merge)
 {
        GList *keys;
 
        gl_debug (DEBUG_WDGT, "START");
 
-       keys = gl_merge_get_key_list (field_defs);
+       keys = gl_merge_get_key_list (merge);
        if ( keys != NULL ) {
                gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo),
                                               keys);
index 06e15126e475659f0e78cb35a24bfe37a191f161..2fd8c001c9ca4b49c4565e813d4e094c6a93fd1f 100644 (file)
@@ -61,10 +61,10 @@ struct _glWdgtBCDataClass {
 
 guint       gl_wdgt_bc_data_get_type        (void);
 
-GtkWidget  *gl_wdgt_bc_data_new             (GList        *field_defs);
+GtkWidget  *gl_wdgt_bc_data_new             (glMerge      *merge);
 
 void        gl_wdgt_bc_data_set_field_defs  (glWdgtBCData *bc_data,
-                                            GList        *field_defs);
+                                            glMerge      *merge);
 
 glTextNode *gl_wdgt_bc_data_get_data        (glWdgtBCData *bc_data);
 
index 1f44555041e83f734925a7049b45aa5d17ee662b..a7419dea6fb728ab87062e276eb523f3faffddb6 100644 (file)
@@ -56,7 +56,7 @@ static void gl_wdgt_text_entry_class_init    (glWdgtTextEntryClass *class);
 static void gl_wdgt_text_entry_instance_init (glWdgtTextEntry      *text_entry);
 static void gl_wdgt_text_entry_finalize      (GObject              *object);
 static void gl_wdgt_text_entry_construct     (glWdgtTextEntry      *text_entry,
-                                             GList                *field_defs);
+                                             glMerge              *merge);
 
 static void changed_cb (glWdgtTextEntry *text_entry);
 static void insert_cb  (glWdgtTextEntry *text_entry);
@@ -151,7 +151,7 @@ gl_wdgt_text_entry_finalize (GObject *object)
 /* New widget.                                                              */
 /****************************************************************************/
 GtkWidget *
-gl_wdgt_text_entry_new (GList *field_defs)
+gl_wdgt_text_entry_new (glMerge *merge)
 {
        glWdgtTextEntry *text_entry;
 
@@ -159,7 +159,7 @@ gl_wdgt_text_entry_new (GList *field_defs)
 
        text_entry = g_object_new (gl_wdgt_text_entry_get_type (), NULL);
 
-       gl_wdgt_text_entry_construct (text_entry, field_defs);
+       gl_wdgt_text_entry_construct (text_entry, merge);
 
        gl_debug (DEBUG_WDGT, "END");
 
@@ -171,7 +171,7 @@ gl_wdgt_text_entry_new (GList *field_defs)
 /*--------------------------------------------------------------------------*/
 static void
 gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry,
-                             GList           *field_defs)
+                             glMerge         *merge)
 {
        GtkWidget *wvbox, *whbox, *wscroll;
        GList *keys;
@@ -216,7 +216,7 @@ gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry,
 
        /* Key entry widget */
        text_entry->key_combo = gtk_combo_new ();
-       keys = gl_merge_get_key_list (field_defs);
+       keys = gl_merge_get_key_list (merge);
        if (keys != NULL)
                gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo),
                                               keys);
@@ -283,11 +283,11 @@ insert_cb (glWdgtTextEntry *text_entry)
 /****************************************************************************/
 void
 gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry,
-                                  GList           *field_defs)
+                                  glMerge         *merge)
 {
        GList *keys;
 
-       keys = gl_merge_get_key_list (field_defs);
+       keys = gl_merge_get_key_list (merge);
        if ( keys != NULL ) {
                gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo),
                                               keys);
index 930b93ca75927d6451d4b2f782247964b86e9a70..c5f513e98a321fd3339c577000d297281e6847bb 100644 (file)
@@ -64,10 +64,10 @@ struct _glWdgtTextEntryClass {
 
 guint      gl_wdgt_text_entry_get_type       (void);
 
-GtkWidget *gl_wdgt_text_entry_new            (GList           *field_defs);
+GtkWidget *gl_wdgt_text_entry_new            (glMerge         *merge);
 
 void       gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry,
-                                             GList           *field_defs);
+                                             glMerge         *merge);
 
 GList     *gl_wdgt_text_entry_get_text       (glWdgtTextEntry *text_entry);
 
index faacbbd178ca9f9b796d0377f583b91db061695d..62625bf04b64e7ab61a366951e03e219338b7624 100644 (file)
@@ -448,32 +448,15 @@ xml04_parse_merge_properties (xmlNodePtr node,
 {
        glMerge                *merge;
        xmlNodePtr             child;
-       glMergeFieldDefinition *field_def;
 
        gl_debug (DEBUG_XML, "START");
 
-       merge = gl_merge_new ();
-       merge->type = gl_merge_text_to_type (xmlGetProp (node, "type"));
-       merge->src  = xmlGetProp (node, "src");
-
-       for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
-
-               if (g_strcasecmp (child->name, "Field") == 0) {
-                       field_def = g_new0 (glMergeFieldDefinition, 1);
-                       field_def->key = xmlGetProp (child, "key");
-                       field_def->loc = xmlGetProp (child, "loc");
-                       merge->field_defs =
-                               g_list_append (merge->field_defs, field_def);
-               } else if (!xmlNodeIsText (child)) {
-                       g_warning ("Unexpected Merge_Properties child: \"%s\"",
-                             child->name);
-               }
-
-       }
+       merge = gl_merge_new (xmlGetProp (node, "type"));
+       gl_merge_set_src (merge, xmlGetProp (node, "src"));
 
        gl_label_set_merge (label, merge);
 
-       gl_merge_free (&merge);
+       g_object_unref (G_OBJECT(merge));
 
        gl_debug (DEBUG_XML, "END");
 }
index a9472e218a52cb4205a45fca8506c3a1030ba77b..71c71caa3824e3853345a23a448324807bd01393 100644 (file)
@@ -611,36 +611,19 @@ static void
 xml_parse_merge_fields (xmlNodePtr node,
                        glLabel * label)
 {
-       xmlNodePtr child;
-       glMerge *merge;
-       glMergeFieldDefinition *field_def;
+       xmlNodePtr  child;
+       glMerge    *merge;
+       gchar      *src;
 
        gl_debug (DEBUG_XML, "START");
 
-       merge = gl_merge_new ();
-
-       merge->type = gl_merge_text_to_type (xmlGetProp (node, "type"));
-       merge->src = xmlGetProp (node, "src");
-
-       for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
-
-               if (g_strcasecmp (child->name, "Field") == 0) {
-                       field_def = g_new0 (glMergeFieldDefinition, 1);
-                       field_def->key = xmlGetProp (child, "key");
-                       field_def->loc = xmlGetProp (child, "loc");
-                       merge->field_defs =
-                           g_list_append (merge->field_defs,
-                                          field_def);
-               } else if (!xmlNodeIsText (child)) {
-                       g_warning ("Unexpected Merge_Fields child: \"%s\"",
-                                  child->name);
-               }
-
-       }
+       merge = gl_merge_new (xmlGetProp (node, "type"));
+       src = xmlGetProp (node, "src");
+       gl_merge_set_src (merge, src);
 
        gl_label_set_merge (label, merge);
 
-       gl_merge_free (&merge);
+       g_object_unref (G_OBJECT(merge));
 
        gl_debug (DEBUG_XML, "END");
 }
@@ -731,10 +714,10 @@ xml_label_to_doc (glLabel * label,
 
        merge = gl_label_get_merge (label);
        gl_debug (DEBUG_XML, "merge=%p", merge);
-       if (merge->type != GL_MERGE_NONE) {
+       if (merge != NULL) {
                xml_create_merge_fields (doc->xmlRootNode, ns, label);
        }
-       gl_merge_free (&merge);
+       g_object_unref (G_OBJECT(merge));
 
        gl_debug (DEBUG_XML, "END");
 
@@ -1122,7 +1105,6 @@ xml_create_merge_fields (xmlNodePtr root,
        gchar *string;
        GList *p;
        glMerge *merge;
-       glMergeFieldDefinition *field_def;
 
        gl_debug (DEBUG_XML, "START");
 
@@ -1130,21 +1112,15 @@ xml_create_merge_fields (xmlNodePtr root,
 
        node = xmlNewChild (root, ns, "Merge_Fields", NULL);
 
-       string = gl_merge_type_to_text (merge->type);
+       string = gl_merge_get_name (merge);
        xmlSetProp (node, "type", string);
        g_free (string);
 
-       xmlSetProp (node, "src", merge->src);
-
-       for (p = merge->field_defs; p != NULL; p = p->next) {
-               field_def = (glMergeFieldDefinition *) p->data;
-
-               child = xmlNewChild (node, ns, "Field", NULL);
-               xmlSetProp (child, "key", field_def->key);
-               xmlSetProp (child, "loc", field_def->loc);
-       }
+       string = gl_merge_get_src (merge);
+       xmlSetProp (node, "src", string);
+       g_free (string);
 
-       gl_merge_free (&merge);
+       g_object_unref (G_OBJECT(merge));
 
        gl_debug (DEBUG_XML, "END");
 }