1 /*
2 * Copyright (C) 2002 2003 2004, Magnus Hjorth
3 *
4 * This file is part of mhWaveEdit.
5 *
6 * mhWaveEdit 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 * mhWaveEdit 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 mhWaveEdit; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21
22 #include <config.h>
23
24 #include <math.h>
25 #include <gtk/gtk.h>
26 #include "mainwindow.h"
27 #include "effectdialog.h"
28 #include "effectbrowser.h"
29 #include "speeddialog.h"
30 #include "float_box.h"
31 #include "gettext.h"
32
apply_proc(Chunk * chunk,StatusBar * bar,gpointer user_data)33 static Chunk *apply_proc(Chunk *chunk, StatusBar *bar, gpointer user_data)
34 {
35 SpeedDialog *s = SPEED_DIALOG(user_data);
36 return chunk_convert_speed(chunk, s->speed->val / 100.0, dither_editing,
37 bar);
38 }
39
apply(EffectDialog * ed)40 static gboolean apply(EffectDialog *ed)
41 {
42 SpeedDialog *s = SPEED_DIALOG(ed);
43 if (floatbox_check(s->speed) || s->speed->val<=0.0) return TRUE;
44 if (s->speed->val==100.0) return FALSE;
45 return document_apply_cb(EFFECT_BROWSER(EFFECT_DIALOG(s)->eb)->
46 dl->selected, apply_proc,TRUE,s);
47 }
48
speed_dialog_class_init(EffectDialogClass * klass)49 static void speed_dialog_class_init(EffectDialogClass *klass)
50 {
51 klass->apply = apply;
52 }
53
speed_dialog_init(SpeedDialog * v)54 static void speed_dialog_init(SpeedDialog *v)
55 {
56 EffectDialog *ed = EFFECT_DIALOG(v);
57 GtkWidget *c;
58 c = gtk_label_new (_("Speed:"));
59 gtk_box_pack_start( GTK_BOX(ed->input_area), c, FALSE, FALSE, 0 );
60 gtk_widget_show(c);
61 c = floatbox_new(100.0);
62 v->speed = FLOATBOX(c);
63 gtk_box_pack_start( GTK_BOX(ed->input_area), c, FALSE, FALSE, 0 );
64 gtk_widget_show(c);
65 c = gtk_label_new("%");
66 gtk_box_pack_start( GTK_BOX(ed->input_area), c, FALSE, FALSE, 0 );
67 gtk_widget_show(c);
68 }
69
speed_dialog_get_type(void)70 GtkType speed_dialog_get_type(void)
71 {
72 static GtkType id = 0;
73 if (!id) {
74 GtkTypeInfo info = {
75 "SpeedDialog",
76 sizeof(SpeedDialog),
77 sizeof(SpeedDialogClass),
78 (GtkClassInitFunc) speed_dialog_class_init,
79 (GtkObjectInitFunc) speed_dialog_init
80 };
81 id = gtk_type_unique(effect_dialog_get_type(),&info);
82 }
83 return id;
84 }
85