-
Notifications
You must be signed in to change notification settings - Fork 2
/
volume.c
144 lines (126 loc) · 3.69 KB
/
volume.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/**
* @file volume.c
* @brief Mode functions
* @author John Melton, G0ORX/N6LYT, Doxygen Comments Dave Larsen, KV0S
* @version 0.1
* @date 2009-04-12
*/
// volume.c
/* Copyright (C)
* 2009 - John Melton, G0ORX/N6LYT, Doxygen Comments Dave Larsen, KV0S
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <getopt.h>
#include "property.h"
#include "screensize.h"
#include "command.h"
#include "main.h"
GtkWidget* volumeFrame;
double volume;
GtkWidget* volumeScale;
int setAFGain(void * data) {
int gain=*(int*)data;
volume=(double)gain;
fprintf(stderr,"setAFGain: %f\n", volume);
#ifdef DTTSP
SetRXOutputGain(0,0,volume/100.0);
#endif
gtk_range_set_value((GtkRange*)volumeScale,volume);
free(data);
return 0;
}
/* --------------------------------------------------------------------------*/
/**
* @brief Select the volume
*
* @param widget
*/
void selectVolume(GtkWidget* widget) {
GtkWidget* label;
char temp[80];
}
/* --------------------------------------------------------------------------*/
/**
* @brief Callback when volume values changes
*
* @param widget
* @param data
*/
void volumeChanged(GtkWidget* widget,gpointer data) {
volume=gtk_range_get_value((GtkRange*)volumeScale);
fprintf(stderr,"volumeChanged: %f\n", volume);
#ifdef DTTSP
SetRXOutputGain(0,0,volume/100.0);
#endif
}
/* --------------------------------------------------------------------------*/
/**
* @brief Build the GUI
*
* @return
*/
GtkWidget* buildVolumeUI() {
GtkWidget* label;
volumeFrame=gtk_frame_new("AF Gain");
gtk_widget_modify_bg(volumeFrame,GTK_STATE_NORMAL,&background);
gtk_widget_modify_fg(gtk_frame_get_label_widget(GTK_FRAME(volumeFrame)),GTK_STATE_NORMAL,&white);
volumeScale=gtk_hscale_new_with_range(0.0,100.0,10.0);
g_signal_connect(G_OBJECT(volumeScale),"value-changed",G_CALLBACK(volumeChanged),NULL);
gtk_range_set_value((GtkRange*)volumeScale,volume);
#ifdef NETBOOK
gtk_widget_set_size_request(GTK_WIDGET(volumeScale),75,25);
#else
gtk_widget_set_size_request(GTK_WIDGET(volumeScale),150,25);
#endif
gtk_widget_show(volumeScale);
gtk_container_add(GTK_CONTAINER(volumeFrame),volumeScale);
#ifdef NETBOOK
gtk_widget_set_size_request(volumeFrame,89,70);
#else
gtk_widget_set_size_request(volumeFrame,200,55);
#endif
gtk_widget_show(volumeFrame);
#ifdef DTTSP
SetRXOutputGain(0,0,volume/100.0);
#endif
return volumeFrame;
}
/* --------------------------------------------------------------------------*/
/**
* @brief Save the volume state
*/
void volumeSaveState() {
char string[128];
sprintf(string,"%f",volume);
setProperty("volume",string);
}
/* --------------------------------------------------------------------------*/
/**
* @brief Restore the volume state
*/
void volumeRestoreState() {
char* value;
value=getProperty("volume");
if(value) volume=atof(value); else volume=3.0f;
}