Updated Finnish translation
[rhythmbox.git] / backends / rb-encoder.c
blob7b216fe2f472ad56a476b97950a190eed192e837
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3 * Copyright (C) 2006 James Livingston <jrl@ids.org.au>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <config.h>
23 #include "rb-encoder.h"
24 #include "rb-encoder-gst.h"
26 /* Signals */
27 enum {
28 PROGRESS,
29 COMPLETED,
30 ERROR,
31 LAST_SIGNAL
34 static guint signals[LAST_SIGNAL] = { 0 };
36 static void
37 rb_encoder_interface_init (RBEncoderIface *iface)
39 signals[PROGRESS] =
40 g_signal_new ("progress",
41 G_TYPE_FROM_INTERFACE (iface),
42 G_SIGNAL_RUN_LAST,
43 G_STRUCT_OFFSET (RBEncoderIface, progress),
44 NULL, NULL,
45 g_cclosure_marshal_VOID__DOUBLE,
46 G_TYPE_NONE,
47 1, G_TYPE_DOUBLE);
48 signals[COMPLETED] =
49 g_signal_new ("completed",
50 G_TYPE_FROM_INTERFACE (iface),
51 G_SIGNAL_RUN_LAST,
52 G_STRUCT_OFFSET (RBEncoderIface, completed),
53 NULL, NULL,
54 g_cclosure_marshal_VOID__VOID,
55 G_TYPE_NONE,
56 0);
57 signals[ERROR] =
58 g_signal_new ("error",
59 G_TYPE_FROM_INTERFACE (iface),
60 G_SIGNAL_RUN_LAST,
61 G_STRUCT_OFFSET (RBEncoderIface, error),
62 NULL, NULL,
63 g_cclosure_marshal_VOID__POINTER,
64 G_TYPE_NONE,
65 1, G_TYPE_POINTER);
69 GType
70 rb_encoder_get_type (void)
72 static GType our_type = 0;
74 if (!our_type) {
75 static const GTypeInfo our_info = {
76 sizeof (RBEncoderIface),
77 NULL, /* base_init */
78 NULL, /* base_finalize */
79 (GClassInitFunc)rb_encoder_interface_init,
80 NULL, /* class_finalize */
81 NULL, /* class_data */
84 NULL
87 our_type = g_type_register_static (G_TYPE_INTERFACE, "RBEncoder", &our_info, 0);
90 return our_type;
93 gboolean
94 rb_encoder_encode (RBEncoder *encoder,
95 RhythmDBEntry *entry,
96 const char *dest,
97 const char *mime_type)
99 RBEncoderIface *iface = RB_ENCODER_GET_IFACE (encoder);
101 return iface->encode (encoder, entry, dest, mime_type);
104 void
105 rb_encoder_cancel (RBEncoder *encoder)
107 RBEncoderIface *iface = RB_ENCODER_GET_IFACE (encoder);
109 iface->cancel (encoder);
112 RBEncoder*
113 rb_encoder_new (void)
115 return rb_encoder_gst_new ();
118 void
119 _rb_encoder_emit_progress (RBEncoder *encoder, double fraction)
121 g_signal_emit (encoder, signals[PROGRESS], 0, fraction);
124 void
125 _rb_encoder_emit_completed (RBEncoder *encoder)
127 g_signal_emit (encoder, signals[COMPLETED], 0);
130 void
131 _rb_encoder_emit_error (RBEncoder *encoder, GError *error)
133 g_signal_emit (encoder, signals[ERROR], 0, error);
136 GQuark
137 rb_encoder_error_quark (void)
139 static GQuark quark = 0;
140 if (!quark)
141 quark = g_quark_from_static_string ("rb_encoder_error");
143 return quark;