1
// -*- Mode: C; tab-width:2; indent-tabs-mode: t; c-basic-offset: 2 -*-
3
* Copyright (C) 2010 Canonical Ltd
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 3 as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18
* Rodrigo Moya <rodrigo.moya@canonical.com>
25
#include "panel-a11y.h"
26
#include "panel-service.h"
28
static GDBusNodeInfo *introspection_data = NULL;
35
* bool label_sensitive;
39
* bool icon_sensitive;
45
static const gchar introspection_xml[] =
47
" <interface name='com.canonical.Unity.Panel.Service'>"
49
" <method name='Sync'>"
50
" <arg type='a(ssssbbusbbi)' name='state' direction='out'/>"
53
" <method name='SyncOne'>"
54
" <arg type='s' name='indicator_id' direction='in'/>"
55
" <arg type='a(ssssbbusbbi)' name='state' direction='out'/>"
58
" <method name='SyncGeometries'>"
59
" <arg type='a(ssiiii)' name='geometries' direction='in'/>"
62
" <method name='ShowEntry'>"
63
" <arg type='s' name='entry_id' direction='in'/>"
64
" <arg type='u' name='timestamp' direction='in'/>"
65
" <arg type='i' name='x' direction='in'/>"
66
" <arg type='i' name='y' direction='in'/>"
67
" <arg type='i' name='button' direction='in'/>"
70
" <method name='SecondaryActivateEntry'>"
71
" <arg type='s' name='entry_id' direction='in'/>"
72
" <arg type='u' name='timestamp' direction='in'/>"
75
" <method name='ScrollEntry'>"
76
" <arg type='s' name='entry_id' direction='in'/>"
77
" <arg type='i' name='delta' direction='in'/>"
80
" <signal name='EntryActivated'>"
81
" <arg type='s' name='entry_id' />"
84
" <signal name='ReSync'>"
85
" <arg type='s' name='indicator_id' />"
88
" <signal name='EntryActivateRequest'>"
89
" <arg type='s' name='entry_id' />"
92
" <signal name='EntryShowNowChanged'>"
93
" <arg type='s' name='entry_id' />"
94
" <arg type='b' name='show_now_state' />"
100
#define S_NAME "com.canonical.Unity.Panel.Service"
101
#define S_PATH "/com/canonical/Unity/Panel/Service"
102
#define S_IFACE "com.canonical.Unity.Panel.Service"
106
handle_method_call (GDBusConnection *connection,
108
const gchar *object_path,
109
const gchar *interface_name,
110
const gchar *method_name,
111
GVariant *parameters,
112
GDBusMethodInvocation *invocation,
116
static const GDBusInterfaceVTable interface_vtable =
127
handle_method_call (GDBusConnection *connection,
129
const gchar *object_path,
130
const gchar *interface_name,
131
const gchar *method_name,
132
GVariant *parameters,
133
GDBusMethodInvocation *invocation,
136
PanelService *service = PANEL_SERVICE (user_data);
138
if (g_strcmp0 (method_name, "Sync") == 0)
140
g_dbus_method_invocation_return_value (invocation,
141
panel_service_sync (service));
143
else if (g_strcmp0 (method_name, "SyncOne") == 0)
146
g_variant_get (parameters, "(s)", &id, NULL);
147
g_dbus_method_invocation_return_value (invocation,
148
panel_service_sync_one (service,
152
else if (g_strcmp0 (method_name, "SyncGeometries") == 0)
155
gchar *indicator_id, *entry_id;
156
gint x, y, width, height;
158
g_variant_get (parameters, "(a(ssiiii))", &iter);
159
while (iter && g_variant_iter_loop (iter, "(ssiiii)",
167
panel_service_sync_geometry (service, indicator_id,
168
entry_id, x, y, width, height);
171
if (iter) g_variant_iter_free (iter);
173
g_dbus_method_invocation_return_value (invocation, NULL);
175
else if (g_strcmp0 (method_name, "ShowEntry") == 0)
182
g_variant_get (parameters, "(suiii)", &entry_id, ×tamp, &x, &y, &button, NULL);
184
panel_service_show_entry (service, entry_id, timestamp, x, y, button);
186
g_dbus_method_invocation_return_value (invocation, NULL);
189
else if (g_strcmp0 (method_name, "SecondaryActivateEntry") == 0)
193
g_variant_get (parameters, "(su)", &entry_id, ×tamp, NULL);
195
panel_service_secondary_activate_entry (service, entry_id, timestamp);
197
g_dbus_method_invocation_return_value (invocation, NULL);
200
else if (g_strcmp0 (method_name, "ScrollEntry") == 0)
204
g_variant_get (parameters, "(si)", &entry_id, &delta, NULL);
205
panel_service_scroll_entry (service, entry_id, delta);
206
g_dbus_method_invocation_return_value (invocation, NULL);
212
on_service_resync (PanelService *service, const gchar *indicator_id, GDBusConnection *connection)
214
GError *error = NULL;
215
g_dbus_connection_emit_signal (connection,
220
g_variant_new ("(s)", indicator_id),
224
g_warning ("Unable to emit ReSync signal: %s", error->message);
225
g_error_free (error);
230
on_service_entry_activated (PanelService *service,
231
const gchar *entry_id,
232
GDBusConnection *connection)
234
GError *error = NULL;
235
g_dbus_connection_emit_signal (connection,
240
g_variant_new ("(s)", entry_id),
245
g_warning ("Unable to emit EntryActivated signal: %s", error->message);
246
g_error_free (error);
251
on_service_entry_activate_request (PanelService *service,
252
const gchar *entry_id,
253
GDBusConnection *connection)
255
GError *error = NULL;
256
g_dbus_connection_emit_signal (connection,
260
"EntryActivateRequest",
261
g_variant_new ("(s)", entry_id),
266
g_warning ("Unable to emit EntryActivateRequest signal: %s", error->message);
267
g_error_free (error);
272
on_service_entry_show_now_changed (PanelService *service,
273
const gchar *entry_id,
274
gboolean show_now_state,
275
GDBusConnection *connection)
277
GError *error = NULL;
278
g_dbus_connection_emit_signal (connection,
282
"EntryShowNowChanged",
283
g_variant_new ("(sb)", entry_id, show_now_state),
288
g_warning ("Unable to emit EntryShowNowChanged signal: %s", error->message);
289
g_error_free (error);
294
on_bus_acquired (GDBusConnection *connection,
298
PanelService *service = PANEL_SERVICE (user_data);
301
reg_id = g_dbus_connection_register_object (connection,
303
introspection_data->interfaces[0],
308
g_signal_connect (service, "re-sync",
309
G_CALLBACK (on_service_resync), connection);
310
g_signal_connect (service, "entry-activated",
311
G_CALLBACK (on_service_entry_activated), connection);
312
g_signal_connect (service, "entry-activate-request",
313
G_CALLBACK (on_service_entry_activate_request), connection);
314
g_signal_connect (service, "entry-show-now-changed",
315
G_CALLBACK (on_service_entry_show_now_changed), connection);
317
g_debug ("%s", G_STRFUNC);
318
g_assert (reg_id > 0);
322
on_name_acquired (GDBusConnection *connection,
326
g_debug ("Name Acquired");
330
on_name_lost (GDBusConnection *connection,
334
PanelService *service = PANEL_SERVICE (user_data);
336
g_debug ("%s", G_STRFUNC);
339
g_signal_handlers_disconnect_by_func (service, on_service_resync, connection);
340
g_signal_handlers_disconnect_by_func (service, on_service_entry_activated, connection);
341
g_signal_handlers_disconnect_by_func (service, on_service_entry_activate_request, connection);
342
g_signal_handlers_disconnect_by_func (service, on_service_entry_show_now_changed, connection);
348
on_indicators_cleared (PanelService *service)
356
PanelService *service = panel_service_get_default ();
357
panel_service_clear_indicators (service);
358
g_signal_connect (service, "indicators-cleared",
359
G_CALLBACK (on_indicators_cleared), NULL);
363
main (gint argc, gchar **argv)
365
PanelService *service;
368
g_unsetenv("UBUNTU_MENUPROXY");
369
g_setenv ("NO_AT_BRIDGE", "1", TRUE);
370
g_unsetenv ("NO_GAIL");
372
gtk_init (&argc, &argv);
373
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),
376
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
377
g_assert (introspection_data != NULL);
381
service = panel_service_get_default ();
383
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
385
G_BUS_NAME_OWNER_FLAGS_NONE,
392
signal (SIGINT, on_signal);
393
signal (SIGTERM, on_signal);
397
g_bus_unown_name (owner_id);
398
g_dbus_node_info_unref (introspection_data);
399
g_object_unref (service);