~fourdollars/indicator-power/zesty

« back to all changes in this revision

Viewing changes to tests/sound-player-mock.c

  • Committer: CI Train Bot
  • Author(s): Charles Kerr
  • Date: 2016-05-16 21:33:30 UTC
  • mfrom: (292.2.9 use-libnotify-for-audio)
  • Revision ID: ci-train-bot@canonical.com-20160516213330-tsw2b5yf7mt2hvpo
Use the fdo 'sound-file' hint to play a sound when a low battery notification is shown.
Approved by: Ted Gould

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2016 Canonical Ltd.
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 version 3, as published
6
 
 * by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but
9
 
 * WITHOUT ANY WARRANTY; without even the implied warranties of
10
 
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
 
 * PURPOSE.  See the GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License along
14
 
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors:
17
 
 *   Charles Kerr <charles.kerr@canonical.com>
18
 
 */
19
 
 
20
 
#include "sound-player.h"
21
 
#include "sound-player-mock.h"
22
 
 
23
 
enum
24
 
{
25
 
  SIGNAL_URI_PLAYED,
26
 
  LAST_SIGNAL
27
 
};
28
 
 
29
 
static guint signals[LAST_SIGNAL] = { 0 };
30
 
 
31
 
/***
32
 
****  GObject boilerplate
33
 
***/
34
 
 
35
 
static void indicator_power_sound_player_interface_init (
36
 
                                IndicatorPowerSoundPlayerInterface * iface);
37
 
 
38
 
G_DEFINE_TYPE_WITH_CODE (
39
 
  IndicatorPowerSoundPlayerMock,
40
 
  indicator_power_sound_player_mock,
41
 
  G_TYPE_OBJECT,
42
 
  G_IMPLEMENT_INTERFACE (INDICATOR_TYPE_POWER_SOUND_PLAYER,
43
 
                         indicator_power_sound_player_interface_init))
44
 
 
45
 
/***
46
 
****  IndicatorPowerSoundPlayer virtual functions
47
 
***/
48
 
 
49
 
static void
50
 
my_play_uri (IndicatorPowerSoundPlayer * self, const gchar * uri)
51
 
{
52
 
  g_signal_emit (self, signals[SIGNAL_URI_PLAYED], 0, uri, NULL);
53
 
}
54
 
 
55
 
/***
56
 
****  Instantiation
57
 
***/
58
 
 
59
 
static void
60
 
indicator_power_sound_player_mock_class_init (IndicatorPowerSoundPlayerMockClass * klass G_GNUC_UNUSED)
61
 
{
62
 
  signals[SIGNAL_URI_PLAYED] = g_signal_new (
63
 
    "uri-played",
64
 
    G_TYPE_FROM_CLASS(klass),
65
 
    G_SIGNAL_RUN_LAST,
66
 
    G_STRUCT_OFFSET (IndicatorPowerSoundPlayerMockClass, uri_played),
67
 
    NULL, NULL,
68
 
    g_cclosure_marshal_VOID__STRING,
69
 
    G_TYPE_NONE, 1, G_TYPE_STRING);
70
 
}
71
 
 
72
 
static void
73
 
indicator_power_sound_player_interface_init (IndicatorPowerSoundPlayerInterface * iface)
74
 
{
75
 
  iface->play_uri = my_play_uri;
76
 
}
77
 
 
78
 
static void
79
 
indicator_power_sound_player_mock_init (IndicatorPowerSoundPlayerMock * self G_GNUC_UNUSED)
80
 
{
81
 
}
82
 
 
83
 
/***
84
 
****  Public API
85
 
***/
86
 
 
87
 
IndicatorPowerSoundPlayer *
88
 
indicator_power_sound_player_mock_new (void)
89
 
{
90
 
  gpointer o = g_object_new (INDICATOR_TYPE_POWER_SOUND_PLAYER_MOCK, NULL);
91
 
 
92
 
  return INDICATOR_POWER_SOUND_PLAYER (o);
93
 
}
94