e0ca1b82ba4c29a31d581c8ed447e824a2cfcb0d
[geeqie.git] / src / editors.h
1 /*
2  * Geeqie
3  * (C) 2004 John Ellis
4  * Copyright (C) 2008 - 2012 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #ifndef EDITORS_H
15 #define EDITORS_H
16
17
18 typedef enum {
19         EDITOR_KEEP_FS            = 0x00000001,
20         EDITOR_VERBOSE            = 0x00000002,
21         EDITOR_VERBOSE_MULTI      = 0x00000004,
22         EDITOR_TERMINAL           = 0x00000008,
23
24         EDITOR_DEST               = 0x00000100,
25         EDITOR_FOR_EACH           = 0x00000200,
26         EDITOR_SINGLE_COMMAND     = 0x00000400,
27         EDITOR_NO_PARAM           = 0x00000800,
28         /* below are errors */
29         EDITOR_ERROR_EMPTY        = 0x00020000,
30         EDITOR_ERROR_SYNTAX       = 0x00040000,
31         EDITOR_ERROR_INCOMPATIBLE = 0x00080000,
32         EDITOR_ERROR_NO_FILE      = 0x00100000,
33         EDITOR_ERROR_CANT_EXEC    = 0x00200000,
34         EDITOR_ERROR_STATUS       = 0x00400000,
35         EDITOR_ERROR_SKIPPED      = 0x00800000,
36         /* mask to match errors only */
37         EDITOR_ERROR_MASK         = 0xffff0000,
38 } EditorFlags;
39
40 struct _EditorDescription {
41         gchar *key;             /* desktop file name, not including path, including extension */
42         gchar *name;            /* Name, localized name presented to user */
43         gchar *icon;            /* Icon */
44         gchar *exec;            /* Exec */
45         gchar *menu_path;       
46         gchar *hotkey;
47         GList *ext_list;
48         gchar *file;
49         gchar *comment;         /* .desktop Comment key, used to show a tooltip */
50         EditorFlags flags;
51         gboolean hidden;        /* explicitly hidden, shown in configuration dialog */
52         gboolean ignored;       /* not interesting, do not show at all */
53 };
54
55 #define EDITOR_ERRORS(flags) ((flags) & EDITOR_ERROR_MASK)
56 #define EDITOR_ERRORS_BUT_SKIPPED(flags) (!!(((flags) & EDITOR_ERROR_MASK) && !((flags) & EDITOR_ERROR_SKIPPED)))
57
58
59 /* return values from callback function */
60 enum {
61         EDITOR_CB_CONTINUE = 0, /* continue multiple editor execution on remaining files*/
62         EDITOR_CB_SKIP,         /* skip the remaining files */
63         EDITOR_CB_SUSPEND       /* suspend execution, one of editor_resume or editor_skip
64                                    must be called later */
65 };
66
67 enum {
68         DESKTOP_FILE_COLUMN_KEY,
69         DESKTOP_FILE_COLUMN_NAME,
70         DESKTOP_FILE_COLUMN_HIDDEN,
71         DESKTOP_FILE_COLUMN_WRITABLE,
72         DESKTOP_FILE_COLUMN_PATH,
73         DESKTOP_FILE_COLUMN_COUNT
74 };
75
76 extern GtkListStore *desktop_file_list;
77
78
79 extern GHashTable *editors;
80
81 void editor_table_finish(void);
82 void editor_table_clear(void);
83 GList *editor_get_desktop_files(void);
84 gboolean editor_read_desktop_file(const gchar *path);
85
86 GList *editor_list_get(void);
87
88
89 /*
90 Callback is called even on skipped files, with the EDITOR_ERROR_SKIPPED flag set.
91 It is a good place to call file_data_change_info_free().
92
93 ed - pointer that can be used for editor_resume/editor_skip or NULL if all files were already processed
94 flags - flags above
95 list - list of procesed FileData structures, typically single file or whole list passed to start_editor_*
96 data - generic pointer
97 */
98 typedef gint (*EditorCallback) (gpointer ed, EditorFlags flags, GList *list, gpointer data);
99
100
101 void editor_resume(gpointer ed);
102 void editor_skip(gpointer ed);
103
104
105
106 EditorFlags start_editor(const gchar *key, const gchar *working_directory);
107 EditorFlags start_editor_from_file(const gchar *key, FileData *fd);
108 EditorFlags start_editor_from_filelist(const gchar *key, GList *list);
109 EditorFlags start_editor_from_file_full(const gchar *key, FileData *fd, EditorCallback cb, gpointer data);
110 EditorFlags start_editor_from_filelist_full(const gchar *key, GList *list, const gchar *working_directory, EditorCallback cb, gpointer data);
111 gboolean editor_window_flag_set(const gchar *key);
112 gboolean editor_is_filter(const gchar *key);
113 gboolean editor_no_param(const gchar *key);
114 const gchar *editor_get_error_str(EditorFlags flags);
115
116 const gchar *editor_get_name(const gchar *key);
117
118 gboolean is_valid_editor_command(const gchar *key);
119 gboolean editor_blocks_file(const gchar *key);
120
121 EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output);
122
123 #endif
124 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */