glMerge *merge;
GtkWidget *type_entry;
+ GtkWidget *src_entry_holder;
GtkWidget *src_entry;
GtkWidget *sample;
PropertyDialogPassback *data;
GtkWidget *dialog;
+ gl_debug (DEBUG_MERGE, "START");
+
data = g_new0 (PropertyDialogPassback, 1);
dialog = gl_hig_dialog_new_with_buttons (
gtk_widget_show_all (GTK_WIDGET (dialog));
+ gl_debug (DEBUG_MERGE, "END");
}
/*--------------------------------------------------------------------------*/
gchar *src;
GtkSizeGroup *label_size_group;
+ gl_debug (DEBUG_MERGE, "START");
+
data->merge = gl_label_get_merge (data->label);
description = gl_merge_get_description (data->merge);
src_type = gl_merge_get_src_type (data->merge);
wcombo = gtk_combo_new ();
texts = gl_merge_get_descriptions ();
+ gl_debug (DEBUG_MERGE, "DESCRIPTIONS:");
+ {
+ GList *p;
+
+ for (p=texts; p!=NULL; p=p->next) {
+ gl_debug (DEBUG_MERGE, " \"%s\"", p->data);
+ }
+ }
gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts);
gl_merge_free_descriptions (&texts);
data->type_entry = GTK_COMBO (wcombo)->entry;
gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wlabel);
+ gl_debug (DEBUG_MERGE, "Src_type = %d", src_type);
switch (src_type) {
case GL_MERGE_SRC_IS_FILE:
data->src_entry =
data->src_entry = gtk_label_new (_("N/A"));
break;
}
- gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), data->src_entry);
+ data->src_entry_holder = gtk_hbox_new (FALSE, 0);
+ gtk_container_add( GTK_CONTAINER(data->src_entry_holder), data->src_entry);
+ gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), data->src_entry_holder);
/* ---- Sample Fields section ---- */
wframe = gl_hig_category_new (_("Sample fields"));
g_free (description);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+ gl_debug (DEBUG_MERGE, "END");
}
/*--------------------------------------------------------------------------*/
glMergeSrcType src_type;
GtkWidget *wentry;
+ gl_debug (DEBUG_MERGE, "START");
+
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));
+ if (data->merge != NULL) {
+ g_object_unref (G_OBJECT(data->merge));
+ }
data->merge = gl_merge_new (name);
gtk_widget_destroy (data->src_entry);
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);
+ if (src != NULL) {
+ gtk_entry_set_text (GTK_ENTRY(wentry), src);
+ }
g_signal_connect (G_OBJECT (wentry), "changed",
G_CALLBACK (src_changed_cb), data);
break;
data->src_entry = gtk_label_new (_("N/A"));
break;
}
+ gtk_container_add( GTK_CONTAINER(data->src_entry_holder), data->src_entry);
+ gtk_widget_show (data->src_entry);
g_free (description);
g_free (name);
g_free (src);
+
+ gl_debug (DEBUG_MERGE, "END");
}
/*--------------------------------------------------------------------------*/
gchar *src;
GtkWidget *wentry;
+ gl_debug (DEBUG_MERGE, "START");
+
wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY(data->src_entry));
src = gtk_editable_get_chars (GTK_EDITABLE (wentry), 0, -1);
gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
(data->sample), type, src);
#endif
+
+ gl_debug (DEBUG_MERGE, "END");
}
/*--------------------------------------------------------------------------*/
gint response,
PropertyDialogPassback * data)
{
+ gl_debug (DEBUG_MERGE, "START");
+
switch (response) {
case GTK_RESPONSE_OK:
}
- g_object_unref (G_OBJECT(data->merge));
+ if (data->merge != NULL) {
+ g_object_unref (G_OBJECT(data->merge));
+ }
g_free (data);
gtk_widget_destroy (GTK_WIDGET(dialog));
+
+ gl_debug (DEBUG_MERGE, "END");
}
#include <config.h>
#include <gnome.h>
+#include <gobject/gvaluecollector.h>
#include <string.h>
#include "merge.h"
gchar *description;
glMergeSrcType src_type;
- const gchar *first_arg_name;
- va_list args;
+ guint n_params;
+ GParameter *params;
} Backend;
const gchar *first_arg_name,
...)
{
- Backend *backend;
- va_list args;
- gchar *a_nam;
- gpointer a_val;
+ Backend *backend;
+ va_list args;
+ const gchar *pname;
+ GObjectClass *class;
+ GParamSpec *pspec;
+ GParameter *params;
+ guint n_params = 0, n_alloced_params = 16;
backend = g_new0 (Backend, 1);
- backend->type = type;
- backend->name = g_strdup (name);
+ backend->type = type;
+ backend->name = g_strdup (name);
backend->description = g_strdup (description);
+ backend->src_type = src_type;
- backend->first_arg_name = first_arg_name;
+ params = g_new (GParameter, n_alloced_params);
va_start (args, first_arg_name);
- G_VA_COPY (backend->args, args);
+ for ( pname=first_arg_name; pname != NULL; pname=va_arg (args,gchar *) ) {
+ gchar *error = NULL;
+
+ class = g_type_class_ref (type);
+ if (class == NULL) {
+ g_warning ("%s: unknown object type %d",
+ G_STRLOC, type);
+ break;
+ }
+ pspec = g_object_class_find_property (class, pname);
+ if (pspec == NULL) {
+ g_warning ("%s: object class `%s' has no property named `%s'",
+ G_STRLOC, g_type_name (type), pname);
+ break;
+ }
+ if (n_params >= n_alloced_params) {
+ n_alloced_params += 16;
+ params = g_renew (GParameter, params, n_alloced_params);
+ }
+ params[n_params].name = pname;
+ params[n_params].value.g_type = 0;
+ g_value_init (¶ms[n_params].value, pspec->value_type);
+ G_VALUE_COLLECT (¶ms[n_params].value, args, 0, &error);
+ if (error) {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ break;
+ }
+
+ n_params++;
+ }
va_end (args);
+ backend->n_params = n_params;
+ backend->params = params;
+
backends = g_list_append (backends, backend);
}
if (g_strcasecmp(name, backend->name) == 0) {
- merge = GL_MERGE (g_object_new_valist (backend->type,
- backend->first_arg_name,
- backend->args));
+ merge = GL_MERGE (g_object_newv (backend->type,
+ backend->n_params,
+ backend->params));
- merge->private->name = name;
- merge->private->description = backend->description;
+ merge->private->name = g_strdup (name);
+ merge->private->description = g_strdup (backend->description);
merge->private->src_type = backend->src_type;
break;
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);
+ dst_merge->private->src_type = src_merge->private->src_type;
if ( GL_MERGE_GET_CLASS(src_merge)->copy != NULL ) {