summaryrefslogtreecommitdiff
path: root/src/runner.h
blob: 94f5d83edb2e32f51b3a61df8db3527fd02a0a0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef GGAZE_RUNNER_H
#define GGAZE_RUNNER_H

#include <gio/gio.h>
#include <glib.h>

G_BEGIN_DECLS

typedef struct {
   char *c_name;
   char *c_command; /* may contain %f and %d */
} RunnerScript;

typedef struct Runner Runner;

Runner          *runner_new(void);
void             runner_delete(Runner *p_r);
void             runner_set_scripts(Runner *p_r, const GPtrArray *p_scripts);
const GPtrArray *runner_get_scripts(Runner *p_r);

/* Run the script via /bin/sh -c with %f and %d expanded (single-quoted).
 * Async: calls p_cb (on the main thread) when the process exits. p_data
 * is passed to p_cb as-is. */
gboolean runner_run(Runner *p_r, GFile *p_file, GFile *p_dir,
                    const RunnerScript *p_script, GAsyncReadyCallback p_cb,
                    gpointer p_data, GError **p_err);

/* Finish: returns the exit code, or -1 on error. */
int runner_run_finish(Runner *p_r, GAsyncResult *p_res, GError **p_err);

G_END_DECLS

#endif