1 /* 2 * Copyright (C) 2009 - 2011 Vivien Malerba <malerba@gnome-db.org> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __GDAUI_TREE_STORE__ 21 #define __GDAUI_TREE_STORE__ 22 23 #include <gtk/gtk.h> 24 #include <libgda/gda-tree.h> 25 26 G_BEGIN_DECLS 27 28 #define GDAUI_TYPE_TREE_STORE (gdaui_tree_store_get_type()) 29 #define GDAUI_TREE_STORE(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gdaui_tree_store_get_type(), GdauiTreeStore) 30 #define GDAUI_TREE_STORE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gdaui_tree_store_get_type (), GdauiTreeStoreClass) 31 #define GDAUI_IS_TREE_STORE(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gdaui_tree_store_get_type ()) 32 33 typedef struct _GdauiTreeStore GdauiTreeStore; 34 typedef struct _GdauiTreeStoreClass GdauiTreeStoreClass; 35 typedef struct _GdauiTreeStorePriv GdauiTreeStorePriv; 36 37 38 /* struct for the object's tree */ 39 struct _GdauiTreeStore 40 { 41 GObject object; 42 43 GdauiTreeStorePriv *priv; 44 }; 45 46 /* struct for the object's class */ 47 struct _GdauiTreeStoreClass 48 { 49 GObjectClass parent_class; 50 51 /* signals */ 52 gboolean (*drag_can_drag) (GdauiTreeStore *store, const gchar *path); 53 gboolean (*drag_get) (GdauiTreeStore *store, const gchar *path, GtkSelectionData *selection_data); 54 gboolean (*drag_can_drop) (GdauiTreeStore *store, const gchar *path, GtkSelectionData *selection_data); 55 gboolean (*drag_drop) (GdauiTreeStore *store, const gchar *path, GtkSelectionData *selection_data); 56 gboolean (*drag_delete) (GdauiTreeStore *store, const gchar *path); 57 }; 58 59 /** 60 * SECTION:gdaui-tree-store 61 * @short_description: Bridge between a #GdaTree and a #GtkTreeModel 62 * @title: GdauiTreeStore 63 * @stability: Stable 64 * @see_also: #GdaTree 65 * 66 * The #GdauiTreeStore implements the #GtkTreeModel interface required 67 * to display data from a #GdaTree in a #GtkTreeView widget. 68 * 69 * To allow a tree to be populated only on request (ie. when the user expands a row), each 70 * #GdaTreeNode can give the attribute named #GDA_ATTRIBUTE_TREE_NODE_UNKNOWN_CHILDREN 71 * a boolean %TRUE #GValue to tell the #GdauiTreeStore data model to artificially add 72 * a dummy child for the row corresponding to the #GdaTreeNode. Then the programmer 73 * can connect to the <link linkend="GtkTreeView-test-expand-row">GtkTreeView::test-expand-row</link> 74 * signal and update the requested children. 75 */ 76 77 GType gdaui_tree_store_get_type (void) G_GNUC_CONST; 78 79 GtkTreeModel *gdaui_tree_store_new (GdaTree *tree, guint n_columns, ...); 80 GtkTreeModel *gdaui_tree_store_newv (GdaTree *tree, guint n_columns, 81 GType *types, const gchar **attribute_names); 82 GdaTreeNode *gdaui_tree_store_get_node (GdauiTreeStore *store, GtkTreeIter *iter); 83 gboolean gdaui_tree_store_get_iter (GdauiTreeStore *store, GtkTreeIter *iter, GdaTreeNode *node); 84 gboolean gdaui_tree_store_get_iter_from_node (GdauiTreeStore *store, GtkTreeIter *iter, GdaTreeNode *node); 85 86 G_END_DECLS 87 88 #endif 89