1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta 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.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "anjuta-command.h"
27 struct _AnjutaCommandPriv
42 static guint anjuta_command_signals
[LAST_SIGNAL
] = { 0 };
44 G_DEFINE_TYPE (AnjutaCommand
, anjuta_command
, G_TYPE_OBJECT
);
47 anjuta_command_init (AnjutaCommand
*self
)
49 self
->priv
= g_new0 (AnjutaCommandPriv
, 1);
53 anjuta_command_finalize (GObject
*object
)
57 self
= ANJUTA_COMMAND (object
);
59 g_free (self
->priv
->error_message
);
62 G_OBJECT_CLASS (anjuta_command_parent_class
)->finalize (object
);
66 anjuta_command_class_init (AnjutaCommandClass
*klass
)
68 GObjectClass
* object_class
= G_OBJECT_CLASS (klass
);
70 object_class
->finalize
= anjuta_command_finalize
;
74 klass
->notify_data_arrived
= NULL
;
75 klass
->notify_complete
= NULL
;
76 klass
->notify_progress
= NULL
;
77 klass
->set_error_message
= anjuta_command_set_error_message
;
78 klass
->get_error_message
= anjuta_command_get_error_message
;
79 klass
->progress
= NULL
;
81 anjuta_command_signals
[DATA_ARRIVED
] =
82 g_signal_new ("data-arrived",
83 G_OBJECT_CLASS_TYPE (klass
),
87 g_cclosure_marshal_VOID__VOID
,
91 anjuta_command_signals
[COMMAND_FINISHED
] =
92 g_signal_new ("command-finished",
93 G_OBJECT_CLASS_TYPE (klass
),
97 g_cclosure_marshal_VOID__UINT
,
101 anjuta_command_signals
[PROGRESS
] =
102 g_signal_new ("progress",
103 G_OBJECT_CLASS_TYPE (klass
),
105 G_STRUCT_OFFSET (AnjutaCommandClass
, progress
),
107 g_cclosure_marshal_VOID__FLOAT
,
113 anjuta_command_start (AnjutaCommand
*self
)
115 ANJUTA_COMMAND_GET_CLASS (self
)->start (self
);
119 anjuta_command_notify_data_arrived (AnjutaCommand
*self
)
121 ANJUTA_COMMAND_GET_CLASS (self
)->notify_data_arrived (self
);
125 anjuta_command_notify_complete (AnjutaCommand
*self
, guint return_code
)
127 ANJUTA_COMMAND_GET_CLASS (self
)->notify_complete (self
, return_code
);
131 anjuta_command_notify_progress (AnjutaCommand
*self
, gfloat progress
)
133 ANJUTA_COMMAND_GET_CLASS (self
)->notify_progress (self
, progress
);
137 anjuta_command_set_error_message (AnjutaCommand
*self
, gchar
*error_message
)
139 if (self
->priv
->error_message
)
140 g_free (error_message
);
142 self
->priv
->error_message
= g_strdup (error_message
);
146 anjuta_command_get_error_message (AnjutaCommand
*self
)
148 return g_strdup (self
->priv
->error_message
);