1 /*
2  * Nautilus-Actions
3  * A Nautilus extension which offers configurable context menu actions.
4  *
5  * Copyright (C) 2005 The GNOME Foundation
6  * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7  * Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8  *
9  * Nautilus-Actions is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * Nautilus-Actions is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Nautilus-Actions; see the file COPYING. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  * Authors:
24  *   Frederic Ruaudel <grumz@grumz.net>
25  *   Rodrigo Moya <rodrigo@gnome-db.org>
26  *   Pierre Wieser <pwieser@trychlos.org>
27  *   ... and many others (see AUTHORS)
28  */
29 
30 #ifndef __NAUTILUS_ACTIONS_API_NA_ICONTEXT_H__
31 #define __NAUTILUS_ACTIONS_API_NA_ICONTEXT_H__
32 
33 /**
34  * SECTION: icontext
35  * @title: NAIContext
36  * @short_description: The Contextual Interface
37  * @include: nautilus-actions/na-icontext.h
38  *
39  * This interface is implemented by all #NAObject -derived objects
40  * whose the display in the Nautilus context menu is subject to some
41  * conditions.
42  *
43  * Implementors, typically #NAObjectAction, #NAObjectProfile and
44  * #NAObjectMenu, host the required data as #NADataBoxed in a dedicated
45  * NA_FACTORY_CONDITIONS_GROUP data group.
46  */
47 
48 #include <glib-object.h>
49 
50 G_BEGIN_DECLS
51 
52 #define NA_TYPE_ICONTEXT                      ( na_icontext_get_type())
53 #define NA_ICONTEXT( instance )               ( G_TYPE_CHECK_INSTANCE_CAST( instance, NA_TYPE_ICONTEXT, NAIContext ))
54 #define NA_IS_ICONTEXT( instance )            ( G_TYPE_CHECK_INSTANCE_TYPE( instance, NA_TYPE_ICONTEXT ))
55 #define NA_ICONTEXT_GET_INTERFACE( instance ) ( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_TYPE_ICONTEXT, NAIContextInterface ))
56 
57 typedef struct _NAIContext                    NAIContext;
58 typedef struct _NAIContextInterfacePrivate    NAIContextInterfacePrivate;
59 
60 /**
61  * NAIContextInterface:
62  * @is_candidate: determines if the given NAObject-derived object is
63  *                candidate to display in Nautilus.
64  *
65  * This interface manages all conditions relevant to a displayable status
66  * in Nautilus.
67  */
68 typedef struct {
69 	/*< private >*/
70 	GTypeInterface              parent;
71 	NAIContextInterfacePrivate *private;
72 
73 	/*< public >*/
74 	/**
75 	 * is_candidate:
76 	 * @object: this NAIContext object.
77 	 * @target: the initial target which triggered this function's stack.
78 	 *  This target is defined in na-object-item.h.
79 	 * @selection: the current selection as a GList of NautilusFileInfo.
80 	 *
81 	 * The NAIContext implementor may take advantage of this
82 	 * virtual function to check for its own specific data. Only if the
83 	 * implementor does return %TRUE (or just doesn't implement this
84 	 * virtual), the conditions themselves will be checked.
85 	 *
86 	 * Returns: %TRUE if the @object may be a potential candidate, %FALSE
87 	 * else.
88 	 *
89 	 * Since: 2.30
90 	 */
91 	gboolean ( *is_candidate )( NAIContext *object, guint target, GList *selection );
92 }
93 	NAIContextInterface;
94 
95 GType    na_icontext_get_type( void );
96 
97 gboolean na_icontext_are_equal       ( const NAIContext *a, const NAIContext *b );
98 gboolean na_icontext_is_candidate    ( const NAIContext *context, guint target, GList *selection );
99 gboolean na_icontext_is_valid        ( const NAIContext *context );
100 
101 void     na_icontext_check_mimetypes ( const NAIContext *context );
102 
103 void     na_icontext_copy            ( NAIContext *context, const NAIContext *source );
104 void     na_icontext_read_done       ( NAIContext *context );
105 void     na_icontext_set_scheme      ( NAIContext *context, const gchar *scheme, gboolean selected );
106 void     na_icontext_set_only_desktop( NAIContext *context, const gchar *desktop, gboolean selected );
107 void     na_icontext_set_not_desktop ( NAIContext *context, const gchar *desktop, gboolean selected );
108 void     na_icontext_replace_folder  ( NAIContext *context, const gchar *old, const gchar *new );
109 
110 G_END_DECLS
111 
112 #endif /* __NAUTILUS_ACTIONS_API_NA_ICONTEXT_H__ */
113