Updated Slovenian translation
[nautilus.git] / libnautilus-extension / nautilus-menu.c
blob8912ab8d2ce2498ea8cfdaba00ba1d0b15a48e6f
1 /*
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>
24 #include <config.h>
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 {
33 GList *item_list;
36 void
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));
45 GList *
46 nautilus_menu_get_items (NautilusMenu *this)
48 GList *item_list;
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);
55 return item_list;
58 void
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 */
69 static void
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);
82 static void
83 nautilus_menu_init (NautilusMenu *this)
85 this->private = NAUTILUS_MENU_GET_PRIVATE (this);
87 this->private->item_list = NULL;
90 static void
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;
100 GType
101 nautilus_menu_get_type (void)
103 static GType type = 0;
105 if(type == 0) {
106 const GTypeInfo info = {
107 sizeof (NautilusMenuClass),
108 (GBaseInitFunc) NULL,
109 (GBaseFinalizeFunc) NULL,
110 (GClassInitFunc) nautilus_menu_class_init,
111 (GClassFinalizeFunc) NULL,
112 NULL,
113 sizeof (NautilusMenu),
115 (GInstanceInitFunc) nautilus_menu_init,
118 type = g_type_register_static (G_TYPE_OBJECT, "NautilusMenu", &info, 0);
121 return type;
124 /* public constructors */
126 NautilusMenu *
127 nautilus_menu_new (void)
129 NautilusMenu *obj;
131 obj = NAUTILUS_MENU (g_object_new (NAUTILUS_TYPE_MENU, NULL));
133 return obj;