From de09b3a907fa4ace875dd2446a9217b940ede6b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 23 Jun 2009 15:00:45 -0500 Subject: Now we're also signalling when a child gets moved around. --- libdbusmenu-glib/menuitem.c | 12 ++++++++++++ libdbusmenu-glib/menuitem.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 9a16353..57f1832 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -509,9 +509,21 @@ dbusmenu_menuitem_child_reorder(DbusmenuMenuitem * mi, DbusmenuMenuitem * child, g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + gint oldpos = g_list_index(priv->children, child); + + if (oldpos == -1) { + g_warning("Can not reorder child that isn't actually a child."); + return FALSE; + } + if (oldpos == position) { + return TRUE; + } + priv->children = g_list_remove(priv->children, child); priv->children = g_list_insert(priv->children, child, position); + g_signal_emit(G_OBJECT(mi), signals[CHILD_MOVED], 0, child, position, oldpos, TRUE); + return TRUE; } diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 18c6e9a..bad687b 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -88,7 +88,7 @@ struct _DbusmenuMenuitemClass void (*item_activated) (void); void (*child_added) (DbusmenuMenuitem * child, guint position); void (*child_removed) (DbusmenuMenuitem * child); - void (*child_moved) (DbusmenuMenuitem * child, guint oldpos, guint newpos); + void (*child_moved) (DbusmenuMenuitem * child, guint newpos, guint oldpos); /* Virtual functions */ void (*buildxml) (GPtrArray * stringarray); -- cgit v1.2.3