~ubuntu-branches/ubuntu/saucy/parole/saucy

« back to all changes in this revision

Viewing changes to src/misc/parole-provider-player.c

  • Committer: Package Import Robot
  • Author(s): Lionel Le Folgoc
  • Date: 2012-08-15 13:56:10 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120815135610-xkgrhm52dq81czhe
Tags: 0.3.0-0ubuntu1
* New upstream release.
* debian/patches:
  - 01_fix-implicit-dso-linking.patch: dropped, included upstream.
  - 01_fix-plugin-install-dir.patch, 02_fix-ftbfs-enable-debug.patch,
    03_fix-ftbfs-built-twice.patch: added, fix wrong install path and build
    failures.
* debian/control:
  - replace b-dep on libxfcegui4-dev with libxfce4ui-1-dev and bump
    libgtk2.0-dev to >= 2.20.
* debian/rules:
  - create empty m4 directory if missing.
  - clean up autogenerated files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * * Copyright (C) 2009 Ali <aliov@xfce.org>
 
3
 *
 
4
 * Licensed under the GNU General Public License Version 2
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#ifdef HAVE_CONFIG_H
 
22
#include <config.h>
 
23
#endif
 
24
 
 
25
#include "parole-provider-player.h"
 
26
#include "parole-marshal.h"
 
27
#include "parole-enum-types.h"
 
28
 
 
29
static void     parole_provider_player_base_init        (gpointer klass);
 
30
static void     parole_provider_player_class_init       (gpointer klass);
 
31
 
 
32
GType
 
33
parole_provider_player_get_type (void)
 
34
{
 
35
    static GType type = G_TYPE_INVALID;
 
36
 
 
37
    if (G_UNLIKELY (type == G_TYPE_INVALID))
 
38
    {
 
39
        static const GTypeInfo info =
 
40
        {
 
41
            sizeof (ParoleProviderPlayerIface),
 
42
            (GBaseInitFunc) parole_provider_player_base_init,
 
43
            NULL,
 
44
            (GClassInitFunc) parole_provider_player_class_init,
 
45
            NULL,
 
46
            NULL,
 
47
            0,
 
48
            0,
 
49
            NULL,
 
50
            NULL,
 
51
        };
 
52
 
 
53
        type = g_type_register_static (G_TYPE_INTERFACE, "ParoleProviderPlayerIface", &info, 0);
 
54
 
 
55
        g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
 
56
    }
 
57
    
 
58
    return type;
 
59
}
 
60
 
 
61
static void parole_provider_player_base_init (gpointer klass)
 
62
{
 
63
    static gboolean initialized = FALSE;
 
64
 
 
65
    if (G_UNLIKELY (!initialized))
 
66
    {
 
67
        /**
 
68
         * ParoleProviderPlayerIface::state-changed:
 
69
         * @player: the object which received the signal.
 
70
         * @stream: a #ParoleStream.
 
71
         * @state: the new state.
 
72
         * 
 
73
         * Issued when the Parole state changed.
 
74
         * 
 
75
         * Since: 0.2 
 
76
         **/
 
77
        g_signal_new ("state-changed",
 
78
                      G_TYPE_FROM_INTERFACE (klass),
 
79
                      G_SIGNAL_RUN_LAST,
 
80
                      G_STRUCT_OFFSET (ParoleProviderPlayerIface, state_changed),
 
81
                      NULL, NULL,
 
82
                      parole_marshal_VOID__OBJECT_ENUM,
 
83
                      G_TYPE_NONE, 2,
 
84
                      PAROLE_TYPE_STREAM, PAROLE_ENUM_TYPE_STATE);
 
85
 
 
86
        /**
 
87
         * ParoleProviderPlayerIface::tag-message:
 
88
         * @player: the object which received the signal.
 
89
         * @stream: a #ParoleStream.
 
90
         * 
 
91
         * Indicated that the stream tags were found and ready to be read.
 
92
         * 
 
93
         * Since: 0.2 
 
94
         **/
 
95
        g_signal_new ("tag-message",
 
96
                      G_TYPE_FROM_INTERFACE (klass),
 
97
                      G_SIGNAL_RUN_LAST,
 
98
                      G_STRUCT_OFFSET (ParoleProviderPlayerIface, tag_message),
 
99
                      NULL, NULL,
 
100
                      g_cclosure_marshal_VOID__OBJECT,
 
101
                      G_TYPE_NONE, 1, PAROLE_TYPE_STREAM);
 
102
                          
 
103
        initialized = TRUE;
 
104
    }
 
105
}
 
106
 
 
107
static void parole_provider_player_class_init (gpointer klass)
 
108
{
 
109
}
 
110
 
 
111
/**
 
112
 * parole_provider_player_get_main_window:
 
113
 * @player: a #ParoleProviderPlayer 
 
114
 * 
 
115
 * Ask the Player to get the Parole main window.
 
116
 * 
 
117
 * Returns: #GtkWidget window.
 
118
 * 
 
119
 * Since: 0.2
 
120
 **/
 
121
GtkWidget *parole_provider_player_get_main_window (ParoleProviderPlayer *player)
 
122
{
 
123
    GtkWidget *window = NULL;
 
124
    
 
125
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), NULL);
 
126
    
 
127
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_main_window )
 
128
    {
 
129
        window  = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_main_window) (player);
 
130
    }
 
131
    return window;
 
132
}
 
133
 
 
134
/**
 
135
 * parole_provider_player_pack:
 
136
 * @player: a #ParoleProviderPlayer
 
137
 * @widget: a #GtkWidget.
 
138
 * @title: title
 
139
 * @container: a #ParolePluginContainer.
 
140
 * 
 
141
 * Ask the player to pack a widget in the playlist notebook if PAROLE_PLUGIN_CONTAINER_PLAYLIST 
 
142
 * is specified or in the main window notebook if PAROLE_PLUGIN_CONTAINER_MAIN_VIEW is specified.
 
143
 * 
 
144
 * This function can be called once, the Player is responsible on removing the widget in
 
145
 * case the plugin was unloaded.
 
146
 * 
 
147
 * 
 
148
 * Since: 0.2
 
149
 **/ 
 
150
void parole_provider_player_pack (ParoleProviderPlayer *player, GtkWidget *widget, 
 
151
                                  const gchar *title, ParolePluginContainer container)
 
152
{
 
153
    g_return_if_fail (PAROLE_IS_PROVIDER_PLAYER (player));
 
154
    
 
155
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pack )
 
156
    {
 
157
        (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pack) (player, widget, title, container);
 
158
    }
 
159
}
 
160
                
 
161
/**
 
162
 * parole_provider_player_get_state:
 
163
 * @player: a #ParoleProviderPlayer
 
164
 * 
 
165
 * Get the current state of the player.
 
166
 * 
 
167
 * Returns: a #ParoleState.
 
168
 * 
 
169
 * 
 
170
 * Since: 0.2
 
171
 **/
 
172
ParoleState parole_provider_player_get_state (ParoleProviderPlayer *player)
 
173
{
 
174
    ParoleState state = PAROLE_STATE_STOPPED;
 
175
    
 
176
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), PAROLE_STATE_STOPPED);
 
177
    
 
178
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_state )
 
179
    {
 
180
        state = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_state) (player);
 
181
    }
 
182
    
 
183
    return state;
 
184
}
 
185
 
 
186
/**
 
187
 * parole_provider_player_get_stream:
 
188
 * @player: a #ParoleProviderPlayer
 
189
 * 
 
190
 * Get the #ParoleStream object.
 
191
 * 
 
192
 * Returns: the #ParoleStream object.
 
193
 * 
 
194
 * Since: 0.2
 
195
 **/
 
196
const ParoleStream *parole_provider_player_get_stream   (ParoleProviderPlayer *player)
 
197
{
 
198
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), NULL);
 
199
    
 
200
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_stream )
 
201
    {
 
202
        return (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_stream) (player);
 
203
    }
 
204
    
 
205
    return NULL;
 
206
}
 
207
 
 
208
/**
 
209
 * parole_provider_player_play_uri:
 
210
 * @player: a #ParoleProviderPlayer
 
211
 * @uri: uri
 
212
 * 
 
213
 * Issue a play command on the backend for the given uri, note this function
 
214
 * can be called only of the Parole current state is PAROLE_STATE_STOPPED.
 
215
 * 
 
216
 * Returning TRUE doesn't mean that the funtion succeeded to change the state of the player, 
 
217
 * the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
 
218
 * 
 
219
 * Returns: TRUE if the command is processed, FALSE otherwise.
 
220
 * 
 
221
 * Since: 0.2
 
222
 **/
 
223
gboolean parole_provider_player_play_uri (ParoleProviderPlayer *player, const gchar *uri)
 
224
{
 
225
    gboolean ret = FALSE;
 
226
     
 
227
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
 
228
    
 
229
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->play_uri )
 
230
    {
 
231
        ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->play_uri) (player, uri);
 
232
    }
 
233
    return ret;
 
234
}
 
235
 
 
236
 
 
237
/**
 
238
 * parole_provider_player_pause:
 
239
 * @player: a #ParoleProviderPlayer
 
240
 * 
 
241
 * Issue a pause command to the backend, this function can be called when the state of the player
 
242
 * is PAROLE_STATE_PLAYING.
 
243
 * 
 
244
 * Returning TRUE doesn't mean that the funtion succeeded to change the state of the player, 
 
245
 * the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
 
246
 * 
 
247
 * Returns: TRUE if the command is processed, FALSE otherwise.
 
248
 * 
 
249
 * 
 
250
 * Since: 0.2
 
251
 **/
 
252
gboolean parole_provider_player_pause (ParoleProviderPlayer *player)
 
253
{
 
254
    gboolean ret = FALSE;
 
255
    
 
256
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
 
257
    
 
258
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pause )
 
259
    {
 
260
        ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pause) (player);
 
261
    }
 
262
    
 
263
    return ret;
 
264
}
 
265
 
 
266
 
 
267
/**
 
268
 * parole_provider_player_resume:
 
269
 * @player: a #ParoleProviderPlayer
 
270
 * 
 
271
 * 
 
272
 * Issue a resume command to the player, this function can be called when
 
273
 * the current state of the player is PAROLE_STATE_PAUSED.
 
274
 * 
 
275
 * Returning TRUE doesn't mean that the funtion succeeded to change the state of the player, 
 
276
 * the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
 
277
 * 
 
278
 * Returns: TRUE if the command is processed, FALSE otherwise.
 
279
 * 
 
280
 * 
 
281
 * Since: 0.2
 
282
 **/
 
283
gboolean parole_provider_player_resume (ParoleProviderPlayer *player)
 
284
{
 
285
    gboolean ret = FALSE;
 
286
    
 
287
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
 
288
    
 
289
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->resume )
 
290
    {
 
291
        ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->resume) (player);
 
292
    }
 
293
    
 
294
    return ret;
 
295
}
 
296
 
 
297
 
 
298
/**
 
299
 * parole_provider_player_stop:
 
300
 * @player: a #ParoleProviderPlayer
 
301
 * 
 
302
 * Issue a stop command to the player.
 
303
 * 
 
304
 * Returning TRUE doesn't mean that the funtion succeeded to change the state of the player, 
 
305
 * the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
 
306
 * 
 
307
 * Returns: TRUE if the command is processed, FALSE otherwise.
 
308
 * 
 
309
 * Since: 0.2
 
310
 **/
 
311
gboolean parole_provider_player_stop (ParoleProviderPlayer *player)
 
312
{
 
313
    gboolean ret = FALSE;
 
314
    
 
315
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
 
316
    
 
317
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->stop )
 
318
    {
 
319
        ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->stop) (player);
 
320
    }
 
321
    
 
322
    return ret;
 
323
}
 
324
 
 
325
 
 
326
/**
 
327
 * parole_provider_player_seek:
 
328
 * @player: a #ParoleProviderPlayer
 
329
 * @pos: position to seek.
 
330
 * 
 
331
 * 
 
332
 * Issue a seek command.
 
333
 * 
 
334
 * Returns: TRUE if the seek command succeeded, FALSE otherwise.
 
335
 * 
 
336
 * 
 
337
 * Since: 0.2
 
338
 **/
 
339
gboolean parole_provider_player_seek (ParoleProviderPlayer *player, gdouble pos)
 
340
{
 
341
    gboolean ret = FALSE;
 
342
    
 
343
    g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
 
344
    
 
345
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->seek )
 
346
    {
 
347
        ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->seek) (player, pos);
 
348
    }
 
349
    
 
350
    return ret;
 
351
}
 
352
 
 
353
 
 
354
/**
 
355
 * parole_provider_player_open_media_chooser:
 
356
 * @player: a #ParoleProviderPlayer
 
357
 * 
 
358
 * Ask Parole to open its media chooser dialog.
 
359
 * 
 
360
 * Since: 0.2
 
361
 **/
 
362
void parole_provider_player_open_media_chooser (ParoleProviderPlayer *player)
 
363
{
 
364
    g_return_if_fail (PAROLE_IS_PROVIDER_PLAYER (player));
 
365
    
 
366
    if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->open_media_chooser )
 
367
    {
 
368
        (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->open_media_chooser) (player);
 
369
    }
 
370
}