summaryrefslogtreecommitdiff
path: root/gvfs
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@src.gnome.org>2007-09-13 10:13:55 +0000
committerAlexander Larsson <alexl@src.gnome.org>2007-09-13 10:13:55 +0000
commit1ec05948cf1399087513da33a9f336afb648059d (patch)
tree63fbbcfcf9656fb40b699d10817262e8ac1204cf /gvfs
parentbed15426677f319c9263a3015444ace0633093f7 (diff)
downloadgvfs-1ec05948cf1399087513da33a9f336afb648059d.tar.gz
Add cancelled signal to GCancellable
Original git commit by Alexander Larsson <alex@greebo.(none)> at 1164620211 +0100 svn path=/trunk/; revision=188
Diffstat (limited to 'gvfs')
-rw-r--r--gvfs/gcancellable.c25
-rw-r--r--gvfs/gcancellable.h2
2 files changed, 25 insertions, 2 deletions
diff --git a/gvfs/gcancellable.c b/gvfs/gcancellable.c
index 04412e27..42e6ab5f 100644
--- a/gvfs/gcancellable.c
+++ b/gvfs/gcancellable.c
@@ -3,8 +3,15 @@
#include <unistd.h>
#include <fcntl.h>
+#include <gvfstypes.h>
+
#include "gcancellable.h"
+enum {
+ CANCELLED,
+ LAST_SIGNAL
+};
+
struct _GCancellable
{
GObject parent_instance;
@@ -14,6 +21,8 @@ struct _GCancellable
int cancel_pipe[2];
};
+static guint signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE (GCancellable, g_cancellable, G_TYPE_OBJECT);
static GStaticPrivate current_cancellable = G_STATIC_PRIVATE_INIT;
@@ -40,6 +49,16 @@ g_cancellable_class_init (GCancellableClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_cancellable_finalize;
+
+ signals[CANCELLED] =
+ g_signal_new (I_("cancelled"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GCancellableClass, cancelled),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
}
static void
@@ -169,7 +188,6 @@ void
g_cancellable_cancel (GCancellable *cancellable)
{
G_LOCK(cancellable);
-
if (cancellable != NULL &&
!cancellable->cancelled)
{
@@ -178,8 +196,11 @@ g_cancellable_cancel (GCancellable *cancellable)
if (cancellable->cancel_pipe[1] != -1)
write (cancellable->cancel_pipe[1], &ch, 1);
}
-
G_UNLOCK(cancellable);
+
+ g_object_ref (cancellable);
+ g_signal_emit (cancellable, signals[CANCELLED], 0);
+ g_object_unref (cancellable);
}
diff --git a/gvfs/gcancellable.h b/gvfs/gcancellable.h
index 62d91b50..07b9e59a 100644
--- a/gvfs/gcancellable.h
+++ b/gvfs/gcancellable.h
@@ -18,6 +18,8 @@ typedef struct _GCancellableClass GCancellableClass;
struct _GCancellableClass
{
GObjectClass parent_class;
+
+ void (* cancelled) (GCancellable *cancellable);
};
GType g_cancellable_get_type (void) G_GNUC_CONST;