aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-06-23 15:00:45 -0500
committerTed Gould <ted@canonical.com>2009-06-23 15:00:45 -0500
commitde09b3a907fa4ace875dd2446a9217b940ede6b5 (patch)
tree094320efef14bbbab75a1c187ed35a13a96809d6 /libdbusmenu-glib
parent33840cbf787d90bde160184e170a211b809b6306 (diff)
downloadlibdbusmenu-de09b3a907fa4ace875dd2446a9217b940ede6b5.tar.gz
libdbusmenu-de09b3a907fa4ace875dd2446a9217b940ede6b5.tar.bz2
libdbusmenu-de09b3a907fa4ace875dd2446a9217b940ede6b5.zip
Now we're also signalling when a child gets moved around.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem.c12
-rw-r--r--libdbusmenu-glib/menuitem.h2
2 files changed, 13 insertions, 1 deletions
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);