1 /* 2 * Copyright © 2018 Benjamin Otte 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.1 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, see <http://www.gnu.org/licenses/>. 16 * 17 * Authors: Benjamin Otte <otte@gnome.org> 18 */ 19 20 #ifndef __GTK_TREE_LIST_MODEL_H__ 21 #define __GTK_TREE_LIST_MODEL_H__ 22 23 24 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) 25 #error "Only <gtk/gtk.h> can be included directly." 26 #endif 27 28 #include <gio/gio.h> 29 #include <gtk/gtkwidget.h> 30 31 32 G_BEGIN_DECLS 33 34 #define GTK_TYPE_TREE_LIST_MODEL (gtk_tree_list_model_get_type ()) 35 #define GTK_TYPE_TREE_LIST_ROW (gtk_tree_list_row_get_type ()) 36 37 GDK_AVAILABLE_IN_ALL 38 G_DECLARE_FINAL_TYPE (GtkTreeListModel, gtk_tree_list_model, GTK, TREE_LIST_MODEL, GObject) 39 GDK_AVAILABLE_IN_ALL 40 G_DECLARE_FINAL_TYPE (GtkTreeListRow, gtk_tree_list_row, GTK, TREE_LIST_ROW, GObject) 41 42 /** 43 * GtkTreeListModelCreateModelFunc: 44 * @item: (type GObject): The item that is being expanded 45 * @user_data: User data passed when registering the function 46 * 47 * Prototype of the function called to create new child models when 48 * gtk_tree_list_row_set_expanded() is called. 49 * 50 * This function can return %NULL to indicate that @item is guaranteed to be 51 * a leaf node and will never have children. If it does not have children but 52 * may get children later, it should return an empty model that is filled once 53 * children arrive. 54 * 55 * Returns: (nullable) (transfer full): The model tracking the children of 56 * @item or %NULL if @item can never have children 57 */ 58 typedef GListModel * (* GtkTreeListModelCreateModelFunc) (gpointer item, gpointer user_data); 59 60 GDK_AVAILABLE_IN_ALL 61 GtkTreeListModel * gtk_tree_list_model_new (GListModel *root, 62 gboolean passthrough, 63 gboolean autoexpand, 64 GtkTreeListModelCreateModelFunc create_func, 65 gpointer user_data, 66 GDestroyNotify user_destroy); 67 68 GDK_AVAILABLE_IN_ALL 69 GListModel * gtk_tree_list_model_get_model (GtkTreeListModel *self); 70 GDK_AVAILABLE_IN_ALL 71 gboolean gtk_tree_list_model_get_passthrough (GtkTreeListModel *self); 72 GDK_AVAILABLE_IN_ALL 73 void gtk_tree_list_model_set_autoexpand (GtkTreeListModel *self, 74 gboolean autoexpand); 75 GDK_AVAILABLE_IN_ALL 76 gboolean gtk_tree_list_model_get_autoexpand (GtkTreeListModel *self); 77 78 GDK_AVAILABLE_IN_ALL 79 GtkTreeListRow * gtk_tree_list_model_get_child_row (GtkTreeListModel *self, 80 guint position); 81 GDK_AVAILABLE_IN_ALL 82 GtkTreeListRow * gtk_tree_list_model_get_row (GtkTreeListModel *self, 83 guint position); 84 85 GDK_AVAILABLE_IN_ALL 86 gpointer gtk_tree_list_row_get_item (GtkTreeListRow *self); 87 GDK_AVAILABLE_IN_ALL 88 void gtk_tree_list_row_set_expanded (GtkTreeListRow *self, 89 gboolean expanded); 90 GDK_AVAILABLE_IN_ALL 91 gboolean gtk_tree_list_row_get_expanded (GtkTreeListRow *self); 92 GDK_AVAILABLE_IN_ALL 93 gboolean gtk_tree_list_row_is_expandable (GtkTreeListRow *self); 94 GDK_AVAILABLE_IN_ALL 95 guint gtk_tree_list_row_get_position (GtkTreeListRow *self); 96 GDK_AVAILABLE_IN_ALL 97 guint gtk_tree_list_row_get_depth (GtkTreeListRow *self); 98 GDK_AVAILABLE_IN_ALL 99 GListModel * gtk_tree_list_row_get_children (GtkTreeListRow *self); 100 GDK_AVAILABLE_IN_ALL 101 GtkTreeListRow * gtk_tree_list_row_get_parent (GtkTreeListRow *self); 102 GDK_AVAILABLE_IN_ALL 103 GtkTreeListRow * gtk_tree_list_row_get_child_row (GtkTreeListRow *self, 104 guint position); 105 106 107 G_END_DECLS 108 109 #endif /* __GTK_TREE_LIST_MODEL_H__ */ 110