File: | ctk/inspector/prop-list.c |
Warning: | line 441, column 42 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 | /* |
2 | * Copyright (c) 2008-2009 Christian Hammond |
3 | * Copyright (c) 2008-2009 David Trowbridge |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a |
6 | * copy of this software and associated documentation files (the "Software"), |
7 | * to deal in the Software without restriction, including without limitation |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 | * and/or sell copies of the Software, and to permit persons to whom the |
10 | * Software is furnished to do so, subject to the following conditions: |
11 | * |
12 | * The above copyright notice and this permission notice shall be included |
13 | * in all copies or substantial portions of the Software. |
14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21 | * THE SOFTWARE. |
22 | */ |
23 | |
24 | #include "config.h" |
25 | #include <glib/gi18n-lib.h> |
26 | |
27 | #include "prop-list.h" |
28 | |
29 | #include "prop-editor.h" |
30 | #include "object-tree.h" |
31 | |
32 | #include "ctkcelllayout.h" |
33 | #include "ctktreeview.h" |
34 | #include "ctktreeselection.h" |
35 | #include "ctkpopover.h" |
36 | #include "ctksearchentry.h" |
37 | #include "ctklabel.h" |
38 | #include "ctkstack.h" |
39 | |
40 | enum |
41 | { |
42 | COLUMN_NAME, |
43 | COLUMN_VALUE, |
44 | COLUMN_TYPE, |
45 | COLUMN_DEFINED_AT, |
46 | COLUMN_TOOLTIP, |
47 | COLUMN_WRITABLE, |
48 | COLUMN_ATTRIBUTE |
49 | }; |
50 | |
51 | enum |
52 | { |
53 | PROP_0, |
54 | PROP_OBJECT_TREE, |
55 | PROP_CHILD_PROPERTIES, |
56 | PROP_SEARCH_ENTRY |
57 | }; |
58 | |
59 | struct _CtkInspectorPropListPrivate |
60 | { |
61 | GObject *object; |
62 | CtkListStore *model; |
63 | GHashTable *prop_iters; |
64 | gulong notify_handler_id; |
65 | CtkInspectorObjectTree *object_tree; |
66 | gboolean child_properties; |
67 | CtkTreeViewColumn *name_column; |
68 | CtkTreeViewColumn *attribute_column; |
69 | CtkWidget *tree; |
70 | CtkWidget *search_entry; |
71 | CtkWidget *search_stack; |
72 | }; |
73 | |
74 | G_DEFINE_TYPE_WITH_PRIVATE (CtkInspectorPropList, ctk_inspector_prop_list, CTK_TYPE_BOX)static void ctk_inspector_prop_list_init (CtkInspectorPropList *self); static void ctk_inspector_prop_list_class_init (CtkInspectorPropListClass *klass); static GType ctk_inspector_prop_list_get_type_once ( void); static gpointer ctk_inspector_prop_list_parent_class = ((void*)0); static gint CtkInspectorPropList_private_offset; static void ctk_inspector_prop_list_class_intern_init (gpointer klass) { ctk_inspector_prop_list_parent_class = g_type_class_peek_parent (klass); if (CtkInspectorPropList_private_offset != 0) g_type_class_adjust_private_offset (klass, &CtkInspectorPropList_private_offset); ctk_inspector_prop_list_class_init ((CtkInspectorPropListClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer ctk_inspector_prop_list_get_instance_private (CtkInspectorPropList *self) { return (((gpointer) ((guint8* ) (self) + (glong) (CtkInspectorPropList_private_offset)))); } GType ctk_inspector_prop_list_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_inspector_prop_list_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_inspector_prop_list_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((ctk_box_get_type ()), g_intern_static_string ("CtkInspectorPropList" ), sizeof (CtkInspectorPropListClass), (GClassInitFunc)(void ( *)(void)) ctk_inspector_prop_list_class_intern_init, sizeof ( CtkInspectorPropList), (GInstanceInitFunc)(void (*)(void)) ctk_inspector_prop_list_init , (GTypeFlags) 0); { {{ CtkInspectorPropList_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (CtkInspectorPropListPrivate )); };} } return g_define_type_id; } |
75 | |
76 | static void |
77 | search_close_clicked (CtkWidget *button G_GNUC_UNUSED__attribute__ ((__unused__)), |
78 | CtkInspectorPropList *pl) |
79 | { |
80 | ctk_entry_set_text (CTK_ENTRY (pl->priv->search_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_entry)), ((ctk_entry_get_type ()) ))))), ""); |
81 | ctk_stack_set_visible_child_name (CTK_STACK (pl->priv->search_stack)((((CtkStack*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_stack)), ((ctk_stack_get_type ()) ))))), "title"); |
82 | } |
83 | |
84 | static gboolean |
85 | key_press_event (CtkWidget *window G_GNUC_UNUSED__attribute__ ((__unused__)), |
86 | CdkEvent *event, |
87 | CtkInspectorPropList *pl) |
88 | { |
89 | if (!ctk_widget_get_mapped (CTK_WIDGET (pl)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl)), ((ctk_widget_get_type ())))))))) |
90 | return CDK_EVENT_PROPAGATE((0)); |
91 | |
92 | if (ctk_search_entry_handle_event (CTK_SEARCH_ENTRY (pl->priv->search_entry)((((CtkSearchEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_entry)), ((ctk_search_entry_get_type ())))))), event)) |
93 | { |
94 | ctk_stack_set_visible_child (CTK_STACK (pl->priv->search_stack)((((CtkStack*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_stack)), ((ctk_stack_get_type ()) ))))), pl->priv->search_entry); |
95 | return CDK_EVENT_STOP((!(0))); |
96 | } |
97 | return CDK_EVENT_PROPAGATE((0)); |
98 | } |
99 | |
100 | static void |
101 | hierarchy_changed (CtkWidget *widget, |
102 | CtkWidget *previous_toplevel) |
103 | { |
104 | if (previous_toplevel) |
105 | g_signal_handlers_disconnect_by_func (previous_toplevel, key_press_event, widget)g_signal_handlers_disconnect_matched ((previous_toplevel), (GSignalMatchType ) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*) 0), (key_press_event), (widget)); |
106 | g_signal_connect (ctk_widget_get_toplevel (widget), "key-press-event",g_signal_connect_data ((ctk_widget_get_toplevel (widget)), ("key-press-event" ), (((GCallback) (key_press_event))), (widget), ((void*)0), ( GConnectFlags) 0) |
107 | G_CALLBACK (key_press_event), widget)g_signal_connect_data ((ctk_widget_get_toplevel (widget)), ("key-press-event" ), (((GCallback) (key_press_event))), (widget), ((void*)0), ( GConnectFlags) 0); |
108 | } |
109 | |
110 | static void |
111 | ctk_inspector_prop_list_init (CtkInspectorPropList *pl) |
112 | { |
113 | pl->priv = ctk_inspector_prop_list_get_instance_private (pl); |
114 | ctk_widget_init_template (CTK_WIDGET (pl)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl)), ((ctk_widget_get_type ()))))))); |
115 | ctk_tree_sortable_set_sort_column_id (CTK_TREE_SORTABLE (pl->priv->model)((((CtkTreeSortable*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->model)), ((ctk_tree_sortable_get_type () )))))), |
116 | COLUMN_NAME, |
117 | CTK_SORT_ASCENDING); |
118 | pl->priv->prop_iters = g_hash_table_new_full (g_str_hash, |
119 | g_str_equal, |
120 | NULL((void*)0), |
121 | (GDestroyNotify) ctk_tree_iter_free); |
122 | } |
123 | |
124 | static void |
125 | get_property (GObject *object, |
126 | guint param_id, |
127 | GValue *value, |
128 | GParamSpec *pspec) |
129 | { |
130 | CtkInspectorPropList *pl = CTK_INSPECTOR_PROP_LIST (object)((((CtkInspectorPropList*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_inspector_prop_list_get_type ())))))); |
131 | |
132 | switch (param_id) |
133 | { |
134 | case PROP_OBJECT_TREE: |
135 | g_value_take_object (value, pl->priv->object_tree); |
136 | break; |
137 | |
138 | case PROP_CHILD_PROPERTIES: |
139 | g_value_set_boolean (value, pl->priv->child_properties); |
140 | break; |
141 | |
142 | case PROP_SEARCH_ENTRY: |
143 | g_value_take_object (value, pl->priv->search_entry); |
144 | break; |
145 | |
146 | default: |
147 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "inspector/prop-list.c", 147, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
148 | break; |
149 | } |
150 | } |
151 | |
152 | static void |
153 | set_property (GObject *object, |
154 | guint param_id, |
155 | const GValue *value, |
156 | GParamSpec *pspec) |
157 | { |
158 | CtkInspectorPropList *pl = CTK_INSPECTOR_PROP_LIST (object)((((CtkInspectorPropList*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_inspector_prop_list_get_type ())))))); |
159 | |
160 | switch (param_id) |
161 | { |
162 | case PROP_OBJECT_TREE: |
163 | pl->priv->object_tree = g_value_get_object (value); |
164 | break; |
165 | |
166 | case PROP_CHILD_PROPERTIES: |
167 | pl->priv->child_properties = g_value_get_boolean (value); |
168 | break; |
169 | |
170 | case PROP_SEARCH_ENTRY: |
171 | pl->priv->search_entry = g_value_get_object (value); |
172 | break; |
173 | |
174 | default: |
175 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((param_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "inspector/prop-list.c", 175, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
176 | break; |
177 | } |
178 | } |
179 | |
180 | static void |
181 | show_object (CtkInspectorPropEditor *editor, |
182 | GObject *object, |
183 | const gchar *name, |
184 | const gchar *tab, |
185 | CtkInspectorPropList *pl) |
186 | { |
187 | CtkTreeIter iter; |
188 | CtkWidget *popover; |
189 | |
190 | popover = ctk_widget_get_ancestor (CTK_WIDGET (editor)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((editor)), ((ctk_widget_get_type ())))))), CTK_TYPE_POPOVER(ctk_popover_get_type ())); |
191 | ctk_widget_hide (popover); |
192 | |
193 | g_object_set_data (G_OBJECT (pl->priv->object_tree)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->object_tree)), (((GType) ((20) << ( 2)))))))), "next-tab", (gpointer)tab); |
194 | if (ctk_inspector_object_tree_find_object (pl->priv->object_tree, object, &iter)) |
195 | { |
196 | ctk_inspector_object_tree_select_object (pl->priv->object_tree, object); |
197 | } |
198 | else if (ctk_inspector_object_tree_find_object (pl->priv->object_tree, pl->priv->object, &iter)) |
199 | { |
200 | ctk_inspector_object_tree_append_object (pl->priv->object_tree, object, &iter, name); |
201 | ctk_inspector_object_tree_select_object (pl->priv->object_tree, object); |
202 | } |
203 | else |
204 | { |
205 | g_warning ("CtkInspector: couldn't find the widget in the tree"); |
206 | } |
207 | } |
208 | |
209 | static void |
210 | row_activated (CtkTreeView *tv, |
211 | CtkTreePath *path, |
212 | CtkTreeViewColumn *col, |
213 | CtkInspectorPropList *pl) |
214 | { |
215 | CtkTreeIter iter; |
216 | CdkRectangle rect; |
217 | gchar *name; |
218 | CtkWidget *editor; |
219 | CtkWidget *popover; |
220 | |
221 | ctk_tree_model_get_iter (CTK_TREE_MODEL (pl->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->model)), ((ctk_tree_model_get_type ()))) ))), &iter, path); |
222 | ctk_tree_model_get (CTK_TREE_MODEL (pl->priv->model)((((CtkTreeModel*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->model)), ((ctk_tree_model_get_type ()))) ))), &iter, COLUMN_NAME, &name, -1); |
223 | ctk_tree_view_get_cell_area (tv, path, col, &rect); |
224 | ctk_tree_view_convert_bin_window_to_widget_coords (tv, rect.x, rect.y, &rect.x, &rect.y); |
225 | |
226 | popover = ctk_popover_new (CTK_WIDGET (tv)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((tv)), ((ctk_widget_get_type ()))))))); |
227 | ctk_popover_set_pointing_to (CTK_POPOVER (popover)((((CtkPopover*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((popover)), ((ctk_popover_get_type ())))))), &rect); |
228 | |
229 | editor = ctk_inspector_prop_editor_new (pl->priv->object, name, pl->priv->child_properties); |
230 | ctk_widget_show (editor); |
231 | |
232 | ctk_container_add (CTK_CONTAINER (popover)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((popover)), ((ctk_container_get_type ())))))), editor); |
233 | |
234 | if (ctk_inspector_prop_editor_should_expand (CTK_INSPECTOR_PROP_EDITOR (editor)((((CtkInspectorPropEditor*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((editor)), ((ctk_inspector_prop_editor_get_type ())))))))) |
235 | ctk_widget_set_vexpand (popover, TRUE(!(0))); |
236 | |
237 | g_signal_connect (editor, "show-object", G_CALLBACK (show_object), pl)g_signal_connect_data ((editor), ("show-object"), (((GCallback ) (show_object))), (pl), ((void*)0), (GConnectFlags) 0); |
238 | |
239 | ctk_popover_popup (CTK_POPOVER (popover)((((CtkPopover*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((popover)), ((ctk_popover_get_type ()))))))); |
240 | |
241 | g_signal_connect (popover, "unmap", G_CALLBACK (ctk_widget_destroy), NULL)g_signal_connect_data ((popover), ("unmap"), (((GCallback) (ctk_widget_destroy ))), (((void*)0)), ((void*)0), (GConnectFlags) 0); |
242 | |
243 | g_free (name); |
244 | } |
245 | |
246 | static void cleanup_object (CtkInspectorPropList *pl); |
247 | |
248 | static void |
249 | finalize (GObject *object) |
250 | { |
251 | CtkInspectorPropList *pl = CTK_INSPECTOR_PROP_LIST (object)((((CtkInspectorPropList*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_inspector_prop_list_get_type ())))))); |
252 | |
253 | cleanup_object (pl); |
254 | g_hash_table_unref (pl->priv->prop_iters); |
255 | |
256 | G_OBJECT_CLASS (ctk_inspector_prop_list_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((ctk_inspector_prop_list_parent_class)), (((GType) ((20) << (2))))))))->finalize (object); |
257 | } |
258 | |
259 | static void |
260 | constructed (GObject *object) |
261 | { |
262 | CtkInspectorPropList *pl = CTK_INSPECTOR_PROP_LIST (object)((((CtkInspectorPropList*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((object)), ((ctk_inspector_prop_list_get_type ())))))); |
263 | |
264 | pl->priv->search_stack = ctk_widget_get_parent (pl->priv->search_entry); |
265 | |
266 | ctk_tree_view_set_search_entry (CTK_TREE_VIEW (pl->priv->tree)((((CtkTreeView*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->tree)), ((ctk_tree_view_get_type ()))))) ), |
267 | CTK_ENTRY (pl->priv->search_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_entry)), ((ctk_entry_get_type ()) )))))); |
268 | |
269 | g_signal_connect (pl->priv->search_entry, "stop-search",g_signal_connect_data ((pl->priv->search_entry), ("stop-search" ), (((GCallback) (search_close_clicked))), (pl), ((void*)0), ( GConnectFlags) 0) |
270 | G_CALLBACK (search_close_clicked), pl)g_signal_connect_data ((pl->priv->search_entry), ("stop-search" ), (((GCallback) (search_close_clicked))), (pl), ((void*)0), ( GConnectFlags) 0); |
271 | } |
272 | |
273 | static void |
274 | ctk_inspector_prop_list_class_init (CtkInspectorPropListClass *klass) |
275 | { |
276 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (((GType) ((20) << (2)))))))); |
277 | CtkWidgetClass *widget_class = CTK_WIDGET_CLASS (klass)((((CtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), ((ctk_widget_get_type ())))))); |
278 | |
279 | object_class->finalize = finalize; |
280 | object_class->get_property = get_property; |
281 | object_class->set_property = set_property; |
282 | object_class->constructed = constructed; |
283 | |
284 | g_object_class_install_property (object_class, PROP_OBJECT_TREE, |
285 | g_param_spec_object ("object-tree", "Object Tree", "Object tree", |
286 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
287 | g_object_class_install_property (object_class, PROP_CHILD_PROPERTIES, |
288 | g_param_spec_boolean ("child-properties", "Child properties", "Child properties", |
289 | FALSE(0), G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
290 | |
291 | g_object_class_install_property (object_class, PROP_SEARCH_ENTRY, |
292 | g_param_spec_object ("search-entry", "Search Entry", "Search Entry", |
293 | CTK_TYPE_WIDGET(ctk_widget_get_type ()), G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); |
294 | |
295 | ctk_widget_class_set_template_from_resource (widget_class, "/org/ctk/libctk/inspector/prop-list.ui"); |
296 | ctk_widget_class_bind_template_child_private (widget_class, CtkInspectorPropList, model)ctk_widget_class_bind_template_child_full (widget_class, "model" , (0), (CtkInspectorPropList_private_offset + (((glong) __builtin_offsetof (CtkInspectorPropListPrivate, model))))); |
297 | ctk_widget_class_bind_template_child_private (widget_class, CtkInspectorPropList, attribute_column)ctk_widget_class_bind_template_child_full (widget_class, "attribute_column" , (0), (CtkInspectorPropList_private_offset + (((glong) __builtin_offsetof (CtkInspectorPropListPrivate, attribute_column))))); |
298 | ctk_widget_class_bind_template_child_private (widget_class, CtkInspectorPropList, tree)ctk_widget_class_bind_template_child_full (widget_class, "tree" , (0), (CtkInspectorPropList_private_offset + (((glong) __builtin_offsetof (CtkInspectorPropListPrivate, tree))))); |
299 | ctk_widget_class_bind_template_callback (widget_class, row_activated)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "row_activated", ((GCallback ) (row_activated))); |
300 | ctk_widget_class_bind_template_callback (widget_class, search_close_clicked)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "search_close_clicked", ( (GCallback) (search_close_clicked))); |
301 | ctk_widget_class_bind_template_callback (widget_class, hierarchy_changed)ctk_widget_class_bind_template_callback_full (((((CtkWidgetClass *) (void *) g_type_check_class_cast ((GTypeClass*) ((widget_class )), ((ctk_widget_get_type ())))))), "hierarchy_changed", ((GCallback ) (hierarchy_changed))); |
302 | } |
303 | |
304 | /* Like g_strdup_value_contents, but keeps the type name separate */ |
305 | static void |
306 | strdup_value_contents (const GValue *value, |
307 | gchar **contents, |
308 | gchar **type) |
309 | { |
310 | const gchar *src; |
311 | |
312 | if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((16) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
313 | { |
314 | src = g_value_get_string (value); |
315 | |
316 | *type = g_strdup ("char*")g_strdup_inline ("char*"); |
317 | |
318 | if (!src) |
319 | { |
320 | *contents = g_strdup ("NULL")g_strdup_inline ("NULL"); |
321 | } |
322 | else |
323 | { |
324 | gchar *s = g_strescape (src, NULL((void*)0)); |
325 | *contents = g_strdup_printf ("\"%s\"", s); |
326 | g_free (s); |
327 | } |
328 | } |
329 | else if (g_value_type_transformable (G_VALUE_TYPE (value)(((GValue*) (value))->g_type), G_TYPE_STRING((GType) ((16) << (2))))) |
330 | { |
331 | GValue tmp_value = G_VALUE_INIT{ 0, { { 0 } } }; |
332 | |
333 | *type = g_strdup (g_type_name (G_VALUE_TYPE (value)))g_strdup_inline (g_type_name ((((GValue*) (value))->g_type ))); |
334 | |
335 | g_value_init (&tmp_value, G_TYPE_STRING((GType) ((16) << (2)))); |
336 | g_value_transform (value, &tmp_value); |
337 | src = g_value_get_string (&tmp_value); |
338 | if (!src) |
339 | *contents = g_strdup ("NULL")g_strdup_inline ("NULL"); |
340 | else |
341 | *contents = g_strescape (src, NULL((void*)0)); |
342 | g_value_unset (&tmp_value); |
343 | } |
344 | else if (g_value_fits_pointer (value)) |
345 | { |
346 | gpointer p = g_value_peek_pointer (value); |
347 | |
348 | if (!p) |
349 | { |
350 | *type = g_strdup (g_type_name (G_VALUE_TYPE (value)))g_strdup_inline (g_type_name ((((GValue*) (value))->g_type ))); |
351 | *contents = g_strdup ("NULL")g_strdup_inline ("NULL"); |
352 | } |
353 | else if (G_VALUE_HOLDS_OBJECT (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((20) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
354 | { |
355 | *type = g_strdup (G_OBJECT_TYPE_NAME (p))g_strdup_inline ((g_type_name ((((((GTypeClass*) (((GTypeInstance *) (p))->g_class))->g_type)))))); |
356 | *contents = g_strdup_printf ("%p", p); |
357 | } |
358 | else if (G_VALUE_HOLDS_PARAM (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((19) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
359 | { |
360 | *type = g_strdup (G_PARAM_SPEC_TYPE_NAME (p))g_strdup_inline ((g_type_name ((((((GTypeClass*) (((GTypeInstance *) (p))->g_class))->g_type)))))); |
361 | *contents = g_strdup_printf ("%p", p); |
362 | } |
363 | else if (G_VALUE_HOLDS (value, G_TYPE_STRV)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((g_strv_get_type ()))); gboolean __r; if (! __val) __r = (0); else if (__val->g_type == __t) __r = (!( 0)); else __r = g_type_check_value_holds (__val, __t); __r; } ))))) |
364 | { |
365 | GStrv strv = g_value_get_boxed (value); |
366 | GString *tmp = g_string_new ("["); |
367 | |
368 | while (*strv != NULL((void*)0)) |
369 | { |
370 | gchar *escaped = g_strescape (*strv, NULL((void*)0)); |
371 | |
372 | g_string_append_printf (tmp, "\"%s\"", escaped); |
373 | g_free (escaped); |
374 | |
375 | if (*++strv != NULL((void*)0)) |
376 | g_string_append (tmp, ", ")(__builtin_constant_p (", ") ? __extension__ ({ const char * const __val = (", "); g_string_append_len_inline (tmp, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize ) -1); }) : g_string_append_len_inline (tmp, ", ", (gssize) - 1)); |
377 | } |
378 | |
379 | g_string_append (tmp, "]")(__builtin_constant_p ("]") ? __extension__ ({ const char * const __val = ("]"); g_string_append_len_inline (tmp, __val, (__val != ((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize ) -1); }) : g_string_append_len_inline (tmp, "]", (gssize) -1 )); |
380 | *type = g_strdup ("char**")g_strdup_inline ("char**"); |
381 | *contents = g_string_free (tmp, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((tmp) , ((0))) : g_string_free_and_steal (tmp)) : (g_string_free) ( (tmp), ((0)))); |
382 | } |
383 | else if (G_VALUE_HOLDS_BOXED (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((18) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
384 | { |
385 | *type = g_strdup (g_type_name (G_VALUE_TYPE (value)))g_strdup_inline (g_type_name ((((GValue*) (value))->g_type ))); |
386 | *contents = g_strdup_printf ("%p", p); |
387 | } |
388 | else if (G_VALUE_HOLDS_POINTER (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((17) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
389 | { |
390 | *type = g_strdup ("gpointer")g_strdup_inline ("gpointer"); |
391 | *contents = g_strdup_printf ("%p", p); |
392 | } |
393 | else |
394 | { |
395 | *type = g_strdup ("???")g_strdup_inline ("???"); |
396 | *contents = g_strdup ("???")g_strdup_inline ("???"); |
397 | } |
398 | } |
399 | else |
400 | { |
401 | *type = g_strdup ("???")g_strdup_inline ("???"); |
402 | *contents = g_strdup ("???")g_strdup_inline ("???"); |
403 | } |
404 | } |
405 | |
406 | static void |
407 | ctk_inspector_prop_list_update_prop (CtkInspectorPropList *pl, |
408 | CtkTreeIter *iter, |
409 | GParamSpec *prop) |
410 | { |
411 | GValue gvalue = {0}; |
412 | gchar *value; |
413 | gchar *type; |
414 | gchar *attribute = NULL((void*)0); |
415 | gboolean writable; |
416 | |
417 | g_value_init (&gvalue, prop->value_type); |
418 | if (pl->priv->child_properties) |
419 | { |
420 | CtkWidget *parent; |
421 | |
422 | parent = ctk_widget_get_parent (CTK_WIDGET (pl->priv->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->object)), ((ctk_widget_get_type ()))))))); |
423 | ctk_container_child_get_property (CTK_CONTAINER (parent)((((CtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((parent)), ((ctk_container_get_type ())))))), |
424 | CTK_WIDGET (pl->priv->object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->object)), ((ctk_widget_get_type ())))))), |
425 | prop->name, &gvalue); |
426 | } |
427 | else |
428 | g_object_get_property (pl->priv->object, prop->name, &gvalue); |
429 | |
430 | strdup_value_contents (&gvalue, &value, &type); |
431 | |
432 | if (CTK_IS_CELL_RENDERER (pl->priv->object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (pl->priv->object)); GType __t = ((ctk_cell_renderer_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; }))))) |
433 | { |
434 | gpointer *layout; |
435 | CtkCellArea *area; |
436 | gint column = -1; |
437 | |
438 | area = NULL((void*)0); |
439 | layout = g_object_get_data (pl->priv->object, "ctk-inspector-cell-layout"); |
440 | if (layout) |
441 | area = ctk_cell_layout_get_area (CTK_CELL_LAYOUT (layout)((((CtkCellLayout*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((layout)), ((ctk_cell_layout_get_type ()))))))); |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
442 | if (area) |
443 | column = ctk_cell_area_attribute_get_column (area, |
444 | CTK_CELL_RENDERER (pl->priv->object)((((CtkCellRenderer*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->object)), ((ctk_cell_renderer_get_type ( ))))))), |
445 | prop->name); |
446 | |
447 | if (column != -1) |
448 | attribute = g_strdup_printf ("%d", column); |
449 | } |
450 | |
451 | writable = ((prop->flags & G_PARAM_WRITABLE) != 0) && |
452 | ((prop->flags & G_PARAM_CONSTRUCT_ONLY) == 0); |
453 | |
454 | ctk_list_store_set (pl->priv->model, iter, |
455 | COLUMN_NAME, prop->name, |
456 | COLUMN_VALUE, value ? value : "", |
457 | COLUMN_TYPE, type ? type : "", |
458 | COLUMN_DEFINED_AT, g_type_name (prop->owner_type), |
459 | COLUMN_TOOLTIP, g_param_spec_get_blurb (prop), |
460 | COLUMN_WRITABLE, writable, |
461 | COLUMN_ATTRIBUTE, attribute ? attribute : "", |
462 | -1); |
463 | |
464 | g_free (value); |
465 | g_free (type); |
466 | g_free (attribute); |
467 | g_value_unset (&gvalue); |
468 | } |
469 | |
470 | static void |
471 | ctk_inspector_prop_list_prop_changed_cb (GObject *pspec G_GNUC_UNUSED__attribute__ ((__unused__)), |
472 | GParamSpec *prop, |
473 | CtkInspectorPropList *pl) |
474 | { |
475 | CtkTreeIter *iter; |
476 | |
477 | if (!pl->priv->object) |
478 | return; |
479 | |
480 | iter = g_hash_table_lookup (pl->priv->prop_iters, prop->name); |
481 | if (iter != NULL((void*)0)) |
482 | ctk_inspector_prop_list_update_prop (pl, iter, prop); |
483 | } |
484 | |
485 | static void |
486 | cleanup_object (CtkInspectorPropList *pl) |
487 | { |
488 | if (pl->priv->object && |
489 | g_signal_handler_is_connected (pl->priv->object, pl->priv->notify_handler_id)) |
490 | g_signal_handler_disconnect (pl->priv->object, pl->priv->notify_handler_id); |
491 | |
492 | pl->priv->object = NULL((void*)0); |
493 | pl->priv->notify_handler_id = 0; |
494 | |
495 | g_hash_table_remove_all (pl->priv->prop_iters); |
496 | if (pl->priv->model) |
497 | ctk_list_store_clear (pl->priv->model); |
498 | } |
499 | |
500 | gboolean |
501 | ctk_inspector_prop_list_set_object (CtkInspectorPropList *pl, |
502 | GObject *object) |
503 | { |
504 | CtkTreeIter iter; |
505 | GParamSpec **props; |
506 | guint num_properties; |
507 | guint i; |
508 | |
509 | if (!object) |
510 | return FALSE(0); |
511 | |
512 | if (pl->priv->object == object) |
513 | return TRUE(!(0)); |
514 | |
515 | cleanup_object (pl); |
516 | |
517 | ctk_entry_set_text (CTK_ENTRY (pl->priv->search_entry)((((CtkEntry*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_entry)), ((ctk_entry_get_type ()) ))))), ""); |
518 | ctk_stack_set_visible_child_name (CTK_STACK (pl->priv->search_stack)((((CtkStack*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl->priv->search_stack)), ((ctk_stack_get_type ()) ))))), "title"); |
519 | |
520 | if (pl->priv->child_properties) |
521 | { |
522 | CtkWidget *parent; |
523 | |
524 | if (!CTK_IS_WIDGET (object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ctk_widget_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; }))))) |
525 | { |
526 | ctk_widget_hide (CTK_WIDGET (pl)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl)), ((ctk_widget_get_type ()))))))); |
527 | return TRUE(!(0)); |
528 | } |
529 | |
530 | parent = ctk_widget_get_parent (CTK_WIDGET (object)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((object)), ((ctk_widget_get_type ()))))))); |
531 | if (!parent) |
532 | { |
533 | ctk_widget_hide (CTK_WIDGET (pl)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl)), ((ctk_widget_get_type ()))))))); |
534 | return TRUE(!(0)); |
535 | } |
536 | |
537 | ctk_tree_view_column_set_visible (pl->priv->attribute_column, FALSE(0)); |
538 | |
539 | props = ctk_container_class_list_child_properties (G_OBJECT_GET_CLASS (parent)((((GObjectClass*) (((GTypeInstance*) ((parent)))->g_class )))), &num_properties); |
540 | } |
541 | else |
542 | { |
543 | ctk_tree_view_column_set_visible (pl->priv->attribute_column, CTK_IS_CELL_RENDERER (object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ctk_cell_renderer_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; }))))); |
544 | |
545 | props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object)((((GObjectClass*) (((GTypeInstance*) ((object)))->g_class )))), &num_properties); |
546 | } |
547 | |
548 | pl->priv->object = object; |
549 | |
550 | for (i = 0; i < num_properties; i++) |
551 | { |
552 | GParamSpec *prop = props[i]; |
553 | |
554 | if (! (prop->flags & G_PARAM_READABLE)) |
555 | continue; |
556 | |
557 | ctk_list_store_append (pl->priv->model, &iter); |
558 | ctk_inspector_prop_list_update_prop (pl, &iter, prop); |
559 | |
560 | g_hash_table_insert (pl->priv->prop_iters, (gpointer) prop->name, ctk_tree_iter_copy (&iter)); |
561 | } |
562 | |
563 | g_free (props); |
564 | |
565 | if (CTK_IS_WIDGET (object)(((__extension__ ({ GTypeInstance *__inst = (GTypeInstance*) ( (object)); GType __t = ((ctk_widget_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; }))))) |
566 | g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object)((GCallback) (cleanup_object)), pl, G_CONNECT_SWAPPED); |
567 | |
568 | /* Listen for updates */ |
569 | pl->priv->notify_handler_id = |
570 | g_signal_connect_object (object, |
571 | pl->priv->child_properties ? "child-notify" : "notify", |
572 | G_CALLBACK (ctk_inspector_prop_list_prop_changed_cb)((GCallback) (ctk_inspector_prop_list_prop_changed_cb)), |
573 | pl, 0); |
574 | |
575 | ctk_widget_show (CTK_WIDGET (pl)((((CtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((pl)), ((ctk_widget_get_type ()))))))); |
576 | |
577 | return TRUE(!(0)); |
578 | } |