1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 3 /* 4 * Engrampa 5 * 6 * Copyright (C) 2001, 2003, 2008 Free Software Foundation, Inc. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 */ 22 23 #ifndef FR_PROCESS_H 24 #define FR_PROCESS_H 25 26 #include <glib.h> 27 #include <gtk/gtk.h> 28 #include <sys/types.h> 29 #include "typedefs.h" 30 31 #define FR_TYPE_PROCESS (fr_process_get_type ()) 32 #define FR_PROCESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_PROCESS, FrProcess)) 33 #define FR_PROCESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_PROCESS, FrProcessClass)) 34 #define FR_IS_PROCESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_PROCESS)) 35 #define FR_IS_PROCESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_PROCESS)) 36 #define FR_PROCESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_PROCESS, FrProcessClass)) 37 38 typedef struct _FrProcess FrProcess; 39 typedef struct _FrProcessClass FrProcessClass; 40 typedef struct _FrProcessPrivate FrProcessPrivate; 41 42 typedef void (*ProcFunc) (gpointer data); 43 typedef gboolean (*ContinueFunc) (gpointer data); 44 typedef void (*LineFunc) (char *line, gpointer data); 45 46 typedef struct { 47 GIOChannel *source; 48 GList *raw; 49 LineFunc line_func; 50 gpointer line_data; 51 GIOStatus status; 52 GError *error; 53 } FrChannelData; 54 55 struct _FrProcess { 56 GObject __parent; 57 58 /*< public >*/ 59 60 gboolean term_on_stop; /* whether we must terminate the 61 * command when calling 62 * fr_process_stop. */ 63 64 /*< public read-only >*/ 65 66 FrChannelData out; 67 FrChannelData err; 68 FrProcError error; 69 70 /*< protected >*/ 71 72 gboolean restart; /* whether to restart the process 73 * after an error. */ 74 75 FrProcessPrivate *priv; 76 }; 77 78 struct _FrProcessClass { 79 GObjectClass __parent_class; 80 81 /* -- Signals -- */ 82 83 void (* start) (FrProcess *fr_proc); 84 void (* done) (FrProcess *fr_proc, 85 FrProcError *error); 86 void (* sticky_only) (FrProcess *fr_proc); 87 }; 88 89 GType fr_process_get_type (void); 90 FrProcess * fr_process_new (void); 91 void fr_process_clear (FrProcess *fr_proc); 92 void fr_process_begin_command (FrProcess *fr_proc, 93 const char *arg); 94 void fr_process_begin_command_at (FrProcess *fr_proc, 95 const char *arg, 96 int index); 97 void fr_process_add_arg (FrProcess *fr_proc, 98 const char *arg); 99 void fr_process_add_arg_concat (FrProcess *fr_proc, 100 const char *arg, 101 ...) G_GNUC_NULL_TERMINATED; 102 void fr_process_add_arg_printf (FrProcess *fr_proc, 103 const char *format, 104 ...) G_GNUC_PRINTF (2, 3); 105 void fr_process_set_arg_at (FrProcess *fr_proc, 106 int n_comm, 107 int n_arg, 108 const char *arg); 109 void fr_process_set_begin_func (FrProcess *fr_proc, 110 ProcFunc func, 111 gpointer func_data); 112 void fr_process_set_end_func (FrProcess *fr_proc, 113 ProcFunc func, 114 gpointer func_data); 115 void fr_process_set_continue_func (FrProcess *fr_proc, 116 ContinueFunc func, 117 gpointer func_data); 118 void fr_process_end_command (FrProcess *fr_proc); 119 void fr_process_set_working_dir (FrProcess *fr_proc, 120 const char *arg); 121 void fr_process_set_sticky (FrProcess *fr_proc, 122 gboolean sticky); 123 void fr_process_set_ignore_error (FrProcess *fr_proc, 124 gboolean ignore_error); 125 void fr_process_use_standard_locale (FrProcess *fr_proc, 126 gboolean use_stand_locale); 127 void fr_process_set_out_line_func (FrProcess *fr_proc, 128 LineFunc func, 129 gpointer func_data); 130 void fr_process_set_err_line_func (FrProcess *fr_proc, 131 LineFunc func, 132 gpointer func_data); 133 void fr_process_start (FrProcess *fr_proc); 134 void fr_process_stop (FrProcess *fr_proc); 135 int start_switch_state (FrProcess *fr_proc); 136 void start_close_suspend_process (FrProcess *fr_proc); 137 #endif /* FR_PROCESS_H */ 138