aboutsummaryrefslogtreecommitdiff
path: root/liblogdiag
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2012-08-30 06:50:46 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2012-08-31 14:04:09 +0200
commitcf5260990c98a3c05856f399d5d96f7d1e697beb (patch)
treeb3269c77746ce870c6cb98c85b43b9bb340620ef /liblogdiag
parent20c2595f2de956f70f164fa3b822989e178f0459 (diff)
downloadlogdiag-cf5260990c98a3c05856f399d5d96f7d1e697beb.tar.gz
logdiag-cf5260990c98a3c05856f399d5d96f7d1e697beb.tar.xz
logdiag-cf5260990c98a3c05856f399d5d96f7d1e697beb.zip
Improve code in LdDiagram a bit.
Diffstat (limited to 'liblogdiag')
-rw-r--r--liblogdiag/ld-diagram.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/liblogdiag/ld-diagram.c b/liblogdiag/ld-diagram.c
index 46f94df..2f5732e 100644
--- a/liblogdiag/ld-diagram.c
+++ b/liblogdiag/ld-diagram.c
@@ -56,7 +56,7 @@ typedef struct _ObjectActionData ObjectActionData;
*/
struct _ObjectActionData
{
- LdDiagram *self;
+ gpointer self;
LdDiagramObject *object;
gint pos;
};
@@ -804,19 +804,14 @@ ld_diagram_end_user_action (LdDiagram *self)
}
static void
-action_finalize_notify_cb (ObjectActionData *data, LdDiagram *self)
-{
- data->self = NULL;
-}
-
-static void
on_object_action_remove (gpointer user_data)
{
ObjectActionData *data;
data = user_data;
g_return_if_fail (data->self != NULL);
- ld_diagram_remove_object (data->self, data->object);
+ ld_diagram_remove_object
+ ((LdDiagram *) data->self, data->object);
}
static void
@@ -826,7 +821,8 @@ on_object_action_insert (gpointer user_data)
data = user_data;
g_return_if_fail (data->self != NULL);
- ld_diagram_insert_object (data->self, data->object, data->pos);
+ ld_diagram_insert_object
+ ((LdDiagram *) data->self, data->object, data->pos);
}
static void
@@ -835,8 +831,8 @@ on_object_action_destroy (gpointer user_data)
ObjectActionData *data;
data = user_data;
- g_object_weak_unref (G_OBJECT (data->self),
- (GWeakNotify) action_finalize_notify_cb, data);
+ if (data->self)
+ g_object_remove_weak_pointer (G_OBJECT (data->self), &data->self);
g_object_unref (data->object);
g_slice_free (ObjectActionData, data);
}
@@ -901,8 +897,7 @@ ld_diagram_insert_object (LdDiagram *self, LdDiagramObject *object, gint pos)
action_data = g_slice_new (ObjectActionData);
action_data->self = self;
- g_object_weak_ref (G_OBJECT (self),
- (GWeakNotify) action_finalize_notify_cb, action_data);
+ g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
action_data->object = g_object_ref (object);
action_data->pos = pos;
@@ -950,8 +945,7 @@ ld_diagram_remove_object (LdDiagram *self, LdDiagramObject *object)
action_data = g_slice_new (ObjectActionData);
action_data->self = self;
- g_object_weak_ref (G_OBJECT (self),
- (GWeakNotify) action_finalize_notify_cb, action_data);
+ g_object_add_weak_pointer (G_OBJECT (self), &action_data->self);
action_data->object = g_object_ref (object);
action_data->pos = pos;
@@ -1037,13 +1031,15 @@ ld_diagram_select (LdDiagram *self, LdDiagramObject *object)
void
ld_diagram_unselect (LdDiagram *self, LdDiagramObject *object)
{
+ GList *link;
+
g_return_if_fail (LD_IS_DIAGRAM (self));
g_return_if_fail (LD_IS_DIAGRAM_OBJECT (object));
- if (!g_list_find (self->priv->selection, object))
+ if (!(link = g_list_find (self->priv->selection, object)))
return;
- self->priv->selection = g_list_remove (self->priv->selection, object);
+ self->priv->selection = g_list_delete_link (self->priv->selection, link);
g_object_unref (object);
g_signal_emit (self,