2
* Copyright (C) 2010 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
23
#include "panel-service.h"
25
static GDBusNodeInfo *introspection_data = NULL;
32
* bool label_sensitive;
36
* bool icon_sensitive;
42
static const gchar introspection_xml[] =
44
" <interface name='com.canonical.Unity.Panel.Service'>"
46
" <method name='Sync'>"
47
" <arg type='a(sssbbusbb)' name='state' direction='out'/>"
50
" <method name='SyncOne'>"
51
" <arg type='s' name='indicator_id' direction='in'/>"
52
" <arg type='a(sssbbusbb)' name='state' direction='out'/>"
55
" <method name='ShowEntry'>"
56
" <arg type='s' name='entry_id' direction='in'/>"
57
" <arg type='u' name='timestamp' direction='in'/>"
58
" <arg type='i' name='x' direction='in'/>"
59
" <arg type='i' name='y' direction='in'/>"
60
" <arg type='i' name='button' direction='in'/>"
63
" <signal name='EntryActivated'>"
64
" <arg type='s' name='entry_id' />"
67
" <signal name='ReSync'>"
68
" <arg type='s' name='indicator_id' />"
71
" <signal name='ActiveMenuPointerMotion'>"
72
" <arg type='i' name='x' />"
73
" <arg type='i' name='y' />"
79
#define S_NAME "com.canonical.Unity.Panel.Service"
80
#define S_PATH "/com/canonical/Unity/Panel/Service"
81
#define S_IFACE "com.canonical.Unity.Panel.Service"
85
handle_method_call (GDBusConnection *connection,
87
const gchar *object_path,
88
const gchar *interface_name,
89
const gchar *method_name,
91
GDBusMethodInvocation *invocation,
95
static const GDBusInterfaceVTable interface_vtable =
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,
115
PanelService *service = PANEL_SERVICE (user_data);
117
if (g_strcmp0 (method_name, "Sync") == 0)
119
g_dbus_method_invocation_return_value (invocation,
120
panel_service_sync (service));
122
else if (g_strcmp0 (method_name, "SyncOne") == 0)
125
g_variant_get (parameters, "(s)", &id, NULL);
126
g_dbus_method_invocation_return_value (invocation,
127
panel_service_sync_one (service,
131
else if (g_strcmp0 (method_name, "ShowEntry") == 0)
138
g_variant_get (parameters, "(suiii)", &entry_id, ×tamp, &x, &y, &button, NULL);
140
g_debug ("button: %u", button);
142
panel_service_show_entry (service, entry_id, timestamp, x, y, button);
144
g_dbus_method_invocation_return_value (invocation, NULL);
150
on_service_resync (PanelService *service, const gchar *indicator_id, GDBusConnection *connection)
152
GError *error = NULL;
153
g_dbus_connection_emit_signal (connection,
158
g_variant_new ("(s)", indicator_id),
163
g_warning ("Unable to emit ReSync signal: %s", error->message);
164
g_error_free (error);
169
on_service_entry_activated (PanelService *service,
170
const gchar *entry_id,
171
GDBusConnection *connection)
173
GError *error = NULL;
174
g_dbus_connection_emit_signal (connection,
179
g_variant_new ("(s)", entry_id),
184
g_warning ("Unable to emit EntryActivated signal: %s", error->message);
185
g_error_free (error);
190
on_service_active_menu_pointer_motion (PanelService *service,
191
GDBusConnection *connection)
193
GError *error = NULL;
196
panel_service_get_last_xy (service, &x, &y);
198
g_dbus_connection_emit_signal (connection,
202
"ActiveMenuPointerMotion",
203
g_variant_new ("(ii)", x, y),
208
g_warning ("Unable to emit ActiveMenuPointerMotionsignal: %s", error->message);
209
g_error_free (error);
214
on_bus_acquired (GDBusConnection *connection,
218
PanelService *service = PANEL_SERVICE (user_data);
221
reg_id = g_dbus_connection_register_object (connection,
223
introspection_data->interfaces[0],
228
g_signal_connect (service, "re-sync",
229
G_CALLBACK (on_service_resync), connection);
230
g_signal_connect (service, "entry-activated",
231
G_CALLBACK (on_service_entry_activated), connection);
232
g_signal_connect (service, "active-menu-pointer-motion",
233
G_CALLBACK (on_service_active_menu_pointer_motion), connection);
235
g_debug ("%s", G_STRFUNC);
236
g_assert (reg_id > 0);
240
on_name_acquired (GDBusConnection *connection,
244
g_debug ("Name Acquired");
248
on_name_lost (GDBusConnection *connection,
252
g_debug ("%s", G_STRFUNC);
257
main (gint argc, gchar **argv)
259
PanelService *service;
262
gtk_init (&argc, &argv);
263
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default(),
266
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
267
g_assert (introspection_data != NULL);
269
service = panel_service_get_default ();
271
owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
273
G_BUS_NAME_OWNER_FLAGS_NONE,
281
g_bus_unown_name (owner_id);
282
g_dbus_node_info_unref (introspection_data);
283
g_object_unref (service);