Add a way to launch external configuration program when using volume applet
[lxde/lxpanel.git] / src / plugins / volumealsa / volumealsa.c
1 /**
2 * Copyright (c) 2008 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #include <gtk/gtk.h>
20 #include <stdlib.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23 #include <glib.h>
24 #include <glib/gi18n.h>
25 #include <gdk-pixbuf/gdk-pixbuf.h>
26 #include <alsa/asoundlib.h>
27 #include <poll.h>
28 #include "panel.h"
29 #include "misc.h"
30 #include "plugin.h"
31 #include "dbg.h"
32
33 #define ICONS_VOLUME_HIGH PACKAGE_DATA_DIR "/lxpanel/images/volume-high.png"
34 #define ICONS_VOLUME_MEDIUM PACKAGE_DATA_DIR "/lxpanel/images/volume-medium.png"
35 #define ICONS_VOLUME_LOW PACKAGE_DATA_DIR "/lxpanel/images/volume-low.png"
36 #define ICONS_MUTE PACKAGE_DATA_DIR "/lxpanel/images/mute.png"
37
38 typedef struct {
39
40 /* Graphics. */
41 Plugin * plugin; /* Back pointer to plugin */
42 GtkWidget * tray_icon; /* Displayed image */
43 GtkWidget * popup_window; /* Top level window for popup */
44 GtkWidget * volume_scale; /* Scale for volume */
45 GtkWidget * mute_check; /* Checkbox for mute state */
46 gboolean show_popup; /* Toggle to show and hide the popup on left click */
47 guint volume_scale_handler; /* Handler for vscale widget */
48 guint mute_check_handler; /* Handler for mute_check widget */
49
50 /* ALSA interface. */
51 snd_mixer_t * mixer; /* The mixer */
52 snd_mixer_selem_id_t * sid; /* The element ID */
53 snd_mixer_elem_t * master_element; /* The Master element */
54 guint mixer_evt_idle; /* Timer to handle restarting poll */
55 } VolumeALSAPlugin;
56
57 static gboolean asound_find_element(VolumeALSAPlugin * vol, const char * ename);
58 static gboolean asound_reset_mixer_evt_idle(VolumeALSAPlugin * vol);
59 static gboolean asound_mixer_event(GIOChannel * channel, GIOCondition cond, gpointer vol_gpointer);
60 static gboolean asound_initialize(VolumeALSAPlugin * vol);
61 static gboolean asound_has_mute(VolumeALSAPlugin * vol);
62 static gboolean asound_is_muted(VolumeALSAPlugin * vol);
63 static int asound_get_volume(VolumeALSAPlugin * vol);
64 static void asound_set_volume(VolumeALSAPlugin * vol, int volume);
65 static void volumealsa_update_display(VolumeALSAPlugin * vol);
66 static gboolean volumealsa_button_press_event(GtkWidget * widget, GdkEventButton * event, VolumeALSAPlugin * vol);
67 static gboolean volumealsa_popup_focus_out(GtkWidget * widget, GdkEvent * event, VolumeALSAPlugin * vol);
68 static void volumealsa_popup_map(GtkWidget * widget, VolumeALSAPlugin * vol);
69 static void volumealsa_popup_scale_changed(GtkRange * range, VolumeALSAPlugin * vol);
70 static void volumealsa_popup_scale_scrolled(GtkScale * scale, GdkEventScroll * evt, VolumeALSAPlugin * vol);
71 static void volumealsa_popup_mute_toggled(GtkWidget * widget, VolumeALSAPlugin * vol);
72 static void volumealsa_build_popup_window(Plugin * p);
73 static int volumealsa_constructor(Plugin * p, char ** fp);
74 static void volumealsa_destructor(Plugin * p);
75 static void volumealsa_panel_configuration_changed(Plugin * p);
76
77 /*** ALSA ***/
78
79 static gboolean asound_find_element(VolumeALSAPlugin * vol, const char * ename)
80 {
81 for (
82 vol->master_element = snd_mixer_first_elem(vol->mixer);
83 vol->master_element != NULL;
84 vol->master_element = snd_mixer_elem_next(vol->master_element))
85 {
86 snd_mixer_selem_get_id(vol->master_element, vol->sid);
87 if ((snd_mixer_selem_is_active(vol->master_element))
88 && (strcmp(ename, snd_mixer_selem_id_get_name(vol->sid)) == 0))
89 return TRUE;
90 }
91 return FALSE;
92 }
93
94 /* NOTE by PCMan:
95 * This is magic! Since ALSA uses its own machanism to handle this part.
96 * After polling of mixer fds, it requires that we should call
97 * snd_mixer_handle_events to clear all pending mixer events.
98 * However, when using the glib IO channels approach, we don't have
99 * poll() and snd_mixer_poll_descriptors_revents(). Due to the design of
100 * glib, on_mixer_event() will be called for every fd whose status was
101 * changed. So, after each poll(), it's called for several times,
102 * not just once. Therefore, we cannot call snd_mixer_handle_events()
103 * directly in the event handler. Otherwise, it will get called for
104 * several times, which might clear unprocessed pending events in the queue.
105 * So, here we call it once in the event callback for the first fd.
106 * Then, we don't call it for the following fds. After all fds with changed
107 * status are handled, we remove this restriction in an idle handler.
108 * The next time the event callback is involked for the first fs, we can
109 * call snd_mixer_handle_events() again. Racing shouldn't happen here
110 * because the idle handler has the same priority as the io channel callback.
111 * So, io callbacks for future pending events should be in the next gmain
112 * iteration, and won't be affected.
113 */
114
115 static gboolean asound_reset_mixer_evt_idle(VolumeALSAPlugin * vol)
116 {
117 vol->mixer_evt_idle = 0;
118 return FALSE;
119 }
120
121 /* Handler for I/O event on ALSA channel. */
122 static gboolean asound_mixer_event(GIOChannel * channel, GIOCondition cond, gpointer vol_gpointer)
123 {
124 VolumeALSAPlugin * vol = (VolumeALSAPlugin *) vol_gpointer;
125
126 if (vol->mixer_evt_idle == 0)
127 {
128 vol->mixer_evt_idle = g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc) asound_reset_mixer_evt_idle, vol, NULL);
129 snd_mixer_handle_events(vol->mixer);
130 }
131
132 if (cond & G_IO_IN)
133 {
134 /* the status of mixer is changed. update of display is needed. */
135 volumealsa_update_display(vol);
136 }
137
138 if (cond & G_IO_HUP)
139 {
140 /* This means there're some problems with alsa. */
141 return FALSE;
142 }
143
144 return TRUE;
145 }
146
147 /* Initialize the ALSA interface. */
148 static gboolean asound_initialize(VolumeALSAPlugin * vol)
149 {
150 /* Access the "default" device. */
151 snd_mixer_selem_id_alloca(&vol->sid);
152 snd_mixer_open(&vol->mixer, 0);
153 snd_mixer_attach(vol->mixer, "default");
154 snd_mixer_selem_register(vol->mixer, NULL, NULL);
155 snd_mixer_load(vol->mixer);
156
157 /* Find Master element, or Front element, or PCM element, or LineOut element.
158 * If one of these succeeds, master_element is valid. */
159 if ( ! asound_find_element(vol, "Master"))
160 if ( ! asound_find_element(vol, "Front"))
161 if ( ! asound_find_element(vol, "PCM"))
162 if ( ! asound_find_element(vol, "LineOut"))
163 return FALSE;
164
165 /* Set the playback volume range as we wish it. */
166 snd_mixer_selem_set_playback_volume_range(vol->master_element, 0, 100);
167
168 /* Listen to events from ALSA. */
169 int n_fds = snd_mixer_poll_descriptors_count(vol->mixer);
170 struct pollfd * fds = g_new0(struct pollfd, n_fds);
171
172 snd_mixer_poll_descriptors(vol->mixer, fds, n_fds);
173 int i;
174 for (i = 0; i < n_fds; ++i)
175 {
176 GIOChannel* channel = g_io_channel_unix_new(fds[i].fd);
177 g_io_add_watch(channel, G_IO_IN | G_IO_HUP, asound_mixer_event, vol);
178 g_io_channel_unref(channel);
179 }
180 g_free(fds);
181 return TRUE;
182 }
183
184 /* Get the presence of the mute control from the sound system. */
185 static gboolean asound_has_mute(VolumeALSAPlugin * vol)
186 {
187 return ((vol->master_element != NULL) ? snd_mixer_selem_has_playback_switch(vol->master_element) : FALSE);
188 }
189
190 /* Get the condition of the mute control from the sound system. */
191 static gboolean asound_is_muted(VolumeALSAPlugin * vol)
192 {
193 /* The switch is on if sound is not muted, and off if the sound is muted.
194 * Initialize so that the sound appears unmuted if the control does not exist. */
195 int value = 1;
196 if (vol->master_element != NULL)
197 snd_mixer_selem_get_playback_switch(vol->master_element, 0, &value);
198 return (value == 0);
199 }
200
201 /* Get the volume from the sound system.
202 * This implementation returns the average of the Front Left and Front Right channels. */
203 static int asound_get_volume(VolumeALSAPlugin * vol)
204 {
205 long aleft = 0;
206 long aright = 0;
207 if (vol->master_element != NULL)
208 {
209 snd_mixer_selem_get_playback_volume(vol->master_element, SND_MIXER_SCHN_FRONT_LEFT, &aleft);
210 snd_mixer_selem_get_playback_volume(vol->master_element, SND_MIXER_SCHN_FRONT_RIGHT, &aright);
211 }
212 return (aleft + aright) >> 1;
213 }
214
215 /* Set the volume to the sound system.
216 * This implementation sets the Front Left and Front Right channels to the specified value. */
217 static void asound_set_volume(VolumeALSAPlugin * vol, int volume)
218 {
219 if (vol->master_element != NULL)
220 {
221 snd_mixer_selem_set_playback_volume(vol->master_element, SND_MIXER_SCHN_FRONT_LEFT, volume);
222 snd_mixer_selem_set_playback_volume(vol->master_element, SND_MIXER_SCHN_FRONT_RIGHT, volume);
223 }
224 }
225
226 /*** Graphics ***/
227
228 /* Do a full redraw of the display. */
229 static void volumealsa_update_display(VolumeALSAPlugin * vol)
230 {
231 /* Mute status. */
232 gboolean mute = asound_is_muted(vol);
233 int level = asound_get_volume(vol);
234
235 /* Change icon according to mute / volume */
236 const char* icon="audio-volume-muted";
237 const char* icon_fallback=ICONS_MUTE;
238 if (mute)
239 {
240 icon="audio-volume-muted";
241 icon_fallback=ICONS_MUTE;
242 }
243 else if (level >= 75)
244 {
245 icon="audio-volume-high";
246 icon_fallback=ICONS_VOLUME_HIGH;
247 }
248 else if (level >= 50)
249 {
250 icon="audio-volume-medium";
251 icon_fallback=ICONS_VOLUME_MEDIUM;
252 }
253 else if (level > 0)
254 {
255 icon="audio-volume-low";
256 icon_fallback=ICONS_VOLUME_LOW;
257 }
258
259 /* Change icon, fallback to default icon if theme doesn't exsit */
260 if ( ! panel_image_set_icon_theme(vol->plugin->panel, vol->tray_icon, icon))
261 {
262 panel_image_set_from_file(vol->plugin->panel, vol->tray_icon, icon_fallback);
263 }
264
265 g_signal_handler_block(vol->mute_check, vol->mute_check_handler);
266 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vol->mute_check), mute);
267 gtk_widget_set_sensitive(vol->mute_check, asound_has_mute(vol));
268 g_signal_handler_unblock(vol->mute_check, vol->mute_check_handler);
269
270 /* Volume. */
271 if (vol->volume_scale != NULL)
272 {
273 g_signal_handler_block(vol->volume_scale, vol->volume_scale_handler);
274 gtk_range_set_value(GTK_RANGE(vol->volume_scale), asound_get_volume(vol));
275 g_signal_handler_unblock(vol->volume_scale, vol->volume_scale_handler);
276 }
277
278 /* Display current level in tooltip. */
279 char * tooltip = g_strdup_printf("%s %d", _("Volume control"), level);
280 gtk_widget_set_tooltip_text(vol->plugin->pwid, tooltip);
281 g_free(tooltip);
282 }
283
284 /* Handler for "button-press-event" signal on main widget. */
285 static gboolean volumealsa_button_press_event(GtkWidget * widget, GdkEventButton * event, VolumeALSAPlugin * vol)
286 {
287 /* Standard right-click handling. */
288 if (plugin_button_press_event(widget, event, vol->plugin))
289 return TRUE;
290
291 /* Left-click. Show or hide the popup window. */
292 if (event->button == 1)
293 {
294 if (vol->show_popup)
295 {
296 gtk_widget_hide(vol->popup_window);
297 vol->show_popup = FALSE;
298 }
299 else
300 {
301 gtk_widget_show_all(vol->popup_window);
302 vol->show_popup = TRUE;
303 }
304 }
305
306 /* Middle-click. Toggle the mute status. */
307 else if (event->button == 2)
308 {
309 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vol->mute_check), ! gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(vol->mute_check)));
310 }
311 return TRUE;
312 }
313
314 /* Handler for "focus-out" signal on popup window. */
315 static gboolean volumealsa_popup_focus_out(GtkWidget * widget, GdkEvent * event, VolumeALSAPlugin * vol)
316 {
317 /* Hide the widget. */
318 gtk_widget_hide(vol->popup_window);
319 vol->show_popup = FALSE;
320 return FALSE;
321 }
322
323 /* Handler for "map" signal on popup window. */
324 static void volumealsa_popup_map(GtkWidget * widget, VolumeALSAPlugin * vol)
325 {
326 plugin_adjust_popup_position(widget, vol->plugin);
327 }
328
329 /* Handler for "value_changed" signal on popup window vertical scale. */
330 static void volumealsa_popup_scale_changed(GtkRange * range, VolumeALSAPlugin * vol)
331 {
332 /* Reflect the value of the control to the sound system. */
333 asound_set_volume(vol, gtk_range_get_value(range));
334
335 /* Redraw the controls. */
336 volumealsa_update_display(vol);
337 }
338
339 /* Handler for "scroll-event" signal on popup window vertical scale. */
340 static void volumealsa_popup_scale_scrolled(GtkScale * scale, GdkEventScroll * evt, VolumeALSAPlugin * vol)
341 {
342 /* Get the state of the vertical scale. */
343 gdouble val = gtk_range_get_value(GTK_RANGE(vol->volume_scale));
344
345 /* Dispatch on scroll direction to update the value. */
346 if ((evt->direction == GDK_SCROLL_UP) || (evt->direction == GDK_SCROLL_LEFT))
347 val += 2;
348 else
349 val -= 2;
350
351 /* Reset the state of the vertical scale. This provokes a "value_changed" event. */
352 gtk_range_set_value(GTK_RANGE(vol->volume_scale), CLAMP((int)val, 0, 100));
353 }
354
355 /* Handler for "toggled" signal on popup window mute checkbox. */
356 static void volumealsa_popup_mute_toggled(GtkWidget * widget, VolumeALSAPlugin * vol)
357 {
358 /* Get the state of the mute toggle. */
359 gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
360
361 /* Reflect the mute toggle to the sound system. */
362 if (vol->master_element != NULL)
363 {
364 int chn;
365 for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++)
366 snd_mixer_selem_set_playback_switch(vol->master_element, chn, ((active) ? 0 : 1));
367 }
368
369 /* Redraw the controls. */
370 volumealsa_update_display(vol);
371 }
372
373 /* Build the window that appears when the top level widget is clicked. */
374 static void volumealsa_build_popup_window(Plugin * p)
375 {
376 VolumeALSAPlugin * vol = p->priv;
377
378 /* Create a new window. */
379 vol->popup_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
380 gtk_window_set_decorated(GTK_WINDOW(vol->popup_window), FALSE);
381 gtk_container_set_border_width(GTK_CONTAINER(vol->popup_window), 5);
382 gtk_window_set_default_size(GTK_WINDOW(vol->popup_window), 80, 140);
383 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(vol->popup_window), TRUE);
384 gtk_window_set_skip_pager_hint(GTK_WINDOW(vol->popup_window), TRUE);
385 gtk_window_set_type_hint(GTK_WINDOW(vol->popup_window), GDK_WINDOW_TYPE_HINT_DIALOG);
386
387 /* Connect signals. */
388 g_signal_connect(G_OBJECT(vol->popup_window), "focus_out_event", G_CALLBACK(volumealsa_popup_focus_out), vol);
389 g_signal_connect(G_OBJECT(vol->popup_window), "map", G_CALLBACK(volumealsa_popup_map), vol);
390
391 /* Create a scrolled window as the child of the top level window. */
392 GtkWidget * scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
393 gtk_container_set_border_width (GTK_CONTAINER(scrolledwindow), 0);
394 gtk_widget_show(scrolledwindow);
395 gtk_container_add(GTK_CONTAINER(vol->popup_window), scrolledwindow);
396 GTK_WIDGET_UNSET_FLAGS(scrolledwindow, GTK_CAN_FOCUS);
397 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
398 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_NONE);
399
400 /* Create a viewport as the child of the scrolled window. */
401 GtkWidget * viewport = gtk_viewport_new(NULL, NULL);
402 gtk_container_add(GTK_CONTAINER(scrolledwindow), viewport);
403 gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
404 gtk_widget_show(viewport);
405
406 /* Create a frame as the child of the viewport. */
407 GtkWidget * frame = gtk_frame_new(_("Volume"));
408 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
409 gtk_container_add(GTK_CONTAINER(viewport), frame);
410
411 /* Create a vertical box as the child of the frame. */
412 GtkWidget * box = gtk_vbox_new(FALSE, 0);
413 gtk_container_add(GTK_CONTAINER(frame), box);
414
415 /* Create a vertical scale as the child of the vertical box. */
416 vol->volume_scale = gtk_vscale_new(GTK_ADJUSTMENT(gtk_adjustment_new(100, 0, 100, 0, 0, 0)));
417 gtk_scale_set_draw_value(GTK_SCALE(vol->volume_scale), FALSE);
418 gtk_range_set_inverted(GTK_RANGE(vol->volume_scale), TRUE);
419 gtk_box_pack_start(GTK_BOX(box), vol->volume_scale, TRUE, TRUE, 0);
420
421 /* Value-changed and scroll-event signals. */
422 vol->volume_scale_handler = g_signal_connect(vol->volume_scale, "value_changed", G_CALLBACK(volumealsa_popup_scale_changed), vol);
423 g_signal_connect(vol->volume_scale, "scroll-event", G_CALLBACK(volumealsa_popup_scale_scrolled), vol);
424
425 /* Create a check button as the child of the vertical box. */
426 vol->mute_check = gtk_check_button_new_with_label(_("Mute"));
427 gtk_box_pack_end(GTK_BOX(box), vol->mute_check, FALSE, FALSE, 0);
428 vol->mute_check_handler = g_signal_connect(vol->mute_check, "toggled", G_CALLBACK(volumealsa_popup_mute_toggled), vol);
429
430 /* Set background to default. */
431 gtk_widget_set_style(viewport, p->panel->defstyle);
432 }
433
434 /* Plugin constructor. */
435 static int volumealsa_constructor(Plugin * p, char ** fp)
436 {
437 /* Allocate and initialize plugin context and set into Plugin private data pointer. */
438 VolumeALSAPlugin * vol = g_new0(VolumeALSAPlugin, 1);
439 vol->plugin = p;
440 p->priv = vol;
441
442 /* Initialize ALSA. If that fails, present nothing. */
443 if ( ! asound_initialize(vol))
444 return 1;
445
446 /* Allocate top level widget and set into Plugin widget pointer. */
447 p->pwid = gtk_event_box_new();
448 gtk_widget_add_events(p->pwid, GDK_BUTTON_PRESS_MASK);
449 gtk_widget_set_tooltip_text(p->pwid, _("Volume control"));
450
451 /* Allocate icon as a child of top level. */
452 vol->tray_icon = gtk_image_new();
453 gtk_container_add(GTK_CONTAINER(p->pwid), vol->tray_icon);
454
455 /* Initialize window to appear when icon clicked. */
456 volumealsa_build_popup_window(p);
457
458 /* Connect signals. */
459 g_signal_connect(G_OBJECT(p->pwid), "button-press-event", G_CALLBACK(volumealsa_button_press_event), vol);
460 g_signal_connect(G_OBJECT(p->pwid), "scroll-event", G_CALLBACK(volumealsa_popup_scale_scrolled), vol );
461
462 /* Update the display, show the widget, and return. */
463 volumealsa_update_display(vol);
464 gtk_widget_show_all(p->pwid);
465 return 1;
466 }
467
468 /* Plugin destructor. */
469 static void volumealsa_destructor(Plugin * p)
470 {
471 VolumeALSAPlugin * vol = (VolumeALSAPlugin *) p->priv;
472
473 /* Remove the periodic timer. */
474 if (vol->mixer_evt_idle != 0)
475 g_source_remove(vol->mixer_evt_idle);
476
477 /* If the dialog box is open, dismiss it. */
478 if (vol->popup_window != NULL)
479 gtk_widget_destroy(vol->popup_window);
480
481 /* Deallocate all memory. */
482 g_free(vol);
483 }
484
485 /* Callback when the configuration dialog is to be shown. */
486
487 static void volumealsa_configure(Plugin * p, GtkWindow * parent)
488 {
489
490 GdkScreen *screen = gdk_screen_get_default();
491 GError *error = NULL;
492 const gchar *command_line = NULL;
493
494 if (g_find_program_in_path("pulseaudio"))
495 {
496 /* Assume that when pulseaudio is installed, it's launching every time */
497 if (g_find_program_in_path("gnome-sound-applet"))
498 {
499 command_line = "gnome-sound-applet";
500 }
501 else
502 {
503 if (g_find_program_in_path("pavucontrol"))
504 {
505 command_line = "pavucontrol";
506 }
507 }
508 }
509
510 /* Fallback to alsamixer when PA is not running, or when no PA utility is find */
511 if (command_line == NULL)
512 {
513 if (g_find_program_in_path("gnome-alsamixer"))
514 {
515 command_line = "gnome-alsamixer";
516 }
517 else
518 {
519 if (g_find_program_in_path("alsamixer"))
520 {
521 if (g_find_program_in_path("xterm"))
522 {
523 command_line = "xterm -e alsamixer";
524 }
525 }
526 }
527 }
528
529 if (command_line)
530 {
531 gdk_spawn_command_line_on_screen(screen,
532 command_line,
533 &error);
534 }
535 else
536 {
537
538 GtkWidget* msg;
539
540 msg = gtk_message_dialog_new( NULL,
541 0,
542 GTK_MESSAGE_ERROR,
543 GTK_BUTTONS_OK,
544 (_("Error, you need to install a application to configure the sound (pavucontol, alsamixer ...)")) );
545 gtk_dialog_run( GTK_DIALOG(msg) );
546 gtk_widget_destroy( msg );
547
548 }
549
550 if (error)
551 {
552 g_print("%s\n", error->message);
553 g_free (error);
554 }
555
556 }
557
558 /* Callback when panel configuration changes. */
559 static void volumealsa_panel_configuration_changed(Plugin * p)
560 {
561 /* Do a full redraw. */
562 volumealsa_update_display((VolumeALSAPlugin *) p->priv);
563 }
564
565 /* Plugin descriptor. */
566 PluginClass volumealsa_plugin_class = {
567
568 PLUGINCLASS_VERSIONING,
569
570 type : "volumealsa",
571 name : N_("Volume Control"),
572 version: "1.0",
573 description : "Display and control volume for ALSA",
574
575 constructor : volumealsa_constructor,
576 destructor : volumealsa_destructor,
577 config :volumealsa_configure,
578 save : NULL,
579 panel_configuration_changed : volumealsa_panel_configuration_changed
580
581 };