1 /* 2 * gnome-keyring 3 * 4 * Copyright (C) 2010 Stefan Walter 5 * Copyright (C) 2011 Collabora Ltd. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation; either version 2.1 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this program; if not, see <http://www.gnu.org/licenses/>. 19 * 20 * Author: Stef Walter <stefw@collabora.co.uk> 21 */ 22 23 #ifndef __GCR_COLLECTION_MODEL_H__ 24 #define __GCR_COLLECTION_MODEL_H__ 25 26 #include <gtk/gtk.h> 27 28 #include "gcr/gcr-collection.h" 29 #include "gcr/gcr-column.h" 30 31 typedef enum { 32 GCR_COLLECTION_MODEL_LIST = 0, 33 GCR_COLLECTION_MODEL_TREE 34 } GcrCollectionModelMode; 35 36 #define GCR_TYPE_COLLECTION_MODEL (gcr_collection_model_get_type ()) 37 #define GCR_COLLECTION_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCR_TYPE_COLLECTION_MODEL, GcrCollectionModel)) 38 #define GCR_COLLECTION_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCR_TYPE_COLLECTION_MODEL, GcrCollectionModelClass)) 39 #define GCR_IS_COLLECTION_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCR_TYPE_COLLECTION_MODEL)) 40 #define GCR_IS_COLLECTION_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCR_TYPE_COLLECTION_MODEL)) 41 #define GCR_COLLECTION_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCR_TYPE_COLLECTION_MODEL, GcrCollectionModelClass)) 42 43 typedef struct _GcrCollectionModel GcrCollectionModel; 44 typedef struct _GcrCollectionModelClass GcrCollectionModelClass; 45 typedef struct _GcrCollectionModelPrivate GcrCollectionModelPrivate; 46 47 struct _GcrCollectionModel { 48 GObject parent; 49 50 /*< private >*/ 51 GcrCollectionModelPrivate *pv; 52 }; 53 54 struct _GcrCollectionModelClass { 55 GObjectClass parent_class; 56 }; 57 58 GType gcr_collection_model_get_type (void); 59 60 GcrCollectionModel* gcr_collection_model_new (GcrCollection *collection, 61 GcrCollectionModelMode mode, 62 ...) G_GNUC_NULL_TERMINATED; 63 64 GcrCollectionModel* gcr_collection_model_new_full (GcrCollection *collection, 65 GcrCollectionModelMode mode, 66 const GcrColumn *columns); 67 68 guint gcr_collection_model_set_columns (GcrCollectionModel *self, 69 const GcrColumn *columns); 70 71 GcrCollection * gcr_collection_model_get_collection (GcrCollectionModel *self); 72 73 void gcr_collection_model_set_collection (GcrCollectionModel *self, 74 GcrCollection *collection); 75 76 GObject* gcr_collection_model_object_for_iter (GcrCollectionModel *self, 77 const GtkTreeIter *iter); 78 79 gboolean gcr_collection_model_iter_for_object (GcrCollectionModel *self, 80 GObject *object, 81 GtkTreeIter *iter); 82 83 gint gcr_collection_model_column_for_selected (GcrCollectionModel *self); 84 85 void gcr_collection_model_toggle_selected (GcrCollectionModel *self, 86 GtkTreeIter *iter); 87 88 void gcr_collection_model_change_selected (GcrCollectionModel *self, 89 GtkTreeIter *iter, 90 gboolean selected); 91 92 gboolean gcr_collection_model_is_selected (GcrCollectionModel *self, 93 GtkTreeIter *iter); 94 95 GList* gcr_collection_model_get_selected_objects (GcrCollectionModel *self); 96 97 void gcr_collection_model_set_selected_objects (GcrCollectionModel *self, 98 GList *selected); 99 100 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GcrCollectionModel, g_object_unref) 101 102 #endif /* __GCR_COLLECTION_MODEL_H__ */ 103