Fix missing translation
[geeqie.git] / src / editors.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef EDITORS_H
23 #define EDITORS_H
24
25 #include <gtk/gtk.h>
26
27 struct FileData;
28
29 enum EditorFlags {
30         EDITOR_KEEP_FS            = 0x00000001,
31         EDITOR_VERBOSE            = 0x00000002,
32         EDITOR_VERBOSE_MULTI      = 0x00000004,
33         EDITOR_TERMINAL           = 0x00000008,
34
35         EDITOR_DEST               = 0x00000100,
36         EDITOR_FOR_EACH           = 0x00000200,
37         EDITOR_SINGLE_COMMAND     = 0x00000400,
38         EDITOR_NO_PARAM           = 0x00000800,
39         /**< below are errors */
40         EDITOR_ERROR_EMPTY        = 0x00020000,
41         EDITOR_ERROR_SYNTAX       = 0x00040000,
42         EDITOR_ERROR_INCOMPATIBLE = 0x00080000,
43         EDITOR_ERROR_NO_FILE      = 0x00100000,
44         EDITOR_ERROR_CANT_EXEC    = 0x00200000,
45         EDITOR_ERROR_STATUS       = 0x00400000,
46         EDITOR_ERROR_SKIPPED      = 0x00800000,
47         /**< mask to match errors only */
48         EDITOR_ERROR_MASK         = ~0xffff,
49 };
50
51 struct EditorDescription {
52         gchar *key;             /**< desktop file name, not including path, including extension */
53         gchar *name;            /**< Name, localized name presented to user */
54         gchar *icon;            /**< Icon */
55         gchar *exec;            /**< Exec */
56         gchar *menu_path;
57         gchar *hotkey;
58         GList *ext_list;
59         gchar *file;
60         gchar *comment;         /**< .desktop Comment key, used to show a tooltip */
61         EditorFlags flags;
62         gboolean hidden;        /**< explicitly hidden, shown in configuration dialog */
63         gboolean ignored;       /**< not interesting, do not show at all */
64         gboolean disabled;      /**< display disabled by user */
65 };
66
67 #define EDITOR_ERRORS(flags) ((flags) & EDITOR_ERROR_MASK)
68 #define EDITOR_ERRORS_BUT_SKIPPED(flags) (!!(((flags) & EDITOR_ERROR_MASK) && !((flags) & EDITOR_ERROR_SKIPPED)))
69
70
71 /**
72  * @note EDITOR_CB_*:
73  * Return values from callback function
74  */
75 enum {
76         EDITOR_CB_CONTINUE = 0, /**< continue multiple editor execution on remaining files*/
77         EDITOR_CB_SKIP,         /**< skip the remaining files */
78         EDITOR_CB_SUSPEND       /**< suspend execution, one of editor_resume or editor_skip
79                                    must be called later */
80 };
81
82 enum {
83         DESKTOP_FILE_COLUMN_KEY,
84         DESKTOP_FILE_COLUMN_DISABLED,
85         DESKTOP_FILE_COLUMN_NAME,
86         DESKTOP_FILE_COLUMN_HIDDEN,
87         DESKTOP_FILE_COLUMN_WRITABLE,
88         DESKTOP_FILE_COLUMN_PATH,
89         DESKTOP_FILE_COLUMN_COUNT
90 };
91
92 extern GtkListStore *desktop_file_list;
93
94
95 extern GHashTable *editors;
96
97 void editor_table_finish();
98 void editor_table_clear();
99 GList *editor_get_desktop_files();
100 gboolean editor_read_desktop_file(const gchar *path);
101
102 GList *editor_list_get();
103
104
105 /**
106  * @typedef EditorCallback
107  *
108  * Callback is called even on skipped files, with the #EDITOR_ERROR_SKIPPED flag set.
109  * It is a good place to call file_data_change_info_free().
110  *
111  * @param ed - pointer that can be used for editor_resume/editor_skip or NULL if all files were already processed \n
112  * @param flags - flags above \n
113  * @param list - list of processed #FileData structures, typically single file or whole list passed to start_editor_* @n
114  * @param data - generic pointer
115 */
116 using EditorCallback = gint (*)(gpointer, EditorFlags, GList *, gpointer);
117
118
119 void editor_resume(gpointer ed);
120 void editor_skip(gpointer ed);
121
122
123
124 EditorFlags start_editor(const gchar *key, const gchar *working_directory);
125 EditorFlags start_editor_from_file(const gchar *key, FileData *fd);
126 EditorFlags start_editor_from_filelist(const gchar *key, GList *list);
127 EditorFlags start_editor_from_file_full(const gchar *key, FileData *fd, EditorCallback cb, gpointer data);
128 EditorFlags start_editor_from_filelist_full(const gchar *key, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data);
129 gboolean editor_window_flag_set(const gchar *key);
130 gboolean editor_is_filter(const gchar *key);
131 gboolean editor_no_param(const gchar *key);
132 const gchar *editor_get_error_str(EditorFlags flags);
133
134 gboolean is_valid_editor_command(const gchar *key);
135 gboolean editor_blocks_file(const gchar *key);
136
137 EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output);
138
139 #endif
140 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */