diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-07-10 19:04:18 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-07-10 19:04:18 +0800 |
commit | 23ca256b7dd10fea00e2914c968e797af6ea0622 (patch) | |
tree | 61744d8851107470ba8b85ccbfbfb6fe49536119 /widgets/e-table | |
parent | 84ba8642c55c514b7fe23aa90fabdbd0d90250ab (diff) | |
download | gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar.gz gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar.bz2 gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar.lz gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar.xz gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.tar.zst gsoc2013-evolution-23ca256b7dd10fea00e2914c968e797af6ea0622.zip |
Add e-table-scrolled.c and e-table-scrolled.h.
2000-07-09 Christopher James Lahey <clahey@helixcode.com>
* Makefile.am: Add e-table-scrolled.c and e-table-scrolled.h.
* e-table-item.c: Make sure that find_cell returns FALSE if the
item doesn't have any cells.
* e-table-scrolled.c, e-table-scrolled.h: Added a widget to
contain an ETable and provide scrollbars (for ease of use.)
* e-table.c, e-table.h: Make this support the scrollable interface
and not contain its own scrollbars.
svn path=/trunk/; revision=4031
Diffstat (limited to 'widgets/e-table')
-rw-r--r-- | widgets/e-table/ChangeLog | 13 | ||||
-rw-r--r-- | widgets/e-table/Makefile.am | 2 | ||||
-rw-r--r-- | widgets/e-table/e-table-field-chooser.c | 4 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.c | 3 | ||||
-rw-r--r-- | widgets/e-table/e-table-scrolled.c | 353 | ||||
-rw-r--r-- | widgets/e-table/e-table-scrolled.h | 65 | ||||
-rw-r--r-- | widgets/e-table/e-table.c | 73 | ||||
-rw-r--r-- | widgets/e-table/e-table.h | 4 |
8 files changed, 476 insertions, 41 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 817a0e70d6..9b5c445ff0 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,5 +1,18 @@ 2000-07-09 Christopher James Lahey <clahey@helixcode.com> + * Makefile.am: Add e-table-scrolled.c and e-table-scrolled.h. + + * e-table-item.c: Make sure that find_cell returns FALSE if the + item doesn't have any cells. + + * e-table-scrolled.c, e-table-scrolled.h: Added a widget to + contain an ETable and provide scrollbars (for ease of use.) + + * e-table.c, e-table.h: Make this support the scrollable interface + and not contain its own scrollbars. + +2000-07-09 Christopher James Lahey <clahey@helixcode.com> + * e-table-item.c (eti_event): Put back e_cell_event sometimes when we're not editing. diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am index c8db9d9e32..7894bc1dec 100644 --- a/widgets/e-table/Makefile.am +++ b/widgets/e-table/Makefile.am @@ -66,6 +66,8 @@ libetable_a_SOURCES = \ e-table-model.h \ e-table-one.c \ e-table-one.h \ + e-table-scrolled.c \ + e-table-scrolled.h \ e-table-simple.c \ e-table-simple.h \ e-table-sort-info.c \ diff --git a/widgets/e-table/e-table-field-chooser.c b/widgets/e-table/e-table-field-chooser.c index 4be2675ce6..0d56945f7f 100644 --- a/widgets/e-table/e-table-field-chooser.c +++ b/widgets/e-table/e-table-field-chooser.c @@ -96,7 +96,7 @@ static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, ETab "height", &height, NULL); height = MAX(height, allocation->height); - gnome_canvas_set_scroll_region(GNOME_CANVAS( etfc->canvas ), 0, 0, allocation->width, height); + gnome_canvas_set_scroll_region(GNOME_CANVAS( etfc->canvas ), 0, 0, allocation->width - 1, height - 1); gnome_canvas_item_set( etfc->rect, "x2", (double) allocation->width, "y2", (double) height, @@ -112,7 +112,7 @@ static void resize(GnomeCanvas *canvas, ETableFieldChooser *etfc) height = MAX(height, etfc->last_alloc.height); - gnome_canvas_set_scroll_region (GNOME_CANVAS(etfc->canvas), 0, 0, etfc->last_alloc.width, height); + gnome_canvas_set_scroll_region (GNOME_CANVAS(etfc->canvas), 0, 0, etfc->last_alloc.width - 1, height - 1); gnome_canvas_item_set( etfc->rect, "x2", (double) etfc->last_alloc.width, "y2", (double) height, diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index c9dc87dc77..947b28107e 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -1170,6 +1170,9 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub int col, row; /* FIXME: this routine is inneficient, fix later */ + + if (cols == 0 || rows == 0) + return FALSE; x -= eti->x1; y -= eti->y1; diff --git a/widgets/e-table/e-table-scrolled.c b/widgets/e-table/e-table-scrolled.c new file mode 100644 index 0000000000..6fcec1e185 --- /dev/null +++ b/widgets/e-table/e-table-scrolled.c @@ -0,0 +1,353 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * E-table-scrolled.c: A graphical view of a Table. + * + * Author: + * Chris Lahey <clahey@helixcode.com> + * Miguel de Icaza (miguel@helixcode.com) + * + * Copyright 2000, 1999, Helix Code, Inc + */ +#include <config.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <stdio.h> +#include <libgnomeui/gnome-canvas.h> +#include <gtk/gtksignal.h> +#include <gnome-xml/parser.h> +#include <gnome-xml/xmlmemory.h> + +#include "e-table.h" +#include "e-table-scrolled.h" + +#define COLUMN_HEADER_HEIGHT 16 + +#define PARENT_TYPE e_scroll_frame_get_type () + +static GtkObjectClass *parent_class; + +enum { + ROW_SELECTION, + CURSOR_CHANGE, + DOUBLE_CLICK, + RIGHT_CLICK, + KEY_PRESS, + LAST_SIGNAL +}; + +enum { + ARG_0, + ARG_TABLE_DRAW_GRID, + ARG_TABLE_DRAW_FOCUS, + ARG_CURSOR_MODE, + ARG_LENGTH_THRESHOLD, + ARG_CLICK_TO_ADD_MESSAGE, +}; + +static gint ets_signals [LAST_SIGNAL] = { 0, }; + +static void +row_selection_proxy (ETable *et, int row, gboolean selected, ETableScrolled *ets) +{ + gtk_signal_emit (GTK_OBJECT (ets), + ets_signals [ROW_SELECTION], + row, selected); +} + +static void +cursor_change_proxy (ETable *et, int row, ETableScrolled *ets) +{ + gtk_signal_emit (GTK_OBJECT (ets), + ets_signals [CURSOR_CHANGE], + row); +} + +static void +double_click_proxy (ETable *et, int row, ETableScrolled *ets) +{ + gtk_signal_emit (GTK_OBJECT (ets), + ets_signals [DOUBLE_CLICK], + row); +} + +static gint +right_click_proxy (ETable *et, int row, int col, GdkEvent *event, ETableScrolled *ets) +{ + int return_val; + gtk_signal_emit (GTK_OBJECT (ets), + ets_signals [RIGHT_CLICK], + row, col, event, &return_val); + return return_val; +} + +static gint +key_press_proxy (ETable *et, int row, int col, GdkEvent *event, ETableScrolled *ets) +{ + int return_val; + gtk_signal_emit (GTK_OBJECT (ets), + ets_signals [KEY_PRESS], + row, col, event, &return_val); + return return_val; +} + +static void +e_table_scrolled_init (GtkObject *object) +{ + ETableScrolled *ets = E_TABLE_SCROLLED(object); + + ets->table = gtk_type_new(e_table_get_type()); +} + +static void +e_table_scrolled_real_construct (ETableScrolled *ets) +{ + gtk_object_set(GTK_OBJECT(ets), + "hadjustment", NULL, + "vadjustment", NULL, + "shadow_type", GTK_SHADOW_IN, + "hscrollbar_policy", GTK_POLICY_NEVER, + "vscrollbar_policy", GTK_POLICY_AUTOMATIC, + NULL); + + gtk_container_add(GTK_CONTAINER(ets), GTK_WIDGET(ets->table)); + + gtk_signal_connect(GTK_OBJECT(ets->table), "row_selection", + GTK_SIGNAL_FUNC(row_selection_proxy), ets); + gtk_signal_connect(GTK_OBJECT(ets->table), "cursor_change", + GTK_SIGNAL_FUNC(cursor_change_proxy), ets); + gtk_signal_connect(GTK_OBJECT(ets->table), "double_click", + GTK_SIGNAL_FUNC(double_click_proxy), ets); + gtk_signal_connect(GTK_OBJECT(ets->table), "right_click", + GTK_SIGNAL_FUNC(right_click_proxy), ets); + gtk_signal_connect(GTK_OBJECT(ets->table), "key_press", + GTK_SIGNAL_FUNC(key_press_proxy), ets); + + gtk_widget_show(GTK_WIDGET(ets->table)); +} + +ETableScrolled * +e_table_scrolled_construct (ETableScrolled *ets, ETableHeader *full_header, + ETableModel *etm, const char *spec) +{ + e_table_construct(ets->table, full_header, etm, spec); + + e_table_scrolled_real_construct(ets); + + return ets; +} + +ETableScrolled * +e_table_scrolled_construct_from_spec_file (ETableScrolled *ets, ETableHeader *full_header, ETableModel *etm, + const char *filename) +{ + e_table_construct_from_spec_file(ets->table, full_header, etm, filename); + + e_table_scrolled_real_construct(ets); + + return ets; +} + +GtkWidget * +e_table_scrolled_new (ETableHeader *full_header, ETableModel *etm, const char *spec) +{ + ETableScrolled *ets; + + ets = gtk_type_new (e_table_scrolled_get_type ()); + + ets = e_table_scrolled_construct (ets, full_header, etm, spec); + + return GTK_WIDGET (ets); +} + +GtkWidget * +e_table_scrolled_new_from_spec_file (ETableHeader *full_header, ETableModel *etm, const char *filename) +{ + ETableScrolled *ets; + + ets = gtk_type_new (e_table_scrolled_get_type ()); + + ets = e_table_scrolled_construct_from_spec_file (ets, full_header, etm, filename); + + return GTK_WIDGET (ets); +} + +gchar * +e_table_scrolled_get_specification (ETableScrolled *ets) +{ + return e_table_get_specification(ets->table); +} + +void +e_table_scrolled_save_specification (ETableScrolled *ets, gchar *filename) +{ + e_table_save_specification(ets->table, filename); +} + +void +e_table_scrolled_set_cursor_row (ETableScrolled *ets, int row) +{ + e_table_set_cursor_row(ets->table, row); +} + +int +e_table_scrolled_get_cursor_row (ETableScrolled *ets) +{ + return e_table_get_cursor_row(ets->table); +} + +void +e_table_scrolled_selected_row_foreach (ETableScrolled *ets, + ETableForeachFunc callback, + gpointer closure) +{ + e_table_selected_row_foreach(ets->table, + callback, + closure); +} + +EPrintable * +e_table_scrolled_get_printable (ETableScrolled *ets) +{ + return e_table_get_printable(ets->table); +} + +static void +ets_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableScrolled *ets = E_TABLE_SCROLLED (o); + gboolean bool_val; + gchar *string_val; + + switch (arg_id){ + case ARG_TABLE_DRAW_GRID: + gtk_object_get(GTK_OBJECT(ets->table), + "drawgrid", &bool_val, + NULL); + GTK_VALUE_BOOL (*arg) = bool_val; + break; + + case ARG_TABLE_DRAW_FOCUS: + gtk_object_get(GTK_OBJECT(ets->table), + "drawfocus", &bool_val, + NULL); + GTK_VALUE_BOOL (*arg) = bool_val; + break; + + case ARG_CLICK_TO_ADD_MESSAGE: + gtk_object_get(GTK_OBJECT(ets->table), + "click_to_add_message", &string_val, + NULL); + GTK_VALUE_STRING (*arg) = string_val; + break; + } +} + +static void +ets_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + ETableScrolled *ets = E_TABLE_SCROLLED (o); + + switch (arg_id){ + case ARG_LENGTH_THRESHOLD: + gtk_object_set(GTK_OBJECT(ets->table), + "length_threshold", GTK_VALUE_INT (*arg), + NULL); + break; + + case ARG_TABLE_DRAW_GRID: + gtk_object_set(GTK_OBJECT(ets->table), + "drawgrid", GTK_VALUE_BOOL (*arg), + NULL); + break; + + case ARG_TABLE_DRAW_FOCUS: + gtk_object_set(GTK_OBJECT(ets->table), + "drawfocus", GTK_VALUE_BOOL (*arg), + NULL); + break; + + case ARG_CURSOR_MODE: + gtk_object_set(GTK_OBJECT(ets->table), + "cursor_mode", GTK_VALUE_INT (*arg), + NULL); + break; + case ARG_CLICK_TO_ADD_MESSAGE: + gtk_object_set(GTK_OBJECT(ets->table), + "click_to_add_message", GTK_VALUE_STRING (*arg), + NULL); + break; + } +} + +static void +e_table_scrolled_class_init (GtkObjectClass *object_class) +{ + ETableScrolledClass *klass = E_TABLE_SCROLLED_CLASS(object_class); + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->set_arg = ets_set_arg; + object_class->get_arg = ets_get_arg; + + klass->row_selection = NULL; + klass->cursor_change = NULL; + klass->double_click = NULL; + klass->right_click = NULL; + klass->key_press = NULL; + + ets_signals [ROW_SELECTION] = + gtk_signal_new ("row_selection", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableScrolledClass, row_selection), + gtk_marshal_NONE__INT_INT, + GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); + + ets_signals [CURSOR_CHANGE] = + gtk_signal_new ("cursor_change", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableScrolledClass, cursor_change), + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, 1, GTK_TYPE_INT); + + ets_signals [DOUBLE_CLICK] = + gtk_signal_new ("double_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableScrolledClass, double_click), + gtk_marshal_NONE__INT, + GTK_TYPE_NONE, 1, GTK_TYPE_INT); + + ets_signals [RIGHT_CLICK] = + gtk_signal_new ("right_click", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableScrolledClass, right_click), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + + ets_signals [KEY_PRESS] = + gtk_signal_new ("key_press", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableScrolledClass, key_press), + e_marshal_INT__INT_INT_POINTER, + GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); + + gtk_object_class_add_signals (object_class, ets_signals, LAST_SIGNAL); + + gtk_object_add_arg_type ("ETableScrolled::drawgrid", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID); + gtk_object_add_arg_type ("ETableScrolled::drawfocus", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_TABLE_DRAW_FOCUS); + gtk_object_add_arg_type ("ETableScrolled::cursor_mode", GTK_TYPE_INT, + GTK_ARG_WRITABLE, ARG_CURSOR_MODE); + gtk_object_add_arg_type ("ETableScrolled::length_threshold", GTK_TYPE_INT, + GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD); + gtk_object_add_arg_type ("ETableScrolled::click_to_add_message", GTK_TYPE_STRING, + GTK_ARG_READWRITE, ARG_CLICK_TO_ADD_MESSAGE); +} + +E_MAKE_TYPE(e_table_scrolled, "ETableScrolled", ETableScrolled, e_table_scrolled_class_init, e_table_scrolled_init, PARENT_TYPE); + diff --git a/widgets/e-table/e-table-scrolled.h b/widgets/e-table/e-table-scrolled.h new file mode 100644 index 0000000000..f527058ca7 --- /dev/null +++ b/widgets/e-table/e-table-scrolled.h @@ -0,0 +1,65 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _E_TABLE_SCROLLED_H_ +#define _E_TABLE_SCROLLED_H_ + +#include "widgets/misc/e-scroll-frame.h" +#include "e-table-model.h" +#include "e-table-header.h" +#include "e-table.h" +#include "e-util/e-printable.h" + +BEGIN_GNOME_DECLS + +#define E_TABLE_SCROLLED_TYPE (e_table_scrolled_get_type ()) +#define E_TABLE_SCROLLED(o) (GTK_CHECK_CAST ((o), E_TABLE_SCROLLED_TYPE, ETableScrolled)) +#define E_TABLE_SCROLLED_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_SCROLLED_TYPE, ETableScrolledClass)) +#define E_IS_SCROLLED_TABLE(o) (GTK_CHECK_TYPE ((o), E_TABLE_SCROLLED_TYPE)) +#define E_IS_SCROLLED_TABLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_SCROLLED_TYPE)) + +typedef struct { + EScrollFrame parent; + + ETable *table; +} ETableScrolled; + +typedef struct { + GtkTableClass parent_class; + + void (*row_selection) (ETableScrolled *est, int row, gboolean selected); + void (*cursor_change) (ETableScrolled *est, int row); + void (*double_click) (ETableScrolled *est, int row); + gint (*right_click) (ETableScrolled *est, int row, int col, GdkEvent *event); + gint (*key_press) (ETableScrolled *est, int row, int col, GdkEvent *event); +} ETableScrolledClass; + +GtkType e_table_scrolled_get_type (void); + +ETableScrolled *e_table_scrolled_construct (ETableScrolled *ets, ETableHeader *full_header, ETableModel *etm, + const char *spec); +GtkWidget *e_table_scrolled_new (ETableHeader *full_header, ETableModel *etm, + const char *spec); + +ETableScrolled *e_table_scrolled_construct_from_spec_file (ETableScrolled *e_table_scrolled, + ETableHeader *full_header, + ETableModel *etm, + const char *filename); +GtkWidget *e_table_scrolled_new_from_spec_file (ETableHeader *full_header, + ETableModel *etm, + const char *filename); + +gchar *e_table_scrolled_get_specification (ETableScrolled *e_table_scrolled); +void e_table_scrolled_save_specification (ETableScrolled *e_table_scrolled, gchar *filename); + +void e_table_scrolled_set_cursor_row (ETableScrolled *e_table_scrolled, + int row); +/* -1 means we don't have the cursor. */ +int e_table_scrolled_get_cursor_row (ETableScrolled *e_table_scrolled); +void e_table_scrolled_selected_row_foreach (ETableScrolled *e_table_scrolled, + ETableForeachFunc callback, + gpointer closure); +EPrintable *e_table_scrolled_get_printable (ETableScrolled *e_table_scrolled); + +END_GNOME_DECLS + +#endif /* _E_TABLE_SCROLLED_H_ */ + diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c index 1fc8394dde..db7ca11b3f 100644 --- a/widgets/e-table/e-table.c +++ b/widgets/e-table/e-table.c @@ -21,8 +21,6 @@ #include <gnome-xml/parser.h> #include <gnome-xml/xmlmemory.h> -#include "widgets/misc/e-scroll-frame.h" - #include "e-util/e-util.h" #include "e-util/e-xml-utils.h" #include "e-util/e-canvas.h" @@ -177,10 +175,12 @@ table_canvas_reflow_idle (ETable *e_table) "height", &height, "width", &width, NULL); + height = MAX ((int)height, alloc->height); + width = MAX((int)width, alloc->width); /* I have no idea why this needs to be -1, but it works. */ gnome_canvas_set_scroll_region ( GNOME_CANVAS (e_table->table_canvas), - 0, 0, MAX((int)width, alloc->width) - 1, MAX ((int)height, alloc->height) - 1); + 0, 0, width - 1, height - 1); e_table->reflow_idle_id = 0; return FALSE; } @@ -362,6 +362,7 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h gtk_widget_show (GTK_WIDGET (e_table->table_canvas)); + e_table->canvas_vbox = gnome_canvas_item_new(gnome_canvas_root(e_table->table_canvas), e_canvas_vbox_get_type(), "spacing", 10.0, @@ -381,7 +382,6 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h e_canvas_vbox_add_item(E_CANVAS_VBOX(e_table->canvas_vbox), e_table->click_to_add); } - e_table->group = e_table_group_new ( GNOME_CANVAS_GROUP (e_table->canvas_vbox), full_header, header, @@ -507,9 +507,6 @@ et_real_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, gboolean no_header; int row = 0; - GtkWidget *internal_table; - GtkWidget *scrollframe; - xmlRoot = xmlDocGetRootElement (xmlSpec); xmlColumns = e_xml_get_child_by_name (xmlRoot, "columns-shown"); xmlGrouping = e_xml_get_child_by_name (xmlRoot, "grouping"); @@ -543,54 +540,25 @@ et_real_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, e_table_setup_table (e_table, full_header, e_table->header, etm); e_table_fill_table (e_table, etm); - scrollframe = e_scroll_frame_new ( - gtk_layout_get_hadjustment (GTK_LAYOUT (e_table->table_canvas)), - gtk_layout_get_vadjustment (GTK_LAYOUT (e_table->table_canvas))); - gtk_layout_get_vadjustment (GTK_LAYOUT (e_table->table_canvas))->step_increment = 20; gtk_adjustment_changed(gtk_layout_get_vadjustment (GTK_LAYOUT (e_table->table_canvas))); - e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scrollframe), - GTK_SHADOW_IN); - - - e_scroll_frame_set_policy ( - E_SCROLL_FRAME (scrollframe), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - internal_table = gtk_table_new(1, 2, FALSE); if (!no_header) { /* * The header */ - gtk_table_attach (GTK_TABLE (internal_table), GTK_WIDGET (e_table->header_canvas), + gtk_table_attach (GTK_TABLE (e_table), GTK_WIDGET (e_table->header_canvas), 0, 1, 0 + row, 1 + row, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0); row ++; } - gtk_table_attach (GTK_TABLE (internal_table), GTK_WIDGET (e_table->table_canvas), + gtk_table_attach (GTK_TABLE (e_table), GTK_WIDGET (e_table->table_canvas), 0, 1, 0 + row, 1 + row, GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); - gtk_widget_show(internal_table); - - gtk_container_add ( - GTK_CONTAINER (scrollframe), - internal_table); - gtk_widget_show (scrollframe); - /* - * The body - */ - gtk_table_attach ( - GTK_TABLE (e_table), GTK_WIDGET (scrollframe), - 0, 1, 0, 1, - GTK_FILL | GTK_EXPAND, - GTK_FILL | GTK_EXPAND, 0, 0); - gtk_widget_pop_colormap (); gtk_widget_pop_visual (); @@ -851,9 +819,26 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) } static void +set_scroll_adjustments (ETable *table, + GtkAdjustment *hadjustment, + GtkAdjustment *vadjustment) +{ + vadjustment->step_increment = 20; + gtk_adjustment_changed(vadjustment); + gtk_layout_set_hadjustment (GTK_LAYOUT(table->table_canvas), + hadjustment); + gtk_layout_set_vadjustment (GTK_LAYOUT(table->table_canvas), + vadjustment); + gtk_layout_set_hadjustment (GTK_LAYOUT(table->header_canvas), + hadjustment); +} + +static void e_table_class_init (GtkObjectClass *object_class) { ETableClass *klass = E_TABLE_CLASS(object_class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(object_class); + e_table_parent_class = gtk_type_class (PARENT_TYPE); object_class->destroy = et_destroy; @@ -905,9 +890,19 @@ e_table_class_init (GtkObjectClass *object_class) GTK_SIGNAL_OFFSET (ETableClass, key_press), e_marshal_INT__INT_INT_POINTER, GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); - + gtk_object_class_add_signals (object_class, et_signals, LAST_SIGNAL); + klass->set_scroll_adjustments = set_scroll_adjustments; + + widget_class->set_scroll_adjustments_signal = + gtk_signal_new ("set_scroll_adjustments", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ETableClass, set_scroll_adjustments), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); + gtk_object_add_arg_type ("ETable::drawgrid", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID); gtk_object_add_arg_type ("ETable::drawfocus", GTK_TYPE_BOOL, diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h index 9b93326ea1..c4644c7a98 100644 --- a/widgets/e-table/e-table.h +++ b/widgets/e-table/e-table.h @@ -73,6 +73,10 @@ typedef struct { void (*double_click) (ETable *et, int row); gint (*right_click) (ETable *et, int row, int col, GdkEvent *event); gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); + + void (*set_scroll_adjustments) (ETable *table, + GtkAdjustment *hadjustment, + GtkAdjustment *vadjustment); } ETableClass; GtkType e_table_get_type (void); |