anjuta r4453 - in trunk: . libanjuta



Author: jrliggett
Date: Wed Dec 17 22:59:53 2008
New Revision: 4453
URL: http://svn.gnome.org/viewvc/anjuta?rev=4453&view=rev

Log:
* libanjuta/Makefile.am:
* libanjuta/anjuta-async-notify.c (anjuta_async_notify_init),
(anjuta_async_notify_finalize), (anjuta_async_notify_finished),
(anjuta_async_notify_class_init), (anjuta_async_notify_new),
(anjuta_async_notify_get_error), (anjuta_async_notify_set_error),
(anjuta_async_notify_notify_finished):
* libanjuta/anjuta-async-notify.h:

Add new AnjutaAsyncNotify object to libanjuta to handle 
finish notifications for interfaces that usually work asynchronously,
like IAnjutaVCS. 

Added:
   trunk/libanjuta/anjuta-async-notify.c
   trunk/libanjuta/anjuta-async-notify.h
Modified:
   trunk/ChangeLog
   trunk/libanjuta/Makefile.am

Modified: trunk/libanjuta/Makefile.am
==============================================================================
--- trunk/libanjuta/Makefile.am	(original)
+++ trunk/libanjuta/Makefile.am	Wed Dec 17 22:59:53 2008
@@ -71,10 +71,11 @@
 	anjuta-async-command.h \
 	anjuta-sync-command.c \
 	anjuta-sync-command.h \
+	anjuta-async-notify.h \
+	anjuta-async-notify.c \
 	anjuta-message-area.h \
 	anjuta-debug.c \
 	anjuta-debug.h
-	
 
 if HAVE_PLUGIN_GLADE
 

Added: trunk/libanjuta/anjuta-async-notify.c
==============================================================================
--- (empty file)
+++ trunk/libanjuta/anjuta-async-notify.c	Wed Dec 17 22:59:53 2008
@@ -0,0 +1,162 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta 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 3 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "anjuta-async-notify.h"
+
+/**
+ * SECTION: anjuta-async-notify
+ * @short_description: Mechanism used by interfaces that run asynchronously to 
+ *					   notify clients of finished tasks and to report errors.
+ *
+ * #AnjutaAsyncNotify is a way to allow Anjuta interfaces that run 
+ * asynchronously, such as #IAnjutaVCS, to notify clients that a method has 
+ * completed. #AnjutaAsyncNotify also reports errors to the user. 
+ * 
+ * All clients need to do is create an instance of #AnjutaAsyncNotify, connect
+ * to the finished signal, and pass it in to the interface method to be called. 
+ */
+
+enum
+{
+	FINISHED,
+
+	LAST_SIGNAL
+};
+
+
+static guint async_notify_signals[LAST_SIGNAL] = { 0 };
+
+struct _AnjutaAsyncNotifyPriv
+{
+	GError *error;
+};
+
+G_DEFINE_TYPE (AnjutaAsyncNotify, anjuta_async_notify, G_TYPE_OBJECT);
+
+static void
+anjuta_async_notify_init (AnjutaAsyncNotify *self)
+{
+	self->priv = g_new0 (AnjutaAsyncNotifyPriv, 1);
+}
+
+static void
+anjuta_async_notify_finalize (GObject *object)
+{
+	AnjutaAsyncNotify *self;
+	
+	self = ANJUTA_ASYNC_NOTIFY (object);
+	
+	g_error_free (self->priv->error);
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (anjuta_async_notify_parent_class)->finalize (object);
+}
+
+static void
+anjuta_async_notify_finished (AnjutaAsyncNotify *self)
+{
+	
+}
+
+static void
+anjuta_async_notify_class_init (AnjutaAsyncNotifyClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = anjuta_async_notify_finalize;
+
+	klass->finished = anjuta_async_notify_finished;
+	
+	/**
+	 * AnjutaAsyncNotify::finished:
+	 * @notify: AnjutaAsyncNotify object.
+	 *
+	 * Notifies clients that the requested task has finished.
+	 */
+	async_notify_signals[FINISHED] =
+		g_signal_new ("finished",
+		              G_OBJECT_CLASS_TYPE (klass),
+		              0,
+		              G_STRUCT_OFFSET (AnjutaAsyncNotifyClass, finished),
+		              NULL, NULL,
+		              g_cclosure_marshal_VOID__VOID,
+		              G_TYPE_NONE, 0,
+		              NULL);
+}
+
+/**
+ * anjuta_async_notify_new:
+ *
+ * Creates a new #AnjutaAsyncNotify object.
+ *
+ * Return value: a new #AnjutaAsyncNotify instance
+ */
+AnjutaAsyncNotify *
+anjuta_async_notify_new (void)
+{
+	return g_object_new (ANJUTA_TYPE_ASYNC_NOTIFY, NULL);
+}
+
+/**
+ * anjuta_async_notify_get_error:
+ *
+ * Gets the error set on @self.
+ *
+ * @self: An #AnjutaAsyncNotify object
+ * @error: Return location for the error set by the called interface to which 
+ *		   this object was passed. If no error is set, @error is set to NULL.
+ */
+void
+anjuta_async_notify_get_error (AnjutaAsyncNotify *self, GError **error)
+{
+	if (self->priv->error)
+		*error = g_error_copy (self->priv->error);
+}
+
+/**
+ * anjuta_async_notify_set_error:
+ *
+ * Sets the error for an interface call. This method should only be used by 
+ * interface implementations themselves, not by clients. 
+ *
+ * @self: An #AnjutaAsyncNotify object
+ * @error: Error to set
+ */
+void
+anjuta_async_notify_set_error (AnjutaAsyncNotify *self, GError *error)
+{
+	if (self->priv->error)
+		g_error_free (self->priv->error);
+	
+	self->priv->error = g_error_copy (error);
+}
+
+/**
+ * anjuta_async_notify_notify_finished:
+ *
+ * Emits the finished signal. This method should only be used by 
+ * interface methods themselves, not by clients. 
+ *
+ * @self: An #AnjutaAsyncNotify object
+ */
+void
+anjuta_async_notify_notify_finished (AnjutaAsyncNotify *self)
+{
+	g_signal_emit_by_name (self, "finished", NULL);
+}

Added: trunk/libanjuta/anjuta-async-notify.h
==============================================================================
--- (empty file)
+++ trunk/libanjuta/anjuta-async-notify.h	Wed Dec 17 22:59:53 2008
@@ -0,0 +1,62 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta 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 3 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _ANJUTA_ASYNC_NOTIFY_H_
+#define _ANJUTA_ASYNC_NOTIFY_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define ANJUTA_TYPE_ASYNC_NOTIFY             (anjuta_async_notify_get_type ())
+#define ANJUTA_ASYNC_NOTIFY(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANJUTA_TYPE_ASYNC_NOTIFY, AnjutaAsyncNotify))
+#define ANJUTA_ASYNC_NOTIFY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ANJUTA_TYPE_ASYNC_NOTIFY, AnjutaAsyncNotifyClass))
+#define ANJUTA_IS_ASYNC_NOTIFY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANJUTA_TYPE_ASYNC_NOTIFY))
+#define ANJUTA_IS_ASYNC_NOTIFY_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ANJUTA_TYPE_ASYNC_NOTIFY))
+#define ANJUTA_ASYNC_NOTIFY_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ANJUTA_TYPE_ASYNC_NOTIFY, AnjutaAsyncNotifyClass))
+
+typedef struct _AnjutaAsyncNotifyClass AnjutaAsyncNotifyClass;
+typedef struct _AnjutaAsyncNotify AnjutaAsyncNotify;
+typedef struct _AnjutaAsyncNotifyPriv AnjutaAsyncNotifyPriv;
+
+
+struct _AnjutaAsyncNotifyClass
+{
+	GObjectClass parent_class;
+
+	/* Signals */
+	void (*finished) (AnjutaAsyncNotify *self);
+};
+
+struct _AnjutaAsyncNotify
+{
+	GObject parent_instance;
+	
+	AnjutaAsyncNotifyPriv *priv;
+};
+
+GType anjuta_async_notify_get_type (void) G_GNUC_CONST;
+AnjutaAsyncNotify *anjuta_async_notify_new (void);
+void anjuta_async_notify_get_error (AnjutaAsyncNotify *self, GError **error);
+void anjuta_async_notify_notify_finished (AnjutaAsyncNotify *self);
+void anjuta_async_notify_set_error (AnjutaAsyncNotify *self, GError *error);
+
+G_END_DECLS
+
+#endif /* _ANJUTA_ASYNC_NOTIFY_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]