~ubuntu-branches/ubuntu/utopic/glame/utopic

« back to all changes in this revision

Viewing changes to src/gui/libgtkwaveform/gtkeditablewavebuffer.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2002-04-09 17:14:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020409171412-jzpnov7mbz2w6zsr
Tags: upstream-0.6.2
ImportĀ upstreamĀ versionĀ 0.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* gtkeditablewavebuffer.c: Interface for editable wavebuffer.
 
2
 * Copyright (c) 2000 David A. Bartold
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 */
 
19
 
 
20
#include <glib.h>
 
21
#include <gtk/gtksignal.h>
 
22
#include <gtk/gtkmain.h>
 
23
#include "gtkeditablewavebuffer.h"
 
24
 
 
25
 
 
26
static void gtk_editable_wave_buffer_class_init      (GtkEditableWaveBufferClass *klass);
 
27
static void gtk_editable_wave_buffer_init            (GtkEditableWaveBuffer      *editable_wave_buffer);
 
28
 
 
29
guint modified_signal;
 
30
guint insert_data_signal;
 
31
guint delete_data_signal;
 
32
 
 
33
 
 
34
GtkType
 
35
gtk_editable_wave_buffer_get_type (void)
 
36
{
 
37
  static GtkType editable_wave_buffer_type = 0;
 
38
 
 
39
  if (!editable_wave_buffer_type)
 
40
    {
 
41
      static const GtkTypeInfo editable_wave_buffer_info =
 
42
      {
 
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
 
51
      };
 
52
 
 
53
      editable_wave_buffer_type = gtk_type_unique (GTK_TYPE_WAVE_BUFFER, &editable_wave_buffer_info);
 
54
    }
 
55
 
 
56
  return editable_wave_buffer_type;
 
57
}
 
58
 
 
59
 
 
60
static void
 
61
gtk_editable_wave_buffer_real_destroy (GtkObject *object)
 
62
{
 
63
  GtkEditableWaveBuffer *editable = GTK_EDITABLE_WAVE_BUFFER (object);
 
64
 
 
65
  if (editable->modified)
 
66
    {
 
67
      gtk_idle_remove (editable->modified_idle);
 
68
      editable->modified = FALSE;
 
69
    }
 
70
}
 
71
 
 
72
 
 
73
static void
 
74
gtk_editable_wave_buffer_class_init (GtkEditableWaveBufferClass *klass)
 
75
{
 
76
  GtkObjectClass *object_class;
 
77
  GtkWaveBufferClass *wavebuffer_class;
 
78
 
 
79
  object_class = (GtkObjectClass *) klass;
 
80
  wavebuffer_class = (GtkWaveBufferClass *) klass;
 
81
 
 
82
  object_class->destroy = gtk_editable_wave_buffer_real_destroy;
 
83
 
 
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;
 
89
  klass->insert = NULL;
 
90
  klass->delete = NULL;
 
91
}
 
92
 
 
93
 
 
94
static void
 
95
gtk_editable_wave_buffer_init (GtkEditableWaveBuffer *editable)
 
96
{
 
97
}
 
98
 
 
99
 
 
100
static gint
 
101
gtk_editable_wave_buffer_emit_modified (GtkEditableWaveBuffer *editable)
 
102
{
 
103
  gtk_signal_emit (GTK_OBJECT (editable), modified_signal, &editable->modified_range);
 
104
  editable->modified = FALSE;
 
105
 
 
106
  return 0;
 
107
}
 
108
 
 
109
 
 
110
void
 
111
gtk_editable_wave_buffer_queue_modified (GtkEditableWaveBuffer *editable, guint32 start, guint32 length)
 
112
{
 
113
  if (editable->modified)
 
114
    {
 
115
      g_range_add (&editable->modified_range, start, length);
 
116
    }
 
117
  else
 
118
    {
 
119
      g_range_set (&editable->modified_range, start, length);
 
120
      editable->modified = TRUE;
 
121
      editable->modified_idle =
 
122
        gtk_idle_add ((GtkFunction) &gtk_editable_wave_buffer_emit_modified,
 
123
                      editable);
 
124
    }
 
125
}
 
126
 
 
127
 
 
128
gint
 
129
gtk_editable_wave_buffer_set_samples (GtkEditableWaveBuffer *editable,
 
130
                                      guint32 start,
 
131
                                      guint32 length,
 
132
                                      guint32 channel_mask,
 
133
                                      gpointer data)
 
134
{
 
135
  return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->set_samples (editable, start, length, channel_mask, data);
 
136
}
 
137
 
 
138
 
 
139
gint
 
140
gtk_editable_wave_buffer_insert (GtkEditableWaveBuffer *editable,
 
141
                                 guint32 start,
 
142
                                 guint32 length)
 
143
{
 
144
  return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->insert (editable, start, length);
 
145
}
 
146
 
 
147
 
 
148
gint
 
149
gtk_editable_wave_buffer_delete (GtkEditableWaveBuffer *editable,
 
150
                                 guint32 start,
 
151
                                 guint32 length)
 
152
{
 
153
  return GTK_EDITABLE_WAVE_BUFFER_CLASS (G_OBJECT_GET_CLASS (editable))->delete (editable, start, length);
 
154
}