Convert NASettings to a private singleton
[nautilus-actions.git] / src / core / na-tokens.h
blob2a90a9631ed15680b3404a44119c2525f6ca8b57
1 /*
2 * Nautilus-Actions
3 * A Nautilus extension which offers configurable context menu modules.
5 * Copyright (C) 2005 The GNOME Foundation
6 * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
7 * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
9 * This Program 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.
14 * This Program 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
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public
20 * License along with this Library; see the file COPYING. If not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307, USA.
24 * Authors:
25 * Frederic Ruaudel <grumz@grumz.net>
26 * Rodrigo Moya <rodrigo@gnome-db.org>
27 * Pierre Wieser <pwieser@trychlos.org>
28 * ... and many others (see AUTHORS)
31 #ifndef __CORE_NA_TOKENS_H__
32 #define __CORE_NA_TOKENS_H__
34 /* @title: NATokens
35 * @short_description: The #NATokens Class Definition
36 * @include: core/na-tokens.h
38 * The #NATokens class manages the tokens which are to be replaced with
39 * elements of the current selection at runtime.
41 * Note that until v2.30, tokens were parsed against selection list only
42 * when an item was selected in the Nautilus context menu (i.e. at
43 * execution time).
44 * Starting with unstable v2.99 (stable v3.0), this same parsing may occur
45 * for each displayed label (as new specs accept tokens in labels) - we so
46 * factorize this parsing one time for each new selection in the Nautilus
47 * plugin, attaching the result to each item in the context menu.
49 * Adding a parameter requires updating of:
50 * - doc/nact/C/figures/nact-legend.png screenshot
51 * - doc/nact/C/nact-execution.xml "Multiple execution" paragraph
52 * - src/core/na-tokens.c::is_singular_exec() function
53 * - src/core/na-tokens.c::parse_singular() function
54 * - src/nact/nautilus-actions-config-tool.ui:LegendDialog labels
55 * - src/core/na-object-profile-factory.c:NAFO_DATA_PARAMETERS comment
57 * Valid parameters are :
59 * %b: (first) basename
60 * %B: space-separated list of basenames
61 * %c: count of selected items
62 * %d: (first) base directory
63 * %D: space-separated list of base directory of each selected item
64 * %f: (first) file name
65 * %F: space-separated list of selected file names
66 * %h: hostname of the (first) URI
67 * %m: (first) mimetype
68 * %M: space-separated list of mimetypes
69 * %n: username of the (first) URI
70 * %o: no-op operator which forces a singular form of execution
71 * %O: no-op operator which forces a plural form of execution
72 * %p: port number of the (first) URI
73 * %s: scheme of the (first) URI
74 * %u: (first) URI
75 * %U: space-separated list of selected URIs
76 * %w: (first) basename without the extension
77 * %W: space-separated list of basenames without their extension
78 * %x: (first) extension
79 * %X: space-separated list of extensions
80 * %%: the « % » character
83 #include <api/na-object-profile.h>
85 G_BEGIN_DECLS
87 #define NA_TOKENS_TYPE ( na_tokens_get_type())
88 #define NA_TOKENS( object ) ( G_TYPE_CHECK_INSTANCE_CAST( object, NA_TOKENS_TYPE, NATokens ))
89 #define NA_TOKENS_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( klass, NA_TOKENS_TYPE, NATokensClass ))
90 #define NA_IS_TOKENS( object ) ( G_TYPE_CHECK_INSTANCE_TYPE( object, NA_TOKENS_TYPE ))
91 #define NA_IS_TOKENS_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE(( klass ), NA_TOKENS_TYPE ))
92 #define NA_TOKENS_GET_CLASS( object ) ( G_TYPE_INSTANCE_GET_CLASS(( object ), NA_TOKENS_TYPE, NATokensClass ))
94 typedef struct _NATokensPrivate NATokensPrivate;
96 typedef struct {
97 /*< private >*/
98 GObject parent;
99 NATokensPrivate *private;
101 NATokens;
103 typedef struct _NATokensClassPrivate NATokensClassPrivate;
105 typedef struct {
106 /*< private >*/
107 GObjectClass parent;
108 NATokensClassPrivate *private;
110 NATokensClass;
112 GType na_tokens_get_type( void );
114 NATokens *na_tokens_new_for_example ( void );
115 NATokens *na_tokens_new_from_selection( GList *selection );
117 gchar *na_tokens_parse_for_display ( const NATokens *tokens, const gchar *string, gboolean utf8 );
118 void na_tokens_execute_action ( const NATokens *tokens, const NAObjectProfile *profile );
120 gchar *na_tokens_command_from_terminal_prefix( const gchar *prefix, const gchar *command );
122 G_END_DECLS
124 #endif /* __CORE_NA_TOKENS_H__ */