aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table-field-chooser-item.c
blob: dafd0b79fe964d2e1682aeee4a3aac8418cfb98f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
 *
 *
 * Authors:
 *      Chris Lahey <clahey@ximian.com>
 *
 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 *
 */

#include <config.h>

#include <string.h>

#include <gtk/gtk.h>
#include <libgnomecanvas/libgnomecanvas.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

#include <glib/gi18n.h>
#include "e-util/e-util.h"
#include "e-util/e-xml-utils.h"
#include "misc/e-canvas.h"

#include "e-table-col-dnd.h"
#include "e-table-defines.h"
#include "e-table-field-chooser-item.h"
#include "e-table-header-utils.h"
#include "e-table-header.h"

#define d(x)

#if 0
enum {
    BUTTON_PRESSED,
    LAST_SIGNAL
};

static guint etfci_signals[LAST_SIGNAL] = { 0, };
#endif

/* workaround for avoiding API breakage */
#define etfci_get_type e_table_field_chooser_item_get_type
G_DEFINE_TYPE (ETableFieldChooserItem, etfci, GNOME_TYPE_CANVAS_ITEM)

static void etfci_drop_table_header (ETableFieldChooserItem *etfci);
static void etfci_drop_full_header (ETableFieldChooserItem *etfci);

enum {
    PROP_0,
    PROP_FULL_HEADER,
    PROP_HEADER,
    PROP_DND_CODE,
    PROP_WIDTH,
    PROP_HEIGHT
};

static void
etfci_dispose (GObject *object)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (object);

    etfci_drop_table_header (etfci);
    etfci_drop_full_header (etfci);

    if (etfci->combined_header)
        g_object_unref (etfci->combined_header);
    etfci->combined_header = NULL;

    if (etfci->font_desc)
        pango_font_description_free (etfci->font_desc);
    etfci->font_desc = NULL;

    if (G_OBJECT_CLASS (etfci_parent_class)->dispose)
        (*G_OBJECT_CLASS (etfci_parent_class)->dispose) (object);
}

static gint
etfci_find_button (ETableFieldChooserItem *etfci, gdouble loc)
{
    gint i;
    gint count;
    gdouble height = 0;

    count = e_table_header_count (etfci->combined_header);
    for (i = 0; i < count; i++) {
        ETableCol *ecol;

        ecol = e_table_header_get_column (etfci->combined_header, i);
        if (ecol->disabled)
            continue;
        height += e_table_header_compute_height (
            ecol, GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas));
        if (height > loc)
            return i;
    }
    return MAX (0, count - 1);
}

static void
etfci_rebuild_combined (ETableFieldChooserItem *etfci)
{
    gint count;
    GHashTable *hash;
    gint i;

    if (etfci->combined_header != NULL)
        g_object_unref (etfci->combined_header);

    etfci->combined_header = e_table_header_new ();

    hash = g_hash_table_new (NULL, NULL);

    count = e_table_header_count (etfci->header);
    for (i = 0; i < count; i++) {
        ETableCol *ecol = e_table_header_get_column (etfci->header, i);
        if (ecol->disabled)
            continue;
        g_hash_table_insert (hash, GINT_TO_POINTER (ecol->col_idx), GINT_TO_POINTER (1));
    }

    count = e_table_header_count (etfci->full_header);
    for (i = 0; i < count; i++) {
        ETableCol *ecol = e_table_header_get_column (etfci->full_header, i);
        if (ecol->disabled)
            continue;
        if (!(GPOINTER_TO_INT (g_hash_table_lookup (hash, GINT_TO_POINTER (ecol->col_idx)))))
            e_table_header_add_column (etfci->combined_header, ecol, -1);
    }

    g_hash_table_destroy (hash);
}

static void
etfci_reflow (GnomeCanvasItem *item, gint flags)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
    gdouble old_height;
    gint i;
    gint count;
    gdouble height = 0;

    etfci_rebuild_combined (etfci);

    old_height = etfci->height;

    count = e_table_header_count (etfci->combined_header);
    for (i = 0; i < count; i++) {
        ETableCol *ecol;

        ecol = e_table_header_get_column (etfci->combined_header, i);
        if (ecol->disabled)
            continue;
        height += e_table_header_compute_height (
            ecol, GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas));
    }

    etfci->height = height;

    if (old_height != etfci->height)
        e_canvas_item_request_parent_reflow (item);

    gnome_canvas_item_request_update (item);
}

static void
etfci_update (GnomeCanvasItem *item,
              const cairo_matrix_t *i2c,
              gint flags)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
    gdouble x1, y1, x2, y2;

    if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update)
        GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->update (
            item, i2c, flags);

    x1 = y1 = 0;
    x2 = etfci->width;
    y2 = etfci->height;

    gnome_canvas_matrix_transform_rect (i2c, &x1, &y1, &x2, &y2);

    if (item->x1 != x1 ||
        item->y1 != y1 ||
        item->x2 != x2 ||
        item->y2 != y2)
        {
            gnome_canvas_request_redraw (
                item->canvas, item->x1,
                item->y1, item->x2, item->y2);
            item->x1 = x1;
            item->y1 = y1;
            item->x2 = x2;
            item->y2 = y2;
/* FIXME: Group Child bounds !? */
#if 0
            gnome_canvas_group_child_bounds (
                GNOME_CANVAS_GROUP (item->parent), item);
#endif
        }
    gnome_canvas_request_redraw (
        item->canvas, item->x1, item->y1, item->x2, item->y2);
}

static void
etfci_font_load (ETableFieldChooserItem *etfci)
{
    GtkWidget *widget;
    GtkStyle *style;

    if (etfci->font_desc)
        pango_font_description_free (etfci->font_desc);

    widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas);
    style = gtk_widget_get_style (widget);
    etfci->font_desc = pango_font_description_copy (style->font_desc);
}

static void
etfci_drop_full_header (ETableFieldChooserItem *etfci)
{
    GObject *header;

    if (!etfci->full_header)
        return;

    header = G_OBJECT (etfci->full_header);
    if (etfci->full_header_structure_change_id)
        g_signal_handler_disconnect (
            header, etfci->full_header_structure_change_id);
    if (etfci->full_header_dimension_change_id)
        g_signal_handler_disconnect (
            header, etfci->full_header_dimension_change_id);
    etfci->full_header_structure_change_id = 0;
    etfci->full_header_dimension_change_id = 0;

    if (header)
        g_object_unref (header);
    etfci->full_header = NULL;
    etfci->height = 0;
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
full_header_structure_changed (ETableHeader *header,
                               ETableFieldChooserItem *etfci)
{
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
full_header_dimension_changed (ETableHeader *header,
                               gint col,
                               ETableFieldChooserItem *etfci)
{
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
etfci_add_full_header (ETableFieldChooserItem *etfci,
                       ETableHeader *header)
{
    etfci->full_header = header;
    g_object_ref (etfci->full_header);

    etfci->full_header_structure_change_id = g_signal_connect (
        header, "structure_change",
        G_CALLBACK (full_header_structure_changed), etfci);
    etfci->full_header_dimension_change_id = g_signal_connect (
        header, "dimension_change",
        G_CALLBACK (full_header_dimension_changed), etfci);
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
etfci_drop_table_header (ETableFieldChooserItem *etfci)
{
    GObject *header;

    if (!etfci->header)
        return;

    header = G_OBJECT (etfci->header);
    if (etfci->table_header_structure_change_id)
        g_signal_handler_disconnect (header, etfci->table_header_structure_change_id);
    if (etfci->table_header_dimension_change_id)
        g_signal_handler_disconnect (header, etfci->table_header_dimension_change_id);
    etfci->table_header_structure_change_id = 0;
    etfci->table_header_dimension_change_id = 0;

    if (header)
        g_object_unref (header);
    etfci->header = NULL;
    etfci->height = 0;
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
table_header_structure_changed (ETableHeader *header,
                                ETableFieldChooserItem *etfci)
{
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
table_header_dimension_changed (ETableHeader *header,
                                gint col,
                                ETableFieldChooserItem *etfci)
{
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
etfci_add_table_header (ETableFieldChooserItem *etfci,
                        ETableHeader *header)
{
    etfci->header = header;
    g_object_ref (etfci->header);

    etfci->table_header_structure_change_id = g_signal_connect (
        header, "structure_change",
        G_CALLBACK (table_header_structure_changed), etfci);
    etfci->table_header_dimension_change_id = g_signal_connect (
        header, "dimension_change",
        G_CALLBACK (table_header_dimension_changed), etfci);
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
etfci_set_property (GObject *object,
                    guint prop_id,
                    const GValue *value,
                    GParamSpec *pspec)
{
    GnomeCanvasItem *item;
    ETableFieldChooserItem *etfci;

    item = GNOME_CANVAS_ITEM (object);
    etfci = E_TABLE_FIELD_CHOOSER_ITEM (object);

    switch (prop_id) {
    case PROP_FULL_HEADER:
        etfci_drop_full_header (etfci);
        if (g_value_get_object (value))
            etfci_add_full_header (etfci, E_TABLE_HEADER (g_value_get_object (value)));
        break;

    case PROP_HEADER:
        etfci_drop_table_header (etfci);
        if (g_value_get_object (value))
            etfci_add_table_header (etfci, E_TABLE_HEADER (g_value_get_object (value)));
        break;

    case PROP_DND_CODE:
        g_free (etfci->dnd_code);
        etfci->dnd_code = g_strdup (g_value_get_string (value));
        break;

    case PROP_WIDTH:
        etfci->width = g_value_get_double (value);
        gnome_canvas_item_request_update (item);
        break;
    }
}

static void
etfci_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
    ETableFieldChooserItem *etfci;

    etfci = E_TABLE_FIELD_CHOOSER_ITEM (object);

    switch (prop_id) {

    case PROP_DND_CODE:
        g_value_set_string (value, etfci->dnd_code);
        break;
    case PROP_WIDTH:
        g_value_set_double (value, etfci->width);
        break;
    case PROP_HEIGHT:
        g_value_set_double (value, etfci->height);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}

static void
etfci_drag_data_get (GtkWidget          *widget,
             GdkDragContext     *context,
             GtkSelectionData   *selection_data,
             guint               info,
             guint               time,
             ETableFieldChooserItem *etfci)
{
    if (etfci->drag_col != -1) {
        gchar *string = g_strdup_printf("%d", etfci->drag_col);
        gtk_selection_data_set (selection_data,
                       GDK_SELECTION_TYPE_STRING,
                       sizeof (string[0]),
                       (guchar *)string,
                       strlen (string));
        g_free (string);
    }
}

static void
etfci_drag_end (GtkWidget      *canvas,
        GdkDragContext *context,
        ETableFieldChooserItem *etfci)
{
    etfci->drag_col = -1;
}

static void
etfci_realize (GnomeCanvasItem *item)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);

    if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)-> realize)
        (*GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->realize)(item);

    if (!etfci->font_desc)
        etfci_font_load (etfci);

    etfci->drag_end_id = g_signal_connect (
        item->canvas, "drag_end",
        G_CALLBACK (etfci_drag_end), etfci);
    etfci->drag_data_get_id = g_signal_connect (
        item->canvas, "drag_data_get",
        G_CALLBACK (etfci_drag_data_get), etfci);
    e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
}

static void
etfci_unrealize (GnomeCanvasItem *item)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);

    if (etfci->font_desc)
        pango_font_description_free (etfci->font_desc);
    etfci->font_desc = NULL;

    g_signal_handler_disconnect (item->canvas, etfci->drag_end_id);
    etfci->drag_end_id = 0;
    g_signal_handler_disconnect (item->canvas, etfci->drag_data_get_id);
    etfci->drag_data_get_id = 0;

    if (GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->unrealize)
        (*GNOME_CANVAS_ITEM_CLASS (etfci_parent_class)->unrealize)(item);
}

static void
etfci_draw (GnomeCanvasItem *item,
            cairo_t *cr,
            gint x,
            gint y,
            gint width,
            gint height)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
    GnomeCanvas *canvas = item->canvas;
    gint rows;
    gint y1, y2;
    gint row;
    GtkStyle *style;
    GtkStateType state;

    if (etfci->combined_header == NULL)
        return;

    rows = e_table_header_count (etfci->combined_header);

    style = gtk_widget_get_style (GTK_WIDGET (canvas));
    state = gtk_widget_get_state (GTK_WIDGET (canvas));

    y1 = y2 = 0;
    for (row = 0; row < rows; row++, y1 = y2) {
        ETableCol *ecol;

        ecol = e_table_header_get_column (etfci->combined_header, row);

        if (ecol->disabled)
            continue;

        y2 += e_table_header_compute_height (ecol, GTK_WIDGET (canvas));

        if (y1 > (y + height))
            break;

        if (y2 < y)
            continue;

        cairo_save (cr);

        e_table_header_draw_button (cr, ecol,
                        style, state,
                        GTK_WIDGET (canvas),
                        -x, y1 - y,
                        width, height,
                        etfci->width, y2 - y1,
                        E_TABLE_COL_ARROW_NONE);

        cairo_restore (cr);
    }
}

static GnomeCanvasItem *
etfci_point (GnomeCanvasItem *item, gdouble x, gdouble y, gint cx, gint cy)
{
    return item;
}

static gboolean
etfci_maybe_start_drag (ETableFieldChooserItem *etfci, gint x, gint y)
{
    if (!etfci->maybe_drag)
        return FALSE;

    if (MAX (abs (etfci->click_x - x),
         abs (etfci->click_y - y)) <= 3)
        return FALSE;

    return TRUE;
}

static void
etfci_start_drag (ETableFieldChooserItem *etfci, GdkEvent *event, gdouble x, gdouble y)
{
    GtkWidget *widget = GTK_WIDGET (GNOME_CANVAS_ITEM (etfci)->canvas);
    GtkTargetList *list;
    GdkDragContext *context;
    GdkWindow *window;
    GtkStyle *style;
    GtkStateType state;
    ETableCol *ecol;
    cairo_surface_t *cs;
    cairo_t *cr;
    gint drag_col;
    gint button_height;
    GdkPixbuf *pixbuf;

    GtkTargetEntry  etfci_drag_types[] = {
        { (gchar *) TARGET_ETABLE_COL_TYPE, 0, TARGET_ETABLE_COL_HEADER },
    };

    if (etfci->combined_header == NULL)
        return;

    drag_col = etfci_find_button (etfci, y);

    if (drag_col < 0 || drag_col > e_table_header_count (etfci->combined_header))
        return;

    ecol = e_table_header_get_column (etfci->combined_header, drag_col);

    if (ecol->disabled)
        return;

    etfci->drag_col = ecol->col_idx;

    etfci_drag_types[0].target = g_strdup_printf (
        "%s-%s", etfci_drag_types[0].target, etfci->dnd_code);
    d(g_print ("etfci - %s\n", etfci_drag_types[0].target));
    list = gtk_target_list_new (etfci_drag_types, G_N_ELEMENTS (etfci_drag_types));
    context = gtk_drag_begin (widget, list, GDK_ACTION_MOVE, 1, event);
    g_free ((gpointer) etfci_drag_types[0].target);

    button_height = e_table_header_compute_height (ecol, widget);
    window = gtk_widget_get_window (widget);
    cs = gdk_window_create_similar_surface (
        window, CAIRO_CONTENT_COLOR, etfci->width, button_height);

    style = gtk_widget_get_style (widget);
    state = gtk_widget_get_state (widget);

    cr = cairo_create (cs);
    e_table_header_draw_button (
        cr, ecol, style,
        state, widget, 0, 0,
        etfci->width, button_height,
        etfci->width, button_height,
        E_TABLE_COL_ARROW_NONE);

    pixbuf = gdk_pixbuf_get_from_window (window, 0, 0, etfci->width, button_height);
    gtk_drag_set_icon_pixbuf (
        context,
        pixbuf,
        etfci->width / 2,
        button_height / 2);
    g_object_unref (pixbuf);

    cairo_surface_destroy (cs);
    cairo_destroy (cr);
    etfci->maybe_drag = FALSE;
}

/*
 * Handles the events on the ETableFieldChooserItem
 */
static gint
etfci_event (GnomeCanvasItem *item, GdkEvent *e)
{
    ETableFieldChooserItem *etfci = E_TABLE_FIELD_CHOOSER_ITEM (item);
    GnomeCanvas *canvas = item->canvas;
    gint x, y;

    switch (e->type) {
    case GDK_MOTION_NOTIFY:
        gnome_canvas_w2c (canvas, e->motion.x, e->motion.y, &x, &y);

        if (etfci_maybe_start_drag (etfci, x, y))
            etfci_start_drag (etfci, e, x, y);
        break;

    case GDK_BUTTON_PRESS:
        gnome_canvas_w2c (canvas, e->button.x, e->button.y, &x, &y);

        if (e->button.button == 1) {
            etfci->click_x = x;
            etfci->click_y = y;
            etfci->maybe_drag = TRUE;
        }
        break;

    case GDK_BUTTON_RELEASE: {
        etfci->maybe_drag = FALSE;
        break;
    }

    default:
        return FALSE;
    }
    return TRUE;
}

static void
etfci_class_init (ETableFieldChooserItemClass *class)
{
    GnomeCanvasItemClass *item_class = GNOME_CANVAS_ITEM_CLASS (class);
    GObjectClass *object_class = G_OBJECT_CLASS (class);

    object_class->dispose = etfci_dispose;
    object_class->set_property = etfci_set_property;
    object_class->get_property = etfci_get_property;

    item_class->update      = etfci_update;
    item_class->realize     = etfci_realize;
    item_class->unrealize   = etfci_unrealize;
    item_class->draw        = etfci_draw;
    item_class->point       = etfci_point;
    item_class->event       = etfci_event;

    g_object_class_install_property (object_class, PROP_DND_CODE,
                     g_param_spec_string ("dnd_code",
                                  "DnD code",
                                  NULL,
                                  NULL,
                                  G_PARAM_READWRITE));

    g_object_class_install_property (object_class, PROP_FULL_HEADER,
                     g_param_spec_object ("full_header",
                                  "Full Header",
                                  NULL,
                                  E_TYPE_TABLE_HEADER,
                                  G_PARAM_READWRITE));

    g_object_class_install_property (object_class, PROP_HEADER,
                     g_param_spec_object ("header",
                                  "Header",
                                  NULL,
                                  E_TYPE_TABLE_HEADER,
                                  G_PARAM_READWRITE));

    g_object_class_install_property (object_class, PROP_WIDTH,
                     g_param_spec_double ("width",
                                  "Width",
                                  NULL,
                                  0, G_MAXDOUBLE, 0,
                                  G_PARAM_READWRITE));

    g_object_class_install_property (object_class, PROP_HEIGHT,
                     g_param_spec_double ("height",
                                  "Height",
                                  NULL,
                                  0, G_MAXDOUBLE, 0,
                                  G_PARAM_READABLE));
}

static void
etfci_init (ETableFieldChooserItem *etfci)
{
    etfci->full_header = NULL;
    etfci->header = NULL;
    etfci->combined_header = NULL;

    etfci->height = etfci->width = 0;

    etfci->font_desc = NULL;

    etfci->full_header_structure_change_id = 0;
    etfci->full_header_dimension_change_id = 0;
    etfci->table_header_structure_change_id = 0;
    etfci->table_header_dimension_change_id = 0;

    etfci->dnd_code = NULL;

    etfci->maybe_drag = 0;
    etfci->drag_end_id = 0;

    e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM (etfci), etfci_reflow);
}