summaryrefslogtreecommitdiff
path: root/src/fr-process.h
blob: 8c907bdb82ecc00c0dcb8b0aeeb0cd882e5157d3 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  Engrampa
 *
 *  Copyright (C) 2001, 2003, 2008 Free Software Foundation, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02110-1301, USA.
 */

#ifndef FR_PROCESS_H
#define FR_PROCESS_H

#include <glib.h>
#include <gtk/gtk.h>
#include <sys/types.h>
#include "typedefs.h"

#define FR_TYPE_PROCESS            (fr_process_get_type ())
#define FR_PROCESS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_PROCESS, FrProcess))
#define FR_PROCESS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_PROCESS, FrProcessClass))
#define FR_IS_PROCESS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_PROCESS))
#define FR_IS_PROCESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_PROCESS))
#define FR_PROCESS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_PROCESS, FrProcessClass))

typedef struct _FrProcess        FrProcess;
typedef struct _FrProcessClass   FrProcessClass;
typedef struct _FrProcessPrivate FrProcessPrivate;

typedef void     (*ProcFunc)     (gpointer data);
typedef gboolean (*ContinueFunc) (gpointer data);
typedef void     (*LineFunc)     (char *line, gpointer data);

typedef struct {
	GIOChannel *source;
	GList      *raw;
	LineFunc    line_func;
	gpointer    line_data;
	GIOStatus   status;
	GError     *error;
} FrChannelData;

struct _FrProcess {
	GObject  __parent;

	/*< public >*/

	gboolean          term_on_stop;  /* whether we must terminate the
					  * command when calling
					  * fr_process_stop. */

	/*< public read-only >*/

	FrChannelData     out;
	FrChannelData     err;
	FrProcError       error;

	/*< protected >*/

	gboolean          restart;       /* whether to restart the process
			  		  * after an error. */

	FrProcessPrivate *priv;
};

struct _FrProcessClass {
	GObjectClass __parent_class;

	/* -- Signals -- */

	void (* start)         (FrProcess   *fr_proc);
	void (* done)          (FrProcess   *fr_proc,
				FrProcError *error);
	void (* sticky_only)   (FrProcess   *fr_proc);
};

GType       fr_process_get_type             (void);
FrProcess * fr_process_new                  (void);
void        fr_process_clear                (FrProcess    *fr_proc);
void        fr_process_begin_command        (FrProcess    *fr_proc,
					     const char   *arg);
void        fr_process_begin_command_at     (FrProcess    *fr_proc,
					     const char   *arg,
					     int           index);
void        fr_process_add_arg              (FrProcess    *fr_proc,
					     const char   *arg);
void        fr_process_add_arg_concat       (FrProcess    *fr_proc,
					     const char   *arg,
					     ...) G_GNUC_NULL_TERMINATED;
void        fr_process_add_arg_printf       (FrProcess    *fr_proc,
					     const char   *format,
					     ...) G_GNUC_PRINTF (2, 3);
void        fr_process_set_arg_at           (FrProcess    *fr_proc,
					     int           n_comm,
					     int           n_arg,
					     const char   *arg);
void        fr_process_set_begin_func       (FrProcess    *fr_proc,
					     ProcFunc      func,
					     gpointer      func_data);
void        fr_process_set_end_func         (FrProcess    *fr_proc,
					     ProcFunc      func,
					     gpointer      func_data);
void        fr_process_set_continue_func    (FrProcess    *fr_proc,
					     ContinueFunc  func,
					     gpointer      func_data);
void        fr_process_end_command          (FrProcess    *fr_proc);
void        fr_process_set_working_dir      (FrProcess    *fr_proc,
					     const char   *arg);
void        fr_process_set_sticky           (FrProcess    *fr_proc,
					     gboolean      sticky);
void        fr_process_set_ignore_error     (FrProcess    *fr_proc,
					     gboolean      ignore_error);
void        fr_process_use_standard_locale  (FrProcess    *fr_proc,
					     gboolean      use_stand_locale);
void        fr_process_set_out_line_func    (FrProcess    *fr_proc,
					     LineFunc      func,
					     gpointer      func_data);
void        fr_process_set_err_line_func    (FrProcess    *fr_proc,
					     LineFunc      func,
					     gpointer      func_data);
void        fr_process_start                (FrProcess    *fr_proc);
void        fr_process_stop                 (FrProcess    *fr_proc);

#endif /* FR_PROCESS_H */