~ken-vandine/indicator-applet/indicator-session-packaging

« back to all changes in this revision

Viewing changes to src/status-service-dbus.c

Merging in the branch that adds in the status icons to
the panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
static void status_service_dbus_dispose    (GObject *object);
35
35
static void status_service_dbus_finalize   (GObject *object);
36
36
static gboolean _status_service_server_watch (StatusServiceDbus * service, GError ** error);
37
 
static gboolean _status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error);
 
37
static gboolean _status_service_server_status_icons (StatusServiceDbus * service, gchar ** icon, GError ** error);
38
38
static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error);
39
39
 
40
40
#include "status-service-server.h"
44
44
struct _StatusServiceDbusPrivate
45
45
{
46
46
        gchar * name;
 
47
        gchar * icon;
47
48
};
48
49
 
49
50
#define STATUS_SERVICE_DBUS_GET_PRIVATE(o) \
102
103
                                                     G_SIGNAL_RUN_LAST,
103
104
                                                     G_STRUCT_OFFSET(StatusServiceDbusClass, status_icons_changed),
104
105
                                                     NULL, NULL,
105
 
                                                     g_cclosure_marshal_VOID__POINTER,
106
 
                                                     G_TYPE_NONE, 1, G_TYPE_POINTER);
 
106
                                                     g_cclosure_marshal_VOID__STRING,
 
107
                                                     G_TYPE_NONE, 1, G_TYPE_STRING);
107
108
 
108
109
        dbus_g_object_type_install_info(STATUS_SERVICE_DBUS_TYPE, &dbus_glib__status_service_server_object_info);
109
110
        
120
121
                                                                                G_OBJECT(self));
121
122
 
122
123
        StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self);
123
 
        priv->name = "test";
 
124
        priv->name = NULL;
 
125
        priv->icon = NULL;
124
126
 
125
127
        return;
126
128
}
149
151
}
150
152
 
151
153
static gboolean
152
 
_status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error)
 
154
_status_service_server_status_icons (StatusServiceDbus * service, gchar ** icon, GError ** error)
153
155
{
 
156
        if (!IS_STATUS_SERVICE_DBUS(service)) {
 
157
                g_warning("NO BAD EVIL!");
 
158
                return FALSE;
 
159
        }
 
160
 
 
161
        StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(service);
 
162
        if (priv->icon == NULL) {
 
163
                *icon = g_strdup("");
 
164
        } else {
 
165
                *icon = g_strdup(priv->icon);
 
166
        }
154
167
 
155
168
        return TRUE;
156
169
}
172
185
 
173
186
        return TRUE;
174
187
}
 
188
 
 
189
void
 
190
status_service_dbus_set_status (StatusServiceDbus * self, const gchar * icon)
 
191
{
 
192
        g_return_if_fail(IS_STATUS_SERVICE_DBUS(self));
 
193
 
 
194
        g_debug("Setting icon to: %s", icon);
 
195
 
 
196
        StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self);
 
197
 
 
198
        if (priv->icon != NULL) {
 
199
                g_free(priv->icon);
 
200
        }
 
201
        priv->icon = g_strdup(icon);
 
202
 
 
203
        g_signal_emit(G_OBJECT(self), signals[STATUS_ICONS_CHANGED], 0, priv->icon, TRUE);
 
204
        return;
 
205
}