2 * nautilus-menu.h - Menus exported by NautilusMenuProvider objects.
4 * Copyright (C) 2005 Raffaele Sandrini
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.
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.
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.
20 * Author: Raffaele Sandrini <rasa@gmx.ch>
25 #include "nautilus-menu.h"
26 #include "nautilus-extension-i18n.h"
28 #include <glib/glist.h>
30 #define NAUTILUS_MENU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NAUTILUS_TYPE_MENU, NautilusMenuPrivate))
32 struct _NautilusMenuPrivate
{
37 nautilus_menu_append_item (NautilusMenu
*this, NautilusMenuItem
*item
)
39 g_return_if_fail (this != NULL
);
40 g_return_if_fail (item
!= NULL
);
42 this->private->item_list
= g_list_append (this->private->item_list
, g_object_ref (item
));
46 nautilus_menu_get_items (NautilusMenu
*this)
50 g_return_val_if_fail (this != NULL
, NULL
);
52 item_list
= g_list_copy (this->private->item_list
);
53 g_list_foreach (item_list
, (GFunc
)g_object_ref
, NULL
);
59 nautilus_menu_item_list_free (GList
*item_list
)
61 g_return_if_fail (item_list
!= NULL
);
63 g_list_foreach (item_list
, (GFunc
)g_object_unref
, NULL
);
64 g_list_free (item_list
);
67 /* Type initialization */
70 nautilus_menu_finalize (GObject
*object
)
72 NautilusMenu
*this = NAUTILUS_MENU (object
);
73 GObjectClass
*parent_class
= g_type_class_peek_parent (NAUTILUS_MENU_GET_CLASS (object
));
75 if (this->private->item_list
) {
76 g_list_free (this->private->item_list
);
79 parent_class
->finalize (object
);
83 nautilus_menu_init (NautilusMenu
*this)
85 this->private = NAUTILUS_MENU_GET_PRIVATE (this);
87 this->private->item_list
= NULL
;
91 nautilus_menu_class_init (NautilusMenuClass
*klass
)
93 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
95 g_type_class_add_private (klass
, sizeof (NautilusMenuPrivate
));
97 object_class
->finalize
= nautilus_menu_finalize
;
101 nautilus_menu_get_type (void)
103 static GType type
= 0;
106 const GTypeInfo info
= {
107 sizeof (NautilusMenuClass
),
108 (GBaseInitFunc
) NULL
,
109 (GBaseFinalizeFunc
) NULL
,
110 (GClassInitFunc
) nautilus_menu_class_init
,
111 (GClassFinalizeFunc
) NULL
,
113 sizeof (NautilusMenu
),
115 (GInstanceInitFunc
) nautilus_menu_init
,
118 type
= g_type_register_static (G_TYPE_OBJECT
, "NautilusMenu", &info
, 0);
124 /* public constructors */
127 nautilus_menu_new (void)
131 obj
= NAUTILUS_MENU (g_object_new (NAUTILUS_TYPE_MENU
, NULL
));