1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/* transport-menu-item.c generated by valac, the Vala compiler
* generated from transport-menu-item.vala, do not modify */
/*
Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 3, as published
by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranties of
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
#include <glib-object.h>
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/menuitem-proxy.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
#include <common-defs.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#define TYPE_PLAYER_ITEM (player_item_get_type ())
#define PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PLAYER_ITEM, PlayerItem))
#define PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PLAYER_ITEM, PlayerItemClass))
#define IS_PLAYER_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PLAYER_ITEM))
#define IS_PLAYER_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PLAYER_ITEM))
#define PLAYER_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PLAYER_ITEM, PlayerItemClass))
typedef struct _PlayerItem PlayerItem;
typedef struct _PlayerItemClass PlayerItemClass;
typedef struct _PlayerItemPrivate PlayerItemPrivate;
#define TYPE_MPRIS_CONTROLLER (mpris_controller_get_type ())
#define MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MPRIS_CONTROLLER, MprisController))
#define MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
#define IS_MPRIS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MPRIS_CONTROLLER))
#define IS_MPRIS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MPRIS_CONTROLLER))
#define MPRIS_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MPRIS_CONTROLLER, MprisControllerClass))
typedef struct _MprisController MprisController;
typedef struct _MprisControllerClass MprisControllerClass;
#define TYPE_TRANSPORT_MENUITEM (transport_menuitem_get_type ())
#define TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitem))
#define TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))
#define IS_TRANSPORT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TRANSPORT_MENUITEM))
#define IS_TRANSPORT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TRANSPORT_MENUITEM))
#define TRANSPORT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TRANSPORT_MENUITEM, TransportMenuitemClass))
typedef struct _TransportMenuitem TransportMenuitem;
typedef struct _TransportMenuitemClass TransportMenuitemClass;
typedef struct _TransportMenuitemPrivate TransportMenuitemPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _PlayerItem {
DbusmenuMenuitem parent_instance;
PlayerItemPrivate * priv;
MprisController* mpris_adaptor;
};
struct _PlayerItemClass {
DbusmenuMenuitemClass parent_class;
void (*check_layout) (PlayerItem* self);
};
struct _TransportMenuitem {
PlayerItem parent_instance;
TransportMenuitemPrivate * priv;
};
struct _TransportMenuitemClass {
PlayerItemClass parent_class;
};
static gpointer transport_menuitem_parent_class = NULL;
GType player_item_get_type (void);
GType mpris_controller_get_type (void);
GType transport_menuitem_get_type (void);
enum {
TRANSPORT_MENUITEM_DUMMY_PROPERTY
};
PlayerItem* player_item_new (void);
PlayerItem* player_item_construct (GType object_type);
TransportMenuitem* transport_menuitem_new (void);
TransportMenuitem* transport_menuitem_construct (GType object_type);
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state);
void mpris_controller_toggle_playback (MprisController* self, gboolean state);
static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp);
static void transport_menuitem_real_check_layout (PlayerItem* base);
GeeHashSet* transport_menuitem_attributes_format (void);
TransportMenuitem* transport_menuitem_construct (GType object_type) {
TransportMenuitem * self;
self = (TransportMenuitem*) player_item_construct (object_type);
dbusmenu_menuitem_property_set ((DbusmenuMenuitem*) self, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_TRANSPORT_MENUITEM_TYPE);
g_debug ("transport-menu-item.vala:30: transport on the vala side");
return self;
}
TransportMenuitem* transport_menuitem_new (void) {
return transport_menuitem_construct (TYPE_TRANSPORT_MENUITEM);
}
void transport_menuitem_change_play_state (TransportMenuitem* self, gint state) {
g_return_if_fail (self != NULL);
dbusmenu_menuitem_property_set_int ((DbusmenuMenuitem*) self, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE, state);
}
static char* bool_to_string (gboolean self) {
char* result = NULL;
if (self) {
result = g_strdup ("true");
return result;
} else {
result = g_strdup ("false");
return result;
}
}
static void transport_menuitem_real_handle_event (DbusmenuMenuitem* base, const char* name, GValue* input_value, guint timestamp) {
TransportMenuitem * self;
char* _tmp0_;
self = (TransportMenuitem*) base;
g_return_if_fail (name != NULL);
g_debug ("transport-menu-item.vala:40: handle_event with bool value %s", _tmp0_ = bool_to_string (g_value_get_boolean (input_value)));
_g_free0 (_tmp0_);
mpris_controller_toggle_playback (((PlayerItem*) self)->mpris_adaptor, g_value_get_boolean (input_value));
}
static void transport_menuitem_real_check_layout (PlayerItem* base) {
TransportMenuitem * self;
self = (TransportMenuitem*) base;
}
GeeHashSet* transport_menuitem_attributes_format (void) {
GeeHashSet* result = NULL;
GeeHashSet* attrs;
attrs = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL);
gee_abstract_collection_add ((GeeAbstractCollection*) attrs, DBUSMENU_TRANSPORT_MENUITEM_PLAY_STATE);
result = attrs;
return result;
}
static void transport_menuitem_class_init (TransportMenuitemClass * klass) {
transport_menuitem_parent_class = g_type_class_peek_parent (klass);
DBUSMENU_MENUITEM_CLASS (klass)->handle_event = transport_menuitem_real_handle_event;
PLAYER_ITEM_CLASS (klass)->check_layout = transport_menuitem_real_check_layout;
}
static void transport_menuitem_instance_init (TransportMenuitem * self) {
}
GType transport_menuitem_get_type (void) {
static volatile gsize transport_menuitem_type_id__volatile = 0;
if (g_once_init_enter (&transport_menuitem_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (TransportMenuitemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) transport_menuitem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TransportMenuitem), 0, (GInstanceInitFunc) transport_menuitem_instance_init, NULL };
GType transport_menuitem_type_id;
transport_menuitem_type_id = g_type_register_static (TYPE_PLAYER_ITEM, "TransportMenuitem", &g_define_type_info, 0);
g_once_init_leave (&transport_menuitem_type_id__volatile, transport_menuitem_type_id);
}
return transport_menuitem_type_id__volatile;
}
|