1
/* gtkeditablewavebuffer.c: Interface for editable wavebuffer.
2
* Copyright (c) 2000 David A. Bartold
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
21
#include <gtk/gtksignal.h>
22
#include <gtk/gtkmain.h>
23
#include "gtkeditablewavebuffer.h"
26
static void gtk_editable_wave_buffer_class_init (GtkEditableWaveBufferClass *klass);
27
static void gtk_editable_wave_buffer_init (GtkEditableWaveBuffer *editable_wave_buffer);
29
guint modified_signal;
30
guint insert_data_signal;
31
guint delete_data_signal;
35
gtk_editable_wave_buffer_get_type (void)
37
static GtkType editable_wave_buffer_type = 0;
39
if (!editable_wave_buffer_type)
41
static const GtkTypeInfo editable_wave_buffer_info =
43
"GtkEditableWaveBuffer",
44
sizeof (GtkEditableWaveBuffer),
45
sizeof (GtkEditableWaveBufferClass),
46
(GtkClassInitFunc) gtk_editable_wave_buffer_class_init,
47
(GtkObjectInitFunc) gtk_editable_wave_buffer_init,
48
/* reserved_1 */ NULL,
49
/* reserved_2 */ NULL,
50
(GtkClassInitFunc) NULL
53
editable_wave_buffer_type = gtk_type_unique (GTK_TYPE_WAVE_BUFFER, &editable_wave_buffer_info);
56
return editable_wave_buffer_type;
61
gtk_editable_wave_buffer_real_destroy (GtkObject *object)
63
GtkEditableWaveBuffer *editable = GTK_EDITABLE_WAVE_BUFFER (object);
65
if (editable->modified)
67
gtk_idle_remove (editable->modified_idle);
68
editable->modified = FALSE;
74
gtk_editable_wave_buffer_class_init (GtkEditableWaveBufferClass *klass)
76
GtkObjectClass *object_class;
77
GtkWaveBufferClass *wavebuffer_class;
79
object_class = (GtkObjectClass *) klass;
80
wavebuffer_class = (GtkWaveBufferClass *) klass;
82
object_class->destroy = gtk_editable_wave_buffer_real_destroy;
84
wavebuffer_class->get_datatype = NULL;
85
wavebuffer_class->get_length = NULL;
86
wavebuffer_class->get_num_channels = NULL;
87
wavebuffer_class->get_samples = NULL;
88
klass->set_samples = NULL;
95
gtk_editable_wave_buffer_init (GtkEditableWaveBuffer *editable)
101
gtk_editable_wave_buffer_emit_modified (GtkEditableWaveBuffer *editable)
103
gtk_signal_emit (GTK_OBJECT (editable), modified_signal, &editable->modified_range);
104
editable->modified = FALSE;
111
gtk_editable_wave_buffer_queue_modified (GtkEditableWaveBuffer *editable, guint32 start, guint32 length)
113
if (editable->modified)
115
g_range_add (&editable->modified_range, start, length);
119
g_range_set (&editable->modified_range, start, length);
120
editable->modified = TRUE;
121
editable->modified_idle =
122
gtk_idle_add ((GtkFunction) >k_editable_wave_buffer_emit_modified,
129
gtk_editable_wave_buffer_set_samples (GtkEditableWaveBuffer *editable,
132
guint32 channel_mask,
135
return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->set_samples (editable, start, length, channel_mask, data);
140
gtk_editable_wave_buffer_insert (GtkEditableWaveBuffer *editable,
144
return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->insert (editable, start, length);
149
gtk_editable_wave_buffer_delete (GtkEditableWaveBuffer *editable,
153
return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->delete (editable, start, length);