aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-selection-model.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-03-01 16:32:16 +0800
committerChris Lahey <clahey@src.gnome.org>2001-03-01 16:32:16 +0800
commit5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b (patch)
treedf03de6655a504f924586dcf1311c5e06b0255d2 /widgets/misc/e-selection-model.c
parent1fc93f47b89b1fc9fab19a48291a1129d979b50e (diff)
downloadgsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar.gz
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar.bz2
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar.lz
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar.xz
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.tar.zst
gsoc2013-evolution-5fa7ce6c09fe6ae8553e6c74281707144f1e7c8b.zip
Added e-selection-model-simple.lo.
2001-03-01 Christopher James Lahey <clahey@ximian.com> * 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
Diffstat (limited to 'widgets/misc/e-selection-model.c')
-rw-r--r--widgets/misc/e-selection-model.c62
1 files changed, 54 insertions, 8 deletions
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;