Fix #314: Remote commands for thumbnail maintenance
[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
26 typedef enum {
27         EDITOR_KEEP_FS            = 0x00000001,
28         EDITOR_VERBOSE            = 0x00000002,
29         EDITOR_VERBOSE_MULTI      = 0x00000004,
30         EDITOR_TERMINAL           = 0x00000008,
31
32         EDITOR_DEST               = 0x00000100,
33         EDITOR_FOR_EACH           = 0x00000200,
34         EDITOR_SINGLE_COMMAND     = 0x00000400,
35         EDITOR_NO_PARAM           = 0x00000800,
36         /* below are errors */
37         EDITOR_ERROR_EMPTY        = 0x00020000,
38         EDITOR_ERROR_SYNTAX       = 0x00040000,
39         EDITOR_ERROR_INCOMPATIBLE = 0x00080000,
40         EDITOR_ERROR_NO_FILE      = 0x00100000,
41         EDITOR_ERROR_CANT_EXEC    = 0x00200000,
42         EDITOR_ERROR_STATUS       = 0x00400000,
43         EDITOR_ERROR_SKIPPED      = 0x00800000,
44         /* mask to match errors only */
45         EDITOR_ERROR_MASK         = 0xffff0000,
46 } EditorFlags;
47
48 struct _EditorDescription {
49         gchar *key;             /* desktop file name, not including path, including extension */
50         gchar *name;            /* Name, localized name presented to user */
51         gchar *icon;            /* Icon */
52         gchar *exec;            /* Exec */
53         gchar *menu_path;
54         gchar *hotkey;
55         GList *ext_list;
56         gchar *file;
57         gchar *comment;         /* .desktop Comment key, used to show a tooltip */
58         EditorFlags flags;
59         gboolean hidden;        /* explicitly hidden, shown in configuration dialog */
60         gboolean ignored;       /* not interesting, do not show at all */
61 };
62
63 #define EDITOR_ERRORS(flags) ((flags) & EDITOR_ERROR_MASK)
64 #define EDITOR_ERRORS_BUT_SKIPPED(flags) (!!(((flags) & EDITOR_ERROR_MASK) && !((flags) & EDITOR_ERROR_SKIPPED)))
65
66
67 /* return values from callback function */
68 enum {
69         EDITOR_CB_CONTINUE = 0, /* continue multiple editor execution on remaining files*/
70         EDITOR_CB_SKIP,         /* skip the remaining files */
71         EDITOR_CB_SUSPEND       /* suspend execution, one of editor_resume or editor_skip
72                                    must be called later */
73 };
74
75 enum {
76         DESKTOP_FILE_COLUMN_KEY,
77         DESKTOP_FILE_COLUMN_NAME,
78         DESKTOP_FILE_COLUMN_HIDDEN,
79         DESKTOP_FILE_COLUMN_WRITABLE,
80         DESKTOP_FILE_COLUMN_PATH,
81         DESKTOP_FILE_COLUMN_COUNT
82 };
83
84 extern GtkListStore *desktop_file_list;
85
86
87 extern GHashTable *editors;
88
89 void editor_table_finish(void);
90 void editor_table_clear(void);
91 GList *editor_get_desktop_files(void);
92 gboolean editor_read_desktop_file(const gchar *path);
93
94 GList *editor_list_get(void);
95
96
97 /*
98 Callback is called even on skipped files, with the EDITOR_ERROR_SKIPPED flag set.
99 It is a good place to call file_data_change_info_free().
100
101 ed - pointer that can be used for editor_resume/editor_skip or NULL if all files were already processed
102 flags - flags above
103 list - list of procesed FileData structures, typically single file or whole list passed to start_editor_*
104 data - generic pointer
105 */
106 typedef gint (*EditorCallback) (gpointer ed, EditorFlags flags, GList *list, gpointer data);
107
108
109 void editor_resume(gpointer ed);
110 void editor_skip(gpointer ed);
111
112
113
114 EditorFlags start_editor(const gchar *key, const gchar *working_directory);
115 EditorFlags start_editor_from_file(const gchar *key, FileData *fd);
116 EditorFlags start_editor_from_filelist(const gchar *key, GList *list);
117 EditorFlags start_editor_from_file_full(const gchar *key, FileData *fd, EditorCallback cb, gpointer data);
118 EditorFlags start_editor_from_filelist_full(const gchar *key, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data);
119 gboolean editor_window_flag_set(const gchar *key);
120 gboolean editor_is_filter(const gchar *key);
121 gboolean editor_no_param(const gchar *key);
122 const gchar *editor_get_error_str(EditorFlags flags);
123
124 const gchar *editor_get_name(const gchar *key);
125
126 gboolean is_valid_editor_command(const gchar *key);
127 gboolean editor_blocks_file(const gchar *key);
128
129 EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output);
130
131 #endif
132 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */