~ubuntu-branches/ubuntu/oneiric/gnome-panel/oneiric

« back to all changes in this revision

Viewing changes to gnome-panel/libpanel-util/panel-dbus-service.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Sebastien Bacher, Jeremy Bicha
  • Date: 2011-05-30 11:04:49 UTC
  • mfrom: (1.13.10 upstream) (2.2.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20110530110449-hinl17kxkcefjw6x
Tags: 1:3.0.2-0ubuntu1
[ Sebastien Bacher ]
* New upstream version
* debian/control.in:
  - the new libgweather version is in oneiric, use it
  - drop the python and python-gconf depends, 
    they were added for gnome-panel-add which is still using gconf and buggy
* debian/gnome-panel-data.install:
  - don't install the apport hook, it's only getting gconf datas which 
    doesn't work since gnome-panel uses gsettings
* debian/patches/90_build_fixes.patch:
  - restore build fix from git not applied in the new serie
* debian/patches/01_panel_submenus.patch:
  - don't take that Debian diff, the .menus use the upstream naming in Ubuntu
* debian/patches/06_no_resize_grip.patch:
  - dropped, the issue is fixed in the new version
* debian/patches/50_fix-potfiles.patch:
  - dropped, the issue is fixed in the new version
* debian/watch:
  - track unstable series as well

Drop those delta, since gnome-panel is not the default Ubuntu session now we
can go back to an experience closer to the upstream one: 
* debian/control.in:
  - drop the indicators recommends, unity-2d is the ubuntu fallback session
    so we can get back to use an upstream config for gnome-panel and reduce
    the delta we carry
* debian/patches/04_default_panel_config.patch:
  - don't modify the upstream layout
* debian/patches/05_no_session_delay.patch:
  - no need to tweak the upstream session to optimize it
* debian/patches/16_compiz_workspace_switcher.patch:
  - go back to the upstream switcher behaviour    
* debian/patches/25_dynamic_fusa_detection.patch:
  - not needed since we use the upstream layout, could be ported if someone
    is wanting to do the work though
* debian/patches/30_disable-initial-animation.patch, debian/rules:
  - drop the --disable-initial-animation, that was some login optimization
    but since it's not the default desktop you should go back to the 
    upstream behaviour

[ Jeremy Bicha ]   
* New upstream version
* Merge from Debian experimental, remaining Ubuntu changes:
* debian/control:
  - Recommends gnome-settings-daemon which has the timezone polkit service
* debian/rules:
  - Update translations template.
* debian/gnome-panel-data.install:
  - Install apport hook
  - Install the "About Ubuntu" menu item.
* debian/patches/01_layout.patch:
  - Disabled, Help & About Ubuntu don't fit as well in Gnome Panel 3
* debian/patches/01_panel_submenus.patch.
  - Dropped
* debian/patches/03_dnd_places_link.patch:
  - Disabled, when using Drag'n'Drop from Places menu, install a link launcher
    (.desktop file) instead of copying the entire directory.
* debian/patches/17_about-ubuntu-translation.patch:
  - List ubuntu-about.desktop for translation.
* debian/patches/40_unset_menuproxy.patch:
  - Make sure gnome-panel and the applets don't pick up menu proxies.
* debian/patches/50_fix-potfiles.patch
  - Fix i18n
* debian/patches/85_disable_shutdown_on_ltsp.patch:
  - Suppress the shutdown option in the panel if LTSP_CLIENT is set.
* debian/patches/71_change_bookmark_submenu_limit_value.patch
  - Dropped, picked up by Debian
* debian/patches/18_lockdown_lock_editor.patch:
* debian/patches/90_git_wnck_show_realize.patch:
* debian/patches/90_fix_linking_DSO_link.patch:
* debian/patches/91_gir_annotations.patch
* debian/patches/92_git_calendar_day.patch
* debian/patches/92_git_fix_applets_in_multiscreen.patch:
  - Dropped, applied upstream
* debian/watch:
  - watch unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * panel-dbus-service.c: a simple base object to use a DBus service. Only
3
 
 * useful when subclassed.
4
 
 *
5
 
 * Copyright (C) 2008 Novell, Inc.
6
 
 *
7
 
 * Based on code from panel-power-manager.c:
8
 
 *  Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
9
 
 *  (not sure the copyright header was complete)
10
 
 *
11
 
 * This program is free software; you can redistribute it and/or
12
 
 * modify it under the terms of the GNU General Public License as
13
 
 * published by the Free Software Foundation; either version 2 of the
14
 
 * License, or (at your option) any later version.
15
 
 *
16
 
 * This program is distributed in the hope that it will be useful, but
17
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19
 
 * General Public License for more details.
20
 
 *
21
 
 * You should have received a copy of the GNU General Public License
22
 
 * along with this program; if not, write to the Free Software
23
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24
 
 * 02111-1307, USA.
25
 
 *
26
 
 * Authors:
27
 
 *      Vincent Untz <vuntz@gnome.org>
28
 
 */
29
 
 
30
 
#include <string.h>
31
 
 
32
 
#include <glib.h>
33
 
#include <glib-object.h>
34
 
 
35
 
#include <dbus/dbus-glib.h>
36
 
 
37
 
#include "panel-dbus-service.h"
38
 
 
39
 
struct _PanelDBusServicePrivate {
40
 
        DBusGConnection *dbus_connection;
41
 
        DBusGProxy      *bus_proxy;
42
 
        DBusGProxy      *service_proxy;
43
 
        guint32          is_connected : 1;
44
 
 
45
 
        const char      *service_name;
46
 
        const char      *service_path;
47
 
        const char      *service_interface;
48
 
};
49
 
 
50
 
static void panel_dbus_service_finalize (GObject *object);
51
 
static void panel_dbus_service_class_install_properties (PanelDBusServiceClass *service_class);
52
 
 
53
 
static void panel_dbus_service_get_property (GObject    *object,
54
 
                                             guint       prop_id,
55
 
                                             GValue     *value,
56
 
                                             GParamSpec *pspec);
57
 
 
58
 
enum {
59
 
  PROP_0 = 0,
60
 
  PROP_IS_CONNECTED
61
 
};
62
 
 
63
 
G_DEFINE_TYPE (PanelDBusService, panel_dbus_service, G_TYPE_OBJECT);
64
 
 
65
 
static void
66
 
panel_dbus_service_class_init (PanelDBusServiceClass *service_class)
67
 
{
68
 
        GObjectClass *object_class;
69
 
 
70
 
        object_class = G_OBJECT_CLASS (service_class);
71
 
 
72
 
        object_class->finalize = panel_dbus_service_finalize;
73
 
 
74
 
        panel_dbus_service_class_install_properties (service_class);
75
 
 
76
 
        g_type_class_add_private (service_class,
77
 
                                  sizeof (PanelDBusServicePrivate));
78
 
}
79
 
 
80
 
static void
81
 
panel_dbus_service_class_install_properties (PanelDBusServiceClass *service_class)
82
 
{
83
 
        GObjectClass *object_class;
84
 
        GParamSpec *param_spec;
85
 
 
86
 
        object_class = G_OBJECT_CLASS (service_class);
87
 
        object_class->get_property = panel_dbus_service_get_property;
88
 
 
89
 
        param_spec = g_param_spec_boolean ("is-connected",
90
 
                                           "Is connected",
91
 
                                           "Whether the panel is connected to "
92
 
                                           "a DBus service",
93
 
                                           FALSE,
94
 
                                           G_PARAM_READABLE);
95
 
        g_object_class_install_property (object_class, PROP_IS_CONNECTED,
96
 
                                         param_spec);
97
 
}
98
 
 
99
 
static void
100
 
panel_dbus_service_init (PanelDBusService *service)
101
 
{
102
 
        service->priv = G_TYPE_INSTANCE_GET_PRIVATE (service,
103
 
                                                     PANEL_TYPE_DBUS_SERVICE,
104
 
                                                     PanelDBusServicePrivate);
105
 
 
106
 
        service->priv->dbus_connection = NULL;
107
 
        service->priv->bus_proxy = NULL;
108
 
        service->priv->service_proxy = NULL;
109
 
        service->priv->is_connected = FALSE;
110
 
 
111
 
        service->priv->service_name = NULL;
112
 
        service->priv->service_path = NULL;
113
 
        service->priv->service_interface = NULL;
114
 
}
115
 
 
116
 
static void
117
 
panel_dbus_service_finalize (GObject *object)
118
 
{
119
 
        PanelDBusService *service;
120
 
                
121
 
        service = PANEL_DBUS_SERVICE (object);
122
 
 
123
 
        if (service->priv->dbus_connection != NULL) {
124
 
                dbus_g_connection_unref (service->priv->dbus_connection);
125
 
                service->priv->dbus_connection = NULL;
126
 
        }
127
 
 
128
 
        if (service->priv->bus_proxy != NULL) {
129
 
                g_object_unref (service->priv->bus_proxy);
130
 
                service->priv->bus_proxy = NULL;
131
 
        }
132
 
 
133
 
        if (service->priv->service_proxy != NULL) {
134
 
                g_object_unref (service->priv->service_proxy);
135
 
                service->priv->service_proxy = NULL;
136
 
        }
137
 
 
138
 
        G_OBJECT_CLASS (panel_dbus_service_parent_class)->finalize (object);
139
 
}
140
 
 
141
 
static void
142
 
panel_dbus_service_get_property (GObject    *object,
143
 
                                 guint       prop_id,
144
 
                                 GValue     *value,
145
 
                                 GParamSpec *pspec)
146
 
{
147
 
        PanelDBusService *service;
148
 
                
149
 
        service = PANEL_DBUS_SERVICE (object);
150
 
 
151
 
        switch (prop_id) {
152
 
        case PROP_IS_CONNECTED:
153
 
                g_value_set_boolean (value,
154
 
                                     service->priv->is_connected);
155
 
                break;
156
 
 
157
 
        default:
158
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
159
 
                                                   prop_id,
160
 
                                                   pspec);
161
 
        }
162
 
}
163
 
 
164
 
static void
165
 
panel_dbus_service_on_name_owner_changed (DBusGProxy       *bus_proxy,
166
 
                                          const char       *name,
167
 
                                          const char       *prev_owner,
168
 
                                          const char       *new_owner,
169
 
                                          PanelDBusService *service)
170
 
{
171
 
        g_assert (service->priv->service_name != NULL);
172
 
 
173
 
        if (name && strcmp (name, service->priv->service_name) != 0)
174
 
                return;
175
 
 
176
 
        if (service->priv->service_proxy != NULL) {
177
 
                g_object_unref (service->priv->service_proxy);
178
 
                service->priv->service_proxy = NULL;
179
 
        }
180
 
 
181
 
        panel_dbus_service_ensure_connection (service, NULL);
182
 
}
183
 
 
184
 
gboolean
185
 
panel_dbus_service_ensure_connection (PanelDBusService  *service,
186
 
                                      GError           **error)
187
 
{
188
 
        GError   *connection_error;
189
 
        gboolean  is_connected;
190
 
 
191
 
        g_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
192
 
 
193
 
        if (!service->priv->service_name ||
194
 
            !service->priv->service_path ||
195
 
            !service->priv->service_interface)
196
 
                return FALSE;
197
 
 
198
 
        connection_error = NULL;
199
 
        if (service->priv->dbus_connection == NULL) {
200
 
                service->priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION,
201
 
                                                                 &connection_error);
202
 
 
203
 
                if (service->priv->dbus_connection == NULL) {
204
 
                        g_propagate_error (error, connection_error);
205
 
                        is_connected = FALSE;
206
 
                        goto out;
207
 
                }
208
 
        }
209
 
 
210
 
        if (service->priv->bus_proxy == NULL) {
211
 
                service->priv->bus_proxy =
212
 
                        dbus_g_proxy_new_for_name_owner (service->priv->dbus_connection,
213
 
                                                         DBUS_SERVICE_DBUS,
214
 
                                                         DBUS_PATH_DBUS,
215
 
                                                         DBUS_INTERFACE_DBUS,
216
 
                                                         &connection_error);
217
 
 
218
 
                if (service->priv->bus_proxy == NULL) {
219
 
                        g_propagate_error (error, connection_error);
220
 
                        is_connected = FALSE;
221
 
                        goto out;
222
 
                }
223
 
 
224
 
                dbus_g_proxy_add_signal (service->priv->bus_proxy,
225
 
                                         "NameOwnerChanged",
226
 
                                         G_TYPE_STRING,
227
 
                                         G_TYPE_STRING,
228
 
                                         G_TYPE_STRING,
229
 
                                         G_TYPE_INVALID);
230
 
                dbus_g_proxy_connect_signal (service->priv->bus_proxy,
231
 
                                             "NameOwnerChanged",
232
 
                                             G_CALLBACK (panel_dbus_service_on_name_owner_changed),
233
 
                                             service, NULL);
234
 
        }
235
 
 
236
 
        if (service->priv->service_proxy == NULL) {
237
 
                service->priv->service_proxy =
238
 
                        dbus_g_proxy_new_for_name_owner (
239
 
                                        service->priv->dbus_connection,
240
 
                                        service->priv->service_name,
241
 
                                        service->priv->service_path,
242
 
                                        service->priv->service_interface,
243
 
                                        &connection_error);
244
 
 
245
 
                if (service->priv->service_proxy == NULL) {
246
 
                        g_propagate_error (error, connection_error);
247
 
                        is_connected = FALSE;
248
 
                        goto out;
249
 
                }
250
 
        }
251
 
        is_connected = TRUE;
252
 
 
253
 
out:
254
 
        if (service->priv->is_connected != is_connected) {
255
 
                service->priv->is_connected = is_connected;
256
 
                g_object_notify (G_OBJECT (service), "is-connected");
257
 
        }
258
 
 
259
 
        if (!is_connected) {
260
 
                if (service->priv->dbus_connection == NULL) {
261
 
                        if (service->priv->bus_proxy != NULL) {
262
 
                                g_object_unref (service->priv->bus_proxy);
263
 
                                service->priv->bus_proxy = NULL;
264
 
                        }
265
 
 
266
 
                        if (service->priv->service_proxy != NULL) {
267
 
                                g_object_unref (service->priv->service_proxy);
268
 
                                service->priv->service_proxy = NULL;
269
 
                        }
270
 
                } else if (service->priv->bus_proxy == NULL) {
271
 
                        if (service->priv->service_proxy != NULL) {
272
 
                                g_object_unref (service->priv->service_proxy);
273
 
                                service->priv->service_proxy = NULL;
274
 
                        }
275
 
                }
276
 
        }
277
 
 
278
 
        return is_connected;
279
 
}
280
 
 
281
 
void
282
 
panel_dbus_service_define_service (PanelDBusService *service,
283
 
                                   const char       *name,
284
 
                                   const char       *path,
285
 
                                   const char       *interface)
286
 
{
287
 
        g_return_if_fail (PANEL_IS_DBUS_SERVICE (service));
288
 
 
289
 
        g_assert (name != NULL);
290
 
        g_assert (path != NULL);
291
 
        g_assert (interface != NULL);
292
 
        g_assert (service->priv->service_name == NULL);
293
 
        g_assert (service->priv->service_path == NULL);
294
 
        g_assert (service->priv->service_interface == NULL);
295
 
 
296
 
        service->priv->service_name = name;
297
 
        service->priv->service_path = path;
298
 
        service->priv->service_interface = interface;
299
 
}
300
 
 
301
 
DBusGProxy *
302
 
panel_dbus_service_get_proxy (PanelDBusService *service)
303
 
{
304
 
        g_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), NULL);
305
 
 
306
 
        return service->priv->service_proxy;
307
 
}