aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog5
-rw-r--r--widgets/e-table/e-table-item.c111
-rw-r--r--widgets/e-table/e-table-item.h67
3 files changed, 82 insertions, 101 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 93b4103bf7..dc9beda343 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,8 @@
+2000-06-20 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table-item.c, e-table-item.h: Started adapting ETableItem to
+ use the canvas selection/cursor system.
+
2000-06-17 Chris Toshok <toshok@helixcode.com>
* e-tree-model.c (e_tree_model_node_insert): call
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index 5167c794e6..b5b775d2f8 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -17,6 +17,7 @@
#include <gdk/gdkkeysyms.h>
#include <math.h>
#include "e-table-item.h"
+#include "e-table-subset.h"
#include "e-cell.h"
#include "e-util/e-canvas.h"
#include "e-util/e-canvas-utils.h"
@@ -58,6 +59,9 @@ enum {
static int eti_get_height (ETableItem *eti);
static int eti_get_minimum_width (ETableItem *eti);
static int eti_row_height (ETableItem *eti, int row);
+static void e_table_item_unselect_row (ETableItem *eti, int row);
+static void e_table_item_select_row (ETableItem *eti, int row);
+static void eti_selection (GnomeCanvasItem *item, int flags, gpointer user_data);
#define ETI_ROW_HEIGHT(eti,row) ((eti)->height_cache && (eti)->height_cache[(row)] != -1 ? (eti)->height_cache[(row)] : eti_row_height((eti),(row)))
static gboolean
@@ -253,6 +257,8 @@ eti_remove_table_model (ETableItem *eti)
gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
eti->table_model_row_deleted_id);
gtk_object_unref (GTK_OBJECT (eti->table_model));
+ if (eti->source_model)
+ gtk_object_unref (GTK_OBJECT (eti->source_model));
eti->table_model_change_id = 0;
eti->table_model_row_change_id = 0;
@@ -260,6 +266,8 @@ eti_remove_table_model (ETableItem *eti)
eti->table_model_row_inserted_id = 0;
eti->table_model_row_deleted_id = 0;
eti->table_model = NULL;
+ eti->source_model = NULL;
+ eti->uses_source_model = 0;
}
/*
@@ -647,6 +655,11 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model)
eti_detach_cell_views (eti);
eti_attach_cell_views (eti);
}
+
+ if (E_IS_TABLE_SUBSET(table_model)) {
+ eti->uses_source_model = 1;
+ eti->source_model = E_TABLE_SUBSET(table_model)->source;
+ }
eti_table_model_changed (table_model, eti);
}
@@ -810,10 +823,6 @@ eti_init (GnomeCanvasItem *item)
{
ETableItem *eti = E_TABLE_ITEM (item);
- eti->cursor_row = -1;
- eti->cursor_col = 0;
- eti->cursor_mode = E_TABLE_CURSOR_SIMPLE;
-
eti->editing_col = -1;
eti->editing_row = -1;
eti->height = 0;
@@ -826,15 +835,21 @@ eti_init (GnomeCanvasItem *item)
eti->length_threshold = -1;
eti->renderers_can_change_size = 1;
+
+ eti->uses_source_model = 0;
+ eti->source_model = NULL;
-#if 0
- eti->selection_mode = GTK_SELECTION_SINGLE;
-#endif
+ eti->cursor_row = -1;
+ eti->cursor_col = 0;
+ eti->cursor_mode = E_TABLE_CURSOR_SIMPLE;
+
+ eti->selection = NULL;
eti->needs_redraw = 0;
eti->needs_compute_height = 0;
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM (eti), eti_reflow);
+ e_canvas_item_set_selection_callback (GNOME_CANVAS_ITEM (eti), eti_selection);
}
#define gray50_width 2
@@ -1587,7 +1602,6 @@ e_table_item_get_focused_column (ETableItem *eti)
}
-#if 0
const GSList *
e_table_item_get_selection (ETableItem *eti)
{
@@ -1597,29 +1611,6 @@ e_table_item_get_selection (ETableItem *eti)
return eti->selection;
}
-GtkSelectionMode
-e_table_item_get_selection_mode (ETableItem *eti)
-{
- g_return_val_if_fail (eti != NULL, GTK_SELECTION_SINGLE);
- g_return_val_if_fail (E_IS_TABLE_ITEM (eti), GTK_SELECTION_SINGLE);
-
- return eti->selection_mode;
-}
-
-void
-e_table_item_set_selection_mode (ETableItem *eti, GtkSelectionMode selection_mode)
-{
- g_return_if_fail (eti != NULL);
- g_return_if_fail (E_IS_TABLE_ITEM (eti));
-
- if (selection_mode == GTK_SELECTION_BROWSE ||
- selection_mode == GTK_SELECTION_EXTENDED){
- g_error ("GTK_SELECTION_BROWSE and GTK_SELECTION_EXTENDED are not implemented");
- }
-
- eti->selection_mode = selection_mode;
-}
-
gboolean
e_table_item_is_row_selected (ETableItem *eti, int row)
{
@@ -1632,53 +1623,49 @@ e_table_item_is_row_selected (ETableItem *eti, int row)
return FALSE;
}
-void
+static void
e_table_item_unselect_row (ETableItem *eti, int row)
{
g_return_if_fail (eti != NULL);
g_return_if_fail (E_IS_TABLE_ITEM (eti));
- if (e_table_item_is_row_selected (eti, row)){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- row, 0);
- }
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
+ row, 0);
}
-void
+static void
e_table_item_select_row (ETableItem *eti, int row)
{
g_return_if_fail (eti != NULL);
g_return_if_fail (E_IS_TABLE_ITEM (eti));
- switch (eti->selection_mode){
- case GTK_SELECTION_SINGLE:
- if (eti->selection){
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GPOINTER_TO_INT (eti->selection->data), 0);
- }
- g_slist_free (eti->selection);
- eti->selection = NULL;
-
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
-
- case GTK_SELECTION_MULTIPLE:
- if (g_slist_find (eti->selection, GINT_TO_POINTER (row)))
- return;
- gtk_signal_emit (
- GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
- GINT_TO_POINTER (row), 1);
- break;
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [ROW_SELECTION],
+ GINT_TO_POINTER (row), 1);
+}
- default:
+static void
+eti_selection (GnomeCanvasItem *item, int flags, gpointer data)
+{
+ int row = (int) data;
+ int col = 0;
+ ETableItem *eti = E_TABLE_ITEM(item);
+ int selected = e_table_item_is_row_selected(eti, row);
+ int cursored = row == eti->cursor_row;
+
+ if (selected && (flags & E_CANVAS_ITEM_SELECTION_SELECT) == 0) {
+ e_table_item_unselect_row (eti, row);
+ }
+ if ((!selected) && (flags & E_CANVAS_ITEM_SELECTION_SELECT) != 0) {
+ e_table_item_select_row (eti, row);
+ }
+ if ((!cursored) && (flags & E_CANVAS_ITEM_SELECTION_CURSOR) != 0) {
+ eti->cursor_row = row;
+ eti->cursor_col = col;
+ }
+ if (flags & E_CANVAS_ITEM_SELECTION_DELETE_DATA) {
}
}
-#endif
void
e_table_item_enter_edit (ETableItem *eti, int col, int row)
diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h
index 7ad5955cdc..1d522413cd 100644
--- a/widgets/e-table/e-table-item.h
+++ b/widgets/e-table/e-table-item.h
@@ -25,6 +25,8 @@ typedef struct {
ETableModel *table_model;
ETableHeader *header;
+ ETableModel *source_model;
+
int x1, y1;
int minimum_width, width, height;
@@ -46,14 +48,17 @@ typedef struct {
GdkGC *focus_gc;
GdkBitmap *stipple;
- guint draw_grid:1;
- guint draw_focus:1;
- guint renderers_can_change_size:1;
- guint cell_views_realized:1;
+ guint draw_grid:1;
+ guint draw_focus:1;
+ guint renderers_can_change_size:1;
+ guint cell_views_realized:1;
+
+ guint needs_redraw : 1;
+ guint needs_compute_height : 1;
+ guint needs_compute_width : 1;
+
+ guint uses_source_model : 1;
- guint needs_redraw : 1;
- guint needs_compute_height : 1;
- guint needs_compute_width : 1;
/*
* Realized views, per column
*/
@@ -74,14 +79,10 @@ typedef struct {
gint cursor_col;
ETableCursorMode cursor_mode;
-#if 0
GSList *selection;
- gint selection_count;
- GtkSelectionMode selection_mode;
-#endif
/*
- * During edition
+ * During editing
*/
int editing_col, editing_row;
void *edit_ctx;
@@ -109,35 +110,23 @@ void e_table_item_unfocus (ETableItem *eti);
gint e_table_item_get_focused_column (ETableItem *eti);
-#if 0
-/*
- * Selection
- */
-void e_table_item_select_row (ETableItem *e_table_Item, int row);
-void e_table_item_unselect_row (ETableItem *e_table_Item, int row);
-
/*
* Handling the selection
*/
-const GSList*e_table_item_get_selection (ETableItem *e_table_Item);
-
-GtkSelectionMode e_table_item_get_selection_mode (ETableItem *e_table_Item);
-void e_table_item_set_selection_mode (ETableItem *e_table_Item,
- GtkSelectionMode selection_mode);
-gboolean e_table_item_is_row_selected (ETableItem *e_table_Item,
- int row);
-#endif
-
-void e_table_item_leave_edit (ETableItem *eti);
-void e_table_item_enter_edit (ETableItem *eti, int col, int row);
-
-void e_table_item_redraw_range (ETableItem *eti,
- int start_col, int start_row,
- int end_col, int end_row);
-
-EPrintable *e_table_item_get_printable (ETableItem *eti);
-void e_table_item_print_height (ETableItem *eti,
- GnomePrintContext *context,
- gdouble width);
+const GSList *e_table_item_get_selection (ETableItem *e_table_Item);
+gboolean e_table_item_is_row_selected (ETableItem *e_table_Item,
+ int row);
+
+void e_table_item_leave_edit (ETableItem *eti);
+void e_table_item_enter_edit (ETableItem *eti, int col, int row);
+
+void e_table_item_redraw_range (ETableItem *eti,
+ int start_col, int start_row,
+ int end_col, int end_row);
+
+EPrintable *e_table_item_get_printable (ETableItem *eti);
+void e_table_item_print_height (ETableItem *eti,
+ GnomePrintContext *context,
+ gdouble width);
#endif /* _E_TABLE_ITEM_H_ */