No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | nautilus-menu.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /*
2 * nautilus-menu.h - Menus exported by NautilusMenuProvider objects.
3 *
4 * Copyright (C) 2005 Raffaele Sandrini
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Author: Raffaele Sandrini <rasa@gmx.ch>
21 *
22 */
23
24 #include <config.h>
25 #include "nautilus-menu.h"
26 #include "nautilus-extension-i18n.h"
27
28 #include <glib.h>
29
30 #define NAUTILUS_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_MENU, NautilusMenuPrivate))
31 G_DEFINE_TYPE (NautilusMenu, nautilus_menu, G_TYPE_OBJECT);
32
33 struct _NautilusMenuPrivate {
34 GList *item_list;
35 };
36
37 void
38 nautilus_menu_append_item (NautilusMenu *menu, NautilusMenuItem *item)
39 {
40 g_return_if_fail (menu != NULL);
41 g_return_if_fail (item != NULL);
42
43 menu->priv->item_list = g_list_append (menu->priv->item_list, g_object_ref (item));
44 }
45
46 /**
47 * nautilus_menu_get_items:
48 * @menu: a #NautilusMenu
49 *
50 * Returns: (element-type NautilusMenuItem) (transfer full): the provided #NautilusMenuItem list
51 */
52 GList *
53 nautilus_menu_get_items (NautilusMenu *menu)
54 {
55 GList *item_list;
56
57 g_return_val_if_fail (menu != NULL, NULL);
58
59 item_list = g_list_copy (menu->priv->item_list);
60 g_list_foreach (item_list, (GFunc)g_object_ref, NULL);
61
62 return item_list;
63 }
64
65 /**
66 * nautilus_menu_item_list_free:
67 * @item_list: (element-type NautilusMenuItem): a list of #NautilusMenuItem
68 *
69 */
70 void
71 nautilus_menu_item_list_free (GList *item_list)
72 {
73 g_return_if_fail (item_list != NULL);
74
75 g_list_foreach (item_list, (GFunc)g_object_unref, NULL);
76 g_list_free (item_list);
77 }
78
79 /* Type initialization */
80
81 static void
82 nautilus_menu_finalize (GObject *object)
83 {
84 NautilusMenu *menu = NAUTILUS_MENU (object);
85
86 if (menu->priv->item_list) {
87 g_list_free (menu->priv->item_list);
88 }
89
90 G_OBJECT_CLASS (nautilus_menu_parent_class)->finalize (object);
91 }
92
93 static void
94 nautilus_menu_init (NautilusMenu *menu)
95 {
96 menu->priv = NAUTILUS_MENU_GET_PRIVATE (menu);
97
98 menu->priv->item_list = NULL;
99 }
100
101 static void
102 nautilus_menu_class_init (NautilusMenuClass *klass)
103 {
104 GObjectClass *object_class = G_OBJECT_CLASS (klass);
105
106 g_type_class_add_private (klass, sizeof (NautilusMenuPrivate));
107
108 object_class->finalize = nautilus_menu_finalize;
109 }
110
111 /* public constructors */
112
113 NautilusMenu *
114 nautilus_menu_new (void)
115 {
116 NautilusMenu *obj;
117
118 obj = NAUTILUS_MENU (g_object_new (NAUTILUS_TYPE_MENU, NULL));
119
120 return obj;
121 }