~jeremywootten/pantheon-files/fix-backspace-in-columnv-view

« back to all changes in this revision

Viewing changes to libcore/SoundManager.vala

  • Committer: jeremy at elementaryos
  • Date: 2016-04-30 11:11:40 UTC
  • mfrom: (2023.1.107 pantheon-files)
  • Revision ID: jeremy@elementaryos.org-20160430111140-ez2siepsfxwj9asi
Merge trunk to r2130

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***
 
2
    Copyright (c) 2016 Elementary Developers
 
3
 
 
4
    This program is free software; you can redistribute it and/or modify it
 
5
    under the terms of the GNU General Public License as published by the Free
 
6
    Software Foundation; either version 2 of the License, or (at your option)
 
7
    any later version.
 
8
 
 
9
    This program is distributed in the hope that it will be useful, but WITHOUT
 
10
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
12
    more details.
 
13
 
 
14
    You should have received a copy of the GNU General Public License along with
 
15
    this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
16
    Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
    Authors : Jeremy Wootten <jeremy@elementaryos.org>
 
19
 
 
20
    Some convenience wrappers around libcanberra for using sounds within pantheon-files.
 
21
 
 
22
 ***/
 
23
 
 
24
namespace PF {
 
25
 
 
26
    public class SoundManager : GLib.Object {
 
27
        private static SoundManager? instance = null;
 
28
        public static unowned SoundManager get_instance () {
 
29
            if (instance == null) {
 
30
                instance = new SoundManager ();
 
31
            }
 
32
            return instance;
 
33
        }
 
34
 
 
35
        Canberra.Context? ca_context;
 
36
 
 
37
        private SoundManager () {
 
38
            ca_context = null;
 
39
            Canberra.Context.create (out ca_context);
 
40
            if (ca_context != null) {
 
41
                ca_context.change_props (Canberra.PROP_APPLICATION_NAME, PF.Sound.APP_TITLE,
 
42
                                         Canberra.PROP_APPLICATION_ID, PF.Sound.APP_ID,
 
43
                                         Canberra.PROP_APPLICATION_ICON_NAME, PF.Sound.APP_LOGO);
 
44
                ca_context.open ();
 
45
            }
 
46
        }
 
47
 
 
48
        public void play_delete_sound () {
 
49
            play_sound (PF.Sound.DELETE);
 
50
        }
 
51
        public void play_empty_trash_sound () {
 
52
            play_sound (PF.Sound.EMPTY_TRASH);
 
53
        }
 
54
        public void play_sound (string pf_sound_id) {
 
55
            if (ca_context == null) {
 
56
                return;
 
57
            }
 
58
            ca_context.play (0, Canberra.PROP_EVENT_ID, pf_sound_id);
 
59
        }
 
60
    }
 
61
 
 
62
    namespace Sound {
 
63
        const string APP_TITLE = "Files";
 
64
        const string APP_ID = "org.pantheon.files";
 
65
        const string APP_LOGO = "system-file-manager";
 
66
        public const string THEME = "freedesktop";
 
67
        public const string DELETE = "trash-empty";
 
68
        public const string EMPTY_TRASH = "trash-empty";
 
69
    }
 
70
}
 
71