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_OBJECT_ITEM_H__
31 #define __NAUTILUS_ACTIONS_API_NA_OBJECT_ITEM_H__
32 
33 /**
34  * SECTION: object-item
35  * @title: NAObjectItem
36  * @short_description: The Object Item Base Class Definition
37  * @include: nautilus-actions/na-object-item.h
38  *
39  * This is a pure virtual class, i.e. not an instantiatable one, but
40  * serves as the base class for #NAObjectAction and #NAObjectMenu.
41  */
42 
43 #include "na-object-id.h"
44 
45 G_BEGIN_DECLS
46 
47 #define NA_TYPE_OBJECT_ITEM                ( na_object_item_get_type())
48 #define NA_OBJECT_ITEM( object )           ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_TYPE_OBJECT_ITEM, NAObjectItem ))
49 #define NA_OBJECT_ITEM_CLASS( klass )      ( G_TYPE_CHECK_CLASS_CAST( klass, NA_TYPE_OBJECT_ITEM, NAObjectItemClass ))
50 #define NA_IS_OBJECT_ITEM( object )        ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_TYPE_OBJECT_ITEM ))
51 #define NA_IS_OBJECT_ITEM_CLASS( klass )   ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_TYPE_OBJECT_ITEM ))
52 #define NA_OBJECT_ITEM_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_TYPE_OBJECT_ITEM, NAObjectItemClass ))
53 
54 typedef struct _NAObjectItemPrivate        NAObjectItemPrivate;
55 
56 typedef struct {
57 	/*< private >*/
58 	NAObjectId           parent;
59 	NAObjectItemPrivate *private;
60 }
61 	NAObjectItem;
62 
63 typedef struct _NAObjectItemClassPrivate   NAObjectItemClassPrivate;
64 
65 typedef struct {
66 	/*< private >*/
67 	NAObjectIdClass           parent;
68 	NAObjectItemClassPrivate *private;
69 }
70 	NAObjectItemClass;
71 
72 /**
73  * NAItemTarget:
74  * @ITEM_TARGET_SELECTION: when targeting the selection context menu.
75  * @ITEM_TARGET_LOCATION:  when targeting the background context menu.
76  * @ITEM_TARGET_TOOLBAR:   when targeting the toolbar.
77  * @ITEM_TARGET_ANY:       a wilcard target defined in order to be able
78  *                         to activate an action from a keyboard shortcut,
79  *                         while keeping this same action hidden from the UI.
80  *
81  * The #NAItemTarget mode is Nautilus-driven. It determines in which part
82  * of the Nautilus UI our actions will be displayed.
83  */
84 typedef enum {
85 	ITEM_TARGET_SELECTION = 1,
86 	ITEM_TARGET_LOCATION,
87 	ITEM_TARGET_TOOLBAR,
88 	ITEM_TARGET_ANY
89 }
90 	NAItemTarget;
91 
92 GType       na_object_item_get_type( void );
93 
94 NAObjectId *na_object_item_get_item    ( const NAObjectItem *item, const gchar *id );
95 gint        na_object_item_get_position( const NAObjectItem *item, const NAObjectId *child );
96 void        na_object_item_append_item ( NAObjectItem *item, const NAObjectId *child );
97 void        na_object_item_insert_at   ( NAObjectItem *item, const NAObjectId *child, gint pos );
98 void        na_object_item_insert_item ( NAObjectItem *item, const NAObjectId *child, const NAObjectId *before );
99 void        na_object_item_remove_item ( NAObjectItem *item, const NAObjectId *child );
100 
101 guint       na_object_item_get_items_count( const NAObjectItem *item );
102 
103 void        na_object_item_count_items  ( GList *items, gint *menus, gint *actions, gint *profiles, gboolean recurse );
104 GList      *na_object_item_copyref_items( GList *items );
105 GList      *na_object_item_free_items   ( GList *items );
106 
107 void        na_object_item_deals_with_version    ( NAObjectItem *item );
108 void        na_object_item_rebuild_children_slist( NAObjectItem *item );
109 
110 gboolean    na_object_item_is_finally_writable   ( const NAObjectItem *item, guint *reason );
111 void        na_object_item_set_writability_status( NAObjectItem *item, gboolean writable, guint reason );
112 
113 G_END_DECLS
114 
115 #endif /* __NAUTILUS_ACTIONS_API_NA_OBJECT_ITEM_H__ */
116