1 /* 2 * 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. 6 * 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. 11 * 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/>. 14 * 15 * 16 * Authors: 17 * Chris Lahey <clahey@ximian.com> 18 * 19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 20 * 21 */ 22 23 #if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) 24 #error "Only <e-util/e-util.h> should be included directly." 25 #endif 26 27 #ifndef E_SELECTION_MODEL_H 28 #define E_SELECTION_MODEL_H 29 30 #include <gtk/gtk.h> 31 #include <e-util/e-misc-utils.h> 32 #include <e-util/e-sorter.h> 33 34 /* Standard GObject macros */ 35 #define E_TYPE_SELECTION_MODEL \ 36 (e_selection_model_get_type ()) 37 #define E_SELECTION_MODEL(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST \ 39 ((obj), E_TYPE_SELECTION_MODEL, ESelectionModel)) 40 #define E_SELECTION_MODEL_CLASS(cls) \ 41 (G_TYPE_CHECK_CLASS_CAST \ 42 ((cls), E_TYPE_SELECTION_MODEL, ESelectionModelClass)) 43 #define E_IS_SELECTION_MODEL(obj) \ 44 (G_TYPE_CHECK_INSTANCE_TYPE \ 45 ((obj), E_TYPE_SELECTION_MODEL)) 46 #define E_IS_SELECTION_MODEL_CLASS(cls) \ 47 (G_TYPE_CHECK_CLASS_TYPE \ 48 ((cls), E_TYPE_SELECTION_MODEL)) 49 #define E_SELECTION_MODEL_GET_CLASS(obj) \ 50 (G_TYPE_INSTANCE_GET_CLASS \ 51 ((obj), E_TYPE_SELECTION_MODEL, ESelectionModelClass)) 52 53 G_BEGIN_DECLS 54 55 typedef struct _ESelectionModel ESelectionModel; 56 typedef struct _ESelectionModelClass ESelectionModelClass; 57 58 /* list selection modes */ 59 typedef enum { 60 E_CURSOR_LINE, 61 E_CURSOR_SIMPLE, 62 E_CURSOR_SPREADSHEET 63 } ECursorMode; 64 65 struct _ESelectionModel { 66 GObject parent; 67 68 ESorter *sorter; 69 70 GtkSelectionMode mode; 71 ECursorMode cursor_mode; 72 73 gint old_selection; 74 }; 75 76 struct _ESelectionModelClass { 77 GObjectClass parent_class; 78 79 /* Virtual methods */ 80 gboolean (*is_row_selected) (ESelectionModel *model, 81 gint row); 82 void (*foreach) (ESelectionModel *model, 83 EForeachFunc callback, 84 gpointer closure); 85 void (*clear) (ESelectionModel *model); 86 gint (*selected_count) (ESelectionModel *model); 87 void (*select_all) (ESelectionModel *model); 88 gint (*row_count) (ESelectionModel *model); 89 90 /* Protected virtual methods. */ 91 void (*change_one_row) (ESelectionModel *model, 92 gint row, 93 gboolean on); 94 void (*change_cursor) (ESelectionModel *model, 95 gint row, 96 gint col); 97 gint (*cursor_row) (ESelectionModel *model); 98 gint (*cursor_col) (ESelectionModel *model); 99 100 void (*select_single_row) (ESelectionModel *model, 101 gint row); 102 void (*toggle_single_row) (ESelectionModel *model, 103 gint row); 104 void (*move_selection_end) (ESelectionModel *model, 105 gint row); 106 void (*set_selection_end) (ESelectionModel *model, 107 gint row); 108 109 /* Signals */ 110 void (*cursor_changed) (ESelectionModel *model, 111 gint row, 112 gint col); 113 void (*cursor_activated) (ESelectionModel *model, 114 gint row, 115 gint col); 116 void (*selection_row_changed)(ESelectionModel *model, 117 gint row); 118 void (*selection_changed) (ESelectionModel *model); 119 }; 120 121 GType e_selection_model_get_type (void) G_GNUC_CONST; 122 void e_selection_model_do_something (ESelectionModel *model, 123 guint row, 124 guint col, 125 GdkModifierType state); 126 gboolean e_selection_model_maybe_do_something 127 (ESelectionModel *model, 128 guint row, 129 guint col, 130 GdkModifierType state); 131 void e_selection_model_right_click_down 132 (ESelectionModel *model, 133 guint row, 134 guint col, 135 GdkModifierType state); 136 void e_selection_model_right_click_up 137 (ESelectionModel *model); 138 gboolean e_selection_model_key_press (ESelectionModel *model, 139 GdkEventKey *key); 140 void e_selection_model_select_as_key_press 141 (ESelectionModel *model, 142 guint row, 143 guint col, 144 GdkModifierType state); 145 146 /* Virtual functions */ 147 gboolean e_selection_model_is_row_selected 148 (ESelectionModel *model, 149 gint n); 150 void e_selection_model_foreach (ESelectionModel *model, 151 EForeachFunc callback, 152 gpointer closure); 153 void e_selection_model_clear (ESelectionModel *model); 154 gint e_selection_model_selected_count 155 (ESelectionModel *model); 156 void e_selection_model_select_all (ESelectionModel *model); 157 gint e_selection_model_row_count (ESelectionModel *model); 158 159 /* Private virtual Functions */ 160 void e_selection_model_change_one_row 161 (ESelectionModel *model, 162 gint row, 163 gboolean on); 164 void e_selection_model_change_cursor (ESelectionModel *model, 165 gint row, 166 gint col); 167 gint e_selection_model_cursor_row (ESelectionModel *model); 168 gint e_selection_model_cursor_col (ESelectionModel *model); 169 void e_selection_model_select_single_row 170 (ESelectionModel *model, 171 gint row); 172 void e_selection_model_toggle_single_row 173 (ESelectionModel *model, 174 gint row); 175 void e_selection_model_move_selection_end 176 (ESelectionModel *model, 177 gint row); 178 void e_selection_model_set_selection_end 179 (ESelectionModel *model, 180 gint row); 181 182 /* Signals */ 183 void e_selection_model_cursor_changed 184 (ESelectionModel *model, 185 gint row, 186 gint col); 187 void e_selection_model_cursor_activated 188 (ESelectionModel *model, 189 gint row, 190 gint col); 191 void e_selection_model_selection_row_changed 192 (ESelectionModel *model, 193 gint row); 194 void e_selection_model_selection_changed 195 (ESelectionModel *model); 196 197 G_END_DECLS 198 199 #endif /* E_SELECTION_MODEL_H */ 200 201