aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-06-08 15:07:21 +0800
committerChris Lahey <clahey@src.gnome.org>2000-06-08 15:07:21 +0800
commit2f3245408c26ebef806b0824a1f5885b15529fce (patch)
treed03313d46f7338dd2fbfb94c22f07e31e1b0ddf4 /widgets/e-table
parente1ef78b8f4d27c83c4d281bf18980b9acf8568b7 (diff)
downloadgsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar.gz
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar.bz2
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar.lz
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar.xz
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.tar.zst
gsoc2013-evolution-2f3245408c26ebef806b0824a1f5885b15529fce.zip
More work on the Field Chooser. Not quite done yet.
2000-06-08 Christopher James Lahey <clahey@helixcode.com> * e-table-field-chooser-dialog.c, e-table-field-chooser-dialog.h, e-table-field-chooser-item.c, e-table-field-chooser.c, e-table-field-chooser.glade, e-table-field-chooser.h, e-table-header-item.c, e-table.c: More work on the Field Chooser. Not quite done yet. svn path=/trunk/; revision=3475
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog8
-rw-r--r--widgets/e-table/Makefile.am2
-rw-r--r--widgets/e-table/e-table-field-chooser-dialog.c78
-rw-r--r--widgets/e-table/e-table-field-chooser-dialog.h5
-rw-r--r--widgets/e-table/e-table-field-chooser-item.c31
-rw-r--r--widgets/e-table/e-table-field-chooser.c135
-rw-r--r--widgets/e-table/e-table-field-chooser.glade4
-rw-r--r--widgets/e-table/e-table-field-chooser.h7
-rw-r--r--widgets/e-table/e-table-header-item.c52
-rw-r--r--widgets/e-table/e-table.c1
10 files changed, 280 insertions, 43 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 55abf70a12..0871535d2a 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,11 @@
+2000-06-08 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table-field-chooser-dialog.c, e-table-field-chooser-dialog.h,
+ e-table-field-chooser-item.c, e-table-field-chooser.c,
+ e-table-field-chooser.glade, e-table-field-chooser.h,
+ e-table-header-item.c, e-table.c: More work on the Field Chooser.
+ Not quite done yet.
+
2000-06-07 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Added e-table-field-chooser*.
diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am
index dc3dc0b526..bb0cc97edb 100644
--- a/widgets/e-table/Makefile.am
+++ b/widgets/e-table/Makefile.am
@@ -13,7 +13,7 @@ glade_headers = \
INCLUDES = \
$(EXTRA_GNOME_CFLAGS) \
$(GNOME_INCLUDEDIR) \
- -DETABLE_GLADEDIR=\""$(gladedir)"\" \
+ -DETABLE_GLADEDIR=\"$(gladedir)\" \
-I$(top_srcdir)/widgets/e-text \
-I$(top_srcdir)/e-util \
-I$(top_srcdir) \
diff --git a/widgets/e-table/e-table-field-chooser-dialog.c b/widgets/e-table/e-table-field-chooser-dialog.c
index 6fbc5ba38c..c4be650bf1 100644
--- a/widgets/e-table/e-table-field-chooser-dialog.c
+++ b/widgets/e-table/e-table-field-chooser-dialog.c
@@ -28,12 +28,15 @@ static void e_table_field_chooser_dialog_init (ETableFieldChooserDialog *card
static void e_table_field_chooser_dialog_class_init (ETableFieldChooserDialogClass *klass);
static void e_table_field_chooser_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
static void e_table_field_chooser_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+static void e_table_field_chooser_dialog_destroy (GtkObject *object);
static GnomeDialogClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
+ ARG_DND_CODE,
+ ARG_FULL_HEADER,
};
GtkType
@@ -55,7 +58,7 @@ e_table_field_chooser_dialog_get_type (void)
(GtkClassInitFunc) NULL,
};
- table_field_chooser_dialog_type = gtk_type_unique (gtk_vbox_get_type (), &table_field_chooser_dialog_info);
+ table_field_chooser_dialog_type = gtk_type_unique (gnome_dialog_get_type (), &table_field_chooser_dialog_info);
}
return table_field_chooser_dialog_type;
@@ -65,20 +68,46 @@ static void
e_table_field_chooser_dialog_class_init (ETableFieldChooserDialogClass *klass)
{
GtkObjectClass *object_class;
- GtkVBoxClass *vbox_class;
object_class = (GtkObjectClass*) klass;
- vbox_class = (GtkVBoxClass *) klass;
- parent_class = gtk_type_class (gtk_vbox_get_type ());
+ parent_class = gtk_type_class (gnome_dialog_get_type ());
+ object_class->destroy = e_table_field_chooser_dialog_destroy;
object_class->set_arg = e_table_field_chooser_dialog_set_arg;
object_class->get_arg = e_table_field_chooser_dialog_get_arg;
+
+ gtk_object_add_arg_type ("ETableFieldChooserDialog::dnd_code", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_DND_CODE);
+ gtk_object_add_arg_type ("ETableFieldChooserDialog::full_header", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_FULL_HEADER);
}
static void
e_table_field_chooser_dialog_init (ETableFieldChooserDialog *e_table_field_chooser_dialog)
{
+ GtkWidget *widget;
+
+ e_table_field_chooser_dialog->etfc = NULL;
+ e_table_field_chooser_dialog->dnd_code = g_strdup("");
+ e_table_field_chooser_dialog->full_header = NULL;
+
+ gnome_dialog_append_buttons(GNOME_DIALOG(e_table_field_chooser_dialog),
+ GNOME_STOCK_BUTTON_CLOSE,
+ NULL);
+
+ widget = e_table_field_chooser_new();
+ e_table_field_chooser_dialog->etfc = E_TABLE_FIELD_CHOOSER(widget);
+
+ gtk_object_set(GTK_OBJECT(widget),
+ "dnd_code", e_table_field_chooser_dialog->dnd_code,
+ "full_header", e_table_field_chooser_dialog->full_header,
+ NULL);
+
+ gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(e_table_field_chooser_dialog)->vbox),
+ widget, TRUE, TRUE, 0);
+
+ gtk_widget_show(GTK_WIDGET(widget));
}
GtkWidget*
@@ -89,9 +118,41 @@ e_table_field_chooser_dialog_new (void)
}
static void
-e_table_field_chooser_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+e_table_field_chooser_dialog_destroy (GtkObject *object)
+{
+ ETableFieldChooserDialog *etfcd = E_TABLE_FIELD_CHOOSER_DIALOG (object);
+ g_free(etfcd->dnd_code);
+ if (etfcd->full_header)
+ gtk_object_unref(GTK_OBJECT(etfcd->full_header));
+}
+
+static void
+e_table_field_chooser_dialog_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
+ ETableFieldChooserDialog *etfcd = E_TABLE_FIELD_CHOOSER_DIALOG(object);
switch (arg_id){
+ case ARG_DND_CODE:
+ g_free(etfcd->dnd_code);
+ etfcd->dnd_code = g_strdup(GTK_VALUE_STRING (*arg));
+ if (etfcd->etfc)
+ gtk_object_set(GTK_OBJECT(etfcd->etfc),
+ "dnd_code", etfcd->dnd_code,
+ NULL);
+ break;
+ case ARG_FULL_HEADER:
+ if (etfcd->full_header)
+ gtk_object_unref(GTK_OBJECT(etfcd->full_header));
+ if (GTK_VALUE_OBJECT(*arg))
+ etfcd->full_header = E_TABLE_HEADER(GTK_VALUE_OBJECT(*arg));
+ else
+ etfcd->full_header = NULL;
+ if (etfcd->full_header)
+ gtk_object_ref(GTK_OBJECT(etfcd->full_header));
+ if (etfcd->etfc)
+ gtk_object_set(GTK_OBJECT(etfcd->etfc),
+ "full_header", etfcd->full_header,
+ NULL);
+ break;
default:
break;
}
@@ -100,7 +161,14 @@ e_table_field_chooser_dialog_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
static void
e_table_field_chooser_dialog_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
+ ETableFieldChooserDialog *etfcd = E_TABLE_FIELD_CHOOSER_DIALOG(object);
switch (arg_id) {
+ case ARG_DND_CODE:
+ GTK_VALUE_STRING (*arg) = g_strdup (etfcd->dnd_code);
+ break;
+ case ARG_FULL_HEADER:
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(etfcd->full_header);
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/widgets/e-table/e-table-field-chooser-dialog.h b/widgets/e-table/e-table-field-chooser-dialog.h
index 3a23f13bb5..c209210dda 100644
--- a/widgets/e-table/e-table-field-chooser-dialog.h
+++ b/widgets/e-table/e-table-field-chooser-dialog.h
@@ -24,6 +24,7 @@
#include <gnome.h>
#include <glade/glade.h>
#include "e-table-field-chooser.h"
+#include "e-table-header.h"
#ifdef __cplusplus
extern "C" {
@@ -53,7 +54,9 @@ struct _ETableFieldChooserDialog
GnomeDialog parent;
/* item specific fields */
- ETableFieldChooser *chooser;
+ ETableFieldChooser *etfc;
+ gchar *dnd_code;
+ ETableHeader *full_header;
};
struct _ETableFieldChooserDialogClass
diff --git a/widgets/e-table/e-table-field-chooser-item.c b/widgets/e-table/e-table-field-chooser-item.c
index fd08af3307..4d0d03b0d4 100644
--- a/widgets/e-table/e-table-field-chooser-item.c
+++ b/widgets/e-table/e-table-field-chooser-item.c
@@ -44,9 +44,8 @@ static void etfci_drop_table_header (ETableFieldChooserItem *etfci);
enum {
ARG_0,
- ARG_TABLE_HEADER,
+ ARG_FULL_HEADER,
ARG_DND_CODE,
- ARG_TABLE_FONTSET,
ARG_WIDTH,
ARG_HEIGHT,
};
@@ -140,10 +139,15 @@ etfci_drop_table_header (ETableFieldChooserItem *etfci)
return;
header = GTK_OBJECT (etfci->full_header);
- gtk_signal_disconnect (header, etfci->structure_change_id);
- gtk_signal_disconnect (header, etfci->dimension_change_id);
+ if (etfci->structure_change_id)
+ gtk_signal_disconnect (header, etfci->structure_change_id);
+ if (etfci->dimension_change_id)
+ gtk_signal_disconnect (header, etfci->dimension_change_id);
+ etfci->structure_change_id = 0;
+ etfci->dimension_change_id = 0;
- gtk_object_unref (header);
+ if (header)
+ gtk_object_unref (header);
etfci->full_header = NULL;
etfci->height = 0;
}
@@ -185,9 +189,10 @@ etfci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
etfci = E_TABLE_FIELD_CHOOSER_ITEM (o);
switch (arg_id){
- case ARG_TABLE_HEADER:
+ case ARG_FULL_HEADER:
etfci_drop_table_header (etfci);
- etfci_add_table_header (etfci, E_TABLE_HEADER(GTK_VALUE_OBJECT (*arg)));
+ if (GTK_VALUE_OBJECT (*arg))
+ etfci_add_table_header (etfci, E_TABLE_HEADER(GTK_VALUE_OBJECT (*arg)));
break;
case ARG_DND_CODE:
@@ -195,11 +200,6 @@ etfci_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
etfci->dnd_code = g_strdup(GTK_VALUE_STRING (*arg));
break;
- case ARG_TABLE_FONTSET:
- etfci_font_load (etfci, GTK_VALUE_STRING (*arg));
- e_canvas_item_request_reflow(item);
- break;
-
case ARG_WIDTH:
etfci->width = GTK_VALUE_DOUBLE (*arg);
gnome_canvas_item_request_update(item);
@@ -506,17 +506,14 @@ etfci_class_init (GtkObjectClass *object_class)
item_class->point = etfci_point;
item_class->event = etfci_event;
- gtk_object_add_arg_type ("ETableFieldChooserItem::ETableHeader", GTK_TYPE_OBJECT,
- GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
gtk_object_add_arg_type ("ETableFieldChooserItem::dnd_code", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_DND_CODE);
- gtk_object_add_arg_type ("ETableFieldChooserItem::fontset", GTK_TYPE_STRING,
- GTK_ARG_WRITABLE, ARG_TABLE_FONTSET);
+ gtk_object_add_arg_type ("ETableFieldChooserItem::full_header", GTK_TYPE_OBJECT,
+ GTK_ARG_WRITABLE, ARG_FULL_HEADER);
gtk_object_add_arg_type ("ETableFieldChooserItem::width", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_WIDTH);
gtk_object_add_arg_type ("ETableFieldChooserItem::height", GTK_TYPE_DOUBLE,
GTK_ARG_READABLE, ARG_HEIGHT);
-
}
static void
diff --git a/widgets/e-table/e-table-field-chooser.c b/widgets/e-table/e-table-field-chooser.c
index 71582edf58..b72c93a197 100644
--- a/widgets/e-table/e-table-field-chooser.c
+++ b/widgets/e-table/e-table-field-chooser.c
@@ -36,6 +36,8 @@ static GtkVBoxClass *parent_class = NULL;
/* The arguments we take */
enum {
ARG_0,
+ ARG_FULL_HEADER,
+ ARG_DND_CODE,
};
GtkType
@@ -77,37 +79,110 @@ e_table_field_chooser_class_init (ETableFieldChooserClass *klass)
object_class->set_arg = e_table_field_chooser_set_arg;
object_class->get_arg = e_table_field_chooser_get_arg;
object_class->destroy = e_table_field_chooser_destroy;
+ gtk_object_add_arg_type ("ETableFieldChooser::dnd_code", GTK_TYPE_STRING,
+ GTK_ARG_READWRITE, ARG_DND_CODE);
+ gtk_object_add_arg_type ("ETableFieldChooser::full_header", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_FULL_HEADER);
+}
+
+static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, ETableFieldChooser *etfc)
+{
+ double height;
+ etfc->last_alloc = *allocation;
+ gnome_canvas_item_set( etfc->item,
+ "width", (double) allocation->width,
+ NULL );
+ gtk_object_get(GTK_OBJECT(etfc->item),
+ "height", &height,
+ NULL);
+ gnome_canvas_set_scroll_region(GNOME_CANVAS( etfc->canvas ), 0, 0, allocation->width, height );
+ gnome_canvas_item_set( etfc->rect,
+ "x2", (double) allocation->width,
+ "y2", (double) height,
+ NULL );
+}
+
+static void resize(GnomeCanvas *canvas, ETableFieldChooser *etfc)
+{
+ double height;
+ gtk_object_get(GTK_OBJECT(etfc->item),
+ "height", &height,
+ NULL);
+
+ gnome_canvas_set_scroll_region (GNOME_CANVAS(etfc->canvas), 0, 0, etfc->last_alloc.width, height);
+ gnome_canvas_item_set( etfc->rect,
+ "x2", (double) etfc->last_alloc.width,
+ "y2", (double) height,
+ NULL );
}
static void
-e_table_field_chooser_init (ETableFieldChooser *e_table_field_chooser)
+e_table_field_chooser_init (ETableFieldChooser *etfc)
{
GladeXML *gui;
GtkWidget *widget;
- gui = glade_xml_new (ETABLE_GLADEDIR "/fullname.glade", NULL);
- e_table_field_chooser->gui = gui;
+ gui = glade_xml_new (ETABLE_GLADEDIR "/e-table-field-chooser.glade", NULL);
+ etfc->gui = gui;
widget = glade_xml_get_widget(gui, "vbox-top");
if (!widget) {
return;
}
gtk_widget_reparent(widget,
- GTK_WIDGET(e_table_field_chooser));
-
- e_table_field_chooser->canvas = GNOME_CANVAS(glade_xml_get_widget(gui, "canvas-buttons"));
- e_table_field_chooser->item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(e_table_field_chooser->canvas->root),
- e_table_field_chooser_item_get_type(),
- NULL);
+ GTK_WIDGET(etfc));
+
+ gtk_widget_push_visual (gdk_rgb_get_visual ());
+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+
+ etfc->canvas = GNOME_CANVAS(glade_xml_get_widget(gui, "canvas-buttons"));
+
+ etfc->rect = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS( etfc->canvas ) ),
+ gnome_canvas_rect_get_type(),
+ "x1", (double) 0,
+ "y1", (double) 0,
+ "x2", (double) 100,
+ "y2", (double) 100,
+ "fill_color", "white",
+ NULL );
+
+ etfc->item = gnome_canvas_item_new(gnome_canvas_root(etfc->canvas),
+ e_table_field_chooser_item_get_type(),
+ "height", (double) 100,
+ "width", (double) 100,
+ "full_header", etfc->full_header,
+ "dnd_code", etfc->dnd_code,
+ NULL );
+
+ gtk_signal_connect( GTK_OBJECT( etfc->canvas ), "reflow",
+ GTK_SIGNAL_FUNC( resize ),
+ etfc);
+
+ gnome_canvas_set_scroll_region ( GNOME_CANVAS( etfc->canvas ),
+ 0, 0,
+ 100, 100 );
+
+ /* Connect the signals */
+ gtk_signal_connect (GTK_OBJECT (etfc->canvas), "size_allocate",
+ GTK_SIGNAL_FUNC (allocate_callback),
+ etfc);
+
+ gtk_widget_pop_visual ();
+ gtk_widget_pop_colormap ();
+ gtk_widget_show(widget);
}
-void
+static void
e_table_field_chooser_destroy (GtkObject *object)
{
- ETableFieldChooser *e_table_field_chooser = E_TABLE_FIELD_CHOOSER(object);
+ ETableFieldChooser *etfc = E_TABLE_FIELD_CHOOSER(object);
- if (e_table_field_chooser->gui)
- gtk_object_unref(GTK_OBJECT(e_table_field_chooser->gui));
+ g_free(etfc->dnd_code);
+ if (etfc->full_header)
+ gtk_object_unref(GTK_OBJECT(etfc->full_header));
+
+ if (etfc->gui)
+ gtk_object_unref(GTK_OBJECT(etfc->gui));
}
GtkWidget*
@@ -118,9 +193,33 @@ e_table_field_chooser_new (void)
}
static void
-e_table_field_chooser_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
+e_table_field_chooser_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
+ ETableFieldChooser *etfc = E_TABLE_FIELD_CHOOSER(object);
+
switch (arg_id){
+ case ARG_DND_CODE:
+ g_free(etfc->dnd_code);
+ etfc->dnd_code = g_strdup(GTK_VALUE_STRING (*arg));
+ if (etfc->item)
+ gtk_object_set(GTK_OBJECT(etfc->item),
+ "dnd_code", etfc->dnd_code,
+ NULL);
+ break;
+ case ARG_FULL_HEADER:
+ if (etfc->full_header)
+ gtk_object_unref(GTK_OBJECT(etfc->full_header));
+ if (GTK_VALUE_OBJECT(*arg))
+ etfc->full_header = E_TABLE_HEADER(GTK_VALUE_OBJECT(*arg));
+ else
+ etfc->full_header = NULL;
+ if (etfc->full_header)
+ gtk_object_ref(GTK_OBJECT(etfc->full_header));
+ if (etfc->item)
+ gtk_object_set(GTK_OBJECT(etfc->item),
+ "full_header", etfc->full_header,
+ NULL);
+ break;
default:
break;
}
@@ -129,7 +228,15 @@ e_table_field_chooser_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
static void
e_table_field_chooser_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
+ ETableFieldChooser *etfc = E_TABLE_FIELD_CHOOSER(object);
+
switch (arg_id) {
+ case ARG_DND_CODE:
+ GTK_VALUE_STRING (*arg) = g_strdup (etfc->dnd_code);
+ break;
+ case ARG_FULL_HEADER:
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(etfc->full_header);
+ break;
default:
arg->type = GTK_TYPE_INVALID;
break;
diff --git a/widgets/e-table/e-table-field-chooser.glade b/widgets/e-table/e-table-field-chooser.glade
index d179e0cca8..96408b9891 100644
--- a/widgets/e-table/e-table-field-chooser.glade
+++ b/widgets/e-table/e-table-field-chooser.glade
@@ -85,8 +85,8 @@
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
- <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
- <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
+ <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
diff --git a/widgets/e-table/e-table-field-chooser.h b/widgets/e-table/e-table-field-chooser.h
index e1d8289824..d84aafdc63 100644
--- a/widgets/e-table/e-table-field-chooser.h
+++ b/widgets/e-table/e-table-field-chooser.h
@@ -23,6 +23,7 @@
#include <gnome.h>
#include <glade/glade.h>
+#include "e-table-header.h"
#ifdef __cplusplus
extern "C" {
@@ -55,6 +56,12 @@ struct _ETableFieldChooser
GladeXML *gui;
GnomeCanvas *canvas;
GnomeCanvasItem *item;
+
+ GnomeCanvasItem *rect;
+ GtkAllocation last_alloc;
+
+ gchar *dnd_code;
+ ETableHeader *full_header;
};
struct _ETableFieldChooserClass
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index 26ed69c73c..d9b10343ce 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -22,6 +22,7 @@
#include "e-table-header-item.h"
#include "e-table-col-dnd.h"
#include "e-table-defines.h"
+#include "e-table-field-chooser-dialog.h"
#include "add-col.xpm"
#include "remove-col.xpm"
@@ -67,6 +68,7 @@ static GdkPixmap *add_col_pixmap, *add_col_mask;
enum {
ARG_0,
ARG_TABLE_HEADER,
+ ARG_FULL_HEADER,
ARG_DND_CODE,
ARG_TABLE_FONTSET,
ARG_SORT_INFO
@@ -213,6 +215,14 @@ ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
ethi_add_table_header (ethi, E_TABLE_HEADER(GTK_VALUE_OBJECT (*arg)));
break;
+ case ARG_FULL_HEADER:
+ if (ethi->full_header)
+ gtk_object_unref(GTK_OBJECT(ethi->full_header));
+ ethi->full_header = E_TABLE_HEADER(GTK_VALUE_OBJECT (*arg));
+ if (ethi->full_header)
+ gtk_object_ref(GTK_OBJECT(ethi->full_header));
+ break;
+
case ARG_DND_CODE:
g_free(ethi->dnd_code);
ethi->dnd_code = g_strdup (GTK_VALUE_STRING (*arg));
@@ -259,6 +269,9 @@ ethi_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
ethi = E_TABLE_HEADER_ITEM (o);
switch (arg_id){
+ case ARG_FULL_HEADER:
+ GTK_VALUE_OBJECT (*arg) = GTK_OBJECT (ethi->full_header);
+ break;
case ARG_DND_CODE:
GTK_VALUE_STRING (*arg) = g_strdup (ethi->dnd_code);
break;
@@ -464,7 +477,32 @@ ethi_drag_data_received (GtkWidget *canvas,
guint time,
ETableHeaderItem *ethi)
{
- e_table_header_move (ethi->eth, ethi->drag_col, ethi->drop_col);
+ int found = FALSE;
+ int count = e_table_header_count(ethi->eth);
+ int column = atoi(data->data);
+ int drop_col = ethi->drop_col;
+ int i;
+ ethi->drop_col = -1;
+ if (column < 0)
+ return;
+ for (i = 0; i < count; i++) {
+ ETableCol *ecol = e_table_header_get_column (ethi->eth, i);
+ if (ecol->col_idx == column) {
+ e_table_header_move(ethi->eth, i, drop_col);
+ found = TRUE;
+ break;
+ }
+ }
+ if (!found) {
+ count = e_table_header_count(ethi->full_header);
+ for (i = 0; i < count; i++) {
+ ETableCol *ecol = e_table_header_get_column (ethi->full_header, i);
+ if (ecol->col_idx == column) {
+ e_table_header_add_column (ethi->eth, ecol, drop_col);
+ break;
+ }
+ }
+ }
gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(ethi));
}
@@ -1032,6 +1070,12 @@ ethi_popup_remove_column(GtkWidget *widget, EthiHeaderInfo *info)
static void
ethi_popup_field_chooser(GtkWidget *widget, EthiHeaderInfo *info)
{
+ GtkWidget *etfcd = e_table_field_chooser_dialog_new();
+ gtk_object_set(GTK_OBJECT(etfcd),
+ "full_header", info->ethi->full_header,
+ "dnd_code", info->ethi->dnd_code,
+ NULL);
+ gtk_widget_show(etfcd);
}
static void
@@ -1062,7 +1106,7 @@ static EPopupMenu ethi_context_menu [] = {
{ "Group By Box", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_box), 1},
{ "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
{ "Remove This Column", NULL, GTK_SIGNAL_FUNC(ethi_popup_remove_column), 0},
- { "Field Chooser", NULL, GTK_SIGNAL_FUNC(ethi_popup_field_chooser), 1},
+ { "Field Chooser", NULL, GTK_SIGNAL_FUNC(ethi_popup_field_chooser), 0},
{ "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
{ "Alignment", NULL, GTK_SIGNAL_FUNC(ethi_popup_alignment), 1},
{ "Best Fit", NULL, GTK_SIGNAL_FUNC(ethi_popup_best_fit), 1},
@@ -1265,8 +1309,10 @@ ethi_class_init (GtkObjectClass *object_class)
gtk_object_add_arg_type ("ETableHeaderItem::ETableHeader", GTK_TYPE_OBJECT,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
+ gtk_object_add_arg_type ("ETableHeaderItem::full_header", GTK_TYPE_OBJECT,
+ GTK_ARG_READWRITE, ARG_FULL_HEADER);
gtk_object_add_arg_type ("ETableHeaderItem::dnd_code", GTK_TYPE_STRING,
- GTK_ARG_WRITABLE, ARG_DND_CODE);
+ GTK_ARG_READWRITE, ARG_DND_CODE);
gtk_object_add_arg_type ("ETableHeaderItem::fontset", GTK_TYPE_STRING,
GTK_ARG_WRITABLE, ARG_TABLE_FONTSET);
gtk_object_add_arg_type ("ETableHeaderItem::sort_info", GTK_TYPE_OBJECT,
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index 21a92f5ecb..1be22b7bde 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -142,6 +142,7 @@ e_table_setup_header (ETable *e_table)
gnome_canvas_root (e_table->header_canvas),
e_table_header_item_get_type (),
"ETableHeader", e_table->header,
+ "full_header", e_table->full_header,
"sort_info", e_table->sort_info,
NULL);