~ubuntu-branches/ubuntu/saucy/cairo-dock-plug-ins/saucy

« back to all changes in this revision

Viewing changes to alsaMixer/src/applet-notifications.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-08-26 21:07:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090826210739-gyjuuqezrzuluao4
Tags: upstream-2.0.8.1
ImportĀ upstreamĀ versionĀ 2.0.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
/******************************************************************************
 
21
 
 
22
This file is a part of the cairo-dock program, 
 
23
released under the terms of the GNU General Public License.
 
24
 
 
25
Written by Fabrice Rey (for any bug report, please mail me to fabounet@users.berlios.de)
 
26
 
 
27
******************************************************************************/
 
28
 
 
29
#include <stdlib.h>
 
30
#include <string.h>
 
31
#include <glib/gi18n.h>
 
32
 
 
33
#include "applet-struct.h"
 
34
#include "applet-mixer.h"
 
35
#include "applet-notifications.h"
 
36
 
 
37
 
 
38
CD_APPLET_ON_CLICK_BEGIN
 
39
        mixer_show_hide_dialog ();
 
40
CD_APPLET_ON_CLICK_END
 
41
 
 
42
 
 
43
static void _mixer_show_advanced_mixer (GtkMenuItem *menu_item, gpointer data)
 
44
{
 
45
        GError *erreur = NULL;
 
46
        if (myConfig.cShowAdvancedMixerCommand != NULL)
 
47
        {
 
48
                g_spawn_command_line_async (myConfig.cShowAdvancedMixerCommand, &erreur);
 
49
        }
 
50
        else
 
51
        {
 
52
                g_spawn_command_line_async ("gnome-volume-control", &erreur);
 
53
        }
 
54
        
 
55
        if (erreur != NULL)
 
56
        {
 
57
                cd_warning ("Attention : when trying to execute '%s' : %s", myConfig.cShowAdvancedMixerCommand, erreur->message);
 
58
                g_error_free (erreur);
 
59
        }
 
60
}
 
61
CD_APPLET_ON_BUILD_MENU_BEGIN
 
62
        GtkWidget *pSubMenu = CD_APPLET_CREATE_MY_SUB_MENU ();
 
63
                CD_APPLET_ADD_IN_MENU(_("Adjsut channels"), _mixer_show_advanced_mixer, pSubMenu);
 
64
                CD_APPLET_ADD_ABOUT_IN_MENU (pSubMenu);
 
65
CD_APPLET_ON_BUILD_MENU_END
 
66
 
 
67
 
 
68
CD_APPLET_ON_MIDDLE_CLICK_BEGIN
 
69
        mixer_switch_mute ();
 
70
CD_APPLET_ON_MIDDLE_CLICK_END
 
71
 
 
72
 
 
73
CD_APPLET_ON_DOUBLE_CLICK_BEGIN
 
74
        _mixer_show_advanced_mixer (NULL, NULL);
 
75
CD_APPLET_ON_DOUBLE_CLICK_END
 
76
 
 
77
 
 
78
void mixer_on_keybinding_pull (const char *keystring, gpointer user_data)
 
79
{
 
80
        mixer_show_hide_dialog ();
 
81
}
 
82
 
 
83
CD_APPLET_ON_SCROLL_BEGIN
 
84
        int iVolume = mixer_get_mean_volume ();  // [0;100]
 
85
        if (CD_APPLET_SCROLL_DOWN)
 
86
        {
 
87
                iVolume = MAX (iVolume - myConfig.iScrollVariation, 0);
 
88
        }
 
89
        else if (CD_APPLET_SCROLL_UP)
 
90
        {
 
91
                iVolume = MIN (iVolume + myConfig.iScrollVariation, 100);
 
92
        }
 
93
        else
 
94
                return CAIRO_DOCK_LET_PASS_NOTIFICATION;
 
95
        
 
96
        mixer_set_volume (iVolume);
 
97
CD_APPLET_ON_SCROLL_END