~ubuntu-branches/ubuntu/lucid/libdbusmenu/lucid

« back to all changes in this revision

Viewing changes to libdbusmenu-glib/client-menuitem.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Ted Gould
  • Date: 2010-02-04 13:56:49 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100204135649-pe86ycwm3xyn0dlu
Tags: 0.2.2-0ubuntu1
* Updated for the soname changes

[ Ted Gould ]
* Upstream Release 0.2.2
  * Interoperability fixes
  * Adding timestamps to events
  * Better handling of XML
  * Adding tools for timing dbusmenu
* debian/libdbusmenu-tools.install: Adding a wildcard to get
  all of the tools in libexec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
A small subclass of the menuitem for using clients.
 
3
 
 
4
Copyright 2010 Canonical Ltd.
 
5
 
 
6
Authors:
 
7
    Ted Gould <ted@canonical.com>
 
8
 
 
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:
 
11
 
 
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.
 
16
 
 
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.
 
22
 
 
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/>
 
26
*/
 
27
 
 
28
#ifdef HAVE_CONFIG_H
 
29
#include "config.h"
 
30
#endif
 
31
 
 
32
#include "client-menuitem.h"
 
33
 
 
34
typedef struct _DbusmenuClientMenuitemPrivate DbusmenuClientMenuitemPrivate;
 
35
 
 
36
struct _DbusmenuClientMenuitemPrivate
 
37
{
 
38
        DbusmenuClient * client;
 
39
};
 
40
 
 
41
#define DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(o) \
 
42
(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemPrivate))
 
43
 
 
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);
 
49
 
 
50
G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM);
 
51
 
 
52
static void
 
53
dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass)
 
54
{
 
55
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
56
 
 
57
        g_type_class_add_private (klass, sizeof (DbusmenuClientMenuitemPrivate));
 
58
 
 
59
        object_class->dispose = dbusmenu_client_menuitem_dispose;
 
60
        object_class->finalize = dbusmenu_client_menuitem_finalize;
 
61
 
 
62
        DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass);
 
63
        mclass->handle_event = handle_event;
 
64
 
 
65
        return;
 
66
}
 
67
 
 
68
static void
 
69
dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self)
 
70
{
 
71
 
 
72
        return;
 
73
}
 
74
 
 
75
static void
 
76
dbusmenu_client_menuitem_dispose (GObject *object)
 
77
{
 
78
 
 
79
        G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->dispose (object);
 
80
        return;
 
81
}
 
82
 
 
83
static void
 
84
dbusmenu_client_menuitem_finalize (GObject *object)
 
85
{
 
86
 
 
87
        G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->finalize (object);
 
88
        return;
 
89
}
 
90
 
 
91
DbusmenuClientMenuitem *
 
92
dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client)
 
93
{
 
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;
 
97
        return mi;
 
98
}
 
99
 
 
100
static void
 
101
handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
 
102
{
 
103
        DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi);
 
104
        dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp);
 
105
        return;
 
106
}