aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-06-23 14:38:58 -0500
committerTed Gould <ted@canonical.com>2009-06-23 14:38:58 -0500
commit33840cbf787d90bde160184e170a211b809b6306 (patch)
tree59f691d476748302087f3ce618d9d9a92fcc6828 /libdbusmenu-glib
parentc5a234b4cda5cba525fdea9345a1b62758bde6b5 (diff)
downloadlibdbusmenu-33840cbf787d90bde160184e170a211b809b6306.tar.gz
libdbusmenu-33840cbf787d90bde160184e170a211b809b6306.tar.bz2
libdbusmenu-33840cbf787d90bde160184e170a211b809b6306.zip
Adding in the 'moved' signal and make it so that the 'added' signal has the position in it.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem-marshal.list2
-rw-r--r--libdbusmenu-glib/menuitem.c29
-rw-r--r--libdbusmenu-glib/menuitem.h5
3 files changed, 30 insertions, 6 deletions
diff --git a/libdbusmenu-glib/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list
index fc0318f..a32e7e3 100644
--- a/libdbusmenu-glib/menuitem-marshal.list
+++ b/libdbusmenu-glib/menuitem-marshal.list
@@ -1,3 +1,5 @@
VOID: STRING, STRING
+VOID: OBJECT, UINT, UINT
+VOID: OBJECT, UINT
VOID: OBJECT
VOID: VOID
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index 95391a4..9a16353 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -58,6 +58,7 @@ enum {
ITEM_ACTIVATED,
CHILD_ADDED,
CHILD_REMOVED,
+ CHILD_MOVED,
LAST_SIGNAL
};
@@ -129,6 +130,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
DbusmenuMenuitem::child-added:
@arg0: The #DbusmenuMenuitem which is the parent.
@arg1: The #DbusmenuMenuitem which is the child.
+ @arg2: The position that the child is being added in.
Signaled when the child menuitem has been added to
the parent.
@@ -138,8 +140,8 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(DbusmenuMenuitemClass, child_added),
NULL, NULL,
- _dbusmenu_menuitem_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ _dbusmenu_menuitem_marshal_VOID__OBJECT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
/**
DbusmenuMenuitem::child-removed:
@arg0: The #DbusmenuMenuitem which was the parent.
@@ -157,6 +159,23 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
NULL, NULL,
_dbusmenu_menuitem_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ /**
+ DbusmenuMenuitem::child-moved:
+ @arg0: The #DbusmenuMenuitem which is the parent.
+ @arg1: The #DbusmenuMenuitem which is the child.
+ @arg2: The position that the child is being moved to.
+ @arg3: The position that the child is was in.
+
+ Signaled when the child menuitem has had it's location
+ in the list change.
+ */
+ signals[CHILD_MOVED] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(DbusmenuMenuitemClass, child_moved),
+ NULL, NULL,
+ _dbusmenu_menuitem_marshal_VOID__OBJECT_UINT_UINT,
+ G_TYPE_NONE, 3, G_TYPE_OBJECT, G_TYPE_UINT, G_TYPE_UINT);
g_object_class_install_property (object_class, PROP_ID,
g_param_spec_uint("id", "ID for the menu item",
@@ -398,7 +417,7 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child)
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
priv->children = g_list_append(priv->children, child);
- g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, TRUE);
+ g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, g_list_length(priv->children) - 1, TRUE);
return TRUE;
}
@@ -420,7 +439,7 @@ dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
priv->children = g_list_prepend(priv->children, child);
- g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, TRUE);
+ g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, 0, TRUE);
return TRUE;
}
@@ -467,7 +486,7 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem *
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
priv->children = g_list_insert(priv->children, child, position);
- g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, TRUE);
+ g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, position, TRUE);
return TRUE;
}
diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h
index c4fcf73..18c6e9a 100644
--- a/libdbusmenu-glib/menuitem.h
+++ b/libdbusmenu-glib/menuitem.h
@@ -46,6 +46,7 @@ G_BEGIN_DECLS
#define DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED "item-activated"
#define DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED "child-added"
#define DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED "child-removed"
+#define DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED "child-moved"
/**
DbusmenuMenuitem:
@@ -69,6 +70,7 @@ struct _DbusmenuMenuitem
@item_activated: Slot for #DbusmenuMenuitem::item-activated.
@child_added: Slot for #DbusmenuMenuitem::child-added.
@child_removed: Slot for #DbusmenuMenuitem::child-removed.
+ @child_moved: Slot for #DbusmenuMenuitem::child-moved.
@buildxml: Virtual function that appends the strings required
to represent this menu item in the menu XML file.
@reserved1: Reserved for future use.
@@ -84,8 +86,9 @@ struct _DbusmenuMenuitemClass
/* Signals */
void (*property_changed) (gchar * property, gchar * value);
void (*item_activated) (void);
- void (*child_added) (DbusmenuMenuitem * child);
+ void (*child_added) (DbusmenuMenuitem * child, guint position);
void (*child_removed) (DbusmenuMenuitem * child);
+ void (*child_moved) (DbusmenuMenuitem * child, guint oldpos, guint newpos);
/* Virtual functions */
void (*buildxml) (GPtrArray * stringarray);