aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-04-13 08:40:49 +0800
committerChris Lahey <clahey@src.gnome.org>2001-04-13 08:40:49 +0800
commit0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f (patch)
tree65b0c7756268decded8c5f5341c85aaaf6476d8e /widgets
parenta4f57fbbde67f1423a741b898d51773310a8c696 (diff)
downloadgsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar.gz
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar.bz2
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar.lz
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar.xz
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.tar.zst
gsoc2013-evolution-0f85f30ab1145a7ed3c6ee7b2e2216874dc2074f.zip
Upped the version number to 0.6.99.0. Upped the so number to 6.
2001-04-12 Christopher James Lahey <clahey@ximian.com> * configure.in: Upped the version number to 0.6.99.0. Upped the so number to 6. * docs/etablexml.txt: Made some updates here. * tests/test-tree-1.c, tests/test-tree-3.c: Added NULL, NULL to the call to e_tree_memory_callbacks_new. From gal/e-table/ChangeLog: 2001-04-12 Christopher James Lahey <clahey@ximian.com> * e-table-item.c (eti_cursor_change): Only move the screen to show the cursor if there are no changes pending. Updated the commented out code for alternating colors a bit. * e-table-model.c, e-table-model.h: Added e_table_model_has_change_pending. * e-tree-memory-callbacks.c, e-tree-memory-callbacks.h: Added has_get_node_by_id and get_node_by_id. * e-tree-model.c, e-tree-model.h: Added e_tree_model_has_get_node_by_id and e_tree_model_get_node_by_id. Added e_tree_model_has_change_pending. * e-tree-selection-model.c: Handle the selection and cursor properly across the tree changing. * e-tree-sorted.c: Implemented has_get_node_by_id and get_node_by_id, and has_changes_pending. * e-tree-table-adapter.c: Implemented has_changes_pending. Fixed an array underflow. svn path=/trunk/; revision=9289
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-table-item.c28
-rw-r--r--widgets/table/e-table-model.c48
-rw-r--r--widgets/table/e-table-model.h123
-rw-r--r--widgets/table/e-tree-memory-callbacks.c81
-rw-r--r--widgets/table/e-tree-memory-callbacks.h9
-rw-r--r--widgets/table/e-tree-model.c68
-rw-r--r--widgets/table/e-tree-model.h11
-rw-r--r--widgets/table/e-tree-selection-model.c83
-rw-r--r--widgets/table/e-tree-sorted.c47
-rw-r--r--widgets/table/e-tree-table-adapter.c12
10 files changed, 396 insertions, 114 deletions
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index c11a41712e..8f2cee1b20 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -1237,7 +1237,6 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
double i2c [6];
ArtPoint eti_base, eti_base_item, lower_right;
GtkWidget *canvas = GTK_WIDGET(item->canvas);
- GdkColor *background;
int height_extra = eti->horizontal_draw_grid ? 1 : 0;
/*
@@ -1352,6 +1351,9 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ECellView *ecell_view = eti->cell_views [col];
gboolean col_selected = selected;
ECellFlags flags;
+ gboolean free_background = FALSE;
+ GdkColor *background;
+
switch (eti->cursor_mode) {
case E_CURSOR_SIMPLE:
case E_CURSOR_SPREADSHEET:
@@ -1374,8 +1376,15 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
#endif
background = &canvas->style->base [GTK_STATE_NORMAL];
#if 0
- else
- background = &canvas->style->base [GTK_STATE_SELECTED];
+ else {
+ free_background = TRUE;
+ background = gdk_color_copy (&canvas->style->base [GTK_STATE_NORMAL]);
+ background->red -= 25000;
+ background->green += 25000;
+ background->blue -= 25000;
+
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (canvas)), background);
+ }
#endif
}
@@ -1383,6 +1392,9 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
gdk_draw_rectangle (drawable, eti->fill_gc, TRUE,
xd, yd, ecol->width, height);
+ if (free_background)
+ gdk_color_free (background);
+
flags = col_selected ? E_CELL_SELECTED : 0;
flags |= GTK_WIDGET_HAS_FOCUS(canvas) ? E_CELL_FOCUSED : 0;
switch (ecol->justification) {
@@ -2274,10 +2286,12 @@ eti_cursor_change (ESelectionModel *selection, int row, int col, ETableItem *eti
return;
}
- if (!eti->in_key_press) {
- eti_request_region_show (eti, view_col, view_row, view_col, view_row, DOUBLE_CLICK_TIME + 10);
- } else {
- eti_request_region_show (eti, view_col, view_row, view_col, view_row, 0);
+ if (! e_table_model_has_change_pending (eti->table_model)) {
+ if (!eti->in_key_press) {
+ eti_request_region_show (eti, view_col, view_row, view_col, view_row, DOUBLE_CLICK_TIME + 10);
+ } else {
+ eti_request_region_show (eti, view_col, view_row, view_col, view_row, 0);
+ }
}
e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(eti), FALSE);
diff --git a/widgets/table/e-table-model.c b/widgets/table/e-table-model.c
index a45150ac73..9429aeb0f9 100644
--- a/widgets/table/e-table-model.c
+++ b/widgets/table/e-table-model.c
@@ -195,6 +195,18 @@ e_table_model_has_save_id(ETableModel *e_table_model)
return FALSE;
}
+gboolean
+e_table_model_has_change_pending(ETableModel *e_table_model)
+{
+ g_return_val_if_fail (e_table_model != NULL, FALSE);
+ g_return_val_if_fail (E_IS_TABLE_MODEL (e_table_model), FALSE);
+
+ if (ETM_CLASS (e_table_model)->has_change_pending)
+ return ETM_CLASS (e_table_model)->has_change_pending (e_table_model);
+ else
+ return FALSE;
+}
+
void *
e_table_model_initialize_value (ETableModel *e_table_model, int col)
{
@@ -296,28 +308,30 @@ e_table_model_class_init (GtkObjectClass *object_class)
gtk_object_class_add_signals (object_class, e_table_model_signals, LAST_SIGNAL);
- klass->column_count = NULL;
- klass->row_count = NULL;
- klass->append_row = NULL;
+ klass->column_count = NULL;
+ klass->row_count = NULL;
+ klass->append_row = NULL;
+
+ klass->value_at = NULL;
+ klass->set_value_at = NULL;
+ klass->is_cell_editable = NULL;
- klass->value_at = NULL;
- klass->set_value_at = NULL;
- klass->is_cell_editable = NULL;
+ klass->get_save_id = NULL;
+ klass->has_save_id = NULL;
- klass->get_save_id = NULL;
- klass->has_save_id = NULL;
+ klass->has_change_pending = NULL;
- klass->duplicate_value = NULL;
- klass->free_value = NULL;
- klass->initialize_value = NULL;
- klass->value_is_empty = NULL;
- klass->value_to_string = NULL;
+ klass->duplicate_value = NULL;
+ klass->free_value = NULL;
+ klass->initialize_value = NULL;
+ klass->value_is_empty = NULL;
+ klass->value_to_string = NULL;
- klass->model_changed = NULL;
- klass->model_row_changed = NULL;
- klass->model_cell_changed = NULL;
+ klass->model_changed = NULL;
+ klass->model_row_changed = NULL;
+ klass->model_cell_changed = NULL;
klass->model_rows_inserted = NULL;
- klass->model_rows_deleted = NULL;
+ klass->model_rows_deleted = NULL;
}
diff --git a/widgets/table/e-table-model.h b/widgets/table/e-table-model.h
index 8cce0054d3..333ab0fcfc 100644
--- a/widgets/table/e-table-model.h
+++ b/widgets/table/e-table-model.h
@@ -24,27 +24,29 @@ typedef struct {
/*
* Virtual methods
*/
- int (*column_count) (ETableModel *etm);
- int (*row_count) (ETableModel *etm);
- void (*append_row) (ETableModel *etm, ETableModel *source, int row);
+ int (*column_count) (ETableModel *etm);
+ int (*row_count) (ETableModel *etm);
+ void (*append_row) (ETableModel *etm, ETableModel *source, int row);
- void *(*value_at) (ETableModel *etm, int col, int row);
- void (*set_value_at) (ETableModel *etm, int col, int row, const void *value);
- gboolean (*is_cell_editable) (ETableModel *etm, int col, int row);
+ void *(*value_at) (ETableModel *etm, int col, int row);
+ void (*set_value_at) (ETableModel *etm, int col, int row, const void *value);
+ gboolean (*is_cell_editable) (ETableModel *etm, int col, int row);
- char *(*get_save_id) (ETableModel *etm, int row);
- gboolean (*has_save_id) (ETableModel *etm);
+ char *(*get_save_id) (ETableModel *etm, int row);
+ gboolean (*has_save_id) (ETableModel *etm);
+
+ gboolean (*has_change_pending) (ETableModel *etm);
/* Allocate a copy of the given value. */
- void *(*duplicate_value) (ETableModel *etm, int col, const void *value);
+ void *(*duplicate_value) (ETableModel *etm, int col, const void *value);
/* Free an allocated value. */
- void (*free_value) (ETableModel *etm, int col, void *value);
+ void (*free_value) (ETableModel *etm, int col, void *value);
/* Return an allocated empty value. */
- void *(*initialize_value) (ETableModel *etm, int col);
+ void *(*initialize_value) (ETableModel *etm, int col);
/* Return TRUE if value is equivalent to an empty cell. */
- gboolean (*value_is_empty) (ETableModel *etm, int col, const void *value);
+ gboolean (*value_is_empty) (ETableModel *etm, int col, const void *value);
/* Return an allocated string. */
- char *(*value_to_string) (ETableModel *etm, int col, const void *value);
+ char *(*value_to_string) (ETableModel *etm, int col, const void *value);
/*
@@ -68,39 +70,76 @@ typedef struct {
void (*model_rows_deleted) (ETableModel *etm, int row, int count);
} ETableModelClass;
-GtkType e_table_model_get_type (void);
-
-int e_table_model_column_count (ETableModel *e_table_model);
-const char *e_table_model_column_name (ETableModel *e_table_model, int col);
-int e_table_model_row_count (ETableModel *e_table_model);
-void e_table_model_append_row (ETableModel *e_table_model, ETableModel *source, int row);
-
-void *e_table_model_value_at (ETableModel *e_table_model, int col, int row);
-void e_table_model_set_value_at (ETableModel *e_table_model, int col, int row, const void *value);
-gboolean e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row);
-
-char *e_table_model_get_save_id (ETableModel *etm, int row);
-gboolean e_table_model_has_save_id (ETableModel *etm);
-
-
-void *e_table_model_duplicate_value (ETableModel *e_table_model, int col, const void *value);
-void e_table_model_free_value (ETableModel *e_table_model, int col, void *value);
-void *e_table_model_initialize_value (ETableModel *e_table_model, int col);
-gboolean e_table_model_value_is_empty (ETableModel *e_table_model, int col, const void *value);
-char *e_table_model_value_to_string (ETableModel *e_table_model, int col, const void *value);
+GtkType e_table_model_get_type (void);
+
+/**/
+int e_table_model_column_count (ETableModel *e_table_model);
+const char *e_table_model_column_name (ETableModel *e_table_model,
+ int col);
+int e_table_model_row_count (ETableModel *e_table_model);
+void e_table_model_append_row (ETableModel *e_table_model,
+ ETableModel *source,
+ int row);
+
+/**/
+void *e_table_model_value_at (ETableModel *e_table_model,
+ int col,
+ int row);
+void e_table_model_set_value_at (ETableModel *e_table_model,
+ int col,
+ int row,
+ const void *value);
+gboolean e_table_model_is_cell_editable (ETableModel *e_table_model,
+ int col,
+ int row);
+
+/**/
+char *e_table_model_get_save_id (ETableModel *etm,
+ int row);
+gboolean e_table_model_has_save_id (ETableModel *etm);
+
+/**/
+gboolean e_table_model_has_change_pending (ETableModel *etm);
+
+
+/**/
+void *e_table_model_duplicate_value (ETableModel *e_table_model,
+ int col,
+ const void *value);
+void e_table_model_free_value (ETableModel *e_table_model,
+ int col,
+ void *value);
+void *e_table_model_initialize_value (ETableModel *e_table_model,
+ int col);
+gboolean e_table_model_value_is_empty (ETableModel *e_table_model,
+ int col,
+ const void *value);
+char *e_table_model_value_to_string (ETableModel *e_table_model,
+ int col,
+ const void *value);
/*
* Routines for emitting signals on the e_table
*/
-void e_table_model_pre_change (ETableModel *e_table_model);
-void e_table_model_changed (ETableModel *e_table_model);
-void e_table_model_row_changed (ETableModel *e_table_model, int row);
-void e_table_model_cell_changed (ETableModel *e_table_model, int col, int row);
-void e_table_model_rows_inserted (ETableModel *e_table_model, int row, int count);
-void e_table_model_rows_deleted (ETableModel *e_table_model, int row, int count);
-
-void e_table_model_row_inserted (ETableModel *e_table_model, int row);
-void e_table_model_row_deleted (ETableModel *e_table_model, int row);
+void e_table_model_pre_change (ETableModel *e_table_model);
+void e_table_model_changed (ETableModel *e_table_model);
+void e_table_model_row_changed (ETableModel *e_table_model,
+ int row);
+void e_table_model_cell_changed (ETableModel *e_table_model,
+ int col,
+ int row);
+void e_table_model_rows_inserted (ETableModel *e_table_model,
+int row,
+int count);
+void e_table_model_rows_deleted (ETableModel *e_table_model,
+int row,
+int count);
+
+/**/
+void e_table_model_row_inserted (ETableModel *e_table_model,
+int row);
+void e_table_model_row_deleted (ETableModel *e_table_model,
+int row);
#ifdef __cplusplus
}
diff --git a/widgets/table/e-tree-memory-callbacks.c b/widgets/table/e-tree-memory-callbacks.c
index 2168ba81c5..adb5160bc2 100644
--- a/widgets/table/e-tree-memory-callbacks.c
+++ b/widgets/table/e-tree-memory-callbacks.c
@@ -57,6 +57,28 @@ etmc_get_save_id (ETreeModel *etm, ETreePath node)
return NULL;
}
+static gboolean
+etmc_has_get_node_by_id (ETreeModel *etm)
+{
+ ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS(etm);
+
+ if (etmc->has_get_node_by_id)
+ return etmc->has_get_node_by_id (etm, etmc->model_data);
+ else
+ return FALSE;
+}
+
+static ETreePath
+etmc_get_node_by_id (ETreeModel *etm, gchar *save_id)
+{
+ ETreeMemoryCallbacks *etmc = E_TREE_MEMORY_CALLBACKS(etm);
+
+ if (etmc->get_node_by_id)
+ return etmc->get_node_by_id (etm, save_id, etmc->model_data);
+ else
+ return NULL;
+}
+
static void *
etmc_value_at (ETreeModel *etm, ETreePath node, int col)
@@ -142,22 +164,25 @@ e_tree_memory_callbacks_class_init (GtkObjectClass *object_class)
{
ETreeModelClass *model_class = (ETreeModelClass *) object_class;
- model_class->icon_at = etmc_icon_at;
+ model_class->icon_at = etmc_icon_at;
+
+ model_class->column_count = etmc_column_count;
- model_class->column_count = etmc_column_count;
+ model_class->has_save_id = etmc_has_save_id;
+ model_class->get_save_id = etmc_get_save_id;
- model_class->has_save_id = etmc_has_save_id;
- model_class->get_save_id = etmc_get_save_id;
+ model_class->has_get_node_by_id = etmc_has_get_node_by_id;
+ model_class->get_node_by_id = etmc_get_node_by_id;
- model_class->value_at = etmc_value_at;
- model_class->set_value_at = etmc_set_value_at;
- model_class->is_editable = etmc_is_editable;
+ model_class->value_at = etmc_value_at;
+ model_class->set_value_at = etmc_set_value_at;
+ model_class->is_editable = etmc_is_editable;
- model_class->duplicate_value = etmc_duplicate_value;
- model_class->free_value = etmc_free_value;
- model_class->initialize_value = etmc_initialize_value;
- model_class->value_is_empty = etmc_value_is_empty;
- model_class->value_to_string = etmc_value_to_string;
+ model_class->duplicate_value = etmc_duplicate_value;
+ model_class->free_value = etmc_free_value;
+ model_class->initialize_value = etmc_initialize_value;
+ model_class->value_is_empty = etmc_value_is_empty;
+ model_class->value_to_string = etmc_value_to_string;
}
E_MAKE_TYPE(e_tree_memory_callbacks, "ETreeMemoryCallbacks", ETreeMemoryCallbacks, e_tree_memory_callbacks_class_init, NULL, PARENT_TYPE)
@@ -191,6 +216,9 @@ e_tree_memory_callbacks_new (ETreeMemoryCallbacksIconAtFn icon_at,
ETreeMemoryCallbacksHasSaveIdFn has_save_id,
ETreeMemoryCallbacksGetSaveIdFn get_save_id,
+ ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id,
+ ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id,
+
ETreeMemoryCallbacksValueAtFn value_at,
ETreeMemoryCallbacksSetValueAtFn set_value_at,
ETreeMemoryCallbacksIsEditableFn is_editable,
@@ -207,24 +235,27 @@ e_tree_memory_callbacks_new (ETreeMemoryCallbacksIconAtFn icon_at,
etmc = gtk_type_new (e_tree_memory_callbacks_get_type ());
- etmc->icon_at = icon_at;
+ etmc->icon_at = icon_at;
+
+ etmc->column_count = column_count;
- etmc->column_count = column_count;
+ etmc->has_save_id = has_save_id;
+ etmc->get_save_id = get_save_id;
- etmc->has_save_id = has_save_id;
- etmc->get_save_id = get_save_id;
+ etmc->has_get_node_by_id = has_get_node_by_id;
+ etmc->get_node_by_id = get_node_by_id;
- etmc->value_at = value_at;
- etmc->set_value_at = set_value_at;
- etmc->is_editable = is_editable;
+ etmc->value_at = value_at;
+ etmc->set_value_at = set_value_at;
+ etmc->is_editable = is_editable;
- etmc->duplicate_value = duplicate_value;
- etmc->free_value = free_value;
- etmc->initialize_value = initialize_value;
- etmc->value_is_empty = value_is_empty;
- etmc->value_to_string = value_to_string;
+ etmc->duplicate_value = duplicate_value;
+ etmc->free_value = free_value;
+ etmc->initialize_value = initialize_value;
+ etmc->value_is_empty = value_is_empty;
+ etmc->value_to_string = value_to_string;
- etmc->model_data = model_data;
+ etmc->model_data = model_data;
return (ETreeModel*)etmc;
}
diff --git a/widgets/table/e-tree-memory-callbacks.h b/widgets/table/e-tree-memory-callbacks.h
index b419ea8d4f..441c5be9f4 100644
--- a/widgets/table/e-tree-memory-callbacks.h
+++ b/widgets/table/e-tree-memory-callbacks.h
@@ -23,6 +23,9 @@ typedef gint (*ETreeMemoryCallbacksColumnCountFn) (ETreeModel *etre
typedef gboolean (*ETreeMemoryCallbacksHasSaveIdFn) (ETreeModel *etree, void *model_data);
typedef gchar *(*ETreeMemoryCallbacksGetSaveIdFn) (ETreeModel *etree, ETreePath path, void *model_data);
+typedef gboolean (*ETreeMemoryCallbacksHasGetNodeByIdFn) (ETreeModel *etree, void *model_data);
+typedef ETreePath (*ETreeMemoryCallbacksGetNodeByIdFn) (ETreeModel *etree, gchar *save_id, void *model_data);
+
typedef void* (*ETreeMemoryCallbacksValueAtFn) (ETreeModel *etree, ETreePath path, int col, void *model_data);
typedef void (*ETreeMemoryCallbacksSetValueAtFn) (ETreeModel *etree, ETreePath path, int col, const void *val, void *model_data);
typedef gboolean (*ETreeMemoryCallbacksIsEditableFn) (ETreeModel *etree, ETreePath path, int col, void *model_data);
@@ -43,6 +46,9 @@ typedef struct {
ETreeMemoryCallbacksHasSaveIdFn has_save_id;
ETreeMemoryCallbacksGetSaveIdFn get_save_id;
+ ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id;
+ ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id;
+
ETreeMemoryCallbacksValueAtFn value_at;
ETreeMemoryCallbacksSetValueAtFn set_value_at;
ETreeMemoryCallbacksIsEditableFn is_editable;
@@ -69,6 +75,9 @@ ETreeModel *e_tree_memory_callbacks_new (ETreeMemoryCallbacksIconAtFn icon_at,
ETreeMemoryCallbacksHasSaveIdFn has_save_id,
ETreeMemoryCallbacksGetSaveIdFn get_save_id,
+ ETreeMemoryCallbacksHasGetNodeByIdFn has_get_node_by_id,
+ ETreeMemoryCallbacksGetNodeByIdFn get_node_by_id,
+
ETreeMemoryCallbacksValueAtFn value_at,
ETreeMemoryCallbacksSetValueAtFn set_value_at,
ETreeMemoryCallbacksIsEditableFn is_editable,
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c
index 895b3fb3cd..90ed489a74 100644
--- a/widgets/table/e-tree-model.c
+++ b/widgets/table/e-tree-model.c
@@ -122,6 +122,10 @@ e_tree_model_class_init (GtkObjectClass *klass)
tree_class->has_save_id = NULL;
tree_class->get_save_id = NULL;
+ tree_class->has_get_node_by_id = NULL;
+ tree_class->get_node_by_id = NULL;
+
+ tree_class->has_change_pending = NULL;
tree_class->value_at = NULL;
tree_class->set_value_at = NULL;
@@ -584,6 +588,70 @@ e_tree_model_get_save_id (ETreeModel *etree, ETreePath node)
}
/**
+ * e_tree_model_has_get_node_by_id
+ * @etree: The ETreeModel.
+ *
+ * XXX docs here.
+ *
+ * return values: Whether this tree can quickly get a node from its save id.
+ */
+gboolean
+e_tree_model_has_get_node_by_id (ETreeModel *etree)
+{
+ g_return_val_if_fail (etree != NULL, FALSE);
+ g_return_val_if_fail (E_IS_TREE_MODEL (etree), FALSE);
+
+ if (ETM_CLASS(etree)->has_get_node_by_id)
+ return ETM_CLASS(etree)->has_get_node_by_id (etree);
+ else
+ return FALSE;
+}
+
+/**
+ * e_tree_model_get_node_by_id
+ * @etree: The ETreeModel.
+ * @node: The ETreePath.
+ *
+ * get_node_by_id(get_save_id(node)) should be the original node.
+ * Likewise if get_node_by_id is not NULL, then
+ * get_save_id(get_node_by_id(string)) should be a copy of the
+ * original string.
+ *
+ * return values: The path for this save id.
+ */
+ETreePath
+e_tree_model_get_node_by_id (ETreeModel *etree, gchar *save_id)
+{
+ g_return_val_if_fail (etree != NULL, NULL);
+ g_return_val_if_fail (E_IS_TREE_MODEL (etree), NULL);
+
+ if (ETM_CLASS(etree)->get_node_by_id)
+ return ETM_CLASS(etree)->get_node_by_id (etree, save_id);
+ else
+ return NULL;
+}
+
+/**
+ * e_tree_model_has_change_pending
+ * @etree: The ETreeModel.
+ *
+ * XXX docs here.
+ *
+ * return values: Whether this tree has valid save id data.
+ */
+gboolean
+e_tree_model_has_change_pending (ETreeModel *etree)
+{
+ g_return_val_if_fail (etree != NULL, FALSE);
+ g_return_val_if_fail (E_IS_TREE_MODEL (etree), FALSE);
+
+ if (ETM_CLASS(etree)->has_change_pending)
+ return ETM_CLASS(etree)->has_change_pending (etree);
+ else
+ return FALSE;
+}
+
+/**
* e_tree_model_icon_of_node
* @etree: The ETreeModel.
* @path: The ETreePath to the node we're getting the icon of.
diff --git a/widgets/table/e-tree-model.h b/widgets/table/e-tree-model.h
index 0db3779e4a..1b48e23963 100644
--- a/widgets/table/e-tree-model.h
+++ b/widgets/table/e-tree-model.h
@@ -53,6 +53,11 @@ struct ETreeModelClass {
gboolean (*has_save_id) (ETreeModel *etm);
gchar *(*get_save_id) (ETreeModel *etm, ETreePath node);
+ gboolean (*has_get_node_by_id) (ETreeModel *etm);
+ ETreePath (*get_node_by_id) (ETreeModel *etm, gchar *save_id);
+
+ gboolean (*has_change_pending) (ETreeModel *etm);
+
/*
* ETable analogs
*/
@@ -112,6 +117,12 @@ gboolean e_tree_model_has_save_id (ETreeModel *model);
gchar *e_tree_model_get_save_id (ETreeModel *model,
ETreePath node);
+gboolean e_tree_model_has_get_node_by_id (ETreeModel *model);
+ETreePath e_tree_model_get_node_by_id (ETreeModel *model,
+ gchar *save_id);
+
+gboolean e_tree_model_has_change_pending (ETreeModel *model);
+
void *e_tree_model_value_at (ETreeModel *etree,
ETreePath node,
int col);
diff --git a/widgets/table/e-tree-selection-model.c b/widgets/table/e-tree-selection-model.c
index e376352f19..6ae9f209a6 100644
--- a/widgets/table/e-tree-selection-model.c
+++ b/widgets/table/e-tree-selection-model.c
@@ -54,6 +54,8 @@ struct ETreeSelectionModelPriv {
gint cursor_col;
ETreePath selection_start_path;
+ char *cursor_save_id;
+
int tree_model_pre_change_id;
int tree_model_node_changed_id;
int tree_model_node_data_changed_id;
@@ -165,8 +167,8 @@ etsm_real_clear (ETreeSelectionModel *etsm)
static ETreeSelectionModelNode *
etsm_find_node_unless_equals (ETreeSelectionModel *etsm,
- ETreePath path,
- gboolean grow)
+ ETreePath path,
+ gboolean grow)
{
ETreeSelectionModelNode *selection_node;
ETreeSorted *ets = etsm->priv->ets;
@@ -333,22 +335,59 @@ update_parents (ETreeSelectionModel *etsm, ETreePath path)
static void
etsm_pre_change (ETreeModel *etm, ETreeSelectionModel *etsm)
{
+ g_free (etsm->priv->cursor_save_id);
+ etsm->priv->cursor_save_id = NULL;
+
+ if (e_tree_model_has_get_node_by_id (etm) &&
+ e_tree_model_has_save_id (etm) &&
+ etsm->priv->cursor_path) {
+ etsm->priv->cursor_save_id = e_tree_model_get_save_id (etm, etsm->priv->cursor_path);
+ }
}
static void
etsm_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm)
{
+ int cursor_row;
+
etsm_real_clear (etsm);
+
+ if (e_tree_model_has_get_node_by_id (etm) && etsm->priv->cursor_save_id) {
+ ETreePath cursor_path;
+
+ cursor_path = e_tree_model_get_node_by_id (etm, etsm->priv->cursor_save_id);
+ etsm->priv->cursor_path = cursor_path;
+ if (cursor_path != NULL && etsm->priv->cursor_col == -1)
+ etsm->priv->cursor_col = 0;
+
+ e_tree_selection_model_select_single_path(etsm, cursor_path);
+ }
+
+ cursor_row = etsm_cursor_row_real (etsm);
+ e_selection_model_selection_changed(E_SELECTION_MODEL(etsm));
+ if (cursor_row != -1)
+ e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), cursor_row, etsm->priv->cursor_col);
+ else {
+ e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), -1, -1);
+ e_selection_model_cursor_activated(E_SELECTION_MODEL(etsm), -1, -1);
+ }
+
+ g_free (etsm->priv->cursor_save_id);
+ etsm->priv->cursor_save_id = NULL;
}
static void
etsm_node_data_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *etsm)
{
+ g_free (etsm->priv->cursor_save_id);
+ etsm->priv->cursor_save_id = NULL;
}
static void
etsm_node_col_changed (ETreeModel *etm, ETreePath node, int col, ETreeSelectionModel *etsm)
{
+ g_free (etsm->priv->cursor_save_id);
+ etsm->priv->cursor_save_id = NULL;
}
static void
@@ -391,6 +430,7 @@ etsm_sorted_node_changed (ETreeModel *etm, ETreePath node, ETreeSelectionModel *
{
int cursor_row = etsm_cursor_row_real (etsm);
e_selection_model_selection_changed(E_SELECTION_MODEL(etsm));
+
if (cursor_row != -1)
e_selection_model_cursor_changed(E_SELECTION_MODEL(etsm), cursor_row, etsm->priv->cursor_col);
else
@@ -546,7 +586,11 @@ etsm_destroy (GtkObject *object)
etsm_real_clear (etsm);
drop_model(etsm);
drop_ets(etsm);
+
+ g_free (etsm->priv->cursor_save_id);
+
g_free(etsm->priv);
+ etsm->priv = NULL;
}
static void
@@ -1110,27 +1154,30 @@ static void
e_tree_selection_model_init (ETreeSelectionModel *etsm)
{
ETreeSelectionModelPriv *priv;
- priv = g_new(ETreeSelectionModelPriv, 1);
- etsm->priv = priv;
+ priv = g_new(ETreeSelectionModelPriv, 1);
+ etsm->priv = priv;
- priv->etta = NULL;
- priv->ets = NULL;
- priv->model = NULL;
+ priv->etta = NULL;
+ priv->ets = NULL;
+ priv->model = NULL;
- priv->root = NULL;
+ priv->root = NULL;
- priv->cursor_path = NULL;
- priv->cursor_col = -1;
- priv->selection_start_path = NULL;
+ priv->cursor_path = NULL;
+ priv->cursor_col = -1;
+ priv->selection_start_path = NULL;
- priv->tree_model_pre_change_id = 0;
- priv->tree_model_node_changed_id = 0;
- priv->tree_model_node_data_changed_id = 0;
- priv->tree_model_node_col_changed_id = 0;
- priv->tree_model_node_inserted_id = 0;
- priv->tree_model_node_removed_id = 0;
+ priv->cursor_save_id = NULL;
+
+
+ priv->tree_model_pre_change_id = 0;
+ priv->tree_model_node_changed_id = 0;
+ priv->tree_model_node_data_changed_id = 0;
+ priv->tree_model_node_col_changed_id = 0;
+ priv->tree_model_node_inserted_id = 0;
+ priv->tree_model_node_removed_id = 0;
- priv->sorted_model_pre_change_id = 0;
+ priv->sorted_model_pre_change_id = 0;
priv->sorted_model_node_changed_id = 0;
priv->sorted_model_node_data_changed_id = 0;
priv->sorted_model_node_col_changed_id = 0;
diff --git a/widgets/table/e-tree-sorted.c b/widgets/table/e-tree-sorted.c
index b369789609..d74fb46cd5 100644
--- a/widgets/table/e-tree-sorted.c
+++ b/widgets/table/e-tree-sorted.c
@@ -110,6 +110,8 @@ ets_sort_idle(gpointer user_data)
ets->priv->sort_idle_id = 0;
if (ets->priv->root) {
resort_node (ets, ets->priv->root, FALSE, FALSE, TRUE);
+ } else {
+ e_tree_model_node_changed (E_TREE_MODEL(ets), ets->priv->root);
}
return FALSE;
}
@@ -513,15 +515,21 @@ mark_path_needs_resort (ETreeSorted *ets, ETreeSortedPath *path, gboolean needs_
static void
schedule_resort (ETreeSorted *ets, ETreeSortedPath *path, gboolean needs_regen, gboolean resort_all_children)
{
- mark_path_needs_resort(ets, path, needs_regen, resort_all_children);
- if (ets->priv->sort_idle_id == 0) {
- ets->priv->sort_idle_id = g_idle_add_full(50, (GSourceFunc) ets_sort_idle, ets, NULL);
- }
ets->priv->insert_count = 0;
if (ets->priv->insert_idle_id != 0) {
g_source_remove(ets->priv->insert_idle_id);
ets->priv->insert_idle_id = 0;
}
+
+ if (path == NULL)
+ return;
+ if (path->num_children == 0)
+ return;
+
+ mark_path_needs_resort(ets, path, needs_regen, resort_all_children);
+ if (ets->priv->sort_idle_id == 0) {
+ ets->priv->sort_idle_id = g_idle_add_full(50, (GSourceFunc) ets_sort_idle, ets, NULL);
+ }
}
@@ -832,6 +840,32 @@ ets_get_save_id (ETreeModel *etm, ETreePath node)
return g_strdup_printf("%p", path->corresponding);
}
+static gboolean
+ets_has_get_node_by_id (ETreeModel *etm)
+{
+ ETreeSorted *ets = E_TREE_SORTED(etm);
+ return e_tree_model_has_get_node_by_id(ets->priv->source);
+}
+
+static ETreePath
+ets_get_node_by_id (ETreeModel *etm, gchar *save_id)
+{
+ ETreeSorted *ets = E_TREE_SORTED(etm);
+ ETreePath node;
+
+ node = e_tree_model_get_node_by_id (ets->priv->source, save_id);
+
+ return find_path(ets, node);
+}
+
+static gboolean
+ets_has_change_pending (ETreeModel *etm)
+{
+ ETreeSorted *ets = E_TREE_SORTED(etm);
+
+ return ets->priv->sort_idle_id != 0;
+}
+
static void *
ets_value_at (ETreeModel *etm, ETreePath node, int col)
@@ -1102,6 +1136,11 @@ e_tree_sorted_class_init (GtkObjectClass *klass)
tree_class->has_save_id = ets_has_save_id;
tree_class->get_save_id = ets_get_save_id;
+ tree_class->has_get_node_by_id = ets_has_get_node_by_id;
+ tree_class->get_node_by_id = ets_get_node_by_id;
+
+ tree_class->has_change_pending = ets_has_change_pending;
+
diff --git a/widgets/table/e-tree-table-adapter.c b/widgets/table/e-tree-table-adapter.c
index 82bb4186f9..caa513c4ad 100644
--- a/widgets/table/e-tree-table-adapter.c
+++ b/widgets/table/e-tree-table-adapter.c
@@ -242,7 +242,7 @@ find_row_num(ETreeTableAdapter *etta, ETreePath path)
return i;
}
}
- for (i = etta->priv->last_access - 1; i <= start; i++) {
+ for (i = etta->priv->last_access - 1; i >= start; i--) {
if(etta->priv->map_table[i] == path) {
d(g_print("Found last access %d at row %d. (find_row_num)\n", etta->priv->last_access, i));
return i;
@@ -417,6 +417,15 @@ etta_get_save_id (ETableModel *etm, int row)
return e_tree_model_get_save_id (etta->priv->source, etta->priv->map_table [row + 1]);
}
+static gboolean
+etta_has_change_pending (ETableModel *etm)
+{
+ ETreeTableAdapter *etta = (ETreeTableAdapter *)etm;
+
+ return e_tree_model_has_change_pending (etta->priv->source);
+}
+
+
static int
etta_row_count (ETableModel *etm)
{
@@ -546,6 +555,7 @@ etta_class_init (ETreeTableAdapterClass *klass)
table_class->column_count = etta_column_count;
table_class->has_save_id = etta_has_save_id;
table_class->get_save_id = etta_get_save_id;
+ table_class->has_change_pending = etta_has_change_pending;
table_class->row_count = etta_row_count;
table_class->value_at = etta_value_at;
table_class->set_value_at = etta_set_value_at;