Updated Spanish translation
[evolution.git] / e-util / e-selection-model-simple.c
blob06691171bbe788850794ba001049827c6b67cc50
1 /*
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
10 * for more details.
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/>.
16 * Authors:
17 * Chris Lahey <clahey@ximian.com>
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include "e-selection-model-array.h"
28 #include "e-selection-model-simple.h"
30 static gint esms_get_row_count (ESelectionModelArray *esma);
32 G_DEFINE_TYPE (
33 ESelectionModelSimple,
34 e_selection_model_simple,
35 E_TYPE_SELECTION_MODEL_ARRAY)
37 static void
38 e_selection_model_simple_init (ESelectionModelSimple *selection)
40 selection->row_count = 0;
43 static void
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;
52 /**
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);
65 void
66 e_selection_model_simple_set_row_count (ESelectionModelSimple *esms,
67 gint row_count)
69 gboolean any_selected = FALSE;
71 if (esms->row_count != row_count) {
72 ESelectionModelArray *esma = E_SELECTION_MODEL_ARRAY (esms);
73 if (esma->eba) {
74 any_selected = e_bit_array_selected_count (esma->eba) > 0;
75 g_object_unref (esma->eba);
77 esma->eba = NULL;
78 esma->selected_row = -1;
79 esma->selected_range_end = -1;
82 esms->row_count = row_count;
84 if (any_selected)
85 e_selection_model_selection_changed (E_SELECTION_MODEL (esms));
88 static gint
89 esms_get_row_count (ESelectionModelArray *esma)
91 ESelectionModelSimple *esms = E_SELECTION_MODEL_SIMPLE (esma);
93 return esms->row_count;
96 void
97 e_selection_model_simple_insert_rows (ESelectionModelSimple *esms,
98 gint row,
99 gint count)
101 esms->row_count += count;
102 e_selection_model_array_insert_rows (
103 E_SELECTION_MODEL_ARRAY (esms), row, count);
106 void
107 e_selection_model_simple_delete_rows (ESelectionModelSimple *esms,
108 gint row,
109 gint count)
111 esms->row_count -= count;
112 e_selection_model_array_delete_rows (
113 E_SELECTION_MODEL_ARRAY (esms), row, count);
116 void
117 e_selection_model_simple_move_row (ESelectionModelSimple *esms,
118 gint old_row,
119 gint new_row)
121 e_selection_model_array_move_row (
122 E_SELECTION_MODEL_ARRAY (esms), old_row, new_row);