From f3121cfdc03b6952249f217b5368643c2e557088 Mon Sep 17 00:00:00 2001 From: James Liggett Date: Sat, 29 Mar 2008 17:46:15 -0700 Subject: [PATCH] Implement AnjutaSyncCommand class in libanjuta. --- libanjuta/Makefile.am | 4 ++- libanjuta/anjuta-sync-command.c | 74 +++++++++++++++++++++++++++++++++++++++++ libanjuta/anjuta-sync-command.h | 57 +++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 libanjuta/anjuta-sync-command.c create mode 100644 libanjuta/anjuta-sync-command.h diff --git a/libanjuta/Makefile.am b/libanjuta/Makefile.am index c3b4cd77..17d94036 100644 --- a/libanjuta/Makefile.am +++ b/libanjuta/Makefile.am @@ -65,7 +65,9 @@ libanjuta_la_SOURCES= \ anjuta-command.c \ anjuta-command.h \ anjuta-async-command.c \ - anjuta-async-command.h + anjuta-async-command.h \ + anjuta-sync-command.c \ + anjuta-sync-command.h if HAVE_PLUGIN_GLADE diff --git a/libanjuta/anjuta-sync-command.c b/libanjuta/anjuta-sync-command.c new file mode 100644 index 00000000..4d9b9964 --- /dev/null +++ b/libanjuta/anjuta-sync-command.c @@ -0,0 +1,74 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2007 + * + * anjuta is free software. + * + * You may 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. + * + * anjuta 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 anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#include "anjuta-sync-command.h" + +G_DEFINE_TYPE (AnjutaSyncCommand, anjuta_sync_command, ANJUTA_TYPE_COMMAND); + +static void +anjuta_sync_command_init (AnjutaSyncAnjutaCommand *self) +{ + +} + +static void +anjuta_sync_command_finalize (GObject *object) +{ + G_OBJECT_CLASS (anjuta_sync_command_parent_class)->finalize (object); +} + +static void +start_command (AnjutaCommand *command) +{ + guint return_code; + + return_code = COMMAND_GET_CLASS (command)->run (command); + command_notify_complete (command, return_code); +} + +static void +notify_data_arrived (AnjutaCommand *command) +{ + g_signal_emit_by_name (command, "data-arrived"); +} + +static void +notify_complete (AnjutaCommand *command, guint return_code) +{ + g_signal_emit_by_name (command, "command-finished", + return_code); +} + +static void +anjuta_sync_command_class_init (AnjutaSyncAnjutaCommandClass *klass) +{ + GObjectClass* object_class = G_OBJECT_CLASS (klass); + AnjutaCommandClass* parent_class = ANJUTA_COMMAND_CLASS (klass); + + object_class->finalize = anjuta_anjuta_sync_command_finalize; + + parent_class->start = start_command; + parent_class->notify_data_arrived = notify_data_arrived; + parent_class->notify_complete = notify_complete; +} diff --git a/libanjuta/anjuta-sync-command.h b/libanjuta/anjuta-sync-command.h new file mode 100644 index 00000000..43bd842b --- /dev/null +++ b/libanjuta/anjuta-sync-command.h @@ -0,0 +1,57 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * anjuta + * Copyright (C) James Liggett 2007 + * + * anjuta is free software. + * + * You may 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. + * + * anjuta 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 anjuta. If not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef _ANJUTA_SYNC_COMMAND_H_ +#define _ANJUTA_SYNC_COMMAND_H_ + +#include +#include "anjuta-command.h" + +G_BEGIN_DECLS + +#define ANJUTA_TYPE_SYNC_COMMAND (sync_command_get_type ()) +#define ANJUTA_SYNC_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_SYNC_COMMAND, SyncCommand)) +#define ANJUTA_SYNC_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_SYNC_COMMAND, SyncCommandClass)) +#define ANJUTA_IS_SYNC_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_SYNC_COMMAND)) +#define ANJUTA_IS_SYNC_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_SYNC_COMMAND)) +#define ANJUTA_SYNC_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_SYNC_COMMAND, SyncCommandClass)) + +typedef struct _AnjutaSyncCommandClass AnjutaSyncCommandClass; +typedef struct _AnjutaSyncCommand AnjutaSyncCommand; + +struct _AnjutaSyncCommandClass +{ + AnjutaCommandClass parent_class; +}; + +struct _AnjutaSyncCommand +{ + AnjutaCommand parent_instance; +}; + +GType anjuta_sync_command_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* _ANJUTA_SYNC_COMMAND_H_ */ -- 2.11.4.GIT