~cjcurran/indicator-sound/notify-scroll-event-from-service

« back to all changes in this revision

Viewing changes to src/device.c

  • Committer: Harry van Haaren
  • Date: 2011-06-24 16:10:13 UTC
  • Revision ID: harryhaaren@gmail.com-20110624161013-ijhk0u998gvdjugp
Implemented notifications from device.c
Makefile still needs updating, currently hacking -lnotify to the link-list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
*/
19
19
#include <libdbusmenu-glib/menuitem.h>
20
20
 
 
21
#include <libindicator/indicator-image-helper.h>
 
22
#include <libnotify/notify.h>
 
23
 
21
24
#include "device.h"
22
25
#include "slider-menu-item.h"
23
26
#include "mute-menu-item.h"
34
37
  VoipInputMenuItem*  voip_input_menu_item;
35
38
  SoundState          current_sound_state;
36
39
  SoundServiceDbus*   service;
 
40
  NotifyNotification* notification;
37
41
  char*               sink_name;
38
42
  char*               client_name;
39
43
};
74
78
  
75
79
  priv->sink_name = NULL;
76
80
  priv->client_name = NULL;
 
81
  
 
82
  // notification
 
83
  notify_init(PACKAGE_NAME);
 
84
  priv->notification = notify_notification_new(PACKAGE_NAME, NULL, NULL);
77
85
 
78
86
  // Init our menu items.
79
87
  priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
107
115
  {
108
116
    // send message
109
117
    printf("device_set_sink_name: send message!\n");
 
118
    device_show_auto_stream_change_notification(self);
110
119
    
111
120
    // after message is sent, clear the info
112
121
    priv->sink_name = NULL;
113
122
    priv->client_name = NULL;
114
123
  }
115
124
}
 
125
 
116
126
void device_set_client_name(Device* self, const char* name)
117
127
{
118
128
  DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
124
134
  {
125
135
    // send message
126
136
    printf("device_set_client_name: send message!\n");
 
137
    device_show_auto_stream_change_notification(self);
127
138
    
128
139
    // after message is sent, clear the info
129
140
    priv->sink_name = NULL;
131
142
  }
132
143
}
133
144
 
 
145
void device_show_auto_stream_change_notification(Device* self)
 
146
{
 
147
  DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
 
148
  device_show_notification(self, 0.0d);
 
149
}
 
150
 
134
151
void
135
152
device_sink_populate (Device* self,
136
153
                      const pa_sink_info* update)
148
165
}
149
166
 
150
167
void
 
168
device_show_notification (Device *self,
 
169
                          double value)
 
170
{
 
171
  DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
 
172
 
 
173
  const gchar* message[200];
 
174
  sprintf( message, "Auto stream switch from %s to %s", priv->client_name, priv->sink_name);
 
175
 
 
176
  notify_notification_update    ( priv->notification,
 
177
                                "Stream Switch",
 
178
                                message,
 
179
                                "GTK_STOCK_DIALOG_INFO");
 
180
 
 
181
  notify_notification_show (priv->notification, NULL);
 
182
}
 
183
 
 
184
void
151
185
device_sink_update (Device* self,
152
186
                    const pa_sink_info* update)
153
187
{