1 /* 2 * Clutter. 3 * 4 * An OpenGL based 'interactive canvas' library. 5 * 6 * Authored By Matthew Allum <mallum@openedhand.com> 7 * Neil Jagdish Patel <njp@o-hand.com> 8 * Emmanuele Bassi <ebassi@openedhand.com> 9 * 10 * Copyright (C) 2006 OpenedHand 11 * 12 * This library is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU Lesser General Public 14 * License as published by the Free Software Foundation; either 15 * version 2 of the License, or (at your option) any later version. 16 * 17 * This library is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 * Lesser General Public License for more details. 21 * 22 * You should have received a copy of the GNU Lesser General Public 23 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 24 */ 25 26 #if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) 27 #error "Only <clutter/clutter.h> can be included directly." 28 #endif 29 30 #ifndef __CLUTTER_MODEL_H__ 31 #define __CLUTTER_MODEL_H__ 32 33 #include <clutter/clutter-types.h> 34 35 G_BEGIN_DECLS 36 37 #define CLUTTER_TYPE_MODEL (clutter_model_get_type ()) 38 #define CLUTTER_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_MODEL, ClutterModel)) 39 #define CLUTTER_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_MODEL, ClutterModelClass)) 40 #define CLUTTER_IS_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_MODEL)) 41 #define CLUTTER_IS_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_MODEL)) 42 #define CLUTTER_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_MODEL, ClutterModelClass)) 43 44 typedef struct _ClutterModel ClutterModel; 45 typedef struct _ClutterModelClass ClutterModelClass; 46 typedef struct _ClutterModelPrivate ClutterModelPrivate; 47 typedef struct _ClutterModelIter ClutterModelIter; 48 typedef struct _ClutterModelIterClass ClutterModelIterClass; 49 typedef struct _ClutterModelIterPrivate ClutterModelIterPrivate; 50 51 52 /** 53 * ClutterModelFilterFunc: 54 * @model: a #ClutterModel 55 * @iter: the iterator for the row 56 * @user_data: data passed to clutter_model_set_filter() 57 * 58 * Filters the content of a row in the model. 59 * 60 * Return value: If the row should be displayed, return %TRUE 61 * 62 * Since: 0.6 63 * 64 * Deprecated: 1.24: Implement filters using a custom #GListModel instead 65 */ 66 typedef gboolean (*ClutterModelFilterFunc) (ClutterModel *model, 67 ClutterModelIter *iter, 68 gpointer user_data); 69 70 /** 71 * ClutterModelSortFunc: 72 * @model: a #ClutterModel 73 * @a: a #GValue representing the contents of the row 74 * @b: a #GValue representing the contents of the second row 75 * @user_data: data passed to clutter_model_set_sort() 76 * 77 * Compares the content of two rows in the model. 78 * 79 * Return value: a positive integer if @a is after @b, a negative integer if 80 * @a is before @b, or 0 if the rows are the same 81 * 82 * Since: 0.6 83 * 84 * Deprecated: 1.24: Implement sorting using a custom #GListModel instead 85 */ 86 typedef gint (*ClutterModelSortFunc) (ClutterModel *model, 87 const GValue *a, 88 const GValue *b, 89 gpointer user_data); 90 91 /** 92 * ClutterModelForeachFunc: 93 * @model: a #ClutterModel 94 * @iter: the iterator for the row 95 * @user_data: data passed to clutter_model_foreach() 96 * 97 * Iterates on the content of a row in the model 98 * 99 * Return value: %TRUE if the iteration should continue, %FALSE otherwise 100 * 101 * Since: 0.6 102 * 103 * Deprecated: 1.24: Use #GListModel 104 */ 105 typedef gboolean (*ClutterModelForeachFunc) (ClutterModel *model, 106 ClutterModelIter *iter, 107 gpointer user_data); 108 109 /** 110 * ClutterModel: 111 * 112 * Base class for list models. The #ClutterModel structure contains 113 * only private data and should be manipulated using the provided 114 * API. 115 * 116 * Since: 0.6 117 * 118 * Deprecated: 1.24: Use #GListModel instead 119 */ 120 struct _ClutterModel 121 { 122 /*< private >*/ 123 GObject parent_instance; 124 125 ClutterModelPrivate *priv; 126 }; 127 128 /** 129 * ClutterModelClass: 130 * @row_added: signal class handler for ClutterModel::row-added 131 * @row_removed: signal class handler for ClutterModel::row-removed 132 * @row_changed: signal class handler for ClutterModel::row-changed 133 * @sort_changed: signal class handler for ClutterModel::sort-changed 134 * @filter_changed: signal class handler for ClutterModel::filter-changed 135 * @get_column_name: virtual function for returning the name of a column 136 * @get_column_type: virtual function for returning the type of a column 137 * @get_iter_at_row: virtual function for returning an iterator for the 138 * given row 139 * @get_n_rows: virtual function for returning the number of rows 140 * of the model 141 * @get_n_columns: virtual function for retuning the number of columns 142 * of the model 143 * @resort: virtual function for sorting the model using the passed 144 * sorting function 145 * @insert_row: virtual function for inserting a row at the given index 146 * and returning an iterator pointing to it; if the index is a negative 147 * integer, the row should be appended to the model 148 * @remove_row: virtual function for removing a row at the given index 149 * 150 * Class for #ClutterModel instances. 151 * 152 * Since: 0.6 153 * 154 * Deprecated: 1.24: Use #GListModel instead 155 */ 156 struct _ClutterModelClass 157 { 158 /*< private >*/ 159 GObjectClass parent_class; 160 161 /*< public >*/ 162 /* vtable */ 163 guint (* get_n_rows) (ClutterModel *model); 164 guint (* get_n_columns) (ClutterModel *model); 165 const gchar * (* get_column_name) (ClutterModel *model, 166 guint column); 167 GType (* get_column_type) (ClutterModel *model, 168 guint column); 169 ClutterModelIter *(* insert_row) (ClutterModel *model, 170 gint index_); 171 void (* remove_row) (ClutterModel *model, 172 guint row); 173 ClutterModelIter *(* get_iter_at_row) (ClutterModel *model, 174 guint row); 175 void (* resort) (ClutterModel *model, 176 ClutterModelSortFunc func, 177 gpointer data); 178 179 /* signals */ 180 void (* row_added) (ClutterModel *model, 181 ClutterModelIter *iter); 182 void (* row_removed) (ClutterModel *model, 183 ClutterModelIter *iter); 184 void (* row_changed) (ClutterModel *model, 185 ClutterModelIter *iter); 186 void (* sort_changed) (ClutterModel *model); 187 void (* filter_changed) (ClutterModel *model); 188 189 /*< private >*/ 190 /* padding for future expansion */ 191 void (*_clutter_model_1) (void); 192 void (*_clutter_model_2) (void); 193 void (*_clutter_model_3) (void); 194 void (*_clutter_model_4) (void); 195 void (*_clutter_model_5) (void); 196 void (*_clutter_model_6) (void); 197 void (*_clutter_model_7) (void); 198 void (*_clutter_model_8) (void); 199 }; 200 201 CLUTTER_DEPRECATED_IN_1_24_FOR(g_list_model_get_type) 202 GType clutter_model_get_type (void) G_GNUC_CONST; 203 204 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 205 void clutter_model_set_types (ClutterModel *model, 206 guint n_columns, 207 GType *types); 208 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 209 void clutter_model_set_names (ClutterModel *model, 210 guint n_columns, 211 const gchar * const names[]); 212 213 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 214 void clutter_model_append (ClutterModel *model, 215 ...); 216 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 217 void clutter_model_appendv (ClutterModel *model, 218 guint n_columns, 219 guint *columns, 220 GValue *values); 221 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 222 void clutter_model_prepend (ClutterModel *model, 223 ...); 224 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 225 void clutter_model_prependv (ClutterModel *model, 226 guint n_columns, 227 guint *columns, 228 GValue *values); 229 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 230 void clutter_model_insert (ClutterModel *model, 231 guint row, 232 ...); 233 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 234 void clutter_model_insertv (ClutterModel *model, 235 guint row, 236 guint n_columns, 237 guint *columns, 238 GValue *values); 239 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 240 void clutter_model_insert_value (ClutterModel *model, 241 guint row, 242 guint column, 243 const GValue *value); 244 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 245 void clutter_model_remove (ClutterModel *model, 246 guint row); 247 248 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 249 guint clutter_model_get_n_rows (ClutterModel *model); 250 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 251 guint clutter_model_get_n_columns (ClutterModel *model); 252 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 253 const gchar * clutter_model_get_column_name (ClutterModel *model, 254 guint column); 255 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 256 GType clutter_model_get_column_type (ClutterModel *model, 257 guint column); 258 259 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 260 ClutterModelIter * clutter_model_get_first_iter (ClutterModel *model); 261 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 262 ClutterModelIter * clutter_model_get_last_iter (ClutterModel *model); 263 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 264 ClutterModelIter * clutter_model_get_iter_at_row (ClutterModel *model, 265 guint row); 266 267 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 268 void clutter_model_set_sorting_column (ClutterModel *model, 269 gint column); 270 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 271 gint clutter_model_get_sorting_column (ClutterModel *model); 272 273 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 274 void clutter_model_foreach (ClutterModel *model, 275 ClutterModelForeachFunc func, 276 gpointer user_data); 277 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 278 void clutter_model_set_sort (ClutterModel *model, 279 gint column, 280 ClutterModelSortFunc func, 281 gpointer user_data, 282 GDestroyNotify notify); 283 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 284 void clutter_model_set_filter (ClutterModel *model, 285 ClutterModelFilterFunc func, 286 gpointer user_data, 287 GDestroyNotify notify); 288 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 289 gboolean clutter_model_get_filter_set (ClutterModel *model); 290 291 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 292 void clutter_model_resort (ClutterModel *model); 293 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 294 gboolean clutter_model_filter_row (ClutterModel *model, 295 guint row); 296 CLUTTER_DEPRECATED_IN_1_24_FOR(GListModel) 297 gboolean clutter_model_filter_iter (ClutterModel *model, 298 ClutterModelIter *iter); 299 300 /* 301 * ClutterModelIter 302 */ 303 304 #define CLUTTER_TYPE_MODEL_ITER (clutter_model_iter_get_type ()) 305 #define CLUTTER_MODEL_ITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_MODEL_ITER, ClutterModelIter)) 306 #define CLUTTER_MODEL_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_MODEL_ITER, ClutterModelIterClass)) 307 #define CLUTTER_IS_MODEL_ITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_MODEL_ITER)) 308 #define CLUTTER_IS_MODEL_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_MODEL_ITER)) 309 #define CLUTTER_MODEL_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_MODEL_ITER, ClutterModelIterClass)) 310 311 /** 312 * ClutterModelIter: 313 * 314 * Base class for list models iters. The #ClutterModelIter structure 315 * contains only private data and should be manipulated using the 316 * provided API. 317 * 318 * Since: 0.6 319 * 320 * Deprecated: 1.24: Use custom iterators for #GListModel 321 */ 322 struct _ClutterModelIter 323 { 324 /*< private >*/ 325 GObject parent_instance; 326 327 ClutterModelIterPrivate *priv; 328 }; 329 330 /** 331 * ClutterModelIterClass: 332 * @get_value: Virtual function for retrieving the value at the given 333 * column of the row pointed by the iterator 334 * @set_value: Virtual function for setting the value at the given 335 * column of the row pointer by the iterator 336 * @is_last: Virtual function for knowing whether the iterator points 337 * at the last row in the model 338 * @is_first: Virtual function for knowing whether the iterator points 339 * at the first row in the model 340 * @next: Virtual function for moving the iterator to the following 341 * row in the model 342 * @prev: Virtual function for moving the iterator toe the previous 343 * row in the model 344 * @get_model: Virtual function for getting the model to which the 345 * iterator belongs to 346 * @get_row: Virtual function for getting the row to which the iterator 347 * points 348 * @copy: Virtual function for copying a #ClutterModelIter. 349 * 350 * Class for #ClutterModelIter instances. 351 * 352 * Since: 0.6 353 * 354 * Deprecated: 1.24: Use custom iterators for #GListModel 355 */ 356 struct _ClutterModelIterClass 357 { 358 /*< private >*/ 359 GObjectClass parent_class; 360 361 /*< public >*/ 362 /* vtable not signals */ 363 void (* get_value) (ClutterModelIter *iter, 364 guint column, 365 GValue *value); 366 void (* set_value) (ClutterModelIter *iter, 367 guint column, 368 const GValue *value); 369 370 gboolean (* is_first) (ClutterModelIter *iter); 371 gboolean (* is_last) (ClutterModelIter *iter); 372 373 ClutterModelIter *(* next) (ClutterModelIter *iter); 374 ClutterModelIter *(* prev) (ClutterModelIter *iter); 375 376 ClutterModel * (* get_model) (ClutterModelIter *iter); 377 guint (* get_row) (ClutterModelIter *iter); 378 379 ClutterModelIter *(* copy) (ClutterModelIter *iter); 380 381 /*< private >*/ 382 /* padding for future expansion */ 383 void (*_clutter_model_iter_1) (void); 384 void (*_clutter_model_iter_2) (void); 385 void (*_clutter_model_iter_3) (void); 386 void (*_clutter_model_iter_4) (void); 387 void (*_clutter_model_iter_5) (void); 388 void (*_clutter_model_iter_6) (void); 389 void (*_clutter_model_iter_7) (void); 390 void (*_clutter_model_iter_8) (void); 391 }; 392 393 CLUTTER_DEPRECATED_IN_1_24 394 GType clutter_model_iter_get_type (void) G_GNUC_CONST; 395 396 CLUTTER_DEPRECATED_IN_1_24 397 void clutter_model_iter_get (ClutterModelIter *iter, 398 ...); 399 CLUTTER_DEPRECATED_IN_1_24 400 void clutter_model_iter_get_valist (ClutterModelIter *iter, 401 va_list args); 402 CLUTTER_DEPRECATED_IN_1_24 403 void clutter_model_iter_get_value (ClutterModelIter *iter, 404 guint column, 405 GValue *value); 406 CLUTTER_DEPRECATED_IN_1_24 407 void clutter_model_iter_set (ClutterModelIter *iter, 408 ...); 409 CLUTTER_DEPRECATED_IN_1_24 410 void clutter_model_iter_set_valist (ClutterModelIter *iter, 411 va_list args); 412 CLUTTER_DEPRECATED_IN_1_24 413 void clutter_model_iter_set_value (ClutterModelIter *iter, 414 guint column, 415 const GValue *value); 416 417 CLUTTER_DEPRECATED_IN_1_24 418 gboolean clutter_model_iter_is_first (ClutterModelIter *iter); 419 CLUTTER_DEPRECATED_IN_1_24 420 gboolean clutter_model_iter_is_last (ClutterModelIter *iter); 421 CLUTTER_DEPRECATED_IN_1_24 422 ClutterModelIter *clutter_model_iter_next (ClutterModelIter *iter); 423 CLUTTER_DEPRECATED_IN_1_24 424 ClutterModelIter *clutter_model_iter_prev (ClutterModelIter *iter); 425 426 CLUTTER_DEPRECATED_IN_1_24 427 ClutterModel * clutter_model_iter_get_model (ClutterModelIter *iter); 428 CLUTTER_DEPRECATED_IN_1_24 429 guint clutter_model_iter_get_row (ClutterModelIter *iter); 430 431 CLUTTER_DEPRECATED_IN_1_24 432 ClutterModelIter *clutter_model_iter_copy (ClutterModelIter *iter); 433 434 G_END_DECLS 435 436 #endif /* __CLUTTER_MODEL_H__ */ 437