aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/menuitem.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib/menuitem.c')
-rw-r--r--libdbusmenu-glib/menuitem.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index 8198929..14bc2db 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -92,6 +92,7 @@ static void set_property (GObject * obj, guint id, const GValue * value, GParamS
static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out);
static void g_value_transform_STRING_INT (const GValue * in, GValue * out);
+static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
/* GObject stuff */
G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT);
@@ -108,6 +109,8 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
+ klass->handle_event = handle_event;
+
/**
DbusmenuMenuitem::property-changed:
@arg0: The #DbusmenuMenuitem object.
@@ -339,6 +342,16 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec)
return;
}
+/* Handles the activate event if it is sent. */
+static void
+handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
+{
+ if (g_strcmp0(name, "clicked") == 0) {
+ g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, timestamp, TRUE);
+ }
+
+ return;
+}
/* Public interface */
@@ -1113,21 +1126,35 @@ dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem
}
/**
- dbusmenu_menuitem_activate:
+ dbusmenu_menuitem_handle_event:
@mi: The #DbusmenuMenuitem to send the signal on.
+ @name: The name of the signal
+ @value: A value that could be set for the event
@timestamp: The timestamp of when the event happened
+ This function is called to create an event. It is likely
+ to be overrided by subclasses. The default menu item
+ will respond to the activate signal and do:
+
Emits the #DbusmenuMenuitem::item-activate signal on this
menu item. Called by server objects when they get the
appropriate DBus signals from the client.
+
+ If you subclass this function you should really think
+ about calling the parent function unless you have a good
+ reason not to.
*/
void
-dbusmenu_menuitem_activate (DbusmenuMenuitem * mi, guint timestamp)
+dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
{
g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
#ifdef MASSIVEDEBUGGING
- g_debug("Menuitem %d (%s) activated", ID(mi), LABEL(mi));
+ g_debug("Menuitem %d (%s) is getting event '%s'", ID(mi), LABEL(mi), name);
#endif
- g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, timestamp, TRUE);
+ DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi);
+
+ if (class->handle_event != NULL) {
+ return class->handle_event(mi, name, value, timestamp);
+ }
return;
}