195
int Volume_Slider::handle(int event) {
196
Indicator* Indy = (Indicator*)(parent()->user_data());
197
int ret = Fl_Slider::handle(event);
198
std::string volume_text;
199
int prcnt_int = Indy->get_volume();
204
Indy->change_volume(this->value());
205
volume_text = Indy->volumeText() + " %";
206
copy_tooltip(volume_text.c_str());
207
Indy->update_volume();
211
Indy->change_volume(this->value());
212
Indy->update_volume();// sleep(0.7);
217
Indy->change_volume(this->value());
218
Indy->update_volume();
226
Volume_Slider::Volume_Slider(int X, int Y, int W, int H, const char *L):Fl_Slider(X, Y, W, H, L) {
228
tooltip(gettext("Volume"));
229
Fl_Slider::box(FL_FLAT_BOX);
231
labelcolor(FL_BACKGROUND2_COLOR);
195
236
void Indicator::cb_Close_i(Fl_Button*, void*) {
196
237
about_win->hide();
269
310
((Indicator*)(o->parent()->user_data()))->cb_Cancel1_i(o,v);
272
void Indicator::cb_slide_i(Fl_Slider* o, void*) {
273
change_volume(o->value());
274
std::string vol=volumeText()+ " %";
275
o->copy_tooltip(vol.c_str());
277
volume_slider->hide();
279
void Indicator::cb_slide(Fl_Slider* o, void* v) {
280
((Indicator*)(o->parent()->user_data()))->cb_slide_i(o,v);
283
313
Indicator::Indicator(void *Class, bool isBattery, int X , int Y , int W , int H ,const char*l ):Fl_Window(X,Y,W,H,l) {
284
314
menu = new Fl_Menu_Bar(0, 0, 520, 25);
293
323
About = gettext("About");
294
324
Quit = gettext("Quit");
304
334
Icon = new Fl_Box(0,0,w(),h());
305
335
Icon->box(FL_NO_BOX);
309
trace("setup for battery");
313
trace("Setup for volume");
314
MIXER_PROGRAM=get_mixer();
340
MIXER_PROGRAM = get_mixer();
315
341
volume_window()->show();
318
345
get_preferences();
461
488
void Indicator::checkIcon(unsigned int check) {
463
490
Icon->position(0,0);
464
if((check!=ICON)&&(check > 0))
494
check = get_mute_icon(LIGHT);
496
if((check != ICON) && (check > 0))
465
497
changeIcon(check,Icon);
470
503
std::string Indicator::convert_num_to_string(int num) {
583
617
std::string Indicator::get_mixer() {
584
618
if((!test_exec(MIXER_PROGRAM))||(MIXER_PROGRAM.compare("")==0))
585
619
MIXER_PROGRAM=get_default_mixer();
586
trace("get_mixer::Mixer="+MIXER_PROGRAM);
620
//trace("get_mixer::Mixer="+MIXER_PROGRAM);
587
621
return MIXER_PROGRAM;
850
880
void Indicator::mixer() {
851
trace("mixer::testing="+MIXER_PROGRAM);
881
//trace("mixer::testing="+MIXER_PROGRAM);
852
883
if(!test_exec(MIXER_PROGRAM))
853
MIXER_PROGRAM=get_default_mixer();
884
MIXER_PROGRAM = get_default_mixer();
854
886
if(!program_is_running(MIXER_PROGRAM))
856
888
run_a_program_in_background(MIXER_PROGRAM);
1067
1099
void Indicator::toggle_volume() {
1100
//TODO bottom panel support, side panel support
1101
volume_slider->position(x(),y()+h());
1068
1103
if(volume_slider->visible())
1069
1104
volume_slider->hide();
1072
int percent_int=get_volume();
1073
slide->value(percent_int);
1074
1107
volume_slider->show();
1108
volume_slider->wait_for_expose();
1076
//todo bottom panel....
1077
volume_slider->position(x(),y()+h());
1080
1113
void Indicator::update_colors(unsigned int BG) {
1130
1163
slide->value(percent_int);
1132
1165
//get the numerical value for the icon switch/case in checkIcon()
1133
check=get_icon(percent_int,LIGHT,true,muted);
1166
check = get_icon(percent_int,LIGHT,true,muted);
1135
1168
//oh yeah is it big?
1141
1174
checkIcon(check);
1142
1175
//changeIcon(check,Icon);
1143
1176
//get the text for the tooltip
1144
std::string vol=volumeText();
1177
std::string vol = volumeText();
1146
1179
//set the tooltip!
1147
1180
setTooltip(vol.c_str());
1148
1181
slide->redraw();
1152
1184
std::string Indicator::volumeText() {
1158
1190
{ volume_slider = new Fl_Double_Window(91, 210);
1159
1191
volume_slider->color(FL_FOREGROUND_COLOR);
1160
1192
volume_slider->user_data((void*)(this));
1161
{ Fl_Slider* o = slide = new Fl_Slider(20, 5, 25, 180, gettext("Volume"));
1162
slide->tooltip(gettext("Volume"));
1163
slide->box(FL_FLAT_BOX);
1164
slide->color(FL_DARK3);
1165
slide->labelcolor(FL_BACKGROUND2_COLOR);
1166
slide->maximum(100);
1168
slide->callback((Fl_Callback*)cb_slide);
1169
slide->when(FL_WHEN_RELEASE);
1170
std::string vol=volumeText()+ " %";
1171
o->copy_tooltip(vol.c_str());
1172
o->value(m_volumecontrol.GetVolume());
1173
} // Fl_Slider* slide
1174
1193
{ zero = new Fl_Box(45, 0, 30, 25, gettext("0"));
1175
1194
zero->labelcolor(FL_BACKGROUND2_COLOR);
1176
1195
} // Fl_Box* zero
1177
1196
{ hundred = new Fl_Box(50, 160, 30, 25, gettext("100"));
1178
1197
hundred->labelcolor(FL_BACKGROUND2_COLOR);
1198
volume_initializer();
1179
1199
} // Fl_Box* hundred
1180
1200
volume_slider->clear_border();
1201
volume_slider->xclass("popup");
1181
1202
volume_slider->end();
1182
1203
} // Fl_Double_Window* volume_slider
1183
1204
return volume_slider;
1207
void Indicator::volume_initializer() {
1208
slide = new Volume_Slider(volume_slider->x() + 20,
1209
volume_slider->y() + 5,
1214
std::string vol = volumeText() + " %";
1216
slide->copy_tooltip(vol.c_str());
1217
slide->value(m_volumecontrol.GetVolume());
1218
volume_slider->add(slide);
1186
1222
void UserInterface::battery_CB(void* myclass) {
1187
1223
UserInterface *o = (UserInterface*)myclass;
1382
1416
if(INDICATOR->w()>16)
1384
1418
//get our volume to help get an icon
1385
int percent_int=INDICATOR->get_volume();
1419
int percent_int = INDICATOR->get_volume();
1386
1420
//set the volume on the slider to match the actual volume
1387
1421
INDICATOR->slide->value(percent_int);
1389
1423
//get the numerical value for the icon switch/case in checkIcon()
1390
check=get_icon(percent_int,INDICATOR->LIGHT,true,muted);
1424
check = get_icon(percent_int,INDICATOR->LIGHT,true,muted);
1392
1426
//oh yeah is it big?
1397
1431
//get the actual icon and set it!
1398
1432
INDICATOR->checkIcon(check);
1399
1433
//get the text for the tooltip
1400
std::string vol=INDICATOR->volumeText();
1434
std::string vol = INDICATOR->volumeText();
1402
1436
//set the tooltip!
1403
1437
INDICATOR->setTooltip(vol.c_str());