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 __GDA_TREE_NODE_H__ 21 #define __GDA_TREE_NODE_H__ 22 23 #include <glib-object.h> 24 #include "gda-decl.h" 25 26 G_BEGIN_DECLS 27 28 #define GDA_TYPE_TREE_NODE (gda_tree_node_get_type()) 29 #define GDA_TREE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_TREE_NODE, GdaTreeNode)) 30 #define GDA_TREE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_TREE_NODE, GdaTreeNodeClass)) 31 #define GDA_IS_TREE_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, GDA_TYPE_TREE_NODE)) 32 #define GDA_IS_TREE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GDA_TYPE_TREE_NODE)) 33 #define GDA_TREE_NODE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDA_TYPE_TREE_NODE, GdaTreeNodeClass)) 34 35 /* error reporting */ 36 extern GQuark gda_tree_node_error_quark (void); 37 #define GDA_TREE_NODE_ERROR gda_tree_node_error_quark () 38 39 typedef enum { 40 GDA_TREE_NODE_UNKNOWN_ERROR 41 } GdaTreeNodeError; 42 43 struct _GdaTreeNode { 44 GObject object; 45 GdaTreeNodePrivate *priv; 46 }; 47 48 struct _GdaTreeNodeClass { 49 GObjectClass object_class; 50 51 /* signals */ 52 void (* node_changed) (GdaTreeNode *reporting, GdaTreeNode *node); 53 void (* node_inserted) (GdaTreeNode *reporting, GdaTreeNode *node); 54 void (* node_has_child_toggled) (GdaTreeNode *reporting, GdaTreeNode *node); 55 void (* node_deleted) (GdaTreeNode *reporting, const gchar *relative_path); 56 57 /* virtual methods */ 58 gchar *(*dump_header) (GdaTreeNode *node); 59 void (*dump_children) (GdaTreeNode *node, const gchar *prefix, GString *in_string); 60 61 /*< private >*/ 62 /* Padding for future expansion */ 63 void (*_gda_reserved1) (void); 64 void (*_gda_reserved2) (void); 65 void (*_gda_reserved3) (void); 66 void (*_gda_reserved4) (void); 67 }; 68 69 /** 70 * SECTION:gda-tree-node 71 * @short_description: A node in a #GdaTree 72 * @title: GdaTreeNode 73 * @stability: Stable 74 * @see_also: 75 * 76 * Every node in a #GdaTree tree is represented by a single #GdaTreeNode object. There is no distinction 77 * between nodes which have children and those which don't (leaf nodes). 78 * 79 * The #GdaTreeNode is very basic as it only has a "name" attribute: users are encouraged to subclass it to 80 * add more features if needed (and make use of them by defining a #GdaTreeManagerNodeFunc function and 81 * calling gda_tree_manager_set_node_create_func()). 82 */ 83 84 GType gda_tree_node_get_type (void) G_GNUC_CONST; 85 GdaTreeNode* gda_tree_node_new (const gchar *name); 86 87 GdaTreeNode *gda_tree_node_get_parent (GdaTreeNode *node); 88 GSList *gda_tree_node_get_children (GdaTreeNode *node); 89 GdaTreeNode *gda_tree_node_get_child_index (GdaTreeNode *node, gint index); 90 GdaTreeNode *gda_tree_node_get_child_name (GdaTreeNode *node, const gchar *name); 91 92 void gda_tree_node_set_node_attribute(GdaTreeNode *node, const gchar *attribute, const GValue *value, 93 GDestroyNotify destroy); 94 const GValue *gda_tree_node_get_node_attribute(GdaTreeNode *node, const gchar *attribute); 95 const GValue *gda_tree_node_fetch_attribute (GdaTreeNode *node, const gchar *attribute); 96 97 /* private */ 98 void _gda_tree_node_add_children (GdaTreeNode *node, GdaTreeManager *mgr, const GSList *children); 99 const GSList *_gda_tree_node_get_children_for_manager (GdaTreeNode *node, GdaTreeManager *mgr); 100 GSList *_gda_tree_node_get_managers_for_children (GdaTreeNode *node); 101 GdaTreeManager *_gda_tree_node_get_manager_for_child (GdaTreeNode *node, GdaTreeNode *child); 102 103 G_END_DECLS 104 105 #endif 106