30
30
#include "plugin.h"
33
#define ICONS_VOLUME PACKAGE_DATA_DIR "/lxpanel/images/volume.png"
34
#define ICONS_MUTE PACKAGE_DATA_DIR "/lxpanel/images/mute.png"
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"
229
231
/* Mute status. */
230
232
gboolean mute = asound_is_muted(vol);
233
int level = asound_get_volume(vol);
232
if ( ! panel_image_set_icon_theme(vol->plugin->panel, vol->tray_icon, ((mute) ? "audio-volume-muted" : "audio-volume-high")))
234
panel_image_set_from_file(vol->plugin->panel, vol->tray_icon, ((mute) ? ICONS_MUTE : ICONS_VOLUME));
235
/* Change icon according to mute / volume */
236
const char* icon="audio-volume-muted";
237
const char* icon_fallback=ICONS_MUTE;
240
icon="audio-volume-muted";
241
icon_fallback=ICONS_MUTE;
243
else if (level >= 75)
245
icon="audio-volume-high";
246
icon_fallback=ICONS_VOLUME_HIGH;
248
else if (level >= 50)
250
icon="audio-volume-medium";
251
icon_fallback=ICONS_VOLUME_MEDIUM;
255
icon="audio-volume-low";
256
icon_fallback=ICONS_VOLUME_LOW;
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))
262
panel_image_set_from_file(vol->plugin->panel, vol->tray_icon, icon_fallback);
237
265
g_signal_handler_block(vol->mute_check, vol->mute_check_handler);
240
268
g_signal_handler_unblock(vol->mute_check, vol->mute_check_handler);
243
int level = asound_get_volume(vol);
244
271
if (vol->volume_scale != NULL)
246
273
g_signal_handler_block(vol->volume_scale, vol->volume_scale_handler);
485
/* Callback when the configuration dialog is to be shown. */
487
static void volumealsa_configure(Plugin * p, GtkWindow * parent)
490
GdkScreen *screen = gdk_screen_get_default();
491
GError *error = NULL;
492
const gchar *command_line = NULL;
494
if (g_find_program_in_path("pulseaudio"))
496
/* Assume that when pulseaudio is installed, it's launching every time */
497
if (g_find_program_in_path("gnome-sound-applet"))
499
command_line = "gnome-sound-applet";
503
if (g_find_program_in_path("pavucontrol"))
505
command_line = "pavucontrol";
510
/* Fallback to alsamixer when PA is not running, or when no PA utility is find */
511
if (command_line == NULL)
513
if (g_find_program_in_path("gnome-alsamixer"))
515
command_line = "gnome-alsamixer";
519
if (g_find_program_in_path("alsamixer"))
521
if (g_find_program_in_path("xterm"))
523
command_line = "xterm -e alsamixer";
531
gdk_spawn_command_line_on_screen(screen,
540
msg = gtk_message_dialog_new( NULL,
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 );
552
g_print("%s\n", error->message);
458
558
/* Callback when panel configuration changes. */
459
559
static void volumealsa_panel_configuration_changed(Plugin * p)
475
575
constructor : volumealsa_constructor,
476
576
destructor : volumealsa_destructor,
577
config :volumealsa_configure,
479
579
panel_configuration_changed : volumealsa_panel_configuration_changed