| File: | ctk/ctkliststore.c |
| Warning: | line 2671, column 25 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* ctkliststore.c |
| 2 | * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library 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 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public |
| 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #include "config.h" |
| 19 | #include <errno(*__errno_location ()).h> |
| 20 | #include <stdlib.h> |
| 21 | #include <string.h> |
| 22 | #include <gobject/gvaluecollector.h> |
| 23 | #include "ctktreemodel.h" |
| 24 | #include "ctkliststore.h" |
| 25 | #include "ctktreedatalist.h" |
| 26 | #include "ctktreednd.h" |
| 27 | #include "ctkintl.h" |
| 28 | #include "ctkbuildable.h" |
| 29 | #include "ctkbuilderprivate.h" |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * SECTION:ctkliststore |
| 34 | * @Short_description: A list-like data structure that can be used with the CtkTreeView |
| 35 | * @Title: CtkListStore |
| 36 | * @See_also:#CtkTreeModel, #CtkTreeStore |
| 37 | * |
| 38 | * The #CtkListStore object is a list model for use with a #CtkTreeView |
| 39 | * widget. It implements the #CtkTreeModel interface, and consequentialy, |
| 40 | * can use all of the methods available there. It also implements the |
| 41 | * #CtkTreeSortable interface so it can be sorted by the view. |
| 42 | * Finally, it also implements the tree |
| 43 | * [drag and drop][ctk3-CtkTreeView-drag-and-drop] |
| 44 | * interfaces. |
| 45 | * |
| 46 | * The #CtkListStore can accept most GObject types as a column type, though |
| 47 | * it can’t accept all custom types. Internally, it will keep a copy of |
| 48 | * data passed in (such as a string or a boxed pointer). Columns that |
| 49 | * accept #GObjects are handled a little differently. The |
| 50 | * #CtkListStore will keep a reference to the object instead of copying the |
| 51 | * value. As a result, if the object is modified, it is up to the |
| 52 | * application writer to call ctk_tree_model_row_changed() to emit the |
| 53 | * #CtkTreeModel::row_changed signal. This most commonly affects lists with |
| 54 | * #GdkPixbufs stored. |
| 55 | * |
| 56 | * An example for creating a simple list store: |
| 57 | * |[<!-- language="C" --> |
| 58 | * enum { |
| 59 | * COLUMN_STRING, |
| 60 | * COLUMN_INT, |
| 61 | * COLUMN_BOOLEAN, |
| 62 | * N_COLUMNS |
| 63 | * }; |
| 64 | * |
| 65 | * { |
| 66 | * CtkListStore *list_store; |
| 67 | * CtkTreePath *path; |
| 68 | * CtkTreeIter iter; |
| 69 | * gint i; |
| 70 | * |
| 71 | * list_store = ctk_list_store_new (N_COLUMNS, |
| 72 | * G_TYPE_STRING, |
| 73 | * G_TYPE_INT, |
| 74 | * G_TYPE_BOOLEAN); |
| 75 | * |
| 76 | * for (i = 0; i < 10; i++) |
| 77 | * { |
| 78 | * gchar *some_data; |
| 79 | * |
| 80 | * some_data = get_some_data (i); |
| 81 | * |
| 82 | * // Add a new row to the model |
| 83 | * ctk_list_store_append (list_store, &iter); |
| 84 | * ctk_list_store_set (list_store, &iter, |
| 85 | * COLUMN_STRING, some_data, |
| 86 | * COLUMN_INT, i, |
| 87 | * COLUMN_BOOLEAN, FALSE, |
| 88 | * -1); |
| 89 | * |
| 90 | * // As the store will keep a copy of the string internally, |
| 91 | * // we free some_data. |
| 92 | * g_free (some_data); |
| 93 | * } |
| 94 | * |
| 95 | * // Modify a particular row |
| 96 | * path = ctk_tree_path_new_from_string ("4"); |
| 97 | * ctk_tree_model_get_iter (CTK_TREE_MODEL (list_store), |
| 98 | * &iter, |
| 99 | * path); |
| 100 | * ctk_tree_path_free (path); |
| 101 | * ctk_list_store_set (list_store, &iter, |
| 102 | * COLUMN_BOOLEAN, TRUE, |
| 103 | * -1); |
| 104 | * } |
| 105 | * ]| |
| 106 | * |
| 107 | * # Performance Considerations |
| 108 | * |
| 109 | * Internally, the #CtkListStore was implemented with a linked list with |
| 110 | * a tail pointer prior to CTK+ 2.6. As a result, it was fast at data |
| 111 | * insertion and deletion, and not fast at random data access. The |
| 112 | * #CtkListStore sets the #CTK_TREE_MODEL_ITERS_PERSIST flag, which means |
| 113 | * that #CtkTreeIters can be cached while the row exists. Thus, if |
| 114 | * access to a particular row is needed often and your code is expected to |
| 115 | * run on older versions of CTK+, it is worth keeping the iter around. |
| 116 | * |
| 117 | * # Atomic Operations |
| 118 | * |
| 119 | * It is important to note that only the methods |
| 120 | * ctk_list_store_insert_with_values() and ctk_list_store_insert_with_valuesv() |
| 121 | * are atomic, in the sense that the row is being appended to the store and the |
| 122 | * values filled in in a single operation with regard to #CtkTreeModel signaling. |
| 123 | * In contrast, using e.g. ctk_list_store_append() and then ctk_list_store_set() |
| 124 | * will first create a row, which triggers the #CtkTreeModel::row-inserted signal |
| 125 | * on #CtkListStore. The row, however, is still empty, and any signal handler |
| 126 | * connecting to #CtkTreeModel::row-inserted on this particular store should be prepared |
| 127 | * for the situation that the row might be empty. This is especially important |
| 128 | * if you are wrapping the #CtkListStore inside a #CtkTreeModelFilter and are |
| 129 | * using a #CtkTreeModelFilterVisibleFunc. Using any of the non-atomic operations |
| 130 | * to append rows to the #CtkListStore will cause the |
| 131 | * #CtkTreeModelFilterVisibleFunc to be visited with an empty row first; the |
| 132 | * function must be prepared for that. |
| 133 | * |
| 134 | * # CtkListStore as CtkBuildable |
| 135 | * |
| 136 | * The CtkListStore implementation of the CtkBuildable interface allows |
| 137 | * to specify the model columns with a <columns> element that may contain |
| 138 | * multiple <column> elements, each specifying one model column. The “type” |
| 139 | * attribute specifies the data type for the column. |
| 140 | * |
| 141 | * Additionally, it is possible to specify content for the list store |
| 142 | * in the UI definition, with the <data> element. It can contain multiple |
| 143 | * <row> elements, each specifying to content for one row of the list model. |
| 144 | * Inside a <row>, the <col> elements specify the content for individual cells. |
| 145 | * |
| 146 | * Note that it is probably more common to define your models in the code, |
| 147 | * and one might consider it a layering violation to specify the content of |
| 148 | * a list store in a UI definition, data, not presentation, and common wisdom |
| 149 | * is to separate the two, as far as possible. |
| 150 | * |
| 151 | * An example of a UI Definition fragment for a list store: |
| 152 | * |[<!-- language="C" --> |
| 153 | * <object class="CtkListStore"> |
| 154 | * <columns> |
| 155 | * <column type="gchararray"/> |
| 156 | * <column type="gchararray"/> |
| 157 | * <column type="gint"/> |
| 158 | * </columns> |
| 159 | * <data> |
| 160 | * <row> |
| 161 | * <col id="0">John</col> |
| 162 | * <col id="1">Doe</col> |
| 163 | * <col id="2">25</col> |
| 164 | * </row> |
| 165 | * <row> |
| 166 | * <col id="0">Johan</col> |
| 167 | * <col id="1">Dahlin</col> |
| 168 | * <col id="2">50</col> |
| 169 | * </row> |
| 170 | * </data> |
| 171 | * </object> |
| 172 | * ]| |
| 173 | */ |
| 174 | |
| 175 | |
| 176 | struct _CtkListStorePrivate |
| 177 | { |
| 178 | CtkTreeIterCompareFunc default_sort_func; |
| 179 | |
| 180 | GDestroyNotify default_sort_destroy; |
| 181 | GList *sort_list; |
| 182 | GType *column_headers; |
| 183 | |
| 184 | gint stamp; |
| 185 | gint n_columns; |
| 186 | gint sort_column_id; |
| 187 | gint length; |
| 188 | |
| 189 | CtkSortType order; |
| 190 | |
| 191 | guint columns_dirty : 1; |
| 192 | |
| 193 | gpointer default_sort_data; |
| 194 | gpointer seq; /* head of the list */ |
| 195 | }; |
| 196 | |
| 197 | #define CTK_LIST_STORE_IS_SORTED(list)(((CtkListStore*)(list))->priv->sort_column_id != (-2)) (((CtkListStore*)(list))->priv->sort_column_id != CTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID(-2)) |
| 198 | static void ctk_list_store_tree_model_init (CtkTreeModelIface *iface); |
| 199 | static void ctk_list_store_drag_source_init(CtkTreeDragSourceIface *iface); |
| 200 | static void ctk_list_store_drag_dest_init (CtkTreeDragDestIface *iface); |
| 201 | static void ctk_list_store_sortable_init (CtkTreeSortableIface *iface); |
| 202 | static void ctk_list_store_buildable_init (CtkBuildableIface *iface); |
| 203 | static void ctk_list_store_finalize (GObject *object); |
| 204 | static CtkTreeModelFlags ctk_list_store_get_flags (CtkTreeModel *tree_model); |
| 205 | static gint ctk_list_store_get_n_columns (CtkTreeModel *tree_model); |
| 206 | static GType ctk_list_store_get_column_type (CtkTreeModel *tree_model, |
| 207 | gint index); |
| 208 | static gboolean ctk_list_store_get_iter (CtkTreeModel *tree_model, |
| 209 | CtkTreeIter *iter, |
| 210 | CtkTreePath *path); |
| 211 | static CtkTreePath *ctk_list_store_get_path (CtkTreeModel *tree_model, |
| 212 | CtkTreeIter *iter); |
| 213 | static void ctk_list_store_get_value (CtkTreeModel *tree_model, |
| 214 | CtkTreeIter *iter, |
| 215 | gint column, |
| 216 | GValue *value); |
| 217 | static gboolean ctk_list_store_iter_next (CtkTreeModel *tree_model, |
| 218 | CtkTreeIter *iter); |
| 219 | static gboolean ctk_list_store_iter_previous (CtkTreeModel *tree_model, |
| 220 | CtkTreeIter *iter); |
| 221 | static gboolean ctk_list_store_iter_children (CtkTreeModel *tree_model, |
| 222 | CtkTreeIter *iter, |
| 223 | CtkTreeIter *parent); |
| 224 | static gboolean ctk_list_store_iter_has_child (CtkTreeModel *tree_model, |
| 225 | CtkTreeIter *iter); |
| 226 | static gint ctk_list_store_iter_n_children (CtkTreeModel *tree_model, |
| 227 | CtkTreeIter *iter); |
| 228 | static gboolean ctk_list_store_iter_nth_child (CtkTreeModel *tree_model, |
| 229 | CtkTreeIter *iter, |
| 230 | CtkTreeIter *parent, |
| 231 | gint n); |
| 232 | static gboolean ctk_list_store_iter_parent (CtkTreeModel *tree_model, |
| 233 | CtkTreeIter *iter, |
| 234 | CtkTreeIter *child); |
| 235 | |
| 236 | |
| 237 | static void ctk_list_store_set_n_columns (CtkListStore *list_store, |
| 238 | gint n_columns); |
| 239 | static void ctk_list_store_set_column_type (CtkListStore *list_store, |
| 240 | gint column, |
| 241 | GType type); |
| 242 | |
| 243 | static void ctk_list_store_increment_stamp (CtkListStore *list_store); |
| 244 | |
| 245 | |
| 246 | /* Drag and Drop */ |
| 247 | static gboolean real_ctk_list_store_row_draggable (CtkTreeDragSource *drag_source, |
| 248 | CtkTreePath *path); |
| 249 | static gboolean ctk_list_store_drag_data_delete (CtkTreeDragSource *drag_source, |
| 250 | CtkTreePath *path); |
| 251 | static gboolean ctk_list_store_drag_data_get (CtkTreeDragSource *drag_source, |
| 252 | CtkTreePath *path, |
| 253 | CtkSelectionData *selection_data); |
| 254 | static gboolean ctk_list_store_drag_data_received (CtkTreeDragDest *drag_dest, |
| 255 | CtkTreePath *dest, |
| 256 | CtkSelectionData *selection_data); |
| 257 | static gboolean ctk_list_store_row_drop_possible (CtkTreeDragDest *drag_dest, |
| 258 | CtkTreePath *dest_path, |
| 259 | CtkSelectionData *selection_data); |
| 260 | |
| 261 | |
| 262 | /* sortable */ |
| 263 | static void ctk_list_store_sort (CtkListStore *list_store); |
| 264 | static void ctk_list_store_sort_iter_changed (CtkListStore *list_store, |
| 265 | CtkTreeIter *iter, |
| 266 | gint column); |
| 267 | static gboolean ctk_list_store_get_sort_column_id (CtkTreeSortable *sortable, |
| 268 | gint *sort_column_id, |
| 269 | CtkSortType *order); |
| 270 | static void ctk_list_store_set_sort_column_id (CtkTreeSortable *sortable, |
| 271 | gint sort_column_id, |
| 272 | CtkSortType order); |
| 273 | static void ctk_list_store_set_sort_func (CtkTreeSortable *sortable, |
| 274 | gint sort_column_id, |
| 275 | CtkTreeIterCompareFunc func, |
| 276 | gpointer data, |
| 277 | GDestroyNotify destroy); |
| 278 | static void ctk_list_store_set_default_sort_func (CtkTreeSortable *sortable, |
| 279 | CtkTreeIterCompareFunc func, |
| 280 | gpointer data, |
| 281 | GDestroyNotify destroy); |
| 282 | static gboolean ctk_list_store_has_default_sort_func (CtkTreeSortable *sortable); |
| 283 | |
| 284 | |
| 285 | /* buildable */ |
| 286 | static gboolean ctk_list_store_buildable_custom_tag_start (CtkBuildable *buildable, |
| 287 | CtkBuilder *builder, |
| 288 | GObject *child, |
| 289 | const gchar *tagname, |
| 290 | GMarkupParser *parser, |
| 291 | gpointer *data); |
| 292 | static void ctk_list_store_buildable_custom_tag_end (CtkBuildable *buildable, |
| 293 | CtkBuilder *builder, |
| 294 | GObject *child, |
| 295 | const gchar *tagname, |
| 296 | gpointer *data); |
| 297 | |
| 298 | G_DEFINE_TYPE_WITH_CODE (CtkListStore, ctk_list_store, G_TYPE_OBJECT,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 299 | G_ADD_PRIVATE (CtkListStore)static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 300 | G_IMPLEMENT_INTERFACE (CTK_TYPE_TREE_MODEL,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 301 | ctk_list_store_tree_model_init)static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 302 | G_IMPLEMENT_INTERFACE (CTK_TYPE_TREE_DRAG_SOURCE,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 303 | ctk_list_store_drag_source_init)static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 304 | G_IMPLEMENT_INTERFACE (CTK_TYPE_TREE_DRAG_DEST,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 305 | ctk_list_store_drag_dest_init)static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 306 | G_IMPLEMENT_INTERFACE (CTK_TYPE_TREE_SORTABLE,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 307 | ctk_list_store_sortable_init)static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 308 | G_IMPLEMENT_INTERFACE (CTK_TYPE_BUILDABLE,static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 309 | ctk_list_store_buildable_init))static void ctk_list_store_init (CtkListStore *self); static void ctk_list_store_class_init (CtkListStoreClass *klass); static GType ctk_list_store_get_type_once (void); static gpointer ctk_list_store_parent_class = ((void*)0); static gint CtkListStore_private_offset; static void ctk_list_store_class_intern_init (gpointer klass) { ctk_list_store_parent_class = g_type_class_peek_parent (klass); if (CtkListStore_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkListStore_private_offset ); ctk_list_store_class_init ((CtkListStoreClass*) klass); } __attribute__ ((__unused__)) static inline gpointer ctk_list_store_get_instance_private (CtkListStore *self) { return (((gpointer) ((guint8*) (self) + (glong) (CtkListStore_private_offset)))); } GType ctk_list_store_get_type (void) { static GType static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0)) ; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter_pointer ( &static_g_define_type_id)); })) ) { GType g_define_type_id = ctk_list_store_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer) , "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id ) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer ((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id )); })) ; } return static_g_define_type_id; } __attribute__ ( (__noinline__)) static GType ctk_list_store_get_type_once (void ) { GType g_define_type_id = g_type_register_static_simple (( (GType) ((20) << (2))), g_intern_static_string ("CtkListStore" ), sizeof (CtkListStoreClass), (GClassInitFunc)(void (*)(void )) ctk_list_store_class_intern_init, sizeof (CtkListStore), ( GInstanceInitFunc)(void (*)(void)) ctk_list_store_init, (GTypeFlags ) 0); { {{ CtkListStore_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkListStorePrivate)); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_tree_model_init, ((void*)0), ((void*)0 ) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_model_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_source_init, ((void*)0), ((void*) 0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_source_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_drag_dest_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_tree_drag_dest_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_sortable_init, ((void*)0), ((void*)0) } ; g_type_add_interface_static (g_define_type_id, (ctk_tree_sortable_get_type ()), &g_implement_interface_info); } { const GInterfaceInfo g_implement_interface_info = { (GInterfaceInitFunc)(void (*) (void)) ctk_list_store_buildable_init, ((void*)0), ((void*)0) }; g_type_add_interface_static (g_define_type_id, (ctk_buildable_get_type ()), &g_implement_interface_info); };} } return g_define_type_id ; } |
| 310 | |
| 311 | |
| 312 | static void |
| 313 | ctk_list_store_class_init (CtkListStoreClass *class) |
| 314 | { |
| 315 | GObjectClass *object_class; |
| 316 | |
| 317 | object_class = (GObjectClass*) class; |
| 318 | |
| 319 | object_class->finalize = ctk_list_store_finalize; |
| 320 | } |
| 321 | |
| 322 | static void |
| 323 | ctk_list_store_tree_model_init (CtkTreeModelIface *iface) |
| 324 | { |
| 325 | iface->get_flags = ctk_list_store_get_flags; |
| 326 | iface->get_n_columns = ctk_list_store_get_n_columns; |
| 327 | iface->get_column_type = ctk_list_store_get_column_type; |
| 328 | iface->get_iter = ctk_list_store_get_iter; |
| 329 | iface->get_path = ctk_list_store_get_path; |
| 330 | iface->get_value = ctk_list_store_get_value; |
| 331 | iface->iter_next = ctk_list_store_iter_next; |
| 332 | iface->iter_previous = ctk_list_store_iter_previous; |
| 333 | iface->iter_children = ctk_list_store_iter_children; |
| 334 | iface->iter_has_child = ctk_list_store_iter_has_child; |
| 335 | iface->iter_n_children = ctk_list_store_iter_n_children; |
| 336 | iface->iter_nth_child = ctk_list_store_iter_nth_child; |
| 337 | iface->iter_parent = ctk_list_store_iter_parent; |
| 338 | } |
| 339 | |
| 340 | static void |
| 341 | ctk_list_store_drag_source_init (CtkTreeDragSourceIface *iface) |
| 342 | { |
| 343 | iface->row_draggable = real_ctk_list_store_row_draggable; |
| 344 | iface->drag_data_delete = ctk_list_store_drag_data_delete; |
| 345 | iface->drag_data_get = ctk_list_store_drag_data_get; |
| 346 | } |
| 347 | |
| 348 | static void |
| 349 | ctk_list_store_drag_dest_init (CtkTreeDragDestIface *iface) |
| 350 | { |
| 351 | iface->drag_data_received = ctk_list_store_drag_data_received; |
| 352 | iface->row_drop_possible = ctk_list_store_row_drop_possible; |
| 353 | } |
| 354 | |
| 355 | static void |
| 356 | ctk_list_store_sortable_init (CtkTreeSortableIface *iface) |
| 357 | { |
| 358 | iface->get_sort_column_id = ctk_list_store_get_sort_column_id; |
| 359 | iface->set_sort_column_id = ctk_list_store_set_sort_column_id; |
| 360 | iface->set_sort_func = ctk_list_store_set_sort_func; |
| 361 | iface->set_default_sort_func = ctk_list_store_set_default_sort_func; |
| 362 | iface->has_default_sort_func = ctk_list_store_has_default_sort_func; |
| 363 | } |
| 364 | |
| 365 | void |
| 366 | ctk_list_store_buildable_init (CtkBuildableIface *iface) |
| 367 | { |
| 368 | iface->custom_tag_start = ctk_list_store_buildable_custom_tag_start; |
| 369 | iface->custom_tag_end = ctk_list_store_buildable_custom_tag_end; |
| 370 | } |
| 371 | |
| 372 | static void |
| 373 | ctk_list_store_init (CtkListStore *list_store) |
| 374 | { |
| 375 | CtkListStorePrivate *priv; |
| 376 | |
| 377 | list_store->priv = ctk_list_store_get_instance_private (list_store); |
| 378 | priv = list_store->priv; |
| 379 | |
| 380 | priv->seq = g_sequence_new (NULL((void*)0)); |
| 381 | priv->sort_list = NULL((void*)0); |
| 382 | priv->stamp = g_random_int (); |
| 383 | priv->sort_column_id = CTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID(-2); |
| 384 | priv->columns_dirty = FALSE(0); |
| 385 | priv->length = 0; |
| 386 | } |
| 387 | |
| 388 | static gboolean |
| 389 | iter_is_valid (CtkTreeIter *iter, |
| 390 | CtkListStore *list_store) |
| 391 | { |
| 392 | return iter != NULL((void*)0) && |
| 393 | iter->user_data != NULL((void*)0) && |
| 394 | list_store->priv->stamp == iter->stamp && |
| 395 | !g_sequence_iter_is_end (iter->user_data) && |
| 396 | g_sequence_iter_get_sequence (iter->user_data) == list_store->priv->seq; |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * ctk_list_store_new: |
| 401 | * @n_columns: number of columns in the list store |
| 402 | * @...: all #GType types for the columns, from first to last |
| 403 | * |
| 404 | * Creates a new list store as with @n_columns columns each of the types passed |
| 405 | * in. Note that only types derived from standard GObject fundamental types |
| 406 | * are supported. |
| 407 | * |
| 408 | * As an example, `ctk_list_store_new (3, G_TYPE_INT, G_TYPE_STRING, |
| 409 | * GDK_TYPE_PIXBUF);` will create a new #CtkListStore with three columns, of type |
| 410 | * int, string and #GdkPixbuf respectively. |
| 411 | * |
| 412 | * Returns: a new #CtkListStore |
| 413 | */ |
| 414 | CtkListStore * |
| 415 | ctk_list_store_new (gint n_columns, |
| 416 | ...) |
| 417 | { |
| 418 | CtkListStore *retval; |
| 419 | va_list args; |
| 420 | gint i; |
| 421 | |
| 422 | g_return_val_if_fail (n_columns > 0, NULL)do { if ((n_columns > 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "n_columns > 0"); return (((void*)0)); } } while (0); |
| 423 | |
| 424 | retval = g_object_new (CTK_TYPE_LIST_STORE(ctk_list_store_get_type ()), NULL((void*)0)); |
| 425 | ctk_list_store_set_n_columns (retval, n_columns); |
| 426 | |
| 427 | va_start (args, n_columns)__builtin_va_start(args, n_columns); |
| 428 | |
| 429 | for (i = 0; i < n_columns; i++) |
| 430 | { |
| 431 | GType type = va_arg (args, GType)__builtin_va_arg(args, GType); |
| 432 | if (! _ctk_tree_data_list_check_type (type)) |
| 433 | { |
| 434 | g_warning ("%s: Invalid type %s", G_STRLOC"ctkliststore.c" ":" "434", g_type_name (type)); |
| 435 | g_object_unref (retval); |
| 436 | va_end (args)__builtin_va_end(args); |
| 437 | |
| 438 | return NULL((void*)0); |
| 439 | } |
| 440 | |
| 441 | ctk_list_store_set_column_type (retval, i, type); |
| 442 | } |
| 443 | |
| 444 | va_end (args)__builtin_va_end(args); |
| 445 | |
| 446 | return retval; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | /** |
| 451 | * ctk_list_store_newv: (rename-to ctk_list_store_new) |
| 452 | * @n_columns: number of columns in the list store |
| 453 | * @types: (array length=n_columns): an array of #GType types for the columns, from first to last |
| 454 | * |
| 455 | * Non-vararg creation function. Used primarily by language bindings. |
| 456 | * |
| 457 | * Returns: (transfer full): a new #CtkListStore |
| 458 | **/ |
| 459 | CtkListStore * |
| 460 | ctk_list_store_newv (gint n_columns, |
| 461 | GType *types) |
| 462 | { |
| 463 | CtkListStore *retval; |
| 464 | gint i; |
| 465 | |
| 466 | g_return_val_if_fail (n_columns > 0, NULL)do { if ((n_columns > 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "n_columns > 0"); return (((void*)0)); } } while (0); |
| 467 | |
| 468 | retval = g_object_new (CTK_TYPE_LIST_STORE(ctk_list_store_get_type ()), NULL((void*)0)); |
| 469 | ctk_list_store_set_n_columns (retval, n_columns); |
| 470 | |
| 471 | for (i = 0; i < n_columns; i++) |
| 472 | { |
| 473 | if (! _ctk_tree_data_list_check_type (types[i])) |
| 474 | { |
| 475 | g_warning ("%s: Invalid type %s", G_STRLOC"ctkliststore.c" ":" "475", g_type_name (types[i])); |
| 476 | g_object_unref (retval); |
| 477 | return NULL((void*)0); |
| 478 | } |
| 479 | |
| 480 | ctk_list_store_set_column_type (retval, i, types[i]); |
| 481 | } |
| 482 | |
| 483 | return retval; |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * ctk_list_store_set_column_types: |
| 488 | * @list_store: A #CtkListStore |
| 489 | * @n_columns: Number of columns for the list store |
| 490 | * @types: (array length=n_columns): An array length n of #GTypes |
| 491 | * |
| 492 | * This function is meant primarily for #GObjects that inherit from #CtkListStore, |
| 493 | * and should only be used when constructing a new #CtkListStore. It will not |
| 494 | * function after a row has been added, or a method on the #CtkTreeModel |
| 495 | * interface is called. |
| 496 | **/ |
| 497 | void |
| 498 | ctk_list_store_set_column_types (CtkListStore *list_store, |
| 499 | gint n_columns, |
| 500 | GType *types) |
| 501 | { |
| 502 | CtkListStorePrivate *priv; |
| 503 | gint i; |
| 504 | |
| 505 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 506 | |
| 507 | priv = list_store->priv; |
| 508 | |
| 509 | g_return_if_fail (priv->columns_dirty == 0)do { if ((priv->columns_dirty == 0)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "priv->columns_dirty == 0" ); return; } } while (0); |
| 510 | |
| 511 | ctk_list_store_set_n_columns (list_store, n_columns); |
| 512 | for (i = 0; i < n_columns; i++) |
| 513 | { |
| 514 | if (! _ctk_tree_data_list_check_type (types[i])) |
| 515 | { |
| 516 | g_warning ("%s: Invalid type %s", G_STRLOC"ctkliststore.c" ":" "516", g_type_name (types[i])); |
| 517 | continue; |
| 518 | } |
| 519 | ctk_list_store_set_column_type (list_store, i, types[i]); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | static void |
| 524 | ctk_list_store_set_n_columns (CtkListStore *list_store, |
| 525 | gint n_columns) |
| 526 | { |
| 527 | CtkListStorePrivate *priv = list_store->priv; |
| 528 | int i; |
| 529 | |
| 530 | if (priv->n_columns == n_columns) |
| 531 | return; |
| 532 | |
| 533 | priv->column_headers = g_renew (GType, priv->column_headers, n_columns)((GType *) g_realloc_n (priv->column_headers, (n_columns), sizeof (GType))); |
| 534 | for (i = priv->n_columns; i < n_columns; i++) |
| 535 | priv->column_headers[i] = G_TYPE_INVALID((GType) ((0) << (2))); |
| 536 | priv->n_columns = n_columns; |
| 537 | |
| 538 | if (priv->sort_list) |
| 539 | _ctk_tree_data_list_header_free (priv->sort_list); |
| 540 | priv->sort_list = _ctk_tree_data_list_header_new (n_columns, priv->column_headers); |
| 541 | } |
| 542 | |
| 543 | static void |
| 544 | ctk_list_store_set_column_type (CtkListStore *list_store, |
| 545 | gint column, |
| 546 | GType type) |
| 547 | { |
| 548 | CtkListStorePrivate *priv = list_store->priv; |
| 549 | |
| 550 | if (!_ctk_tree_data_list_check_type (type)) |
| 551 | { |
| 552 | g_warning ("%s: Invalid type %s", G_STRLOC"ctkliststore.c" ":" "552", g_type_name (type)); |
| 553 | return; |
| 554 | } |
| 555 | |
| 556 | priv->column_headers[column] = type; |
| 557 | } |
| 558 | |
| 559 | static void |
| 560 | ctk_list_store_finalize (GObject *object) |
| 561 | { |
| 562 | CtkListStore *list_store = CTK_LIST_STORE (object)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_list_store_get_type ())))))); |
| 563 | CtkListStorePrivate *priv = list_store->priv; |
| 564 | |
| 565 | g_sequence_foreach (priv->seq, |
| 566 | (GFunc) _ctk_tree_data_list_free, priv->column_headers); |
| 567 | |
| 568 | g_sequence_free (priv->seq); |
| 569 | |
| 570 | _ctk_tree_data_list_header_free (priv->sort_list); |
| 571 | g_free (priv->column_headers); |
| 572 | |
| 573 | if (priv->default_sort_destroy) |
| 574 | { |
| 575 | GDestroyNotify d = priv->default_sort_destroy; |
| 576 | |
| 577 | priv->default_sort_destroy = NULL((void*)0); |
| 578 | d (priv->default_sort_data); |
| 579 | priv->default_sort_data = NULL((void*)0); |
| 580 | } |
| 581 | |
| 582 | G_OBJECT_CLASS (ctk_list_store_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_list_store_parent_class)), (((GType) ((20) << ( 2))))))))->finalize (object); |
| 583 | } |
| 584 | |
| 585 | /* Fulfill the CtkTreeModel requirements */ |
| 586 | static CtkTreeModelFlags |
| 587 | ctk_list_store_get_flags (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 588 | { |
| 589 | return CTK_TREE_MODEL_ITERS_PERSIST | CTK_TREE_MODEL_LIST_ONLY; |
| 590 | } |
| 591 | |
| 592 | static gint |
| 593 | ctk_list_store_get_n_columns (CtkTreeModel *tree_model) |
| 594 | { |
| 595 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 596 | CtkListStorePrivate *priv = list_store->priv; |
| 597 | |
| 598 | priv->columns_dirty = TRUE(!(0)); |
| 599 | |
| 600 | return priv->n_columns; |
| 601 | } |
| 602 | |
| 603 | static GType |
| 604 | ctk_list_store_get_column_type (CtkTreeModel *tree_model, |
| 605 | gint index) |
| 606 | { |
| 607 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 608 | CtkListStorePrivate *priv = list_store->priv; |
| 609 | |
| 610 | g_return_val_if_fail (index < priv->n_columns, G_TYPE_INVALID)do { if ((index < priv->n_columns)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "index < priv->n_columns" ); return (((GType) ((0) << (2)))); } } while (0); |
| 611 | |
| 612 | priv->columns_dirty = TRUE(!(0)); |
| 613 | |
| 614 | return priv->column_headers[index]; |
| 615 | } |
| 616 | |
| 617 | static gboolean |
| 618 | ctk_list_store_get_iter (CtkTreeModel *tree_model, |
| 619 | CtkTreeIter *iter, |
| 620 | CtkTreePath *path) |
| 621 | { |
| 622 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 623 | CtkListStorePrivate *priv = list_store->priv; |
| 624 | GSequence *seq; |
| 625 | gint i; |
| 626 | |
| 627 | priv->columns_dirty = TRUE(!(0)); |
| 628 | |
| 629 | seq = priv->seq; |
| 630 | |
| 631 | i = ctk_tree_path_get_indices (path)[0]; |
| 632 | |
| 633 | if (i >= g_sequence_get_length (seq)) |
| 634 | { |
| 635 | iter->stamp = 0; |
| 636 | return FALSE(0); |
| 637 | } |
| 638 | |
| 639 | iter->stamp = priv->stamp; |
| 640 | iter->user_data = g_sequence_get_iter_at_pos (seq, i); |
| 641 | |
| 642 | return TRUE(!(0)); |
| 643 | } |
| 644 | |
| 645 | static CtkTreePath * |
| 646 | ctk_list_store_get_path (CtkTreeModel *tree_model, |
| 647 | CtkTreeIter *iter) |
| 648 | { |
| 649 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 650 | CtkListStorePrivate *priv = list_store->priv; |
| 651 | CtkTreePath *path; |
| 652 | |
| 653 | g_return_val_if_fail (iter->stamp == priv->stamp, NULL)do { if ((iter->stamp == priv->stamp)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter->stamp == priv->stamp" ); return (((void*)0)); } } while (0); |
| 654 | |
| 655 | if (g_sequence_iter_is_end (iter->user_data)) |
| 656 | return NULL((void*)0); |
| 657 | |
| 658 | path = ctk_tree_path_new (); |
| 659 | ctk_tree_path_append_index (path, g_sequence_iter_get_position (iter->user_data)); |
| 660 | |
| 661 | return path; |
| 662 | } |
| 663 | |
| 664 | static void |
| 665 | ctk_list_store_get_value (CtkTreeModel *tree_model, |
| 666 | CtkTreeIter *iter, |
| 667 | gint column, |
| 668 | GValue *value) |
| 669 | { |
| 670 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 671 | CtkListStorePrivate *priv = list_store->priv; |
| 672 | CtkTreeDataList *list; |
| 673 | gint tmp_column = column; |
| 674 | |
| 675 | g_return_if_fail (column < priv->n_columns)do { if ((column < priv->n_columns)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "column < priv->n_columns" ); return; } } while (0); |
| 676 | g_return_if_fail (iter_is_valid (iter, list_store))do { if ((iter_is_valid (iter, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); return; } } while (0); |
| 677 | |
| 678 | list = g_sequence_get (iter->user_data); |
| 679 | |
| 680 | while (tmp_column-- > 0 && list) |
| 681 | list = list->next; |
| 682 | |
| 683 | if (list == NULL((void*)0)) |
| 684 | g_value_init (value, priv->column_headers[column]); |
| 685 | else |
| 686 | _ctk_tree_data_list_node_to_value (list, |
| 687 | priv->column_headers[column], |
| 688 | value); |
| 689 | } |
| 690 | |
| 691 | static gboolean |
| 692 | ctk_list_store_iter_next (CtkTreeModel *tree_model, |
| 693 | CtkTreeIter *iter) |
| 694 | { |
| 695 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 696 | CtkListStorePrivate *priv = list_store->priv; |
| 697 | gboolean retval; |
| 698 | |
| 699 | g_return_val_if_fail (priv->stamp == iter->stamp, FALSE)do { if ((priv->stamp == iter->stamp)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "priv->stamp == iter->stamp" ); return ((0)); } } while (0); |
| 700 | iter->user_data = g_sequence_iter_next (iter->user_data); |
| 701 | |
| 702 | retval = g_sequence_iter_is_end (iter->user_data); |
| 703 | if (retval) |
| 704 | iter->stamp = 0; |
| 705 | |
| 706 | return !retval; |
| 707 | } |
| 708 | |
| 709 | static gboolean |
| 710 | ctk_list_store_iter_previous (CtkTreeModel *tree_model, |
| 711 | CtkTreeIter *iter) |
| 712 | { |
| 713 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 714 | CtkListStorePrivate *priv = list_store->priv; |
| 715 | |
| 716 | g_return_val_if_fail (priv->stamp == iter->stamp, FALSE)do { if ((priv->stamp == iter->stamp)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "priv->stamp == iter->stamp" ); return ((0)); } } while (0); |
| 717 | |
| 718 | if (g_sequence_iter_is_begin (iter->user_data)) |
| 719 | { |
| 720 | iter->stamp = 0; |
| 721 | return FALSE(0); |
| 722 | } |
| 723 | |
| 724 | iter->user_data = g_sequence_iter_prev (iter->user_data); |
| 725 | |
| 726 | return TRUE(!(0)); |
| 727 | } |
| 728 | |
| 729 | static gboolean |
| 730 | ctk_list_store_iter_children (CtkTreeModel *tree_model, |
| 731 | CtkTreeIter *iter, |
| 732 | CtkTreeIter *parent) |
| 733 | { |
| 734 | CtkListStore *list_store = (CtkListStore *) tree_model; |
| 735 | CtkListStorePrivate *priv = list_store->priv; |
| 736 | |
| 737 | /* this is a list, nodes have no children */ |
| 738 | if (parent) |
| 739 | { |
| 740 | iter->stamp = 0; |
| 741 | return FALSE(0); |
| 742 | } |
| 743 | |
| 744 | if (g_sequence_get_length (priv->seq) > 0) |
| 745 | { |
| 746 | iter->stamp = priv->stamp; |
| 747 | iter->user_data = g_sequence_get_begin_iter (priv->seq); |
| 748 | return TRUE(!(0)); |
| 749 | } |
| 750 | else |
| 751 | { |
| 752 | iter->stamp = 0; |
| 753 | return FALSE(0); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | static gboolean |
| 758 | ctk_list_store_iter_has_child (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 759 | CtkTreeIter *iter G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 760 | { |
| 761 | return FALSE(0); |
| 762 | } |
| 763 | |
| 764 | static gint |
| 765 | ctk_list_store_iter_n_children (CtkTreeModel *tree_model, |
| 766 | CtkTreeIter *iter) |
| 767 | { |
| 768 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 769 | CtkListStorePrivate *priv = list_store->priv; |
| 770 | |
| 771 | if (iter == NULL((void*)0)) |
| 772 | return g_sequence_get_length (priv->seq); |
| 773 | |
| 774 | g_return_val_if_fail (priv->stamp == iter->stamp, -1)do { if ((priv->stamp == iter->stamp)) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "priv->stamp == iter->stamp" ); return (-1); } } while (0); |
| 775 | |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | static gboolean |
| 780 | ctk_list_store_iter_nth_child (CtkTreeModel *tree_model, |
| 781 | CtkTreeIter *iter, |
| 782 | CtkTreeIter *parent, |
| 783 | gint n) |
| 784 | { |
| 785 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 786 | CtkListStorePrivate *priv = list_store->priv; |
| 787 | GSequenceIter *child; |
| 788 | |
| 789 | iter->stamp = 0; |
| 790 | |
| 791 | if (parent) |
| 792 | return FALSE(0); |
| 793 | |
| 794 | child = g_sequence_get_iter_at_pos (priv->seq, n); |
| 795 | |
| 796 | if (g_sequence_iter_is_end (child)) |
| 797 | return FALSE(0); |
| 798 | |
| 799 | iter->stamp = priv->stamp; |
| 800 | iter->user_data = child; |
| 801 | |
| 802 | return TRUE(!(0)); |
| 803 | } |
| 804 | |
| 805 | static gboolean |
| 806 | ctk_list_store_iter_parent (CtkTreeModel *tree_model G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 807 | CtkTreeIter *iter, |
| 808 | CtkTreeIter *child G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 809 | { |
| 810 | iter->stamp = 0; |
| 811 | return FALSE(0); |
| 812 | } |
| 813 | |
| 814 | static gboolean |
| 815 | ctk_list_store_real_set_value (CtkListStore *list_store, |
| 816 | CtkTreeIter *iter, |
| 817 | gint column, |
| 818 | GValue *value, |
| 819 | gboolean sort) |
| 820 | { |
| 821 | CtkListStorePrivate *priv = list_store->priv; |
| 822 | CtkTreeDataList *list; |
| 823 | CtkTreeDataList *prev; |
| 824 | gint old_column = column; |
| 825 | GValue real_value = G_VALUE_INIT{ 0, { { 0 } } }; |
| 826 | gboolean converted = FALSE(0); |
| 827 | gboolean retval = FALSE(0); |
| 828 | |
| 829 | if (! g_type_is_a (G_VALUE_TYPE (value), priv->column_headers[column])(((((GValue*) (value))->g_type)) == (priv->column_headers [column]) || (g_type_is_a) (((((GValue*) (value))->g_type) ), (priv->column_headers[column])))) |
| 830 | { |
| 831 | if (! (g_value_type_transformable (G_VALUE_TYPE (value)(((GValue*) (value))->g_type), priv->column_headers[column]))) |
| 832 | { |
| 833 | g_warning ("%s: Unable to convert from %s to %s", |
| 834 | G_STRLOC"ctkliststore.c" ":" "834", |
| 835 | g_type_name (G_VALUE_TYPE (value)(((GValue*) (value))->g_type)), |
| 836 | g_type_name (priv->column_headers[column])); |
| 837 | return retval; |
| 838 | } |
| 839 | |
| 840 | g_value_init (&real_value, priv->column_headers[column]); |
| 841 | if (!g_value_transform (value, &real_value)) |
| 842 | { |
| 843 | g_warning ("%s: Unable to make conversion from %s to %s", |
| 844 | G_STRLOC"ctkliststore.c" ":" "844", |
| 845 | g_type_name (G_VALUE_TYPE (value)(((GValue*) (value))->g_type)), |
| 846 | g_type_name (priv->column_headers[column])); |
| 847 | g_value_unset (&real_value); |
| 848 | return retval; |
| 849 | } |
| 850 | converted = TRUE(!(0)); |
| 851 | } |
| 852 | |
| 853 | prev = list = g_sequence_get (iter->user_data); |
| 854 | |
| 855 | while (list != NULL((void*)0)) |
| 856 | { |
| 857 | if (column == 0) |
| 858 | { |
| 859 | if (converted) |
| 860 | _ctk_tree_data_list_value_to_node (list, &real_value); |
| 861 | else |
| 862 | _ctk_tree_data_list_value_to_node (list, value); |
| 863 | retval = TRUE(!(0)); |
| 864 | if (converted) |
| 865 | g_value_unset (&real_value); |
| 866 | if (sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 867 | ctk_list_store_sort_iter_changed (list_store, iter, old_column); |
| 868 | return retval; |
| 869 | } |
| 870 | |
| 871 | column--; |
| 872 | prev = list; |
| 873 | list = list->next; |
| 874 | } |
| 875 | |
| 876 | if (g_sequence_get (iter->user_data) == NULL((void*)0)) |
| 877 | { |
| 878 | list = _ctk_tree_data_list_alloc(); |
| 879 | g_sequence_set (iter->user_data, list); |
| 880 | list->next = NULL((void*)0); |
| 881 | } |
| 882 | else |
| 883 | { |
| 884 | list = prev->next = _ctk_tree_data_list_alloc (); |
| 885 | list->next = NULL((void*)0); |
| 886 | } |
| 887 | |
| 888 | while (column != 0) |
| 889 | { |
| 890 | list->next = _ctk_tree_data_list_alloc (); |
| 891 | list = list->next; |
| 892 | list->next = NULL((void*)0); |
| 893 | column --; |
| 894 | } |
| 895 | |
| 896 | if (converted) |
| 897 | _ctk_tree_data_list_value_to_node (list, &real_value); |
| 898 | else |
| 899 | _ctk_tree_data_list_value_to_node (list, value); |
| 900 | |
| 901 | retval = TRUE(!(0)); |
| 902 | if (converted) |
| 903 | g_value_unset (&real_value); |
| 904 | |
| 905 | if (sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 906 | ctk_list_store_sort_iter_changed (list_store, iter, old_column); |
| 907 | |
| 908 | return retval; |
| 909 | } |
| 910 | |
| 911 | |
| 912 | /** |
| 913 | * ctk_list_store_set_value: |
| 914 | * @list_store: A #CtkListStore |
| 915 | * @iter: A valid #CtkTreeIter for the row being modified |
| 916 | * @column: column number to modify |
| 917 | * @value: new value for the cell |
| 918 | * |
| 919 | * Sets the data in the cell specified by @iter and @column. |
| 920 | * The type of @value must be convertible to the type of the |
| 921 | * column. |
| 922 | * |
| 923 | **/ |
| 924 | void |
| 925 | ctk_list_store_set_value (CtkListStore *list_store, |
| 926 | CtkTreeIter *iter, |
| 927 | gint column, |
| 928 | GValue *value) |
| 929 | { |
| 930 | CtkListStorePrivate *priv; |
| 931 | |
| 932 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 933 | g_return_if_fail (iter_is_valid (iter, list_store))do { if ((iter_is_valid (iter, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); return; } } while (0); |
| 934 | g_return_if_fail (G_IS_VALUE (value))do { if (((((g_type_check_value ((GValue*) (value))))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "G_IS_VALUE (value)"); return; } } while (0); |
| 935 | priv = list_store->priv; |
| 936 | g_return_if_fail (column >= 0 && column < priv->n_columns)do { if ((column >= 0 && column < priv->n_columns )) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "column >= 0 && column < priv->n_columns" ); return; } } while (0); |
| 937 | |
| 938 | if (ctk_list_store_real_set_value (list_store, iter, column, value, TRUE(!(0)))) |
| 939 | { |
| 940 | CtkTreePath *path; |
| 941 | |
| 942 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 943 | ctk_tree_model_row_changed (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 944 | ctk_tree_path_free (path); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | static CtkTreeIterCompareFunc |
| 949 | ctk_list_store_get_compare_func (CtkListStore *list_store) |
| 950 | { |
| 951 | CtkListStorePrivate *priv = list_store->priv; |
| 952 | CtkTreeIterCompareFunc func = NULL((void*)0); |
| 953 | |
| 954 | if (CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 955 | { |
| 956 | if (priv->sort_column_id != -1) |
| 957 | { |
| 958 | CtkTreeDataSortHeader *header; |
| 959 | header = _ctk_tree_data_list_get_header (priv->sort_list, |
| 960 | priv->sort_column_id); |
| 961 | g_return_val_if_fail (header != NULL, NULL)do { if ((header != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header != NULL"); return (((void*)0)); } } while (0); |
| 962 | g_return_val_if_fail (header->func != NULL, NULL)do { if ((header->func != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header->func != NULL" ); return (((void*)0)); } } while (0); |
| 963 | func = header->func; |
| 964 | } |
| 965 | else |
| 966 | { |
| 967 | func = priv->default_sort_func; |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | return func; |
| 972 | } |
| 973 | |
| 974 | static void |
| 975 | ctk_list_store_set_vector_internal (CtkListStore *list_store, |
| 976 | CtkTreeIter *iter, |
| 977 | gboolean *emit_signal, |
| 978 | gboolean *maybe_need_sort, |
| 979 | gint *columns, |
| 980 | GValue *values, |
| 981 | gint n_values) |
| 982 | { |
| 983 | CtkListStorePrivate *priv = list_store->priv; |
| 984 | gint i; |
| 985 | CtkTreeIterCompareFunc func = NULL((void*)0); |
| 986 | |
| 987 | func = ctk_list_store_get_compare_func (list_store); |
| 988 | if (func != _ctk_tree_data_list_compare_func) |
| 989 | *maybe_need_sort = TRUE(!(0)); |
| 990 | |
| 991 | for (i = 0; i < n_values; i++) |
| 992 | { |
| 993 | *emit_signal = ctk_list_store_real_set_value (list_store, |
| 994 | iter, |
| 995 | columns[i], |
| 996 | &values[i], |
| 997 | FALSE(0)) || *emit_signal; |
| 998 | |
| 999 | if (func == _ctk_tree_data_list_compare_func && |
| 1000 | columns[i] == priv->sort_column_id) |
| 1001 | *maybe_need_sort = TRUE(!(0)); |
| 1002 | } |
| 1003 | } |
| 1004 | |
| 1005 | static void |
| 1006 | ctk_list_store_set_valist_internal (CtkListStore *list_store, |
| 1007 | CtkTreeIter *iter, |
| 1008 | gboolean *emit_signal, |
| 1009 | gboolean *maybe_need_sort, |
| 1010 | va_list var_args) |
| 1011 | { |
| 1012 | CtkListStorePrivate *priv = list_store->priv; |
| 1013 | gint column; |
| 1014 | CtkTreeIterCompareFunc func = NULL((void*)0); |
| 1015 | |
| 1016 | column = va_arg (var_args, gint)__builtin_va_arg(var_args, gint); |
| 1017 | |
| 1018 | func = ctk_list_store_get_compare_func (list_store); |
| 1019 | if (func != _ctk_tree_data_list_compare_func) |
| 1020 | *maybe_need_sort = TRUE(!(0)); |
| 1021 | |
| 1022 | while (column != -1) |
| 1023 | { |
| 1024 | GValue value = G_VALUE_INIT{ 0, { { 0 } } }; |
| 1025 | gchar *error = NULL((void*)0); |
| 1026 | |
| 1027 | if (column < 0 || column >= priv->n_columns) |
| 1028 | { |
| 1029 | g_warning ("%s: Invalid column number %d added to iter (remember to end your list of columns with a -1)", G_STRLOC"ctkliststore.c" ":" "1029", column); |
| 1030 | break; |
| 1031 | } |
| 1032 | |
| 1033 | G_VALUE_COLLECT_INIT (&value, priv->column_headers[column],do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (& value); guint g_vci_flags = (0); const gchar *g_vci_collect_format ; GTypeCValue g_vci_cvalues[(8)] = { { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek (priv->column_headers [column]); g_vci_collect_format = g_vci_vtab->collect_format ; g_vci_val->g_type = priv->column_headers[column]; while (*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues + g_vci_n_values++; switch (*g_vci_collect_format++) { case G_VALUE_COLLECT_INT : g_vci_cvalue->v_int = __builtin_va_arg((var_args), gint) ; break; case G_VALUE_COLLECT_LONG: g_vci_cvalue->v_long = __builtin_va_arg((var_args), glong); break; case G_VALUE_COLLECT_INT64 : g_vci_cvalue->v_int64 = __builtin_va_arg((var_args), gint64 ); break; case G_VALUE_COLLECT_DOUBLE: g_vci_cvalue->v_double = __builtin_va_arg((var_args), gdouble); break; case G_VALUE_COLLECT_POINTER : g_vci_cvalue->v_pointer = __builtin_va_arg((var_args), gpointer ); break; default: do { g_assertion_message_expr ("Ctk", "ctkliststore.c" , 1034, ((const char*) (__func__)), ((void*)0)); } while (0); } } *(&error) = g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues, g_vci_flags); } while (0); } while (0) |
| 1034 | var_args, 0, &error)do { GTypeValueTable *g_vci_vtab; do { GValue *g_vci_val = (& value); guint g_vci_flags = (0); const gchar *g_vci_collect_format ; GTypeCValue g_vci_cvalues[(8)] = { { 0, }, }; guint g_vci_n_values = 0; g_vci_vtab = g_type_value_table_peek (priv->column_headers [column]); g_vci_collect_format = g_vci_vtab->collect_format ; g_vci_val->g_type = priv->column_headers[column]; while (*g_vci_collect_format) { GTypeCValue *g_vci_cvalue = g_vci_cvalues + g_vci_n_values++; switch (*g_vci_collect_format++) { case G_VALUE_COLLECT_INT : g_vci_cvalue->v_int = __builtin_va_arg((var_args), gint) ; break; case G_VALUE_COLLECT_LONG: g_vci_cvalue->v_long = __builtin_va_arg((var_args), glong); break; case G_VALUE_COLLECT_INT64 : g_vci_cvalue->v_int64 = __builtin_va_arg((var_args), gint64 ); break; case G_VALUE_COLLECT_DOUBLE: g_vci_cvalue->v_double = __builtin_va_arg((var_args), gdouble); break; case G_VALUE_COLLECT_POINTER : g_vci_cvalue->v_pointer = __builtin_va_arg((var_args), gpointer ); break; default: do { g_assertion_message_expr ("Ctk", "ctkliststore.c" , 1034, ((const char*) (__func__)), ((void*)0)); } while (0); } } *(&error) = g_vci_vtab->collect_value (g_vci_val, g_vci_n_values, g_vci_cvalues, g_vci_flags); } while (0); } while (0); |
| 1035 | if (error) |
| 1036 | { |
| 1037 | g_warning ("%s: %s", G_STRLOC"ctkliststore.c" ":" "1037", error); |
| 1038 | g_free (error); |
| 1039 | |
| 1040 | /* we purposely leak the value here, it might not be |
| 1041 | * in a sane state if an error condition occoured |
| 1042 | */ |
| 1043 | break; |
| 1044 | } |
| 1045 | |
| 1046 | /* FIXME: instead of calling this n times, refactor with above */ |
| 1047 | *emit_signal = ctk_list_store_real_set_value (list_store, |
| 1048 | iter, |
| 1049 | column, |
| 1050 | &value, |
| 1051 | FALSE(0)) || *emit_signal; |
| 1052 | |
| 1053 | if (func == _ctk_tree_data_list_compare_func && |
| 1054 | column == priv->sort_column_id) |
| 1055 | *maybe_need_sort = TRUE(!(0)); |
| 1056 | |
| 1057 | g_value_unset (&value); |
| 1058 | |
| 1059 | column = va_arg (var_args, gint)__builtin_va_arg(var_args, gint); |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * ctk_list_store_set_valuesv: (rename-to ctk_list_store_set) |
| 1065 | * @list_store: A #CtkListStore |
| 1066 | * @iter: A valid #CtkTreeIter for the row being modified |
| 1067 | * @columns: (array length=n_values): an array of column numbers |
| 1068 | * @values: (array length=n_values): an array of GValues |
| 1069 | * @n_values: the length of the @columns and @values arrays |
| 1070 | * |
| 1071 | * A variant of ctk_list_store_set_valist() which |
| 1072 | * takes the columns and values as two arrays, instead of |
| 1073 | * varargs. This function is mainly intended for |
| 1074 | * language-bindings and in case the number of columns to |
| 1075 | * change is not known until run-time. |
| 1076 | * |
| 1077 | * Since: 2.12 |
| 1078 | */ |
| 1079 | void |
| 1080 | ctk_list_store_set_valuesv (CtkListStore *list_store, |
| 1081 | CtkTreeIter *iter, |
| 1082 | gint *columns, |
| 1083 | GValue *values, |
| 1084 | gint n_values) |
| 1085 | { |
| 1086 | CtkListStorePrivate *priv; |
| 1087 | gboolean emit_signal = FALSE(0); |
| 1088 | gboolean maybe_need_sort = FALSE(0); |
| 1089 | |
| 1090 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1091 | g_return_if_fail (iter_is_valid (iter, list_store))do { if ((iter_is_valid (iter, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); return; } } while (0); |
| 1092 | |
| 1093 | priv = list_store->priv; |
| 1094 | |
| 1095 | ctk_list_store_set_vector_internal (list_store, iter, |
| 1096 | &emit_signal, |
| 1097 | &maybe_need_sort, |
| 1098 | columns, values, n_values); |
| 1099 | |
| 1100 | if (maybe_need_sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 1101 | ctk_list_store_sort_iter_changed (list_store, iter, priv->sort_column_id); |
| 1102 | |
| 1103 | if (emit_signal) |
| 1104 | { |
| 1105 | CtkTreePath *path; |
| 1106 | |
| 1107 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 1108 | ctk_tree_model_row_changed (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 1109 | ctk_tree_path_free (path); |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | /** |
| 1114 | * ctk_list_store_set_valist: |
| 1115 | * @list_store: A #CtkListStore |
| 1116 | * @iter: A valid #CtkTreeIter for the row being modified |
| 1117 | * @var_args: va_list of column/value pairs |
| 1118 | * |
| 1119 | * See ctk_list_store_set(); this version takes a va_list for use by language |
| 1120 | * bindings. |
| 1121 | * |
| 1122 | **/ |
| 1123 | void |
| 1124 | ctk_list_store_set_valist (CtkListStore *list_store, |
| 1125 | CtkTreeIter *iter, |
| 1126 | va_list var_args) |
| 1127 | { |
| 1128 | CtkListStorePrivate *priv; |
| 1129 | gboolean emit_signal = FALSE(0); |
| 1130 | gboolean maybe_need_sort = FALSE(0); |
| 1131 | |
| 1132 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1133 | g_return_if_fail (iter_is_valid (iter, list_store))do { if ((iter_is_valid (iter, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); return; } } while (0); |
| 1134 | |
| 1135 | priv = list_store->priv; |
| 1136 | |
| 1137 | ctk_list_store_set_valist_internal (list_store, iter, |
| 1138 | &emit_signal, |
| 1139 | &maybe_need_sort, |
| 1140 | var_args); |
| 1141 | |
| 1142 | if (maybe_need_sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 1143 | ctk_list_store_sort_iter_changed (list_store, iter, priv->sort_column_id); |
| 1144 | |
| 1145 | if (emit_signal) |
| 1146 | { |
| 1147 | CtkTreePath *path; |
| 1148 | |
| 1149 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 1150 | ctk_tree_model_row_changed (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 1151 | ctk_tree_path_free (path); |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | /** |
| 1156 | * ctk_list_store_set: |
| 1157 | * @list_store: a #CtkListStore |
| 1158 | * @iter: row iterator |
| 1159 | * @...: pairs of column number and value, terminated with -1 |
| 1160 | * |
| 1161 | * Sets the value of one or more cells in the row referenced by @iter. |
| 1162 | * The variable argument list should contain integer column numbers, |
| 1163 | * each column number followed by the value to be set. |
| 1164 | * The list is terminated by a -1. For example, to set column 0 with type |
| 1165 | * %G_TYPE_STRING to “Foo”, you would write `ctk_list_store_set (store, iter, |
| 1166 | * 0, "Foo", -1)`. |
| 1167 | * |
| 1168 | * The value will be referenced by the store if it is a %G_TYPE_OBJECT, and it |
| 1169 | * will be copied if it is a %G_TYPE_STRING or %G_TYPE_BOXED. |
| 1170 | */ |
| 1171 | void |
| 1172 | ctk_list_store_set (CtkListStore *list_store, |
| 1173 | CtkTreeIter *iter, |
| 1174 | ...) |
| 1175 | { |
| 1176 | va_list var_args; |
| 1177 | |
| 1178 | va_start (var_args, iter)__builtin_va_start(var_args, iter); |
| 1179 | ctk_list_store_set_valist (list_store, iter, var_args); |
| 1180 | va_end (var_args)__builtin_va_end(var_args); |
| 1181 | } |
| 1182 | |
| 1183 | /** |
| 1184 | * ctk_list_store_remove: |
| 1185 | * @list_store: A #CtkListStore |
| 1186 | * @iter: A valid #CtkTreeIter |
| 1187 | * |
| 1188 | * Removes the given row from the list store. After being removed, |
| 1189 | * @iter is set to be the next valid row, or invalidated if it pointed |
| 1190 | * to the last row in @list_store. |
| 1191 | * |
| 1192 | * Returns: %TRUE if @iter is valid, %FALSE if not. |
| 1193 | **/ |
| 1194 | gboolean |
| 1195 | ctk_list_store_remove (CtkListStore *list_store, |
| 1196 | CtkTreeIter *iter) |
| 1197 | { |
| 1198 | CtkListStorePrivate *priv; |
| 1199 | CtkTreePath *path; |
| 1200 | GSequenceIter *ptr, *next; |
| 1201 | |
| 1202 | g_return_val_if_fail (CTK_IS_LIST_STORE (list_store), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return ((0 )); } } while (0); |
| 1203 | g_return_val_if_fail (iter_is_valid (iter, list_store), FALSE)do { if ((iter_is_valid (iter, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); return ((0)); } } while (0); |
| 1204 | |
| 1205 | priv = list_store->priv; |
| 1206 | |
| 1207 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 1208 | |
| 1209 | ptr = iter->user_data; |
| 1210 | next = g_sequence_iter_next (ptr); |
| 1211 | |
| 1212 | _ctk_tree_data_list_free (g_sequence_get (ptr), priv->column_headers); |
| 1213 | g_sequence_remove (iter->user_data); |
| 1214 | |
| 1215 | priv->length--; |
| 1216 | |
| 1217 | ctk_tree_model_row_deleted (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path); |
| 1218 | ctk_tree_path_free (path); |
| 1219 | |
| 1220 | if (g_sequence_iter_is_end (next)) |
| 1221 | { |
| 1222 | iter->stamp = 0; |
| 1223 | return FALSE(0); |
| 1224 | } |
| 1225 | else |
| 1226 | { |
| 1227 | iter->stamp = priv->stamp; |
| 1228 | iter->user_data = next; |
| 1229 | return TRUE(!(0)); |
| 1230 | } |
| 1231 | } |
| 1232 | |
| 1233 | /** |
| 1234 | * ctk_list_store_insert: |
| 1235 | * @list_store: A #CtkListStore |
| 1236 | * @iter: (out): An unset #CtkTreeIter to set to the new row |
| 1237 | * @position: position to insert the new row, or -1 for last |
| 1238 | * |
| 1239 | * Creates a new row at @position. @iter will be changed to point to this new |
| 1240 | * row. If @position is -1 or is larger than the number of rows on the list, |
| 1241 | * then the new row will be appended to the list. The row will be empty after |
| 1242 | * this function is called. To fill in values, you need to call |
| 1243 | * ctk_list_store_set() or ctk_list_store_set_value(). |
| 1244 | * |
| 1245 | **/ |
| 1246 | void |
| 1247 | ctk_list_store_insert (CtkListStore *list_store, |
| 1248 | CtkTreeIter *iter, |
| 1249 | gint position) |
| 1250 | { |
| 1251 | CtkListStorePrivate *priv; |
| 1252 | CtkTreePath *path; |
| 1253 | GSequence *seq; |
| 1254 | GSequenceIter *ptr; |
| 1255 | gint length; |
| 1256 | |
| 1257 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1258 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
| 1259 | |
| 1260 | priv = list_store->priv; |
| 1261 | |
| 1262 | priv->columns_dirty = TRUE(!(0)); |
| 1263 | |
| 1264 | seq = priv->seq; |
| 1265 | |
| 1266 | length = g_sequence_get_length (seq); |
| 1267 | if (position > length || position < 0) |
| 1268 | position = length; |
| 1269 | |
| 1270 | ptr = g_sequence_get_iter_at_pos (seq, position); |
| 1271 | ptr = g_sequence_insert_before (ptr, NULL((void*)0)); |
| 1272 | |
| 1273 | iter->stamp = priv->stamp; |
| 1274 | iter->user_data = ptr; |
| 1275 | |
| 1276 | g_assert (iter_is_valid (iter, list_store))do { if (iter_is_valid (iter, list_store)) ; else g_assertion_message_expr ("Ctk", "ctkliststore.c", 1276, ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); } while (0); |
| 1277 | |
| 1278 | priv->length++; |
| 1279 | |
| 1280 | path = ctk_tree_path_new (); |
| 1281 | ctk_tree_path_append_index (path, position); |
| 1282 | ctk_tree_model_row_inserted (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 1283 | ctk_tree_path_free (path); |
| 1284 | } |
| 1285 | |
| 1286 | /** |
| 1287 | * ctk_list_store_insert_before: |
| 1288 | * @list_store: A #CtkListStore |
| 1289 | * @iter: (out): An unset #CtkTreeIter to set to the new row |
| 1290 | * @sibling: (allow-none): A valid #CtkTreeIter, or %NULL |
| 1291 | * |
| 1292 | * Inserts a new row before @sibling. If @sibling is %NULL, then the row will |
| 1293 | * be appended to the end of the list. @iter will be changed to point to this |
| 1294 | * new row. The row will be empty after this function is called. To fill in |
| 1295 | * values, you need to call ctk_list_store_set() or ctk_list_store_set_value(). |
| 1296 | * |
| 1297 | **/ |
| 1298 | void |
| 1299 | ctk_list_store_insert_before (CtkListStore *list_store, |
| 1300 | CtkTreeIter *iter, |
| 1301 | CtkTreeIter *sibling) |
| 1302 | { |
| 1303 | CtkListStorePrivate *priv; |
| 1304 | GSequenceIter *after; |
| 1305 | |
| 1306 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1307 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
| 1308 | |
| 1309 | priv = list_store->priv; |
| 1310 | |
| 1311 | if (sibling) |
| 1312 | g_return_if_fail (iter_is_valid (sibling, list_store))do { if ((iter_is_valid (sibling, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (sibling, list_store)" ); return; } } while (0); |
| 1313 | |
| 1314 | if (!sibling) |
| 1315 | after = g_sequence_get_end_iter (priv->seq); |
| 1316 | else |
| 1317 | after = sibling->user_data; |
| 1318 | |
| 1319 | ctk_list_store_insert (list_store, iter, g_sequence_iter_get_position (after)); |
| 1320 | } |
| 1321 | |
| 1322 | /** |
| 1323 | * ctk_list_store_insert_after: |
| 1324 | * @list_store: A #CtkListStore |
| 1325 | * @iter: (out): An unset #CtkTreeIter to set to the new row |
| 1326 | * @sibling: (allow-none): A valid #CtkTreeIter, or %NULL |
| 1327 | * |
| 1328 | * Inserts a new row after @sibling. If @sibling is %NULL, then the row will be |
| 1329 | * prepended to the beginning of the list. @iter will be changed to point to |
| 1330 | * this new row. The row will be empty after this function is called. To fill |
| 1331 | * in values, you need to call ctk_list_store_set() or ctk_list_store_set_value(). |
| 1332 | * |
| 1333 | **/ |
| 1334 | void |
| 1335 | ctk_list_store_insert_after (CtkListStore *list_store, |
| 1336 | CtkTreeIter *iter, |
| 1337 | CtkTreeIter *sibling) |
| 1338 | { |
| 1339 | CtkListStorePrivate *priv; |
| 1340 | GSequenceIter *after; |
| 1341 | |
| 1342 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1343 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
| 1344 | |
| 1345 | priv = list_store->priv; |
| 1346 | |
| 1347 | if (sibling) |
| 1348 | g_return_if_fail (iter_is_valid (sibling, list_store))do { if ((iter_is_valid (sibling, list_store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (sibling, list_store)" ); return; } } while (0); |
| 1349 | |
| 1350 | if (!sibling) |
| 1351 | after = g_sequence_get_begin_iter (priv->seq); |
| 1352 | else |
| 1353 | after = g_sequence_iter_next (sibling->user_data); |
| 1354 | |
| 1355 | ctk_list_store_insert (list_store, iter, g_sequence_iter_get_position (after)); |
| 1356 | } |
| 1357 | |
| 1358 | /** |
| 1359 | * ctk_list_store_prepend: |
| 1360 | * @list_store: A #CtkListStore |
| 1361 | * @iter: (out): An unset #CtkTreeIter to set to the prepend row |
| 1362 | * |
| 1363 | * Prepends a new row to @list_store. @iter will be changed to point to this new |
| 1364 | * row. The row will be empty after this function is called. To fill in |
| 1365 | * values, you need to call ctk_list_store_set() or ctk_list_store_set_value(). |
| 1366 | * |
| 1367 | **/ |
| 1368 | void |
| 1369 | ctk_list_store_prepend (CtkListStore *list_store, |
| 1370 | CtkTreeIter *iter) |
| 1371 | { |
| 1372 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1373 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
| 1374 | |
| 1375 | ctk_list_store_insert (list_store, iter, 0); |
| 1376 | } |
| 1377 | |
| 1378 | /** |
| 1379 | * ctk_list_store_append: |
| 1380 | * @list_store: A #CtkListStore |
| 1381 | * @iter: (out): An unset #CtkTreeIter to set to the appended row |
| 1382 | * |
| 1383 | * Appends a new row to @list_store. @iter will be changed to point to this new |
| 1384 | * row. The row will be empty after this function is called. To fill in |
| 1385 | * values, you need to call ctk_list_store_set() or ctk_list_store_set_value(). |
| 1386 | * |
| 1387 | **/ |
| 1388 | void |
| 1389 | ctk_list_store_append (CtkListStore *list_store, |
| 1390 | CtkTreeIter *iter) |
| 1391 | { |
| 1392 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1393 | g_return_if_fail (iter != NULL)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return; } } while (0); |
| 1394 | |
| 1395 | ctk_list_store_insert (list_store, iter, -1); |
| 1396 | } |
| 1397 | |
| 1398 | static void |
| 1399 | ctk_list_store_increment_stamp (CtkListStore *list_store) |
| 1400 | { |
| 1401 | CtkListStorePrivate *priv = list_store->priv; |
| 1402 | |
| 1403 | do |
| 1404 | { |
| 1405 | priv->stamp++; |
| 1406 | } |
| 1407 | while (priv->stamp == 0); |
| 1408 | } |
| 1409 | |
| 1410 | /** |
| 1411 | * ctk_list_store_clear: |
| 1412 | * @list_store: a #CtkListStore. |
| 1413 | * |
| 1414 | * Removes all rows from the list store. |
| 1415 | * |
| 1416 | **/ |
| 1417 | void |
| 1418 | ctk_list_store_clear (CtkListStore *list_store) |
| 1419 | { |
| 1420 | CtkListStorePrivate *priv; |
| 1421 | CtkTreeIter iter; |
| 1422 | |
| 1423 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 1424 | |
| 1425 | priv = list_store->priv; |
| 1426 | |
| 1427 | while (g_sequence_get_length (priv->seq) > 0) |
| 1428 | { |
| 1429 | iter.stamp = priv->stamp; |
| 1430 | iter.user_data = g_sequence_get_begin_iter (priv->seq); |
| 1431 | ctk_list_store_remove (list_store, &iter); |
| 1432 | } |
| 1433 | |
| 1434 | ctk_list_store_increment_stamp (list_store); |
| 1435 | } |
| 1436 | |
| 1437 | /** |
| 1438 | * ctk_list_store_iter_is_valid: |
| 1439 | * @list_store: A #CtkListStore. |
| 1440 | * @iter: A #CtkTreeIter. |
| 1441 | * |
| 1442 | * > This function is slow. Only use it for debugging and/or testing |
| 1443 | * > purposes. |
| 1444 | * |
| 1445 | * Checks if the given iter is a valid iter for this #CtkListStore. |
| 1446 | * |
| 1447 | * Returns: %TRUE if the iter is valid, %FALSE if the iter is invalid. |
| 1448 | * |
| 1449 | * Since: 2.2 |
| 1450 | **/ |
| 1451 | gboolean |
| 1452 | ctk_list_store_iter_is_valid (CtkListStore *list_store, |
| 1453 | CtkTreeIter *iter) |
| 1454 | { |
| 1455 | CtkListStorePrivate *priv; |
| 1456 | GSequenceIter *seq_iter; |
| 1457 | |
| 1458 | g_return_val_if_fail (CTK_IS_LIST_STORE (list_store), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return ((0 )); } } while (0); |
| 1459 | g_return_val_if_fail (iter != NULL, FALSE)do { if ((iter != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter != NULL"); return ( (0)); } } while (0); |
| 1460 | |
| 1461 | /* can't use iter_is_valid() here, because iter might point |
| 1462 | * to random memory. |
| 1463 | * |
| 1464 | * We MUST NOT dereference it. |
| 1465 | */ |
| 1466 | |
| 1467 | priv = list_store->priv; |
| 1468 | |
| 1469 | if (iter == NULL((void*)0) || |
| 1470 | iter->user_data == NULL((void*)0) || |
| 1471 | priv->stamp != iter->stamp) |
| 1472 | return FALSE(0); |
| 1473 | |
| 1474 | for (seq_iter = g_sequence_get_begin_iter (priv->seq); |
| 1475 | !g_sequence_iter_is_end (seq_iter); |
| 1476 | seq_iter = g_sequence_iter_next (seq_iter)) |
| 1477 | { |
| 1478 | if (seq_iter == iter->user_data) |
| 1479 | return TRUE(!(0)); |
| 1480 | } |
| 1481 | |
| 1482 | return FALSE(0); |
| 1483 | } |
| 1484 | |
| 1485 | static gboolean real_ctk_list_store_row_draggable (CtkTreeDragSource *drag_source G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 1486 | CtkTreePath *path G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 1487 | { |
| 1488 | return TRUE(!(0)); |
| 1489 | } |
| 1490 | |
| 1491 | static gboolean |
| 1492 | ctk_list_store_drag_data_delete (CtkTreeDragSource *drag_source, |
| 1493 | CtkTreePath *path) |
| 1494 | { |
| 1495 | CtkTreeIter iter; |
| 1496 | |
| 1497 | if (ctk_list_store_get_iter (CTK_TREE_MODEL (drag_source)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_source)), ((ctk_tree_model_get_type ())))))), |
| 1498 | &iter, |
| 1499 | path)) |
| 1500 | { |
| 1501 | ctk_list_store_remove (CTK_LIST_STORE (drag_source)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_source)), ((ctk_list_store_get_type ())))))), &iter); |
| 1502 | return TRUE(!(0)); |
| 1503 | } |
| 1504 | return FALSE(0); |
| 1505 | } |
| 1506 | |
| 1507 | static gboolean |
| 1508 | ctk_list_store_drag_data_get (CtkTreeDragSource *drag_source, |
| 1509 | CtkTreePath *path, |
| 1510 | CtkSelectionData *selection_data) |
| 1511 | { |
| 1512 | /* Note that we don't need to handle the CTK_TREE_MODEL_ROW |
| 1513 | * target, because the default handler does it for us, but |
| 1514 | * we do anyway for the convenience of someone maybe overriding the |
| 1515 | * default handler. |
| 1516 | */ |
| 1517 | |
| 1518 | if (ctk_tree_set_row_drag_data (selection_data, |
| 1519 | CTK_TREE_MODEL (drag_source)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_source)), ((ctk_tree_model_get_type ())))))), |
| 1520 | path)) |
| 1521 | { |
| 1522 | return TRUE(!(0)); |
| 1523 | } |
| 1524 | else |
| 1525 | { |
| 1526 | /* FIXME handle text targets at least. */ |
| 1527 | } |
| 1528 | |
| 1529 | return FALSE(0); |
| 1530 | } |
| 1531 | |
| 1532 | static gboolean |
| 1533 | ctk_list_store_drag_data_received (CtkTreeDragDest *drag_dest, |
| 1534 | CtkTreePath *dest, |
| 1535 | CtkSelectionData *selection_data) |
| 1536 | { |
| 1537 | CtkTreeModel *tree_model = CTK_TREE_MODEL (drag_dest)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_dest)), ((ctk_tree_model_get_type ())))))); |
| 1538 | CtkListStore *list_store = CTK_LIST_STORE (tree_model)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tree_model)), ((ctk_list_store_get_type ())))))); |
| 1539 | CtkListStorePrivate *priv = list_store->priv; |
| 1540 | CtkTreeModel *src_model = NULL((void*)0); |
| 1541 | CtkTreePath *src_path = NULL((void*)0); |
| 1542 | gboolean retval = FALSE(0); |
| 1543 | |
| 1544 | if (ctk_tree_get_row_drag_data (selection_data, |
| 1545 | &src_model, |
| 1546 | &src_path) && |
| 1547 | src_model == tree_model) |
| 1548 | { |
| 1549 | /* Copy the given row to a new position */ |
| 1550 | CtkTreeIter src_iter; |
| 1551 | CtkTreeIter dest_iter; |
| 1552 | CtkTreePath *prev; |
| 1553 | |
| 1554 | if (!ctk_list_store_get_iter (src_model, |
| 1555 | &src_iter, |
| 1556 | src_path)) |
| 1557 | { |
| 1558 | goto out; |
| 1559 | } |
| 1560 | |
| 1561 | /* Get the path to insert _after_ (dest is the path to insert _before_) */ |
| 1562 | prev = ctk_tree_path_copy (dest); |
| 1563 | |
| 1564 | if (!ctk_tree_path_prev (prev)) |
| 1565 | { |
| 1566 | /* dest was the first spot in the list; which means we are supposed |
| 1567 | * to prepend. |
| 1568 | */ |
| 1569 | ctk_list_store_prepend (list_store, &dest_iter); |
| 1570 | |
| 1571 | retval = TRUE(!(0)); |
| 1572 | } |
| 1573 | else |
| 1574 | { |
| 1575 | if (ctk_list_store_get_iter (tree_model, &dest_iter, prev)) |
| 1576 | { |
| 1577 | CtkTreeIter tmp_iter = dest_iter; |
| 1578 | |
| 1579 | ctk_list_store_insert_after (list_store, &dest_iter, &tmp_iter); |
| 1580 | |
| 1581 | retval = TRUE(!(0)); |
| 1582 | } |
| 1583 | } |
| 1584 | |
| 1585 | ctk_tree_path_free (prev); |
| 1586 | |
| 1587 | /* If we succeeded in creating dest_iter, copy data from src |
| 1588 | */ |
| 1589 | if (retval) |
| 1590 | { |
| 1591 | CtkTreeDataList *dl = g_sequence_get (src_iter.user_data); |
| 1592 | CtkTreeDataList *copy_head = NULL((void*)0); |
| 1593 | CtkTreeDataList *copy_prev = NULL((void*)0); |
| 1594 | CtkTreeDataList *copy_iter = NULL((void*)0); |
| 1595 | CtkTreePath *path; |
| 1596 | gint col; |
| 1597 | |
| 1598 | col = 0; |
| 1599 | while (dl) |
| 1600 | { |
| 1601 | copy_iter = _ctk_tree_data_list_node_copy (dl, |
| 1602 | priv->column_headers[col]); |
| 1603 | |
| 1604 | if (copy_head == NULL((void*)0)) |
| 1605 | copy_head = copy_iter; |
| 1606 | |
| 1607 | if (copy_prev) |
| 1608 | copy_prev->next = copy_iter; |
| 1609 | |
| 1610 | copy_prev = copy_iter; |
| 1611 | |
| 1612 | dl = dl->next; |
| 1613 | ++col; |
| 1614 | } |
| 1615 | |
| 1616 | dest_iter.stamp = priv->stamp; |
| 1617 | g_sequence_set (dest_iter.user_data, copy_head); |
| 1618 | |
| 1619 | path = ctk_list_store_get_path (tree_model, &dest_iter); |
| 1620 | ctk_tree_model_row_changed (tree_model, path, &dest_iter); |
| 1621 | ctk_tree_path_free (path); |
| 1622 | } |
| 1623 | } |
| 1624 | else |
| 1625 | { |
| 1626 | /* FIXME maybe add some data targets eventually, or handle text |
| 1627 | * targets in the simple case. |
| 1628 | */ |
| 1629 | } |
| 1630 | |
| 1631 | out: |
| 1632 | |
| 1633 | if (src_path) |
| 1634 | ctk_tree_path_free (src_path); |
| 1635 | |
| 1636 | return retval; |
| 1637 | } |
| 1638 | |
| 1639 | static gboolean |
| 1640 | ctk_list_store_row_drop_possible (CtkTreeDragDest *drag_dest, |
| 1641 | CtkTreePath *dest_path, |
| 1642 | CtkSelectionData *selection_data) |
| 1643 | { |
| 1644 | gint *indices; |
| 1645 | CtkTreeModel *src_model = NULL((void*)0); |
| 1646 | CtkTreePath *src_path = NULL((void*)0); |
| 1647 | gboolean retval = FALSE(0); |
| 1648 | |
| 1649 | /* don't accept drops if the list has been sorted */ |
| 1650 | if (CTK_LIST_STORE_IS_SORTED (drag_dest)(((CtkListStore*)(drag_dest))->priv->sort_column_id != ( -2))) |
| 1651 | return FALSE(0); |
| 1652 | |
| 1653 | if (!ctk_tree_get_row_drag_data (selection_data, |
| 1654 | &src_model, |
| 1655 | &src_path)) |
| 1656 | goto out; |
| 1657 | |
| 1658 | if (src_model != CTK_TREE_MODEL (drag_dest)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_dest)), ((ctk_tree_model_get_type ()))))))) |
| 1659 | goto out; |
| 1660 | |
| 1661 | if (ctk_tree_path_get_depth (dest_path) != 1) |
| 1662 | goto out; |
| 1663 | |
| 1664 | /* can drop before any existing node, or before one past any existing. */ |
| 1665 | |
| 1666 | indices = ctk_tree_path_get_indices (dest_path); |
| 1667 | |
| 1668 | if (indices[0] <= g_sequence_get_length (CTK_LIST_STORE (drag_dest)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((drag_dest)), ((ctk_list_store_get_type ()))))))->priv->seq)) |
| 1669 | retval = TRUE(!(0)); |
| 1670 | |
| 1671 | out: |
| 1672 | if (src_path) |
| 1673 | ctk_tree_path_free (src_path); |
| 1674 | |
| 1675 | return retval; |
| 1676 | } |
| 1677 | |
| 1678 | /* Sorting and reordering */ |
| 1679 | |
| 1680 | /* Reordering */ |
| 1681 | static gint |
| 1682 | ctk_list_store_reorder_func (GSequenceIter *a, |
| 1683 | GSequenceIter *b, |
| 1684 | gpointer user_data) |
| 1685 | { |
| 1686 | GHashTable *new_positions = user_data; |
| 1687 | gint apos = GPOINTER_TO_INT (g_hash_table_lookup (new_positions, a))((gint) (glong) (g_hash_table_lookup (new_positions, a))); |
| 1688 | gint bpos = GPOINTER_TO_INT (g_hash_table_lookup (new_positions, b))((gint) (glong) (g_hash_table_lookup (new_positions, b))); |
| 1689 | |
| 1690 | if (apos < bpos) |
| 1691 | return -1; |
| 1692 | if (apos > bpos) |
| 1693 | return 1; |
| 1694 | return 0; |
| 1695 | } |
| 1696 | |
| 1697 | /** |
| 1698 | * ctk_list_store_reorder: |
| 1699 | * @store: A #CtkListStore. |
| 1700 | * @new_order: (array zero-terminated=1): an array of integers mapping the new |
| 1701 | * position of each child to its old position before the re-ordering, |
| 1702 | * i.e. @new_order`[newpos] = oldpos`. It must have |
| 1703 | * exactly as many items as the list store’s length. |
| 1704 | * |
| 1705 | * Reorders @store to follow the order indicated by @new_order. Note that |
| 1706 | * this function only works with unsorted stores. |
| 1707 | * |
| 1708 | * Since: 2.2 |
| 1709 | **/ |
| 1710 | void |
| 1711 | ctk_list_store_reorder (CtkListStore *store, |
| 1712 | gint *new_order) |
| 1713 | { |
| 1714 | CtkListStorePrivate *priv; |
| 1715 | gint i; |
| 1716 | CtkTreePath *path; |
| 1717 | GHashTable *new_positions; |
| 1718 | GSequenceIter *ptr; |
| 1719 | gint *order; |
| 1720 | |
| 1721 | g_return_if_fail (CTK_IS_LIST_STORE (store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((store)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_LIST_STORE (store)"); return; } } while (0); |
| 1722 | g_return_if_fail (!CTK_LIST_STORE_IS_SORTED (store))do { if ((!(((CtkListStore*)(store))->priv->sort_column_id != (-2)))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!CTK_LIST_STORE_IS_SORTED (store)"); return ; } } while (0); |
| 1723 | g_return_if_fail (new_order != NULL)do { if ((new_order != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "new_order != NULL"); return ; } } while (0); |
| 1724 | |
| 1725 | priv = store->priv; |
| 1726 | |
| 1727 | order = g_new (gint, g_sequence_get_length (priv->seq))((gint *) g_malloc_n ((g_sequence_get_length (priv->seq)), sizeof (gint))); |
| 1728 | for (i = 0; i < g_sequence_get_length (priv->seq); i++) |
| 1729 | order[new_order[i]] = i; |
| 1730 | |
| 1731 | new_positions = g_hash_table_new (g_direct_hash, g_direct_equal); |
| 1732 | |
| 1733 | ptr = g_sequence_get_begin_iter (priv->seq); |
| 1734 | i = 0; |
| 1735 | while (!g_sequence_iter_is_end (ptr)) |
| 1736 | { |
| 1737 | g_hash_table_insert (new_positions, ptr, GINT_TO_POINTER (order[i++])((gpointer) (glong) (order[i++]))); |
| 1738 | |
| 1739 | ptr = g_sequence_iter_next (ptr); |
| 1740 | } |
| 1741 | g_free (order); |
| 1742 | |
| 1743 | g_sequence_sort_iter (priv->seq, ctk_list_store_reorder_func, new_positions); |
| 1744 | |
| 1745 | g_hash_table_destroy (new_positions); |
| 1746 | |
| 1747 | /* emit signal */ |
| 1748 | path = ctk_tree_path_new (); |
| 1749 | ctk_tree_model_rows_reordered (CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))), |
| 1750 | path, NULL((void*)0), new_order); |
| 1751 | ctk_tree_path_free (path); |
| 1752 | } |
| 1753 | |
| 1754 | static GHashTable * |
| 1755 | save_positions (GSequence *seq) |
| 1756 | { |
| 1757 | GHashTable *positions = g_hash_table_new (g_direct_hash, g_direct_equal); |
| 1758 | GSequenceIter *ptr; |
| 1759 | |
| 1760 | ptr = g_sequence_get_begin_iter (seq); |
| 1761 | while (!g_sequence_iter_is_end (ptr)) |
| 1762 | { |
| 1763 | g_hash_table_insert (positions, ptr, |
| 1764 | GINT_TO_POINTER (g_sequence_iter_get_position (ptr))((gpointer) (glong) (g_sequence_iter_get_position (ptr)))); |
| 1765 | ptr = g_sequence_iter_next (ptr); |
| 1766 | } |
| 1767 | |
| 1768 | return positions; |
| 1769 | } |
| 1770 | |
| 1771 | static int * |
| 1772 | generate_order (GSequence *seq, |
| 1773 | GHashTable *old_positions) |
| 1774 | { |
| 1775 | GSequenceIter *ptr; |
| 1776 | int *order = g_new (int, g_sequence_get_length (seq))((int *) g_malloc_n ((g_sequence_get_length (seq)), sizeof (int ))); |
| 1777 | int i; |
| 1778 | |
| 1779 | i = 0; |
| 1780 | ptr = g_sequence_get_begin_iter (seq); |
| 1781 | while (!g_sequence_iter_is_end (ptr)) |
| 1782 | { |
| 1783 | int old_pos = GPOINTER_TO_INT (g_hash_table_lookup (old_positions, ptr))((gint) (glong) (g_hash_table_lookup (old_positions, ptr))); |
| 1784 | order[i++] = old_pos; |
| 1785 | ptr = g_sequence_iter_next (ptr); |
| 1786 | } |
| 1787 | |
| 1788 | g_hash_table_destroy (old_positions); |
| 1789 | |
| 1790 | return order; |
| 1791 | } |
| 1792 | |
| 1793 | /** |
| 1794 | * ctk_list_store_swap: |
| 1795 | * @store: A #CtkListStore. |
| 1796 | * @a: A #CtkTreeIter. |
| 1797 | * @b: Another #CtkTreeIter. |
| 1798 | * |
| 1799 | * Swaps @a and @b in @store. Note that this function only works with |
| 1800 | * unsorted stores. |
| 1801 | * |
| 1802 | * Since: 2.2 |
| 1803 | **/ |
| 1804 | void |
| 1805 | ctk_list_store_swap (CtkListStore *store, |
| 1806 | CtkTreeIter *a, |
| 1807 | CtkTreeIter *b) |
| 1808 | { |
| 1809 | CtkListStorePrivate *priv; |
| 1810 | GHashTable *old_positions; |
| 1811 | gint *order; |
| 1812 | CtkTreePath *path; |
| 1813 | |
| 1814 | g_return_if_fail (CTK_IS_LIST_STORE (store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((store)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_LIST_STORE (store)"); return; } } while (0); |
| 1815 | g_return_if_fail (!CTK_LIST_STORE_IS_SORTED (store))do { if ((!(((CtkListStore*)(store))->priv->sort_column_id != (-2)))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!CTK_LIST_STORE_IS_SORTED (store)"); return ; } } while (0); |
| 1816 | g_return_if_fail (iter_is_valid (a, store))do { if ((iter_is_valid (a, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (a, store)" ); return; } } while (0); |
| 1817 | g_return_if_fail (iter_is_valid (b, store))do { if ((iter_is_valid (b, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (b, store)" ); return; } } while (0); |
| 1818 | |
| 1819 | priv = store->priv; |
| 1820 | |
| 1821 | if (a->user_data == b->user_data) |
| 1822 | return; |
| 1823 | |
| 1824 | old_positions = save_positions (priv->seq); |
| 1825 | |
| 1826 | g_sequence_swap (a->user_data, b->user_data); |
| 1827 | |
| 1828 | order = generate_order (priv->seq, old_positions); |
| 1829 | path = ctk_tree_path_new (); |
| 1830 | |
| 1831 | ctk_tree_model_rows_reordered (CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))), |
| 1832 | path, NULL((void*)0), order); |
| 1833 | |
| 1834 | ctk_tree_path_free (path); |
| 1835 | g_free (order); |
| 1836 | } |
| 1837 | |
| 1838 | static void |
| 1839 | ctk_list_store_move_to (CtkListStore *store, |
| 1840 | CtkTreeIter *iter, |
| 1841 | gint new_pos) |
| 1842 | { |
| 1843 | CtkListStorePrivate *priv = store->priv; |
| 1844 | GHashTable *old_positions; |
| 1845 | CtkTreePath *path; |
| 1846 | gint *order; |
| 1847 | |
| 1848 | old_positions = save_positions (priv->seq); |
| 1849 | |
| 1850 | g_sequence_move (iter->user_data, g_sequence_get_iter_at_pos (priv->seq, new_pos)); |
| 1851 | |
| 1852 | order = generate_order (priv->seq, old_positions); |
| 1853 | |
| 1854 | path = ctk_tree_path_new (); |
| 1855 | ctk_tree_model_rows_reordered (CTK_TREE_MODEL (store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((store)), ((ctk_tree_model_get_type ())))))), |
| 1856 | path, NULL((void*)0), order); |
| 1857 | ctk_tree_path_free (path); |
| 1858 | g_free (order); |
| 1859 | } |
| 1860 | |
| 1861 | /** |
| 1862 | * ctk_list_store_move_before: |
| 1863 | * @store: A #CtkListStore. |
| 1864 | * @iter: A #CtkTreeIter. |
| 1865 | * @position: (allow-none): A #CtkTreeIter, or %NULL. |
| 1866 | * |
| 1867 | * Moves @iter in @store to the position before @position. Note that this |
| 1868 | * function only works with unsorted stores. If @position is %NULL, @iter |
| 1869 | * will be moved to the end of the list. |
| 1870 | * |
| 1871 | * Since: 2.2 |
| 1872 | **/ |
| 1873 | void |
| 1874 | ctk_list_store_move_before (CtkListStore *store, |
| 1875 | CtkTreeIter *iter, |
| 1876 | CtkTreeIter *position) |
| 1877 | { |
| 1878 | gint pos; |
| 1879 | |
| 1880 | g_return_if_fail (CTK_IS_LIST_STORE (store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((store)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_LIST_STORE (store)"); return; } } while (0); |
| 1881 | g_return_if_fail (!CTK_LIST_STORE_IS_SORTED (store))do { if ((!(((CtkListStore*)(store))->priv->sort_column_id != (-2)))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!CTK_LIST_STORE_IS_SORTED (store)"); return ; } } while (0); |
| 1882 | g_return_if_fail (iter_is_valid (iter, store))do { if ((iter_is_valid (iter, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, store)" ); return; } } while (0); |
| 1883 | if (position) |
| 1884 | g_return_if_fail (iter_is_valid (position, store))do { if ((iter_is_valid (position, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (position, store)" ); return; } } while (0); |
| 1885 | |
| 1886 | if (position) |
| 1887 | pos = g_sequence_iter_get_position (position->user_data); |
| 1888 | else |
| 1889 | pos = -1; |
| 1890 | |
| 1891 | ctk_list_store_move_to (store, iter, pos); |
| 1892 | } |
| 1893 | |
| 1894 | /** |
| 1895 | * ctk_list_store_move_after: |
| 1896 | * @store: A #CtkListStore. |
| 1897 | * @iter: A #CtkTreeIter. |
| 1898 | * @position: (allow-none): A #CtkTreeIter or %NULL. |
| 1899 | * |
| 1900 | * Moves @iter in @store to the position after @position. Note that this |
| 1901 | * function only works with unsorted stores. If @position is %NULL, @iter |
| 1902 | * will be moved to the start of the list. |
| 1903 | * |
| 1904 | * Since: 2.2 |
| 1905 | **/ |
| 1906 | void |
| 1907 | ctk_list_store_move_after (CtkListStore *store, |
| 1908 | CtkTreeIter *iter, |
| 1909 | CtkTreeIter *position) |
| 1910 | { |
| 1911 | gint pos; |
| 1912 | |
| 1913 | g_return_if_fail (CTK_IS_LIST_STORE (store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((store)); GType __t = ((ctk_list_store_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; })))))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__ )), "CTK_IS_LIST_STORE (store)"); return; } } while (0); |
| 1914 | g_return_if_fail (!CTK_LIST_STORE_IS_SORTED (store))do { if ((!(((CtkListStore*)(store))->priv->sort_column_id != (-2)))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "!CTK_LIST_STORE_IS_SORTED (store)"); return ; } } while (0); |
| 1915 | g_return_if_fail (iter_is_valid (iter, store))do { if ((iter_is_valid (iter, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (iter, store)" ); return; } } while (0); |
| 1916 | if (position) |
| 1917 | g_return_if_fail (iter_is_valid (position, store))do { if ((iter_is_valid (position, store))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "iter_is_valid (position, store)" ); return; } } while (0); |
| 1918 | |
| 1919 | if (position) |
| 1920 | pos = g_sequence_iter_get_position (position->user_data) + 1; |
| 1921 | else |
| 1922 | pos = 0; |
| 1923 | |
| 1924 | ctk_list_store_move_to (store, iter, pos); |
| 1925 | } |
| 1926 | |
| 1927 | /* Sorting */ |
| 1928 | static gint |
| 1929 | ctk_list_store_compare_func (GSequenceIter *a, |
| 1930 | GSequenceIter *b, |
| 1931 | gpointer user_data) |
| 1932 | { |
| 1933 | CtkListStore *list_store = user_data; |
| 1934 | CtkListStorePrivate *priv = list_store->priv; |
| 1935 | CtkTreeIter iter_a; |
| 1936 | CtkTreeIter iter_b; |
| 1937 | gint retval; |
| 1938 | CtkTreeIterCompareFunc func; |
| 1939 | gpointer data; |
| 1940 | |
| 1941 | if (priv->sort_column_id != -1) |
| 1942 | { |
| 1943 | CtkTreeDataSortHeader *header; |
| 1944 | |
| 1945 | header = _ctk_tree_data_list_get_header (priv->sort_list, |
| 1946 | priv->sort_column_id); |
| 1947 | g_return_val_if_fail (header != NULL, 0)do { if ((header != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header != NULL"); return (0); } } while (0); |
| 1948 | g_return_val_if_fail (header->func != NULL, 0)do { if ((header->func != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header->func != NULL" ); return (0); } } while (0); |
| 1949 | |
| 1950 | func = header->func; |
| 1951 | data = header->data; |
| 1952 | } |
| 1953 | else |
| 1954 | { |
| 1955 | g_return_val_if_fail (priv->default_sort_func != NULL, 0)do { if ((priv->default_sort_func != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "priv->default_sort_func != NULL"); return (0); } } while (0); |
| 1956 | func = priv->default_sort_func; |
| 1957 | data = priv->default_sort_data; |
| 1958 | } |
| 1959 | |
| 1960 | iter_a.stamp = priv->stamp; |
| 1961 | iter_a.user_data = (gpointer)a; |
| 1962 | iter_b.stamp = priv->stamp; |
| 1963 | iter_b.user_data = (gpointer)b; |
| 1964 | |
| 1965 | g_assert (iter_is_valid (&iter_a, list_store))do { if (iter_is_valid (&iter_a, list_store)) ; else g_assertion_message_expr ("Ctk", "ctkliststore.c", 1965, ((const char*) (__func__)), "iter_is_valid (&iter_a, list_store)" ); } while (0); |
| 1966 | g_assert (iter_is_valid (&iter_b, list_store))do { if (iter_is_valid (&iter_b, list_store)) ; else g_assertion_message_expr ("Ctk", "ctkliststore.c", 1966, ((const char*) (__func__)), "iter_is_valid (&iter_b, list_store)" ); } while (0); |
| 1967 | |
| 1968 | retval = (* func) (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), &iter_a, &iter_b, data); |
| 1969 | |
| 1970 | if (priv->order == CTK_SORT_DESCENDING) |
| 1971 | { |
| 1972 | if (retval > 0) |
| 1973 | retval = -1; |
| 1974 | else if (retval < 0) |
| 1975 | retval = 1; |
| 1976 | } |
| 1977 | |
| 1978 | return retval; |
| 1979 | } |
| 1980 | |
| 1981 | static void |
| 1982 | ctk_list_store_sort (CtkListStore *list_store) |
| 1983 | { |
| 1984 | CtkListStorePrivate *priv = list_store->priv; |
| 1985 | gint *new_order; |
| 1986 | CtkTreePath *path; |
| 1987 | GHashTable *old_positions; |
| 1988 | |
| 1989 | if (!CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2)) || |
| 1990 | g_sequence_get_length (priv->seq) <= 1) |
| 1991 | return; |
| 1992 | |
| 1993 | old_positions = save_positions (priv->seq); |
| 1994 | |
| 1995 | g_sequence_sort_iter (priv->seq, ctk_list_store_compare_func, list_store); |
| 1996 | |
| 1997 | /* Let the world know about our new order */ |
| 1998 | new_order = generate_order (priv->seq, old_positions); |
| 1999 | |
| 2000 | path = ctk_tree_path_new (); |
| 2001 | ctk_tree_model_rows_reordered (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), |
| 2002 | path, NULL((void*)0), new_order); |
| 2003 | ctk_tree_path_free (path); |
| 2004 | g_free (new_order); |
| 2005 | } |
| 2006 | |
| 2007 | static gboolean |
| 2008 | iter_is_sorted (CtkListStore *list_store, |
| 2009 | CtkTreeIter *iter) |
| 2010 | { |
| 2011 | GSequenceIter *cmp; |
| 2012 | |
| 2013 | if (!g_sequence_iter_is_begin (iter->user_data)) |
| 2014 | { |
| 2015 | cmp = g_sequence_iter_prev (iter->user_data); |
| 2016 | if (ctk_list_store_compare_func (cmp, iter->user_data, list_store) > 0) |
| 2017 | return FALSE(0); |
| 2018 | } |
| 2019 | |
| 2020 | cmp = g_sequence_iter_next (iter->user_data); |
| 2021 | if (!g_sequence_iter_is_end (cmp)) |
| 2022 | { |
| 2023 | if (ctk_list_store_compare_func (iter->user_data, cmp, list_store) > 0) |
| 2024 | return FALSE(0); |
| 2025 | } |
| 2026 | |
| 2027 | return TRUE(!(0)); |
| 2028 | } |
| 2029 | |
| 2030 | static void |
| 2031 | ctk_list_store_sort_iter_changed (CtkListStore *list_store, |
| 2032 | CtkTreeIter *iter, |
| 2033 | gint column G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 2034 | |
| 2035 | { |
| 2036 | CtkListStorePrivate *priv = list_store->priv; |
| 2037 | CtkTreePath *path; |
| 2038 | |
| 2039 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 2040 | ctk_tree_model_row_changed (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 2041 | ctk_tree_path_free (path); |
| 2042 | |
| 2043 | if (!iter_is_sorted (list_store, iter)) |
| 2044 | { |
| 2045 | GHashTable *old_positions; |
| 2046 | gint *order; |
| 2047 | |
| 2048 | old_positions = save_positions (priv->seq); |
| 2049 | g_sequence_sort_changed_iter (iter->user_data, |
| 2050 | ctk_list_store_compare_func, |
| 2051 | list_store); |
| 2052 | order = generate_order (priv->seq, old_positions); |
| 2053 | path = ctk_tree_path_new (); |
| 2054 | ctk_tree_model_rows_reordered (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), |
| 2055 | path, NULL((void*)0), order); |
| 2056 | ctk_tree_path_free (path); |
| 2057 | g_free (order); |
| 2058 | } |
| 2059 | } |
| 2060 | |
| 2061 | static gboolean |
| 2062 | ctk_list_store_get_sort_column_id (CtkTreeSortable *sortable, |
| 2063 | gint *sort_column_id, |
| 2064 | CtkSortType *order) |
| 2065 | { |
| 2066 | CtkListStore *list_store = CTK_LIST_STORE (sortable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sortable)), ((ctk_list_store_get_type ())))))); |
| 2067 | CtkListStorePrivate *priv = list_store->priv; |
| 2068 | |
| 2069 | if (sort_column_id) |
| 2070 | * sort_column_id = priv->sort_column_id; |
| 2071 | if (order) |
| 2072 | * order = priv->order; |
| 2073 | |
| 2074 | if (priv->sort_column_id == CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1) || |
| 2075 | priv->sort_column_id == CTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID(-2)) |
| 2076 | return FALSE(0); |
| 2077 | |
| 2078 | return TRUE(!(0)); |
| 2079 | } |
| 2080 | |
| 2081 | static void |
| 2082 | ctk_list_store_set_sort_column_id (CtkTreeSortable *sortable, |
| 2083 | gint sort_column_id, |
| 2084 | CtkSortType order) |
| 2085 | { |
| 2086 | CtkListStore *list_store = CTK_LIST_STORE (sortable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sortable)), ((ctk_list_store_get_type ())))))); |
| 2087 | CtkListStorePrivate *priv = list_store->priv; |
| 2088 | |
| 2089 | if ((priv->sort_column_id == sort_column_id) && |
| 2090 | (priv->order == order)) |
| 2091 | return; |
| 2092 | |
| 2093 | if (sort_column_id != CTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID(-2)) |
| 2094 | { |
| 2095 | if (sort_column_id != CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1)) |
| 2096 | { |
| 2097 | CtkTreeDataSortHeader *header = NULL((void*)0); |
| 2098 | |
| 2099 | header = _ctk_tree_data_list_get_header (priv->sort_list, |
| 2100 | sort_column_id); |
| 2101 | |
| 2102 | /* We want to make sure that we have a function */ |
| 2103 | g_return_if_fail (header != NULL)do { if ((header != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header != NULL"); return ; } } while (0); |
| 2104 | g_return_if_fail (header->func != NULL)do { if ((header->func != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__)), "header->func != NULL" ); return; } } while (0); |
| 2105 | } |
| 2106 | else |
| 2107 | { |
| 2108 | g_return_if_fail (priv->default_sort_func != NULL)do { if ((priv->default_sort_func != ((void*)0))) { } else { g_return_if_fail_warning ("Ctk", ((const char*) (__func__) ), "priv->default_sort_func != NULL"); return; } } while ( 0); |
| 2109 | } |
| 2110 | } |
| 2111 | |
| 2112 | |
| 2113 | priv->sort_column_id = sort_column_id; |
| 2114 | priv->order = order; |
| 2115 | |
| 2116 | ctk_tree_sortable_sort_column_changed (sortable); |
| 2117 | |
| 2118 | ctk_list_store_sort (list_store); |
| 2119 | } |
| 2120 | |
| 2121 | static void |
| 2122 | ctk_list_store_set_sort_func (CtkTreeSortable *sortable, |
| 2123 | gint sort_column_id, |
| 2124 | CtkTreeIterCompareFunc func, |
| 2125 | gpointer data, |
| 2126 | GDestroyNotify destroy) |
| 2127 | { |
| 2128 | CtkListStore *list_store = CTK_LIST_STORE (sortable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sortable)), ((ctk_list_store_get_type ())))))); |
| 2129 | CtkListStorePrivate *priv = list_store->priv; |
| 2130 | |
| 2131 | priv->sort_list = _ctk_tree_data_list_set_header (priv->sort_list, |
| 2132 | sort_column_id, |
| 2133 | func, data, destroy); |
| 2134 | |
| 2135 | if (priv->sort_column_id == sort_column_id) |
| 2136 | ctk_list_store_sort (list_store); |
| 2137 | } |
| 2138 | |
| 2139 | static void |
| 2140 | ctk_list_store_set_default_sort_func (CtkTreeSortable *sortable, |
| 2141 | CtkTreeIterCompareFunc func, |
| 2142 | gpointer data, |
| 2143 | GDestroyNotify destroy) |
| 2144 | { |
| 2145 | CtkListStore *list_store = CTK_LIST_STORE (sortable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sortable)), ((ctk_list_store_get_type ())))))); |
| 2146 | CtkListStorePrivate *priv = list_store->priv; |
| 2147 | |
| 2148 | if (priv->default_sort_destroy) |
| 2149 | { |
| 2150 | GDestroyNotify d = priv->default_sort_destroy; |
| 2151 | |
| 2152 | priv->default_sort_destroy = NULL((void*)0); |
| 2153 | d (priv->default_sort_data); |
| 2154 | } |
| 2155 | |
| 2156 | priv->default_sort_func = func; |
| 2157 | priv->default_sort_data = data; |
| 2158 | priv->default_sort_destroy = destroy; |
| 2159 | |
| 2160 | if (priv->sort_column_id == CTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID(-1)) |
| 2161 | ctk_list_store_sort (list_store); |
| 2162 | } |
| 2163 | |
| 2164 | static gboolean |
| 2165 | ctk_list_store_has_default_sort_func (CtkTreeSortable *sortable) |
| 2166 | { |
| 2167 | CtkListStore *list_store = CTK_LIST_STORE (sortable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((sortable)), ((ctk_list_store_get_type ())))))); |
| 2168 | CtkListStorePrivate *priv = list_store->priv; |
| 2169 | |
| 2170 | return (priv->default_sort_func != NULL((void*)0)); |
| 2171 | } |
| 2172 | |
| 2173 | |
| 2174 | /** |
| 2175 | * ctk_list_store_insert_with_values: |
| 2176 | * @list_store: A #CtkListStore |
| 2177 | * @iter: (out) (allow-none): An unset #CtkTreeIter to set to the new row, or %NULL |
| 2178 | * @position: position to insert the new row, or -1 to append after existing |
| 2179 | * rows |
| 2180 | * @...: pairs of column number and value, terminated with -1 |
| 2181 | * |
| 2182 | * Creates a new row at @position. @iter will be changed to point to this new |
| 2183 | * row. If @position is -1, or larger than the number of rows in the list, then |
| 2184 | * the new row will be appended to the list. The row will be filled with the |
| 2185 | * values given to this function. |
| 2186 | * |
| 2187 | * Calling |
| 2188 | * `ctk_list_store_insert_with_values (list_store, iter, position...)` |
| 2189 | * has the same effect as calling |
| 2190 | * |[<!-- language="C" --> |
| 2191 | * static void |
| 2192 | * insert_value (CtkListStore *list_store, |
| 2193 | * CtkTreeIter *iter, |
| 2194 | * int position) |
| 2195 | * { |
| 2196 | * ctk_list_store_insert (list_store, iter, position); |
| 2197 | * ctk_list_store_set (list_store, |
| 2198 | * iter |
| 2199 | * // ... |
| 2200 | * ); |
| 2201 | * } |
| 2202 | * ]| |
| 2203 | * with the difference that the former will only emit a row_inserted signal, |
| 2204 | * while the latter will emit row_inserted, row_changed and, if the list store |
| 2205 | * is sorted, rows_reordered. Since emitting the rows_reordered signal |
| 2206 | * repeatedly can affect the performance of the program, |
| 2207 | * ctk_list_store_insert_with_values() should generally be preferred when |
| 2208 | * inserting rows in a sorted list store. |
| 2209 | * |
| 2210 | * Since: 2.6 |
| 2211 | */ |
| 2212 | void |
| 2213 | ctk_list_store_insert_with_values (CtkListStore *list_store, |
| 2214 | CtkTreeIter *iter, |
| 2215 | gint position, |
| 2216 | ...) |
| 2217 | { |
| 2218 | CtkListStorePrivate *priv; |
| 2219 | CtkTreePath *path; |
| 2220 | GSequence *seq; |
| 2221 | GSequenceIter *ptr; |
| 2222 | CtkTreeIter tmp_iter; |
| 2223 | gint length; |
| 2224 | gboolean changed = FALSE(0); |
| 2225 | gboolean maybe_need_sort = FALSE(0); |
| 2226 | va_list var_args; |
| 2227 | |
| 2228 | /* FIXME: refactor to reduce overlap with ctk_list_store_set() */ |
| 2229 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 2230 | |
| 2231 | priv = list_store->priv; |
| 2232 | |
| 2233 | if (!iter) |
| 2234 | iter = &tmp_iter; |
| 2235 | |
| 2236 | priv->columns_dirty = TRUE(!(0)); |
| 2237 | |
| 2238 | seq = priv->seq; |
| 2239 | |
| 2240 | length = g_sequence_get_length (seq); |
| 2241 | if (position > length || position < 0) |
| 2242 | position = length; |
| 2243 | |
| 2244 | ptr = g_sequence_get_iter_at_pos (seq, position); |
| 2245 | ptr = g_sequence_insert_before (ptr, NULL((void*)0)); |
| 2246 | |
| 2247 | iter->stamp = priv->stamp; |
| 2248 | iter->user_data = ptr; |
| 2249 | |
| 2250 | g_assert (iter_is_valid (iter, list_store))do { if (iter_is_valid (iter, list_store)) ; else g_assertion_message_expr ("Ctk", "ctkliststore.c", 2250, ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); } while (0); |
| 2251 | |
| 2252 | priv->length++; |
| 2253 | |
| 2254 | va_start (var_args, position)__builtin_va_start(var_args, position); |
| 2255 | ctk_list_store_set_valist_internal (list_store, iter, |
| 2256 | &changed, &maybe_need_sort, |
| 2257 | var_args); |
| 2258 | va_end (var_args)__builtin_va_end(var_args); |
| 2259 | |
| 2260 | /* Don't emit rows_reordered here */ |
| 2261 | if (maybe_need_sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 2262 | g_sequence_sort_changed_iter (iter->user_data, |
| 2263 | ctk_list_store_compare_func, |
| 2264 | list_store); |
| 2265 | |
| 2266 | /* Just emit row_inserted */ |
| 2267 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 2268 | ctk_tree_model_row_inserted (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 2269 | ctk_tree_path_free (path); |
| 2270 | } |
| 2271 | |
| 2272 | |
| 2273 | /** |
| 2274 | * ctk_list_store_insert_with_valuesv: |
| 2275 | * @list_store: A #CtkListStore |
| 2276 | * @iter: (out) (allow-none): An unset #CtkTreeIter to set to the new row, or %NULL. |
| 2277 | * @position: position to insert the new row, or -1 for last |
| 2278 | * @columns: (array length=n_values): an array of column numbers |
| 2279 | * @values: (array length=n_values): an array of GValues |
| 2280 | * @n_values: the length of the @columns and @values arrays |
| 2281 | * |
| 2282 | * A variant of ctk_list_store_insert_with_values() which |
| 2283 | * takes the columns and values as two arrays, instead of |
| 2284 | * varargs. This function is mainly intended for |
| 2285 | * language-bindings. |
| 2286 | * |
| 2287 | * Since: 2.6 |
| 2288 | */ |
| 2289 | void |
| 2290 | ctk_list_store_insert_with_valuesv (CtkListStore *list_store, |
| 2291 | CtkTreeIter *iter, |
| 2292 | gint position, |
| 2293 | gint *columns, |
| 2294 | GValue *values, |
| 2295 | gint n_values) |
| 2296 | { |
| 2297 | CtkListStorePrivate *priv; |
| 2298 | CtkTreePath *path; |
| 2299 | GSequence *seq; |
| 2300 | GSequenceIter *ptr; |
| 2301 | CtkTreeIter tmp_iter; |
| 2302 | gint length; |
| 2303 | gboolean changed = FALSE(0); |
| 2304 | gboolean maybe_need_sort = FALSE(0); |
| 2305 | |
| 2306 | /* FIXME refactor to reduce overlap with |
| 2307 | * ctk_list_store_insert_with_values() |
| 2308 | */ |
| 2309 | g_return_if_fail (CTK_IS_LIST_STORE (list_store))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((list_store)); GType __t = ((ctk_list_store_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } )))))) { } else { g_return_if_fail_warning ("Ctk", ((const char *) (__func__)), "CTK_IS_LIST_STORE (list_store)"); return; } } while (0); |
| 2310 | |
| 2311 | priv = list_store->priv; |
| 2312 | |
| 2313 | if (!iter) |
| 2314 | iter = &tmp_iter; |
| 2315 | |
| 2316 | priv->columns_dirty = TRUE(!(0)); |
| 2317 | |
| 2318 | seq = priv->seq; |
| 2319 | |
| 2320 | length = g_sequence_get_length (seq); |
| 2321 | if (position > length || position < 0) |
| 2322 | position = length; |
| 2323 | |
| 2324 | ptr = g_sequence_get_iter_at_pos (seq, position); |
| 2325 | ptr = g_sequence_insert_before (ptr, NULL((void*)0)); |
| 2326 | |
| 2327 | iter->stamp = priv->stamp; |
| 2328 | iter->user_data = ptr; |
| 2329 | |
| 2330 | g_assert (iter_is_valid (iter, list_store))do { if (iter_is_valid (iter, list_store)) ; else g_assertion_message_expr ("Ctk", "ctkliststore.c", 2330, ((const char*) (__func__)), "iter_is_valid (iter, list_store)" ); } while (0); |
| 2331 | |
| 2332 | priv->length++; |
| 2333 | |
| 2334 | ctk_list_store_set_vector_internal (list_store, iter, |
| 2335 | &changed, &maybe_need_sort, |
| 2336 | columns, values, n_values); |
| 2337 | |
| 2338 | /* Don't emit rows_reordered here */ |
| 2339 | if (maybe_need_sort && CTK_LIST_STORE_IS_SORTED (list_store)(((CtkListStore*)(list_store))->priv->sort_column_id != (-2))) |
| 2340 | g_sequence_sort_changed_iter (iter->user_data, |
| 2341 | ctk_list_store_compare_func, |
| 2342 | list_store); |
| 2343 | |
| 2344 | /* Just emit row_inserted */ |
| 2345 | path = ctk_list_store_get_path (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), iter); |
| 2346 | ctk_tree_model_row_inserted (CTK_TREE_MODEL (list_store)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((list_store)), ((ctk_tree_model_get_type ())))))), path, iter); |
| 2347 | ctk_tree_path_free (path); |
| 2348 | } |
| 2349 | |
| 2350 | /* CtkBuildable custom tag implementation |
| 2351 | * |
| 2352 | * <columns> |
| 2353 | * <column type="..."/> |
| 2354 | * <column type="..."/> |
| 2355 | * </columns> |
| 2356 | */ |
| 2357 | typedef struct { |
| 2358 | gboolean translatable; |
| 2359 | gchar *context; |
| 2360 | int id; |
| 2361 | } ColInfo; |
| 2362 | |
| 2363 | typedef struct { |
| 2364 | CtkBuilder *builder; |
| 2365 | GObject *object; |
| 2366 | GSList *column_type_names; |
| 2367 | GType *column_types; |
| 2368 | GValue *values; |
| 2369 | gint *colids; |
| 2370 | ColInfo **columns; |
| 2371 | gint last_row; |
| 2372 | gint n_columns; |
| 2373 | gint row_column; |
| 2374 | gboolean is_data; |
| 2375 | const gchar *domain; |
| 2376 | } SubParserData; |
| 2377 | |
| 2378 | static void |
| 2379 | list_store_start_element (GMarkupParseContext *context, |
| 2380 | const gchar *element_name, |
| 2381 | const gchar **names, |
| 2382 | const gchar **values, |
| 2383 | gpointer user_data, |
| 2384 | GError **error) |
| 2385 | { |
| 2386 | SubParserData *data = (SubParserData*)user_data; |
| 2387 | |
| 2388 | if (strcmp (element_name, "col") == 0) |
| 2389 | { |
| 2390 | gint id = -1; |
| 2391 | const gchar *id_str; |
| 2392 | const gchar *msg_context = NULL((void*)0); |
| 2393 | gboolean translatable = FALSE(0); |
| 2394 | ColInfo *info; |
| 2395 | GValue val = G_VALUE_INIT{ 0, { { 0 } } }; |
| 2396 | |
| 2397 | if (!_ctk_builder_check_parent (data->builder, context, "row", error)) |
| 2398 | return; |
| 2399 | |
| 2400 | if (data->row_column >= data->n_columns) |
| 2401 | { |
| 2402 | g_set_error (error, |
| 2403 | CTK_BUILDER_ERROR(ctk_builder_error_quark ()), CTK_BUILDER_ERROR_INVALID_VALUE, |
| 2404 | "Too many columns, maximum is %d", data->n_columns - 1); |
| 2405 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2406 | return; |
| 2407 | } |
| 2408 | |
| 2409 | if (!g_markup_collect_attributes (element_name, names, values, error, |
| 2410 | G_MARKUP_COLLECT_STRING, "id", &id_str, |
| 2411 | G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable, |
| 2412 | G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL((void*)0), |
| 2413 | G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &msg_context, |
| 2414 | G_MARKUP_COLLECT_INVALID)) |
| 2415 | { |
| 2416 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2417 | return; |
| 2418 | } |
| 2419 | |
| 2420 | if (!ctk_builder_value_from_string_type (data->builder, G_TYPE_INT((GType) ((6) << (2))), id_str, &val, error)) |
| 2421 | { |
| 2422 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2423 | return; |
| 2424 | } |
| 2425 | |
| 2426 | id = g_value_get_int (&val); |
| 2427 | if (id < 0 || id >= data->n_columns) |
| 2428 | { |
| 2429 | g_set_error (error, |
| 2430 | CTK_BUILDER_ERROR(ctk_builder_error_quark ()), CTK_BUILDER_ERROR_INVALID_VALUE, |
| 2431 | "id value %d out of range", id); |
| 2432 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2433 | return; |
| 2434 | } |
| 2435 | |
| 2436 | info = g_slice_new0 (ColInfo)((ColInfo*) g_slice_alloc0 (sizeof (ColInfo))); |
| 2437 | info->translatable = translatable; |
| 2438 | info->context = g_strdup (msg_context)g_strdup_inline (msg_context); |
| 2439 | info->id = id; |
| 2440 | |
| 2441 | data->colids[data->row_column] = id; |
| 2442 | data->columns[data->row_column] = info; |
| 2443 | data->row_column++; |
| 2444 | data->is_data = TRUE(!(0)); |
| 2445 | } |
| 2446 | else if (strcmp (element_name, "row") == 0) |
| 2447 | { |
| 2448 | if (!_ctk_builder_check_parent (data->builder, context, "data", error)) |
| 2449 | return; |
| 2450 | |
| 2451 | if (!g_markup_collect_attributes (element_name, names, values, error, |
| 2452 | G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0), |
| 2453 | G_MARKUP_COLLECT_INVALID)) |
| 2454 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2455 | } |
| 2456 | else if (strcmp (element_name, "columns") == 0 || |
| 2457 | strcmp (element_name, "data") == 0) |
| 2458 | { |
| 2459 | if (!_ctk_builder_check_parent (data->builder, context, "object", error)) |
| 2460 | return; |
| 2461 | |
| 2462 | if (!g_markup_collect_attributes (element_name, names, values, error, |
| 2463 | G_MARKUP_COLLECT_INVALID, NULL((void*)0), NULL((void*)0), |
| 2464 | G_MARKUP_COLLECT_INVALID)) |
| 2465 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2466 | } |
| 2467 | else if (strcmp (element_name, "column") == 0) |
| 2468 | { |
| 2469 | const gchar *type; |
| 2470 | |
| 2471 | if (!_ctk_builder_check_parent (data->builder, context, "columns", error)) |
| 2472 | return; |
| 2473 | |
| 2474 | if (!g_markup_collect_attributes (element_name, names, values, error, |
| 2475 | G_MARKUP_COLLECT_STRING, "type", &type, |
| 2476 | G_MARKUP_COLLECT_INVALID)) |
| 2477 | { |
| 2478 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2479 | return; |
| 2480 | } |
| 2481 | |
| 2482 | data->column_type_names = g_slist_prepend (data->column_type_names, g_strdup (type)g_strdup_inline (type)); |
| 2483 | } |
| 2484 | else |
| 2485 | { |
| 2486 | _ctk_builder_error_unhandled_tag (data->builder, context, |
| 2487 | "CtkListStore", element_name, |
| 2488 | error); |
| 2489 | } |
| 2490 | } |
| 2491 | |
| 2492 | static void |
| 2493 | list_store_end_element (GMarkupParseContext *context G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 2494 | const gchar *element_name, |
| 2495 | gpointer user_data, |
| 2496 | GError **error G_GNUC_UNUSED__attribute__ ((__unused__))) |
| 2497 | { |
| 2498 | SubParserData *data = (SubParserData*)user_data; |
| 2499 | |
| 2500 | g_assert (data->builder)do { if (data->builder) ; else g_assertion_message_expr ("Ctk" , "ctkliststore.c", 2500, ((const char*) (__func__)), "data->builder" ); } while (0); |
| 2501 | |
| 2502 | if (strcmp (element_name, "row") == 0) |
| 2503 | { |
| 2504 | CtkTreeIter iter; |
| 2505 | int i; |
| 2506 | |
| 2507 | ctk_list_store_insert_with_valuesv (CTK_LIST_STORE (data->object)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->object)), ((ctk_list_store_get_type ())))))), |
| 2508 | &iter, |
| 2509 | data->last_row, |
| 2510 | data->colids, |
| 2511 | data->values, |
| 2512 | data->row_column); |
| 2513 | for (i = 0; i < data->row_column; i++) |
| 2514 | { |
| 2515 | ColInfo *info = data->columns[i]; |
| 2516 | g_free (info->context); |
| 2517 | g_slice_free (ColInfo, info)do { if (1) g_slice_free1 (sizeof (ColInfo), (info)); else (void ) ((ColInfo*) 0 == (info)); } while (0); |
| 2518 | data->columns[i] = NULL((void*)0); |
| 2519 | g_value_unset (&data->values[i]); |
| 2520 | } |
| 2521 | g_free (data->values); |
| 2522 | data->values = g_new0 (GValue, data->n_columns)((GValue *) g_malloc0_n ((data->n_columns), sizeof (GValue ))); |
| 2523 | data->last_row++; |
| 2524 | data->row_column = 0; |
| 2525 | } |
| 2526 | else if (strcmp (element_name, "columns") == 0) |
| 2527 | { |
| 2528 | GType *column_types; |
| 2529 | GSList *l; |
| 2530 | int i; |
| 2531 | GType type; |
| 2532 | |
| 2533 | data->column_type_names = g_slist_reverse (data->column_type_names); |
| 2534 | column_types = g_new0 (GType, g_slist_length (data->column_type_names))((GType *) g_malloc0_n ((g_slist_length (data->column_type_names )), sizeof (GType))); |
| 2535 | |
| 2536 | for (l = data->column_type_names, i = 0; l; l = l->next, i++) |
| 2537 | { |
| 2538 | type = ctk_builder_get_type_from_name (data->builder, l->data); |
| 2539 | if (type == G_TYPE_INVALID((GType) ((0) << (2)))) |
| 2540 | { |
| 2541 | g_warning ("Unknown type %s specified in treemodel %s", |
| 2542 | (const gchar*)l->data, |
| 2543 | ctk_buildable_get_name (CTK_BUILDABLE (data->object)((((CtkBuildable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->object)), ((ctk_buildable_get_type ())))))))); |
| 2544 | continue; |
| 2545 | } |
| 2546 | column_types[i] = type; |
| 2547 | |
| 2548 | g_free (l->data); |
| 2549 | } |
| 2550 | |
| 2551 | ctk_list_store_set_column_types (CTK_LIST_STORE (data->object)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((data->object)), ((ctk_list_store_get_type ())))))), i, column_types); |
| 2552 | |
| 2553 | g_free (column_types); |
| 2554 | } |
| 2555 | else if (strcmp (element_name, "col") == 0) |
| 2556 | { |
| 2557 | data->is_data = FALSE(0); |
| 2558 | } |
| 2559 | } |
| 2560 | |
| 2561 | static void |
| 2562 | list_store_text (GMarkupParseContext *context, |
| 2563 | const gchar *text, |
| 2564 | gsize text_len, |
| 2565 | gpointer user_data, |
| 2566 | GError **error) |
| 2567 | { |
| 2568 | SubParserData *data = (SubParserData*)user_data; |
| 2569 | gint i; |
| 2570 | gchar *string; |
| 2571 | ColInfo *info; |
| 2572 | |
| 2573 | if (!data->is_data) |
| 2574 | return; |
| 2575 | |
| 2576 | i = data->row_column - 1; |
| 2577 | info = data->columns[i]; |
| 2578 | |
| 2579 | string = g_strndup (text, text_len); |
| 2580 | if (info->translatable && text_len) |
| 2581 | { |
| 2582 | gchar *translated; |
| 2583 | |
| 2584 | /* FIXME: This will not use the domain set in the .ui file, |
| 2585 | * since the parser is not telling the builder about the domain. |
| 2586 | * However, it will work for ctk_builder_set_translation_domain() calls. |
| 2587 | */ |
| 2588 | translated = g_strdup (_ctk_builder_parser_translate (data->domain,g_strdup_inline (_ctk_builder_parser_translate (data->domain , info->context, string)) |
| 2589 | info->context,g_strdup_inline (_ctk_builder_parser_translate (data->domain , info->context, string)) |
| 2590 | string))g_strdup_inline (_ctk_builder_parser_translate (data->domain , info->context, string)); |
| 2591 | g_free (string); |
| 2592 | string = translated; |
| 2593 | } |
| 2594 | |
| 2595 | if (!ctk_builder_value_from_string_type (data->builder, |
| 2596 | data->column_types[info->id], |
| 2597 | string, |
| 2598 | &data->values[i], |
| 2599 | error)) |
| 2600 | { |
| 2601 | _ctk_builder_prefix_error (data->builder, context, error); |
| 2602 | } |
| 2603 | g_free (string); |
| 2604 | } |
| 2605 | |
| 2606 | static const GMarkupParser list_store_parser = |
| 2607 | { |
| 2608 | .start_element = list_store_start_element, |
| 2609 | .end_element = list_store_end_element, |
| 2610 | .text = list_store_text |
| 2611 | }; |
| 2612 | |
| 2613 | static gboolean |
| 2614 | ctk_list_store_buildable_custom_tag_start (CtkBuildable *buildable, |
| 2615 | CtkBuilder *builder, |
| 2616 | GObject *child, |
| 2617 | const gchar *tagname, |
| 2618 | GMarkupParser *parser, |
| 2619 | gpointer *parser_data) |
| 2620 | { |
| 2621 | SubParserData *data; |
| 2622 | |
| 2623 | if (child) |
| 2624 | return FALSE(0); |
| 2625 | |
| 2626 | if (strcmp (tagname, "columns") == 0) |
| 2627 | { |
| 2628 | data = g_slice_new0 (SubParserData)((SubParserData*) g_slice_alloc0 (sizeof (SubParserData))); |
| 2629 | data->builder = builder; |
| 2630 | data->object = G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))); |
| 2631 | data->column_type_names = NULL((void*)0); |
| 2632 | |
| 2633 | *parser = list_store_parser; |
| 2634 | *parser_data = data; |
| 2635 | |
| 2636 | return TRUE(!(0)); |
| 2637 | } |
| 2638 | else if (strcmp (tagname, "data") == 0) |
| 2639 | { |
| 2640 | gint n_columns = ctk_list_store_get_n_columns (CTK_TREE_MODEL (buildable)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_tree_model_get_type ()))))))); |
| 2641 | if (n_columns == 0) |
| 2642 | g_error ("Cannot append data to an empty model"); |
| 2643 | |
| 2644 | data = g_slice_new0 (SubParserData)((SubParserData*) g_slice_alloc0 (sizeof (SubParserData))); |
| 2645 | data->builder = builder; |
| 2646 | data->object = G_OBJECT (buildable)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), (((GType) ((20) << (2)))))))); |
| 2647 | data->values = g_new0 (GValue, n_columns)((GValue *) g_malloc0_n ((n_columns), sizeof (GValue))); |
| 2648 | data->colids = g_new0 (gint, n_columns)((gint *) g_malloc0_n ((n_columns), sizeof (gint))); |
| 2649 | data->columns = g_new0 (ColInfo*, n_columns)((ColInfo* *) g_malloc0_n ((n_columns), sizeof (ColInfo*))); |
| 2650 | data->column_types = CTK_LIST_STORE (buildable)((((CtkListStore*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((buildable)), ((ctk_list_store_get_type ()))))))->priv->column_headers; |
| 2651 | data->n_columns = n_columns; |
| 2652 | data->last_row = 0; |
| 2653 | data->domain = ctk_builder_get_translation_domain (builder); |
| 2654 | |
| 2655 | *parser = list_store_parser; |
| 2656 | *parser_data = data; |
| 2657 | |
| 2658 | return TRUE(!(0)); |
| 2659 | } |
| 2660 | |
| 2661 | return FALSE(0); |
| 2662 | } |
| 2663 | |
| 2664 | static void |
| 2665 | ctk_list_store_buildable_custom_tag_end (CtkBuildable *buildable G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 2666 | CtkBuilder *builder G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 2667 | GObject *child G_GNUC_UNUSED__attribute__ ((__unused__)), |
| 2668 | const gchar *tagname, |
| 2669 | gpointer *parser_data) |
| 2670 | { |
| 2671 | SubParserData *data = (SubParserData*)parser_data; |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
| 2672 | |
| 2673 | if (strcmp (tagname, "columns") == 0) |
| 2674 | { |
| 2675 | g_slist_free (data->column_type_names); |
| 2676 | g_slice_free (SubParserData, data)do { if (1) g_slice_free1 (sizeof (SubParserData), (data)); else (void) ((SubParserData*) 0 == (data)); } while (0); |
| 2677 | } |
| 2678 | else if (strcmp (tagname, "data") == 0) |
| 2679 | { |
| 2680 | int i; |
| 2681 | for (i = 0; i < data->n_columns; i++) |
| 2682 | { |
| 2683 | ColInfo *info = data->columns[i]; |
| 2684 | if (info) |
| 2685 | { |
| 2686 | g_free (info->context); |
| 2687 | g_slice_free (ColInfo, info)do { if (1) g_slice_free1 (sizeof (ColInfo), (info)); else (void ) ((ColInfo*) 0 == (info)); } while (0); |
| 2688 | } |
| 2689 | } |
| 2690 | g_free (data->colids); |
| 2691 | g_free (data->columns); |
| 2692 | g_free (data->values); |
| 2693 | g_slice_free (SubParserData, data)do { if (1) g_slice_free1 (sizeof (SubParserData), (data)); else (void) ((SubParserData*) 0 == (data)); } while (0); |
| 2694 | } |
| 2695 | } |