2008-05-05 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / libnautilus-extension / nautilus-info-provider.c
blobe916e9d714189695dc44c707208de71806ae8169
1 /*
2 * nautilus-info-provider.c - Interface for Nautilus extensions that
3 * provide info about files.
5 * Copyright (C) 2003 Novell, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Author: Dave Camp <dave@ximian.com>
25 #include <config.h>
26 #include "nautilus-info-provider.h"
28 #include <glib-object.h>
30 static void
31 nautilus_info_provider_base_init (gpointer g_class)
35 GType
36 nautilus_info_provider_get_type (void)
38 static GType type = 0;
40 if (!type) {
41 const GTypeInfo info = {
42 sizeof (NautilusInfoProviderIface),
43 nautilus_info_provider_base_init,
44 NULL,
45 NULL,
46 NULL,
47 NULL,
50 NULL
53 type = g_type_register_static (G_TYPE_INTERFACE,
54 "NautilusInfoProvider",
55 &info, 0);
56 g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
59 return type;
62 NautilusOperationResult
63 nautilus_info_provider_update_file_info (NautilusInfoProvider *provider,
64 NautilusFileInfo *file,
65 GClosure *update_complete,
66 NautilusOperationHandle **handle)
68 g_return_val_if_fail (NAUTILUS_IS_INFO_PROVIDER (provider),
69 NAUTILUS_OPERATION_FAILED);
70 g_return_val_if_fail (NAUTILUS_INFO_PROVIDER_GET_IFACE (provider)->update_file_info != NULL,
71 NAUTILUS_OPERATION_FAILED);
72 g_return_val_if_fail (update_complete != NULL,
73 NAUTILUS_OPERATION_FAILED);
74 g_return_val_if_fail (handle != NULL, NAUTILUS_OPERATION_FAILED);
76 return NAUTILUS_INFO_PROVIDER_GET_IFACE (provider)->update_file_info
77 (provider, file, update_complete, handle);
80 void
81 nautilus_info_provider_cancel_update (NautilusInfoProvider *provider,
82 NautilusOperationHandle *handle)
84 g_return_if_fail (NAUTILUS_IS_INFO_PROVIDER (provider));
85 g_return_if_fail (NAUTILUS_INFO_PROVIDER_GET_IFACE (provider)->cancel_update != NULL);
86 g_return_if_fail (NAUTILUS_INFO_PROVIDER_GET_IFACE (provider)->cancel_update != NULL);
87 g_return_if_fail (handle != NULL);
89 NAUTILUS_INFO_PROVIDER_GET_IFACE (provider)->cancel_update (provider,
90 handle);
93 void
94 nautilus_info_provider_update_complete_invoke (GClosure *update_complete,
95 NautilusInfoProvider *provider,
96 NautilusOperationHandle *handle,
97 NautilusOperationResult result)
99 GValue args[3] = { { 0, } };
100 GValue return_val = { 0, };
102 g_return_if_fail (update_complete != NULL);
103 g_return_if_fail (NAUTILUS_IS_INFO_PROVIDER (provider));
105 g_value_init (&args[0], NAUTILUS_TYPE_INFO_PROVIDER);
106 g_value_init (&args[1], G_TYPE_POINTER);
107 g_value_init (&args[2], NAUTILUS_TYPE_OPERATION_RESULT);
109 g_value_set_object (&args[0], provider);
110 g_value_set_pointer (&args[1], handle);
111 g_value_set_enum (&args[2], result);
113 g_closure_invoke (update_complete, &return_val, 3, args, NULL);
115 g_value_unset (&args[0]);
116 g_value_unset (&args[1]);
117 g_value_unset (&args[2]);