From 5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 1 Mar 2001 08:32:16 +0000 Subject: Added e-selection-model-simple.lo. 2001-03-01 Christopher James Lahey * gal/Makefile.am (libgal_la_LIBADD): Added e-selection-model-simple.lo. * gal/widgets/Makefile.am (libwidgets_la_SOURCES): Added e-selection-model-simple.c. (libwidgetsinclude_HEADERS): Added e-selection-model-simple.h. * gal/widgets/e-reflow-sorted.c, gal/widgets/e-reflow-sorted.h: Added a gint *position argument to e_reflow_sorted_remove_item and e_reflow_sorted_get_item and two gint * arguments to e_reflow_sorted_replace_item and e_reflow_sorted_reorder_item to return the positions in the array of the items removed, gotten, or moved. * gal/widgets/e-reflow.c, gal/widgets/e-reflow.h: Added a gint *position argument to e_reflow_sorted_add_item to return the positions in the array of the item added. * gal/widgets/e-selection-model.c, gal/widgets/e-selection-model.h: Added e_selection_model_move_row. svn path=/trunk/; revision=8442 --- widgets/misc/e-selection-model.c | 62 ++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 8 deletions(-) (limited to 'widgets/misc/e-selection-model.c') diff --git a/widgets/misc/e-selection-model.c b/widgets/misc/e-selection-model.c index e1f558f1e0..de48bc3952 100644 --- a/widgets/misc/e-selection-model.c +++ b/widgets/misc/e-selection-model.c @@ -27,6 +27,7 @@ static GtkObjectClass *e_selection_model_parent_class; +static void change_one_row(ESelectionModel *selection, int row, gboolean grow); static void esm_select_single_row (ESelectionModel *selection, int row); enum { @@ -47,8 +48,8 @@ enum { ARG_CURSOR_MODE, }; -void -e_selection_model_insert_row(ESelectionModel *esm, int row) +static void +e_selection_model_insert_row_real(ESelectionModel *esm, int row) { int box; int i; @@ -74,8 +75,8 @@ e_selection_model_insert_row(ESelectionModel *esm, int row) esm->cursor_row ++; } -void -e_selection_model_delete_row(ESelectionModel *esm, int row) +static void +e_selection_model_delete_row_real(ESelectionModel *esm, int row) { int box; int i; @@ -115,6 +116,51 @@ e_selection_model_delete_row(ESelectionModel *esm, int row) esm->cursor_row --; } +void +e_selection_model_delete_row(ESelectionModel *esm, int row) +{ + e_selection_model_delete_row_real(esm, row); + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [SELECTION_CHANGED]); + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [CURSOR_CHANGED], esm->cursor_row, esm->cursor_col); +} + +void +e_selection_model_insert_row(ESelectionModel *esm, int row) +{ + e_selection_model_insert_row_real(esm, row); + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [SELECTION_CHANGED]); + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [CURSOR_CHANGED], esm->cursor_row, esm->cursor_col); +} + +/* FIXME: Implement this more efficiently. */ +void +e_selection_model_move_row(ESelectionModel *esm, int old_row, int new_row) +{ + gint selected = e_selection_model_is_row_selected(esm, old_row); + gint cursor = esm->cursor_row == old_row; + + e_selection_model_delete_row_real(esm, old_row); + e_selection_model_insert_row_real(esm, new_row); + + if (selected) { + if (esm->mode == GTK_SELECTION_SINGLE) + esm_select_single_row (esm, new_row); + else + change_one_row(esm, new_row, TRUE); + } + if (cursor) { + esm->cursor_row = new_row; + } + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [SELECTION_CHANGED]); + gtk_signal_emit(GTK_OBJECT(esm), + e_selection_model_signals [CURSOR_CHANGED], esm->cursor_row, esm->cursor_col); +} + inline static void add_sorter(ESelectionModel *esm, ESorter *sorter) { @@ -288,7 +334,7 @@ gboolean e_selection_model_is_row_selected (ESelectionModel *selection, gint n) { - if (selection->row_count < n) + if (selection->row_count < n || selection->row_count == 0) return 0; else return (selection->selection[BOX(n)] >> OFFSET(n)) & 0x1; @@ -451,9 +497,9 @@ esm_set_selection_end (ESelectionModel *selection, int row) */ void e_selection_model_do_something (ESelectionModel *selection, - guint row, - guint col, - GdkModifierType state) + guint row, + guint col, + GdkModifierType state) { gint shift_p = state & GDK_SHIFT_MASK; gint ctrl_p = state & GDK_CONTROL_MASK; -- cgit v1.2.3