3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
9 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * You should have received a copy of the GNU Lesser General Public License
13 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 * Chris Lahey <clahey@ximian.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
27 #include "e-selection-model-array.h"
28 #include "e-selection-model-simple.h"
30 static gint
esms_get_row_count (ESelectionModelArray
*esma
);
33 ESelectionModelSimple
,
34 e_selection_model_simple
,
35 E_TYPE_SELECTION_MODEL_ARRAY
)
38 e_selection_model_simple_init (ESelectionModelSimple
*selection
)
40 selection
->row_count
= 0;
44 e_selection_model_simple_class_init (ESelectionModelSimpleClass
*class)
46 ESelectionModelArrayClass
*esma_class
;
48 esma_class
= E_SELECTION_MODEL_ARRAY_CLASS (class);
49 esma_class
->get_row_count
= esms_get_row_count
;
53 * e_selection_model_simple_new
55 * This routine creates a new #ESelectionModelSimple.
57 * Returns: The new #ESelectionModelSimple.
59 ESelectionModelSimple
*
60 e_selection_model_simple_new (void)
62 return g_object_new (E_TYPE_SELECTION_MODEL_SIMPLE
, NULL
);
66 e_selection_model_simple_set_row_count (ESelectionModelSimple
*esms
,
69 gboolean any_selected
= FALSE
;
71 if (esms
->row_count
!= row_count
) {
72 ESelectionModelArray
*esma
= E_SELECTION_MODEL_ARRAY (esms
);
74 any_selected
= e_bit_array_selected_count (esma
->eba
) > 0;
75 g_object_unref (esma
->eba
);
78 esma
->selected_row
= -1;
79 esma
->selected_range_end
= -1;
82 esms
->row_count
= row_count
;
85 e_selection_model_selection_changed (E_SELECTION_MODEL (esms
));
89 esms_get_row_count (ESelectionModelArray
*esma
)
91 ESelectionModelSimple
*esms
= E_SELECTION_MODEL_SIMPLE (esma
);
93 return esms
->row_count
;
97 e_selection_model_simple_insert_rows (ESelectionModelSimple
*esms
,
101 esms
->row_count
+= count
;
102 e_selection_model_array_insert_rows (
103 E_SELECTION_MODEL_ARRAY (esms
), row
, count
);
107 e_selection_model_simple_delete_rows (ESelectionModelSimple
*esms
,
111 esms
->row_count
-= count
;
112 e_selection_model_array_delete_rows (
113 E_SELECTION_MODEL_ARRAY (esms
), row
, count
);
117 e_selection_model_simple_move_row (ESelectionModelSimple
*esms
,
121 e_selection_model_array_move_row (
122 E_SELECTION_MODEL_ARRAY (esms
), old_row
, new_row
);