2008-05-05 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / libnautilus-extension / nautilus-menu-provider.c
blob09e14d7b4ae8b6077de616a6d1819870d753cc30
1 /*
2 * nautilus-property-page-provider.c - Interface for Nautilus extensions
3 * that provide context menu items
4 * for files.
6 * Copyright (C) 2003 Novell, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Author: Dave Camp <dave@ximian.com>
26 #include <config.h>
27 #include "nautilus-menu-provider.h"
29 #include <glib-object.h>
31 static void
32 nautilus_menu_provider_base_init (gpointer g_class)
34 static gboolean initialized = FALSE;
36 if (!initialized)
38 /* This signal should be emited each time the extension modify the list of menu items */
39 g_signal_new ("items_updated",
40 NAUTILUS_TYPE_MENU_PROVIDER,
41 G_SIGNAL_RUN_LAST,
43 NULL, NULL,
44 g_cclosure_marshal_VOID__VOID,
45 G_TYPE_NONE, 0);
46 initialized = TRUE;
50 GType
51 nautilus_menu_provider_get_type (void)
53 static GType type = 0;
55 if (!type) {
56 const GTypeInfo info = {
57 sizeof (NautilusMenuProviderIface),
58 nautilus_menu_provider_base_init,
59 NULL,
60 NULL,
61 NULL,
62 NULL,
65 NULL
68 type = g_type_register_static (G_TYPE_INTERFACE,
69 "NautilusMenuProvider",
70 &info, 0);
71 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
74 return type;
77 GList *
78 nautilus_menu_provider_get_file_items (NautilusMenuProvider *provider,
79 GtkWidget *window,
80 GList *files)
82 g_return_val_if_fail (NAUTILUS_IS_MENU_PROVIDER (provider), NULL);
84 if (NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_file_items) {
85 return NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_file_items
86 (provider, window, files);
87 } else {
88 return NULL;
92 GList *
93 nautilus_menu_provider_get_background_items (NautilusMenuProvider *provider,
94 GtkWidget *window,
95 NautilusFileInfo *current_folder)
97 g_return_val_if_fail (NAUTILUS_IS_MENU_PROVIDER (provider), NULL);
98 g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (current_folder), NULL);
100 if (NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_background_items) {
101 return NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_background_items
102 (provider, window, current_folder);
103 } else {
104 return NULL;
108 GList *
109 nautilus_menu_provider_get_toolbar_items (NautilusMenuProvider *provider,
110 GtkWidget *window,
111 NautilusFileInfo *current_folder)
113 g_return_val_if_fail (NAUTILUS_IS_MENU_PROVIDER (provider), NULL);
114 g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (current_folder), NULL);
116 if (NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_toolbar_items) {
117 return NAUTILUS_MENU_PROVIDER_GET_IFACE (provider)->get_toolbar_items
118 (provider, window, current_folder);
119 } else {
120 return NULL;
124 /* This function emit a signal to inform nautilus that its item list has changed */
125 void
126 nautilus_menu_provider_emit_items_updated_signal (NautilusMenuProvider* provider)
128 g_return_if_fail (NAUTILUS_IS_MENU_PROVIDER (provider));
130 g_signal_emit_by_name (provider, "items_updated");