1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
2 
3    This program is free software; you can redistribute it and/or
4    modify it under the terms of the GNU General Public License as
5    published by the Free Software Foundation; either version 2 of the
6    License, or (at your option) any later version.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    General Public License for more details.
12 
13    You should have received a copy of the GNU General Public
14    License along with this program; if not, write to the
15    Free Software Foundation, Inc., 51 Franklin Street - Suite 500,
16    Boston, MA 02110-1335, USA.
17 
18 */
19 
20 #ifndef NEMO_ACTION_H
21 #define NEMO_ACTION_H
22 
23 #include <gtk/gtk.h>
24 #include <glib.h>
25 #include "nemo-file.h"
26 
27 #define NEMO_TYPE_ACTION nemo_action_get_type()
28 #define NEMO_ACTION(obj) \
29   (G_TYPE_CHECK_INSTANCE_CAST ((obj), NEMO_TYPE_ACTION, NemoAction))
30 #define NEMO_ACTION_CLASS(klass) \
31   (G_TYPE_CHECK_CLASS_CAST ((klass), NEMO_TYPE_ACTION, NemoActionClass))
32 #define NEMO_IS_ACTION(obj) \
33   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NEMO_TYPE_ACTION))
34 #define NEMO_IS_ACTION_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_TYPE ((klass), NEMO_TYPE_ACTION))
36 #define NEMO_ACTION_GET_CLASS(obj) \
37   (G_TYPE_INSTANCE_GET_CLASS ((obj), NEMO_TYPE_ACTION, NemoActionClass))
38 
39 
40 #define SELECTION_SINGLE_KEY "s"
41 #define SELECTION_MULTIPLE_KEY "m"
42 #define SELECTION_ANY_KEY "any"
43 #define SELECTION_NONE_KEY "none"
44 #define SELECTION_NOT_NONE_KEY "notnone"
45 
46 #define TOKEN_EXEC_URI_LIST "%U"
47 #define TOKEN_EXEC_FILE_LIST "%F"
48 #define TOKEN_EXEC_PARENT "%P"
49 #define TOKEN_EXEC_FILE_NAME "%f"
50 #define TOKEN_EXEC_PARENT_NAME "%p"
51 #define TOKEN_EXEC_DEVICE "%D"
52 #define TOKEN_EXEC_FILE_NO_EXT "%e"
53 #define TOKEN_EXEC_LITERAL_PERCENT "%%"
54 
55 #define TOKEN_LABEL_FILE_NAME "%N" // Leave in for compatibility, same as TOKEN_EXEC_FILE_NAME
56 
57 
58 #define ACTION_FILE_GROUP "Nemo Action"
59 
60 #define KEY_ACTIVE "Active"
61 #define KEY_NAME "Name"
62 #define KEY_COMMENT "Comment"
63 #define KEY_EXEC "Exec"
64 #define KEY_ICON_NAME "Icon-Name"
65 #define KEY_STOCK_ID "Stock-Id"
66 #define KEY_SELECTION "Selection"
67 #define KEY_EXTENSIONS "Extensions"
68 #define KEY_MIME_TYPES "Mimetypes"
69 #define KEY_SEPARATOR "Separator"
70 #define KEY_QUOTE_TYPE "Quote"
71 #define KEY_DEPENDENCIES "Dependencies"
72 #define KEY_CONDITIONS "Conditions"
73 #define KEY_WHITESPACE "EscapeSpaces"
74 #define KEY_DOUBLE_ESCAPE_QUOTES "DoubleEscapeQuotes"
75 #define KEY_TERMINAL "Terminal"
76 
77 typedef struct _NemoAction NemoAction;
78 typedef struct _NemoActionClass NemoActionClass;
79 
80 typedef enum {
81     SELECTION_SINGLE = G_MAXINT - 10,
82     SELECTION_MULTIPLE,
83     SELECTION_NOT_NONE,
84     SELECTION_ANY,
85     SELECTION_NONE
86 } SelectionType;
87 
88 typedef enum {
89     QUOTE_TYPE_SINGLE = 0,
90     QUOTE_TYPE_DOUBLE,
91     QUOTE_TYPE_BACKTICK,
92     QUOTE_TYPE_NONE
93 } QuoteType;
94 
95 typedef enum {
96     TOKEN_NONE = 0,
97     TOKEN_PATH_LIST,
98     TOKEN_URI_LIST,
99     TOKEN_FILE_DISPLAY_NAME,
100     TOKEN_PARENT_DISPLAY_NAME,
101     TOKEN_PARENT_PATH,
102     TOKEN_DEVICE,
103     TOKEN_FILE_DISPLAY_NAME_NO_EXT,
104     TOKEN_LITERAL_PERCENT
105 } TokenType;
106 
107 struct _NemoAction {
108     GtkAction parent;
109     gchar *key_file_path;
110     SelectionType selection_type;
111     gchar **extensions;
112     gchar **mimetypes;
113     gchar *exec;
114     gchar *parent_dir;
115     gchar **conditions;
116     gchar *separator;
117     QuoteType quote_type;
118     gchar *orig_label;
119     gchar *orig_tt;
120     gboolean use_parent_dir;
121     GList *dbus;
122     guint dbus_recalc_timeout_id;
123     GList *gsettings;
124     guint gsettings_recalc_timeout_id;
125     gboolean dbus_satisfied;
126     gboolean gsettings_satisfied;
127     gboolean escape_underscores;
128     gboolean escape_space;
129     gboolean show_in_blank_desktop;
130     gboolean run_in_terminal;
131 
132     gboolean constructing;
133 };
134 
135 struct _NemoActionClass {
136 	GtkActionClass parent_class;
137 };
138 
139 GType         nemo_action_get_type             (void);
140 NemoAction   *nemo_action_new                  (const gchar *name, const gchar *path);
141 void          nemo_action_activate             (NemoAction *action, GList *selection, NemoFile *parent);
142 
143 const gchar  *nemo_action_get_orig_label       (NemoAction *action);
144 const gchar  *nemo_action_get_orig_tt          (NemoAction *action);
145 gchar        *nemo_action_get_label            (NemoAction *action, GList *selection, NemoFile *parent);
146 gchar        *nemo_action_get_tt               (NemoAction *action, GList *selection, NemoFile *parent);
147 gboolean      nemo_action_get_visibility       (NemoAction *action, GList *selection, NemoFile *parent, gboolean for_places);
148 
149 #endif /* NEMO_ACTION_H */
150