2
A small subclass of the menuitem for using clients.
4
Copyright 2010 Canonical Ltd.
7
Ted Gould <ted@canonical.com>
9
This program is free software: you can redistribute it and/or modify it
10
under the terms of either or both of the following licenses:
12
1) the GNU Lesser General Public License version 3, as published by the
13
Free Software Foundation; and/or
14
2) the GNU Lesser General Public License version 2.1, as published by
15
the Free Software Foundation.
17
This program is distributed in the hope that it will be useful, but
18
WITHOUT ANY WARRANTY; without even the implied warranties of
19
MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
20
PURPOSE. See the applicable version of the GNU Lesser General Public
21
License for more details.
23
You should have received a copy of both the GNU Lesser General Public
24
License version 3 and version 2.1 along with this program. If not, see
25
<http://www.gnu.org/licenses/>
32
#include "client-menuitem.h"
34
typedef struct _DbusmenuClientMenuitemPrivate DbusmenuClientMenuitemPrivate;
36
struct _DbusmenuClientMenuitemPrivate
38
DbusmenuClient * client;
41
#define DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(o) \
42
(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemPrivate))
44
static void dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass);
45
static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self);
46
static void dbusmenu_client_menuitem_dispose (GObject *object);
47
static void dbusmenu_client_menuitem_finalize (GObject *object);
48
static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
50
G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM);
53
dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass)
55
GObjectClass *object_class = G_OBJECT_CLASS (klass);
57
g_type_class_add_private (klass, sizeof (DbusmenuClientMenuitemPrivate));
59
object_class->dispose = dbusmenu_client_menuitem_dispose;
60
object_class->finalize = dbusmenu_client_menuitem_finalize;
62
DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass);
63
mclass->handle_event = handle_event;
69
dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self)
76
dbusmenu_client_menuitem_dispose (GObject *object)
79
G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->dispose (object);
84
dbusmenu_client_menuitem_finalize (GObject *object)
87
G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->finalize (object);
91
DbusmenuClientMenuitem *
92
dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client)
94
DbusmenuClientMenuitem * mi = g_object_new(DBUSMENU_CLIENT_MENUITEM_TYPE, "id", id, NULL);
95
DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi);
96
priv->client = client;
101
handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
103
DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi);
104
dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp);