aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/Makefile.am15
-rw-r--r--libdbusmenu-glib/client-marshal.list1
-rw-r--r--libdbusmenu-glib/client.c47
-rw-r--r--libdbusmenu-glib/client.h6
-rw-r--r--libdbusmenu-glib/menuitem.c36
-rw-r--r--libdbusmenu-glib/menuitem.h11
-rw-r--r--libdbusmenu-glib/server.c4
7 files changed, 111 insertions, 9 deletions
diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am
index 3df1513..0a6513f 100644
--- a/libdbusmenu-glib/Makefile.am
+++ b/libdbusmenu-glib/Makefile.am
@@ -4,6 +4,7 @@ CLEANFILES =
EXTRA_DIST = \
dbusmenu-glib.pc.in \
dbus-menu.xml \
+ client-marshal.list \
menuitem-marshal.list \
server-marshal.list
@@ -32,6 +33,8 @@ libdbusmenu_glib_la_SOURCES = \
server.c \
server-marshal.h \
server-marshal.c \
+ client-marshal.h \
+ client-marshal.c \
client-menuitem.h \
client-menuitem.c \
client.h \
@@ -54,6 +57,8 @@ pkgconfigdir = $(libdir)/pkgconfig
BUILT_SOURCES = \
dbusmenu-client.h \
dbusmenu-server.h \
+ client-marshal.h \
+ client-marshal.c \
menuitem-marshal.h \
menuitem-marshal.c \
server-marshal.h \
@@ -73,6 +78,16 @@ dbusmenu-client.h: dbus-menu.xml
--output=dbusmenu-client.h \
$(srcdir)/dbus-menu.xml
+client-marshal.h: $(srcdir)/client-marshal.list
+ glib-genmarshal --header \
+ --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \
+ > client-marshal.h
+
+client-marshal.c: $(srcdir)/client-marshal.list
+ glib-genmarshal --body \
+ --prefix=_dbusmenu_client_marshal $(srcdir)/client-marshal.list \
+ > client-marshal.c
+
server-marshal.h: $(srcdir)/server-marshal.list
glib-genmarshal --header \
--prefix=_dbusmenu_server_marshal $(srcdir)/server-marshal.list \
diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list
new file mode 100644
index 0000000..34e3956
--- /dev/null
+++ b/libdbusmenu-glib/client-marshal.list
@@ -0,0 +1 @@
+VOID: OBJECT, UINT
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 4a93b8e..d88478c 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -41,6 +41,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include "client-menuitem.h"
#include "dbusmenu-client.h"
#include "server-marshal.h"
+#include "client-marshal.h"
/* Properties */
enum {
@@ -54,6 +55,7 @@ enum {
LAYOUT_UPDATED,
ROOT_CHANGED,
NEW_MENUITEM,
+ ITEM_ACTIVATE,
LAST_SIGNAL
};
@@ -123,6 +125,7 @@ static void update_layout (DbusmenuClient * client);
static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data);
static void get_properties_globber (DbusmenuClient * client, gint id, const gchar ** properties, org_ayatana_dbusmenu_get_properties_reply callback, gpointer user_data);
static GQuark error_domain (void);
+static void item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client);
/* Build a type */
G_DEFINE_TYPE (DbusmenuClient, dbusmenu_client, G_TYPE_OBJECT);
@@ -187,6 +190,22 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, G_TYPE_OBJECT);
+ /**
+ DbusmenuClient::item-activate:
+ @arg0: The #DbusmenuClient object
+ @arg1: The #DbusmenuMenuitem activated
+ @arg2: A timestamp that the event happened at
+
+ Signaled when the server wants to activate an item in
+ order to display the menu.
+ */
+ signals[ITEM_ACTIVATE] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE,
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DbusmenuClientClass, item_activate),
+ NULL, NULL,
+ _dbusmenu_client_marshal_VOID__OBJECT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
g_object_class_install_property (object_class, PROP_DBUSOBJECT,
g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent",
@@ -582,6 +601,30 @@ get_properties_globber (DbusmenuClient * client, gint id, const gchar ** propert
return;
}
+/* Called when a server item wants to activate the menu */
+static void
+item_activated (DBusGProxy * proxy, gint id, guint timestamp, DbusmenuClient * client)
+{
+ g_return_if_fail(DBUSMENU_IS_CLIENT(client));
+
+ DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+
+ if (priv->root == NULL) {
+ g_warning("Asked to activate item %d when we don't have a menu structure.", id);
+ return;
+ }
+
+ DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id);
+ if (menuitem == NULL) {
+ g_warning("Unable to find menu item %d to activate.", id);
+ return;
+ }
+
+ g_signal_emit(G_OBJECT(client), signals[ITEM_ACTIVATE], 0, menuitem, timestamp, TRUE);
+
+ return;
+}
+
/* Annoying little wrapper to make the right function update */
static void
layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client)
@@ -821,6 +864,10 @@ build_proxies (DbusmenuClient * client)
dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL);
+ dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(priv->menuproxy, "ItemActivationRequested", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(priv->menuproxy, "ItemActivationRequested", G_CALLBACK(item_activated), client, NULL);
+
update_layout(client);
return;
diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h
index 2b76f5e..6ca2232 100644
--- a/libdbusmenu-glib/client.h
+++ b/libdbusmenu-glib/client.h
@@ -46,6 +46,7 @@ G_BEGIN_DECLS
#define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED "layout-updated"
#define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed"
#define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem"
+#define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate"
#define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name"
#define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object"
@@ -59,10 +60,10 @@ G_BEGIN_DECLS
@parent_class: #GObjectClass
@layout_updated: Slot for #DbusmenuClient::layout-updated.
@new_menuitem: Slot for #DbusmenuClient::new-menuitem.
+ @item_activate: Slote for #DbusmenuClient::item-activate.
@reserved1: Reserved for future use.
@reserved2: Reserved for future use.
@reserved3: Reserved for future use.
- @reserved4: Reserved for future use.
A simple class that takes all of the information from a
#DbusmenuServer over DBus and makes the same set of
@@ -75,12 +76,13 @@ struct _DbusmenuClientClass {
void (*layout_updated)(void);
void (*root_changed) (DbusmenuMenuitem * newroot);
void (*new_menuitem) (DbusmenuMenuitem * newitem);
+ void (*item_activate) (DbusmenuMenuitem * item, guint timestamp);
/* Reserved for future use */
void (*reserved1) (void);
void (*reserved2) (void);
void (*reserved3) (void);
- void (*reserved4) (void);
+ /* void (*reserved4) (void); */
};
/**
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index 623539c..ea69776 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -70,6 +70,7 @@ enum {
CHILD_REMOVED,
CHILD_MOVED,
REALIZED,
+ SHOW_TO_USER,
LAST_SIGNAL
};
@@ -211,6 +212,22 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass)
NULL, NULL,
_dbusmenu_menuitem_marshal_VOID__VOID,
G_TYPE_NONE, 0, G_TYPE_NONE);
+ /**
+ DbusmenuMenuitem::show-to-user:
+ @arg0: The #DbusmenuMenuitem which should be shown.
+ @arg1: Timestamp the event happened at
+
+ Signaled when the application would like the visualization
+ of this menu item shown to the user. This usually requires
+ going over the bus to get it done.
+ */
+ signals[SHOW_TO_USER] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER,
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(DbusmenuMenuitemClass, show_to_user),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE);
g_object_class_install_property (object_class, PROP_ID,
g_param_spec_int(PROP_ID_S, "ID for the menu item",
@@ -1349,3 +1366,22 @@ dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_a
return;
}
+
+/**
+ dbusmenu_menuitem_show_to_user:
+ @mi: #DbusmenuMenuitem to show
+ @timestamp: The time that the user requested it to be shown
+
+ Signals that this menu item should be shown to the user. If this is
+ server side the server will then take it and send it over the
+ bus.
+*/
+void
+dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp)
+{
+ g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
+
+ g_signal_emit(G_OBJECT(mi), signals[SHOW_TO_USER], 0, timestamp, TRUE);
+
+ return;
+}
diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h
index e17d851..9be938b 100644
--- a/libdbusmenu-glib/menuitem.h
+++ b/libdbusmenu-glib/menuitem.h
@@ -49,6 +49,7 @@ G_BEGIN_DECLS
#define DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED "child-moved"
#define DBUSMENU_MENUITEM_SIGNAL_REALIZED "realized"
#define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM))
+#define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user"
#define DBUSMENU_MENUITEM_PROP_TYPE "type"
#define DBUSMENU_MENUITEM_PROP_VISIBLE "visible"
@@ -124,10 +125,7 @@ typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrAr
* @buildxml: Virtual function that appends the strings required to represent this menu item in the menu XML file.
* @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information.
* @send_about_to_show: Virtual function that notifies server that the client is about to show a menu.
- * @reserved1: Reserved for future use.
- * @reserved2: Reserved for future use.
- * @reserved3: Reserved for future use.
- * @reserved4: Reserved for future use.
+ * @show_to_user: Slot for #DbusmenuMenuitem::show-to-user.
*/
typedef struct _DbusmenuMenuitemClass DbusmenuMenuitemClass;
struct _DbusmenuMenuitemClass
@@ -147,7 +145,8 @@ struct _DbusmenuMenuitemClass
void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
void (*send_about_to_show) (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data);
- void (*reserved1) (void);
+ void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data);
+ /* void (*reserved1) (void); */
/* void (*reserved2) (void); */
/* void (*reserved3) (void); */
/* void (*reserved4) (void); -- realized, realloc when bumping lib version */
@@ -192,6 +191,8 @@ void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMen
void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
void dbusmenu_menuitem_send_about_to_show (DbusmenuMenuitem * mi, dbusmenu_menuitem_about_to_show_cb cb, gpointer cb_data);
+void dbusmenu_menuitem_show_to_user (DbusmenuMenuitem * mi, guint timestamp);
+
/**
* SECTION:menuitem
* @short_description: A lowlevel represenation of a menuitem
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index d1b4888..26e7a0d 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -410,7 +410,7 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint
/* Called when a menu item emits its activated signal so it
gets passed across the bus. */
static void
-menuitem_activated (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server)
+menuitem_shown (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server)
{
g_signal_emit(G_OBJECT(server), signals[ITEM_ACTIVATION], 0, dbusmenu_menuitem_get_id(mi), timestamp, TRUE);
return;
@@ -425,7 +425,7 @@ menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data)
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(menuitem_child_removed), data);
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(menuitem_child_moved), data);
g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menuitem_property_changed), data);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activated), data);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER, G_CALLBACK(menuitem_shown), data);
return;
}