Bug Summary

File:cut-n-paste/toolbar-editor/egg-toolbars-model.c
Warning:line 101, column 15
Value stored to 'node' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name egg-toolbars-model.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/cut-n-paste/toolbar-editor -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -D HAVE_CONFIG_H -I . -I ../.. -I ../../lib/egg -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/cafe-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/ctk-3.0/unix-print -I /usr/local/include/libbean-1.0 -I /usr/include/gobject-introspection-1.0 -I /usr/include/exempi-2.0 -I /usr/include/librsvg-2.0 -I /usr/include/libxml2 -D CURSOR_DIR="/usr/local/share/eoc" -D PIC -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir=/rootdir/cut-n-paste/toolbar-editor -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-06-09-093133-31414-1 -x c egg-toolbars-model.c
1/*
2 * Copyright (C) 2002-2004 Marco Pesenti Gritti
3 * Copyright (C) 2004 Christian Persch
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 * $Id: egg-toolbars-model.c 929 2009-02-19 14:49:56Z friemann $
20 */
21
22#include "config.h"
23
24#include "egg-toolbars-model.h"
25#include "eggtypebuiltins.h"
26#include "eggmarshalers.h"
27
28#include <unistd.h>
29#include <string.h>
30#include <libxml/tree.h>
31#include <cdk/cdk.h>
32
33static void egg_toolbars_model_finalize (GObject *object);
34
35enum
36{
37 ITEM_ADDED,
38 ITEM_REMOVED,
39 TOOLBAR_ADDED,
40 TOOLBAR_CHANGED,
41 TOOLBAR_REMOVED,
42 LAST_SIGNAL
43};
44
45typedef struct
46{
47 char *name;
48 EggTbModelFlags flags;
49} EggToolbarsToolbar;
50
51typedef struct
52{
53 char *name;
54} EggToolbarsItem;
55
56static guint signals[LAST_SIGNAL] = { 0 };
57
58struct EggToolbarsModelPrivate
59{
60 GNode *toolbars;
61 GList *types;
62 GHashTable *flags;
63};
64
65G_DEFINE_TYPE_WITH_PRIVATE (EggToolbarsModel, egg_toolbars_model, G_TYPE_OBJECT)static void egg_toolbars_model_init (EggToolbarsModel *self);
static void egg_toolbars_model_class_init (EggToolbarsModelClass
*klass); static GType egg_toolbars_model_get_type_once (void
); static gpointer egg_toolbars_model_parent_class = ((void*)
0); static gint EggToolbarsModel_private_offset; static void egg_toolbars_model_class_intern_init
(gpointer klass) { egg_toolbars_model_parent_class = g_type_class_peek_parent
(klass); if (EggToolbarsModel_private_offset != 0) g_type_class_adjust_private_offset
(klass, &EggToolbarsModel_private_offset); egg_toolbars_model_class_init
((EggToolbarsModelClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer egg_toolbars_model_get_instance_private
(EggToolbarsModel *self) { return (((gpointer) ((guint8*) (self
) + (glong) (EggToolbarsModel_private_offset)))); } GType egg_toolbars_model_get_type
(void) { static gsize 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 (&static_g_define_type_id
)); }))) { GType g_define_type_id = egg_toolbars_model_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 ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType egg_toolbars_model_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("EggToolbarsModel"
), sizeof (EggToolbarsModelClass), (GClassInitFunc)(void (*)(
void)) egg_toolbars_model_class_intern_init, sizeof (EggToolbarsModel
), (GInstanceInitFunc)(void (*)(void)) egg_toolbars_model_init
, (GTypeFlags) 0); { {{ EggToolbarsModel_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (EggToolbarsModelPrivate)); };} } return
g_define_type_id; }
66
67static xmlDocPtr
68egg_toolbars_model_to_xml (EggToolbarsModel *model)
69{
70 GNode *l1, *l2, *tl;
71 GList *l3;
72 xmlDocPtr doc;
73
74 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), NULL)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
(((void*)0)); } } while (0)
;
75
76 tl = model->priv->toolbars;
77
78 xmlIndentTreeOutput(*(__xmlIndentTreeOutput())) = TRUE(!(0));
79 doc = xmlNewDoc ((const xmlChar*) "1.0");
80 doc->children = xmlNewDocNode (doc, NULL((void*)0), (const xmlChar*) "toolbars", NULL((void*)0));
81
82 for (l1 = tl->children; l1 != NULL((void*)0); l1 = l1->next)
83 {
84 xmlNodePtr tnode;
85 EggToolbarsToolbar *toolbar = l1->data;
86
87 tnode = xmlNewChild (doc->children, NULL((void*)0), (const xmlChar*) "toolbar", NULL((void*)0));
88 xmlSetProp (tnode, (const xmlChar*) "name", (const xmlChar*) toolbar->name);
89 xmlSetProp (tnode, (const xmlChar*) "hidden",
90 (toolbar->flags&EGG_TB_MODEL_HIDDEN) ? (const xmlChar*) "true" : (const xmlChar*) "false");
91 xmlSetProp (tnode, (const xmlChar*) "editable",
92 (toolbar->flags&EGG_TB_MODEL_NOT_EDITABLE) ? (const xmlChar*) "false" : (const xmlChar*) "true");
93
94 for (l2 = l1->children; l2 != NULL((void*)0); l2 = l2->next)
95 {
96 xmlNodePtr node;
97 EggToolbarsItem *item = l2->data;
98
99 if (strcmp (item->name, "_separator") == 0)
100 {
101 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "separator", NULL((void*)0));
Value stored to 'node' is never read
102 continue;
103 }
104
105 node = xmlNewChild (tnode, NULL((void*)0), (const xmlChar*) "toolitem", NULL((void*)0));
106 xmlSetProp (node, (const xmlChar*) "name", (const xmlChar*) item->name);
107
108 /* Add 'data' nodes for each data type which can be written out for this
109 * item. Only write types which can be used to restore the data. */
110 for (l3 = model->priv->types; l3 != NULL((void*)0); l3 = l3->next)
111 {
112 EggToolbarsItemType *type = l3->data;
113 if (type->get_name != NULL((void*)0) && type->get_data != NULL((void*)0))
114 {
115 xmlNodePtr dnode;
116 char *tmp;
117
118 tmp = type->get_data (type, item->name);
119 if (tmp != NULL((void*)0))
120 {
121 dnode = xmlNewTextChild (node, NULL((void*)0), (const xmlChar*) "data", (const xmlChar*) tmp);
122 g_free (tmp);
123
124 tmp = cdk_atom_name (type->type);
125 xmlSetProp (dnode, (const xmlChar*) "type", (const xmlChar*) tmp);
126 g_free (tmp);
127 }
128 }
129 }
130 }
131 }
132
133 return doc;
134}
135
136static gboolean
137safe_save_xml (const char *xml_file, xmlDocPtr doc)
138{
139 char *tmp_file;
140 char *old_file;
141 gboolean old_exist;
142 gboolean retval = TRUE(!(0));
143
144 tmp_file = g_strconcat (xml_file, ".tmp", NULL((void*)0));
145 old_file = g_strconcat (xml_file, ".old", NULL((void*)0));
146
147 if (xmlSaveFormatFile (tmp_file, doc, 1) <= 0)
148 {
149 g_warning ("Failed to write XML data to %s", tmp_file);
150 goto failed;
151 }
152
153 old_exist = g_file_test (xml_file, G_FILE_TEST_EXISTS);
154
155 if (old_exist)
156 {
157 if (rename (xml_file, old_file) < 0)
158 {
159 g_warning ("Failed to rename %s to %s", xml_file, old_file);
160 retval = FALSE(0);
161 goto failed;
162 }
163 }
164
165 if (rename (tmp_file, xml_file) < 0)
166 {
167 g_warning ("Failed to rename %s to %s", tmp_file, xml_file);
168
169 if (rename (old_file, xml_file) < 0)
170 {
171 g_warning ("Failed to restore %s from %s", xml_file, tmp_file);
172 }
173 retval = FALSE(0);
174 goto failed;
175 }
176
177 if (old_exist)
178 {
179 if (unlink (old_file) < 0)
180 {
181 g_warning ("Failed to delete old file %s", old_file);
182 }
183 }
184
185 failed:
186 g_free (old_file);
187 g_free (tmp_file);
188
189 return retval;
190}
191
192void
193egg_toolbars_model_save_toolbars (EggToolbarsModel *model,
194 const char *xml_file,
195 const char *version)
196{
197 xmlDocPtr doc;
198 xmlNodePtr root;
199
200 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
201
202 doc = egg_toolbars_model_to_xml (model);
203 root = xmlDocGetRootElement (doc);
204 xmlSetProp (root, (const xmlChar*) "version", (const xmlChar*) version);
205 safe_save_xml (xml_file, doc);
206 xmlFreeDoc (doc);
207}
208
209static gboolean
210is_unique (EggToolbarsModel *model,
211 EggToolbarsItem *idata)
212{
213 EggToolbarsItem *idata2;
214 GNode *toolbar, *item;
215
216
217 for(toolbar = g_node_first_child (model->priv->toolbars)((model->priv->toolbars) ? ((GNode*) (model->priv->
toolbars))->children : ((void*)0))
;
218 toolbar != NULL((void*)0); toolbar = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0)))
219 {
220 for(item = g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0));
221 item != NULL((void*)0); item = g_node_next_sibling (item)((item) ? ((GNode*) (item))->next : ((void*)0)))
222 {
223 idata2 = item->data;
224
225 if (idata != idata2 && strcmp (idata->name, idata2->name) == 0)
226 {
227 return FALSE(0);
228 }
229 }
230 }
231
232 return TRUE(!(0));
233}
234
235static GNode *
236toolbar_node_new (const char *name)
237{
238 EggToolbarsToolbar *toolbar;
239
240 toolbar = g_new (EggToolbarsToolbar, 1)((EggToolbarsToolbar *) g_malloc_n ((1), sizeof (EggToolbarsToolbar
)))
;
241 toolbar->name = g_strdup (name);
242 toolbar->flags = 0;
243
244 return g_node_new (toolbar);
245}
246
247static GNode *
248item_node_new (const char *name, EggToolbarsModel *model)
249{
250 EggToolbarsItem *item;
251 int flags;
252
253 g_return_val_if_fail (name != NULL, NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
(((void*)0)); } } while (0)
;
254
255 item = g_new (EggToolbarsItem, 1)((EggToolbarsItem *) g_malloc_n ((1), sizeof (EggToolbarsItem
)))
;
256 item->name = g_strdup (name);
257
258 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
259 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0)
260 g_hash_table_insert (model->priv->flags,
261 g_strdup (item->name),
262 GINT_TO_POINTER (flags | EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags | EGG_TB_MODEL_NAME_USED)));
263
264 return g_node_new (item);
265}
266
267static void
268item_node_free (GNode *item_node, EggToolbarsModel *model)
269{
270 EggToolbarsItem *item = item_node->data;
271 int flags;
272
273 flags = GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, item->name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, item->name)))
;
274 if ((flags & EGG_TB_MODEL_NAME_INFINITE) == 0 && is_unique (model, item))
275 g_hash_table_insert (model->priv->flags,
276 g_strdup (item->name),
277 GINT_TO_POINTER (flags & ~EGG_TB_MODEL_NAME_USED)((gpointer) (glong) (flags & ~EGG_TB_MODEL_NAME_USED)));
278
279 g_free (item->name);
280 g_free (item);
281
282 g_node_destroy (item_node);
283}
284
285static void
286toolbar_node_free (GNode *toolbar_node, EggToolbarsModel *model)
287{
288 EggToolbarsToolbar *toolbar = toolbar_node->data;
289
290 g_node_children_foreach (toolbar_node, G_TRAVERSE_ALL,
291 (GNodeForeachFunc) item_node_free, model);
292
293 g_free (toolbar->name);
294 g_free (toolbar);
295
296 g_node_destroy (toolbar_node);
297}
298
299EggTbModelFlags
300egg_toolbars_model_get_flags (EggToolbarsModel *model,
301 int toolbar_position)
302{
303 GNode *toolbar_node;
304 EggToolbarsToolbar *toolbar;
305
306 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
307 g_return_val_if_fail (toolbar_node != NULL, 0)do { if ((toolbar_node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar_node != NULL"
); return (0); } } while (0)
;
308
309 toolbar = toolbar_node->data;
310
311 return toolbar->flags;
312}
313
314void
315egg_toolbars_model_set_flags (EggToolbarsModel *model,
316 int toolbar_position,
317 EggTbModelFlags flags)
318{
319 GNode *toolbar_node;
320 EggToolbarsToolbar *toolbar;
321
322 toolbar_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
323 g_return_if_fail (toolbar_node != NULL)do { if ((toolbar_node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar_node != NULL"
); return; } } while (0)
;
324
325 toolbar = toolbar_node->data;
326
327 toolbar->flags = flags;
328
329 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_CHANGED],
330 0, toolbar_position);
331}
332
333
334char *
335egg_toolbars_model_get_data (EggToolbarsModel *model,
336 CdkAtom type,
337 const char *name)
338{
339 EggToolbarsItemType *t;
340 char *data = NULL((void*)0);
341 GList *l;
342
343 if (type == CDK_NONE((CdkAtom)((gpointer) (gulong) (0))) || type == cdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", FALSE(0)))
344 {
345 g_return_val_if_fail (name != NULL, NULL)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
(((void*)0)); } } while (0)
;
346 g_return_val_if_fail (*name != 0, NULL)do { if ((*name != 0)) { } else { g_return_if_fail_warning ((
(gchar*) 0), ((const char*) (__func__)), "*name != 0"); return
(((void*)0)); } } while (0)
;
347 return strdup (name);
348 }
349
350 for (l = model->priv->types; l != NULL((void*)0); l = l->next)
351 {
352 t = l->data;
353 if (t->type == type && t->get_data != NULL((void*)0))
354 {
355 data = t->get_data (t, name);
356 if (data != NULL((void*)0)) break;
357 }
358 }
359
360 return data;
361}
362
363char *
364egg_toolbars_model_get_name (EggToolbarsModel *model,
365 CdkAtom type,
366 const char *data,
367 gboolean create)
368{
369 EggToolbarsItemType *t;
370 char *name = NULL((void*)0);
371 GList *l;
372
373 if (type == CDK_NONE((CdkAtom)((gpointer) (gulong) (0))) || type == cdk_atom_intern (EGG_TOOLBAR_ITEM_TYPE"application/x-toolbar-item", FALSE(0)))
374 {
375 g_return_val_if_fail (data, NULL)do { if ((data)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "data"); return (((void*)0
)); } } while (0)
;
376 g_return_val_if_fail (*data, NULL)do { if ((*data)) { } else { g_return_if_fail_warning (((gchar
*) 0), ((const char*) (__func__)), "*data"); return (((void*)
0)); } } while (0)
;
377 return strdup (data);
378 }
379
380 if (create)
381 {
382 for (l = model->priv->types; name == NULL((void*)0) && l != NULL((void*)0); l = l->next)
383 {
384 t = l->data;
385 if (t->type == type && t->new_name != NULL((void*)0))
386 name = t->new_name (t, data);
387 }
388
389 return name;
390 }
391 else
392 {
393 for (l = model->priv->types; name == NULL((void*)0) && l != NULL((void*)0); l = l->next)
394 {
395 t = l->data;
396 if (t->type == type && t->get_name != NULL((void*)0))
397 name = t->get_name (t, data);
398 }
399
400 return name;
401 }
402}
403
404static gboolean
405impl_add_item (EggToolbarsModel *model,
406 int toolbar_position,
407 int position,
408 const char *name)
409{
410 GNode *parent_node;
411 GNode *child_node;
412 int real_position;
413
414 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
415 g_return_val_if_fail (name != NULL, FALSE)do { if ((name != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "name != NULL"); return
((0)); } } while (0)
;
416
417 parent_node = g_node_nth_child (model->priv->toolbars, toolbar_position);
418 child_node = item_node_new (name, model);
419 g_node_insert (parent_node, position, child_node);
420
421 real_position = g_node_child_position (parent_node, child_node);
422
423 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[ITEM_ADDED], 0,
424 toolbar_position, real_position);
425
426 return TRUE(!(0));
427}
428
429gboolean
430egg_toolbars_model_add_item (EggToolbarsModel *model,
431 int toolbar_position,
432 int position,
433 const char *name)
434{
435 EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (model)((((EggToolbarsModelClass*) (((GTypeInstance*) ((model)))->
g_class))))
;
436 return klass->add_item (model, toolbar_position, position, name);
437}
438
439int
440egg_toolbars_model_add_toolbar (EggToolbarsModel *model,
441 int position,
442 const char *name)
443{
444 GNode *node;
445 int real_position;
446
447 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), -1)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
(-1); } } while (0)
;
448
449 node = toolbar_node_new (name);
450 g_node_insert (model->priv->toolbars, position, node);
451
452 real_position = g_node_child_position (model->priv->toolbars, node);
453
454 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_ADDED],
455 0, real_position);
456
457 return g_node_child_position (model->priv->toolbars, node);
458}
459
460static char *
461parse_data_list (EggToolbarsModel *model,
462 xmlNodePtr child,
463 gboolean create)
464{
465 char *name = NULL((void*)0);
466 while (child && name == NULL((void*)0))
467 {
468 if (xmlStrEqual (child->name, (const xmlChar*) "data"))
469 {
470 xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
471 xmlChar *data = xmlNodeGetContent (child);
472
473 if (type != NULL((void*)0))
474 {
475 CdkAtom atom = cdk_atom_intern ((const char*) type, TRUE(!(0)));
476 name = egg_toolbars_model_get_name (model, atom, (const char*) data, create);
477 }
478
479 xmlFree (type);
480 xmlFree (data);
481 }
482
483 child = child->next;
484 }
485
486 return name;
487}
488
489static void
490parse_item_list (EggToolbarsModel *model,
491 xmlNodePtr child,
492 int position)
493{
494 while (child)
495 {
496 if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
497 {
498 char *name;
499
500 /* Try to get the name using the data elements first,
501 as they are more 'portable' or 'persistent'. */
502 name = parse_data_list (model, child->children, FALSE(0));
503 if (name == NULL((void*)0))
504 {
505 name = parse_data_list (model, child->children, TRUE(!(0)));
506 }
507
508 /* If that fails, try to use the name. */
509 if (name == NULL((void*)0))
510 {
511 xmlChar *type = xmlGetProp (child, (const xmlChar*) "type");
512 xmlChar *data = xmlGetProp (child, (const xmlChar*) "name");
513 CdkAtom atom = type ? cdk_atom_intern ((const char*) type, TRUE(!(0))) : CDK_NONE((CdkAtom)((gpointer) (gulong) (0)));
514
515 /* If an old format, try to use it. */
516 name = egg_toolbars_model_get_name (model, atom, (const char*) data, FALSE(0));
517 if (name == NULL((void*)0))
518 {
519 name = egg_toolbars_model_get_name (model, atom, (const char*) data, TRUE(!(0)));
520 }
521
522 xmlFree (type);
523 xmlFree (data);
524 }
525
526 if (name != NULL((void*)0))
527 {
528 egg_toolbars_model_add_item (model, position, -1, name);
529 g_free (name);
530 }
531 }
532 else if (xmlStrEqual (child->name, (const xmlChar*) "separator"))
533 {
534 egg_toolbars_model_add_item (model, position, -1, "_separator");
535 }
536
537 child = child->next;
538 }
539}
540
541static void
542parse_toolbars (EggToolbarsModel *model,
543 xmlNodePtr child)
544{
545 while (child)
546 {
547 if (xmlStrEqual (child->name, (const xmlChar*) "toolbar"))
548 {
549 xmlChar *string;
550 int position;
551 EggTbModelFlags flags;
552
553 string = xmlGetProp (child, (const xmlChar*) "name");
554 position = egg_toolbars_model_add_toolbar (model, -1, (const char*) string);
555 flags = egg_toolbars_model_get_flags (model, position);
556 xmlFree (string);
557
558 string = xmlGetProp (child, (const xmlChar*) "editable");
559 if (string && xmlStrEqual (string, (const xmlChar*) "false"))
560 flags |= EGG_TB_MODEL_NOT_EDITABLE;
561 xmlFree (string);
562
563 string = xmlGetProp (child, (const xmlChar*) "hidden");
564 if (string && xmlStrEqual (string, (const xmlChar*) "true"))
565 flags |= EGG_TB_MODEL_HIDDEN;
566 xmlFree (string);
567
568 string = xmlGetProp (child, (const xmlChar*) "style");
569 if (string && xmlStrEqual (string, (const xmlChar*) "icons-only"))
570 flags |= EGG_TB_MODEL_ICONS;
571 xmlFree (string);
572
573 egg_toolbars_model_set_flags (model, position, flags);
574
575 parse_item_list (model, child->children, position);
576 }
577
578 child = child->next;
579 }
580}
581
582gboolean
583egg_toolbars_model_load_toolbars (EggToolbarsModel *model,
584 const char *xml_file)
585{
586 xmlDocPtr doc;
587 xmlNodePtr root;
588
589 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
590
591 if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE(0);
592
593 doc = xmlParseFile (xml_file);
594 if (doc == NULL((void*)0))
595 {
596 g_warning ("Failed to load XML data from %s", xml_file);
597 return FALSE(0);
598 }
599 root = xmlDocGetRootElement (doc);
600
601 parse_toolbars (model, root->children);
602
603 xmlFreeDoc (doc);
604
605 return TRUE(!(0));
606}
607
608static void
609parse_available_list (EggToolbarsModel *model,
610 xmlNodePtr child)
611{
612 gint flags;
613
614 while (child)
615 {
616 if (xmlStrEqual (child->name, (const xmlChar*) "toolitem"))
617 {
618 xmlChar *name;
619
620 name = xmlGetProp (child, (const xmlChar*) "name");
621 flags = egg_toolbars_model_get_name_flags
622 (model, (const char*)name);
623 egg_toolbars_model_set_name_flags
624 (model, (const char*)name, flags | EGG_TB_MODEL_NAME_KNOWN);
625 xmlFree (name);
626 }
627 child = child->next;
628 }
629}
630
631static void
632parse_names (EggToolbarsModel *model,
633 xmlNodePtr child)
634{
635 while (child)
636 {
637 if (xmlStrEqual (child->name, (const xmlChar*) "available"))
638 {
639 parse_available_list (model, child->children);
640 }
641
642 child = child->next;
643 }
644}
645
646gboolean
647egg_toolbars_model_load_names (EggToolbarsModel *model,
648 const char *xml_file)
649{
650 xmlDocPtr doc;
651 xmlNodePtr root;
652
653 g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (model), FALSE)do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
((0)); } } while (0)
;
654
655 if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE(0);
656
657 doc = xmlParseFile (xml_file);
658 if (doc == NULL((void*)0))
659 {
660 g_warning ("Failed to load XML data from %s", xml_file);
661 return FALSE(0);
662 }
663 root = xmlDocGetRootElement (doc);
664
665 parse_names (model, root->children);
666
667 xmlFreeDoc (doc);
668
669 return TRUE(!(0));
670}
671
672static void
673egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
674{
675 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
676
677 object_class->finalize = egg_toolbars_model_finalize;
678
679 klass->add_item = impl_add_item;
680
681 signals[ITEM_ADDED] =
682 g_signal_new ("item_added",
683 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
684 G_SIGNAL_RUN_LAST,
685 G_STRUCT_OFFSET (EggToolbarsModelClass, item_added)((glong) __builtin_offsetof(EggToolbarsModelClass, item_added
))
,
686 NULL((void*)0), NULL((void*)0), _egg_marshal_VOID__INT_INT,
687 G_TYPE_NONE((GType) ((1) << (2))), 2, G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2))));
688 signals[TOOLBAR_ADDED] =
689 g_signal_new ("toolbar_added",
690 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
691 G_SIGNAL_RUN_LAST,
692 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_added)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_added
))
,
693 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
694 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
695 signals[ITEM_REMOVED] =
696 g_signal_new ("item_removed",
697 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
698 G_SIGNAL_RUN_LAST,
699 G_STRUCT_OFFSET (EggToolbarsModelClass, item_removed)((glong) __builtin_offsetof(EggToolbarsModelClass, item_removed
))
,
700 NULL((void*)0), NULL((void*)0), _egg_marshal_VOID__INT_INT,
701 G_TYPE_NONE((GType) ((1) << (2))), 2, G_TYPE_INT((GType) ((6) << (2))), G_TYPE_INT((GType) ((6) << (2))));
702 signals[TOOLBAR_REMOVED] =
703 g_signal_new ("toolbar_removed",
704 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
705 G_SIGNAL_RUN_LAST,
706 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_removed)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_removed
))
,
707 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
708 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
709 signals[TOOLBAR_CHANGED] =
710 g_signal_new ("toolbar_changed",
711 G_OBJECT_CLASS_TYPE (object_class)((((GTypeClass*) (object_class))->g_type)),
712 G_SIGNAL_RUN_LAST,
713 G_STRUCT_OFFSET (EggToolbarsModelClass, toolbar_changed)((glong) __builtin_offsetof(EggToolbarsModelClass, toolbar_changed
))
,
714 NULL((void*)0), NULL((void*)0), g_cclosure_marshal_VOID__INT,
715 G_TYPE_NONE((GType) ((1) << (2))), 1, G_TYPE_INT((GType) ((6) << (2))));
716}
717
718static void
719egg_toolbars_model_init (EggToolbarsModel *model)
720{
721 model->priv = egg_toolbars_model_get_instance_private (model);
722
723 model->priv->toolbars = g_node_new (NULL((void*)0));
724 model->priv->flags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL((void*)0));
725 egg_toolbars_model_set_name_flags (model, "_separator",
726 EGG_TB_MODEL_NAME_KNOWN |
727 EGG_TB_MODEL_NAME_INFINITE);
728}
729
730static void
731egg_toolbars_model_finalize (GObject *object)
732{
733 EggToolbarsModel *model = EGG_TOOLBARS_MODEL (object)((((EggToolbarsModel*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((object)), ((egg_toolbars_model_get_type ())
)))))
;
734
735 g_node_children_foreach (model->priv->toolbars, G_TRAVERSE_ALL,
736 (GNodeForeachFunc) toolbar_node_free, model);
737 g_node_destroy (model->priv->toolbars);
738 g_hash_table_destroy (model->priv->flags);
739
740 G_OBJECT_CLASS (egg_toolbars_model_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((egg_toolbars_model_parent_class)), (((GType) ((20) <<
(2))))))))
->finalize (object);
741}
742
743EggToolbarsModel *
744egg_toolbars_model_new (void)
745{
746 return EGG_TOOLBARS_MODEL (g_object_new (EGG_TYPE_TOOLBARS_MODEL, NULL))((((EggToolbarsModel*) (void *) g_type_check_instance_cast ((
GTypeInstance*) ((g_object_new ((egg_toolbars_model_get_type (
)), ((void*)0)))), ((egg_toolbars_model_get_type ()))))))
;
747}
748
749void
750egg_toolbars_model_remove_toolbar (EggToolbarsModel *model,
751 int position)
752{
753 GNode *node;
754 EggTbModelFlags flags;
755
756 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
757
758 flags = egg_toolbars_model_get_flags (model, position);
759
760 if (!(flags & EGG_TB_MODEL_NOT_REMOVABLE))
761 {
762 node = g_node_nth_child (model->priv->toolbars, position);
763 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
764
765 toolbar_node_free (node, model);
766
767 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[TOOLBAR_REMOVED],
768 0, position);
769 }
770}
771
772void
773egg_toolbars_model_remove_item (EggToolbarsModel *model,
774 int toolbar_position,
775 int position)
776{
777 GNode *node, *toolbar;
778
779 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
780
781 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
782 g_return_if_fail (toolbar != NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return; } } while (0)
;
783
784 node = g_node_nth_child (toolbar, position);
785 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
786
787 item_node_free (node, model);
788
789 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[ITEM_REMOVED], 0,
790 toolbar_position, position);
791}
792
793void
794egg_toolbars_model_move_item (EggToolbarsModel *model,
795 int toolbar_position,
796 int position,
797 int new_toolbar_position,
798 int new_position)
799{
800 GNode *node, *toolbar, *new_toolbar;
801
802 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
803
804 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
805 g_return_if_fail (toolbar != NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return; } } while (0)
;
806
807 new_toolbar = g_node_nth_child (model->priv->toolbars, new_toolbar_position);
808 g_return_if_fail (new_toolbar != NULL)do { if ((new_toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "new_toolbar != NULL"
); return; } } while (0)
;
809
810 node = g_node_nth_child (toolbar, position);
811 g_return_if_fail (node != NULL)do { if ((node != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "node != NULL"); return
; } } while (0)
;
812
813 g_node_unlink (node);
814
815 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[ITEM_REMOVED], 0,
816 toolbar_position, position);
817
818 g_node_insert (new_toolbar, new_position, node);
819
820 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
, signals[ITEM_ADDED], 0,
821 new_toolbar_position, new_position);
822}
823
824void
825egg_toolbars_model_delete_item (EggToolbarsModel *model,
826 const char *name)
827{
828 EggToolbarsItem *idata;
829 EggToolbarsToolbar *tdata;
830 GNode *toolbar, *item, *next;
831 int tpos, ipos;
832
833 g_return_if_fail (EGG_IS_TOOLBARS_MODEL (model))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((model)); GType __t = ((egg_toolbars_model_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 (((gchar*) 0), ((const
char*) (__func__)), "EGG_IS_TOOLBARS_MODEL (model)"); return
; } } while (0)
;
834
835 toolbar = g_node_first_child (model->priv->toolbars)((model->priv->toolbars) ? ((GNode*) (model->priv->
toolbars))->children : ((void*)0))
;
836 tpos = 0;
837
838 while (toolbar != NULL((void*)0))
839 {
840 item = g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0));
841 ipos = 0;
842
843 /* Don't delete toolbars that were already empty */
844 if (item == NULL((void*)0))
845 {
846 toolbar = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0));
847 continue;
848 }
849
850 while (item != NULL((void*)0))
851 {
852 next = g_node_next_sibling (item)((item) ? ((GNode*) (item))->next : ((void*)0));
853 idata = item->data;
854 if (strcmp (idata->name, name) == 0)
855 {
856 item_node_free (item, model);
857 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
,
858 signals[ITEM_REMOVED],
859 0, tpos, ipos);
860 }
861 else
862 {
863 ipos++;
864 }
865
866 item = next;
867 }
868
869 next = g_node_next_sibling (toolbar)((toolbar) ? ((GNode*) (toolbar))->next : ((void*)0));
870 tdata = toolbar->data;
871 if (!(tdata->flags & EGG_TB_MODEL_NOT_REMOVABLE) &&
872 g_node_first_child (toolbar)((toolbar) ? ((GNode*) (toolbar))->children : ((void*)0)) == NULL((void*)0))
873 {
874 toolbar_node_free (toolbar, model);
875
876 g_signal_emit (G_OBJECT (model)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((model)), (((GType) ((20) << (2))))))))
,
877 signals[TOOLBAR_REMOVED],
878 0, tpos);
879 }
880 else
881 {
882 tpos++;
883 }
884
885 toolbar = next;
886 }
887}
888
889int
890egg_toolbars_model_n_items (EggToolbarsModel *model,
891 int toolbar_position)
892{
893 GNode *toolbar;
894
895 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
896 g_return_val_if_fail (toolbar != NULL, -1)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (-1); } } while (0)
;
897
898 return g_node_n_children (toolbar);
899}
900
901const char *
902egg_toolbars_model_item_nth (EggToolbarsModel *model,
903 int toolbar_position,
904 int position)
905{
906 GNode *toolbar;
907 GNode *item;
908 EggToolbarsItem *idata;
909
910 toolbar = g_node_nth_child (model->priv->toolbars, toolbar_position);
911 g_return_val_if_fail (toolbar != NULL, NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (((void*)0)); } } while (0)
;
912
913 item = g_node_nth_child (toolbar, position);
914 g_return_val_if_fail (item != NULL, NULL)do { if ((item != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "item != NULL"); return
(((void*)0)); } } while (0)
;
915
916 idata = item->data;
917 return idata->name;
918}
919
920int
921egg_toolbars_model_n_toolbars (EggToolbarsModel *model)
922{
923 return g_node_n_children (model->priv->toolbars);
924}
925
926const char *
927egg_toolbars_model_toolbar_nth (EggToolbarsModel *model,
928 int position)
929{
930 GNode *toolbar;
931 EggToolbarsToolbar *tdata;
932
933 toolbar = g_node_nth_child (model->priv->toolbars, position);
934 g_return_val_if_fail (toolbar != NULL, NULL)do { if ((toolbar != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "toolbar != NULL"
); return (((void*)0)); } } while (0)
;
935
936 tdata = toolbar->data;
937
938 return tdata->name;
939}
940
941GList *
942egg_toolbars_model_get_types (EggToolbarsModel *model)
943{
944 return model->priv->types;
945}
946
947void
948egg_toolbars_model_set_types (EggToolbarsModel *model, GList *types)
949{
950 model->priv->types = types;
951}
952
953static void
954fill_avail_array (gpointer key, gpointer value, GPtrArray *array)
955{
956 int flags = GPOINTER_TO_INT (value)((gint) (glong) (value));
957 if ((flags & EGG_TB_MODEL_NAME_KNOWN) && !(flags & EGG_TB_MODEL_NAME_USED))
958 g_ptr_array_add (array, key);
959}
960
961GPtrArray *
962egg_toolbars_model_get_name_avail (EggToolbarsModel *model)
963{
964 GPtrArray *array = g_ptr_array_new ();
965 g_hash_table_foreach (model->priv->flags, (GHFunc) fill_avail_array, array);
966 return array;
967}
968
969gint
970egg_toolbars_model_get_name_flags (EggToolbarsModel *model, const char *name)
971{
972 return GPOINTER_TO_INT (g_hash_table_lookup (model->priv->flags, name))((gint) (glong) (g_hash_table_lookup (model->priv->flags
, name)))
;
973}
974
975void
976egg_toolbars_model_set_name_flags (EggToolbarsModel *model, const char *name, gint flags)
977{
978 g_hash_table_insert (model->priv->flags, g_strdup (name), GINT_TO_POINTER (flags)((gpointer) (glong) (flags)));
979}