~torios-dev/+junk/fltk-volume

« back to all changes in this revision

Viewing changes to src/fltk-indicator.fld

  • Committer: Israel Dahl
  • Date: 2020-04-10 11:59:21 UTC
  • Revision ID: israeldahl@gmail.com-20200410115921-qep0lv3ofmdbs6f4
Hide volume slider when clicked

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
decl {\#include <pthread.h>} {public global
89
89
}
90
90
 
91
 
class FltkVolume {open
92
 
} {
 
91
class FltkVolume {} {
93
92
  decl {\#ifdef USE_PULSE
94
93
pa_simple *simple;
95
94
pa_sample_spec simple_spec;
136
135
  }
137
136
  Function {isMuted()} {return_type bool
138
137
  } {
139
 
    code {bool mute=false;
140
 
int val = AlsaMute(AUDIO_VOLUME_GET,mute);
 
138
    code {bool mute = false;
 
139
int val = AlsaMute(AUDIO_VOLUME_GET);
141
140
if(val == 0)
142
141
  mute=true;
 
142
else
 
143
  std::cout<<"Mute value = "<<val<<std::endl;
143
144
return mute;} {}
144
145
  }
145
146
  Function {AlsaMute(FltkVolume::audio_volume_action action, bool mute=false)} {return_type int
189
190
 
190
191
if( action == AUDIO_VOLUME_GET)
191
192
{
192
 
  int ismuted = 0;
193
 
  if( (snd_mixer_selem_get_playback_switch(elem,SND_MIXER_SCHN_MONO,&ismuted)) <0)
 
193
  int ismuted = 7;
 
194
  if( (snd_mixer_selem_get_playback_switch(elem, SND_MIXER_SCHN_MONO, &ismuted)) < 0)
194
195
  {
195
196
    snd_mixer_close(handle);
196
197
    return -7;
197
198
  }
 
199
  //std::cout<<"MUTED="<<ismuted<<std::endl;
198
200
  snd_mixer_close(handle);
199
201
  return ismuted;
200
202
}
201
203
else if ( action == AUDIO_VOLUME_SET )
202
204
{
203
 
  int value = 1;
204
 
  if(mute)
205
 
    value = 0;
 
205
  int value;
 
206
  value = mute ? 0 : 1;
206
207
  int ret=snd_mixer_selem_set_playback_switch_all(elem,value);
207
208
  snd_mixer_close(handle);
208
209
  return ret;
375
376
      }
376
377
    }
377
378
  }
378
 
  Function {batt_info()} {open return_type void
 
379
  Function {batt_info()} {return_type void
379
380
  } {
380
381
    code {batt_info_window()->show();
381
382
std::string PATH="/sys/class/power_supply/";
463
464
      }
464
465
    }
465
466
  }
466
 
  Function {batt_string(std::string path, std::string file)} {open return_type {std::string}
 
467
  Function {batt_string(std::string path, std::string file)} {return_type {std::string}
467
468
  } {
468
469
    code {std::string tmp = file_to_string(path+file);
469
470
return (file+"= "+tmp+"\\n");} {}
1075
1076
if((end) == 0){return "";}
1076
1077
return result.erase(end-1,1);} {}
1077
1078
  }
1078
 
  Function {toggle_volume()} {} {
 
1079
  Function {toggle_volume()} {open
 
1080
  } {
1079
1081
    code {if(volume_slider->visible())
1080
1082
  volume_slider->hide();
1081
1083
else
1087
1089
//todo bottom panel....
1088
1090
volume_slider->position(x(),y()+h());} {}
1089
1091
  }
1090
 
  Function {update_colors(unsigned int BG)} {open
1091
 
  } {
 
1092
  Function {update_colors(unsigned int BG)} {} {
1092
1093
    code {unsigned int Color = color();
1093
1094
unsigned int Text = 0;
1094
1095
 
1118
1119
  LIGHT=true;
1119
1120
 
1120
1121
menu->color(Color);
1121
 
menu->textcolor(Text);} {selected
1122
 
    }
 
1122
menu->textcolor(Text);} {}
1123
1123
  }
1124
1124
  Function {update_volume()} {} {
1125
1125
    code {//is it muted?
1164
1164
    code {int val = m_volumecontrol.GetVolume();
1165
1165
return convert_num_to_string(val);} {}
1166
1166
  }
1167
 
  Function {volume_window()} {} {
 
1167
  Function {volume_window()} {open
 
1168
  } {
1168
1169
    Fl_Window volume_slider {open
1169
 
      xywh {531 220 91 210} type Double color 0 hide noborder
 
1170
      xywh {531 220 91 210} type Double color 0 noborder visible
1170
1171
    } {
1171
1172
      Fl_Slider slide {
1172
1173
        label Volume
1173
1174
        callback {change_volume(o->value());
1174
1175
std::string vol=volumeText()+ " %";
1175
1176
o->copy_tooltip(vol.c_str());
1176
 
update_volume();}
 
1177
update_volume();
 
1178
volume_slider->hide();} selected
1177
1179
        tooltip Volume xywh {20 5 25 180} box FLAT_BOX color 39 labelcolor 7 maximum 100 step 1
1178
1180
        code0 {std::string vol=volumeText()+ " %";}
1179
1181
        code1 {o->copy_tooltip(vol.c_str());}
1362
1364
if(big)
1363
1365
  check++;
1364
1366
 
1365
 
//std::cout<<"Checking:"<<check<<"::"<<percent_int<<std::endl;
 
1367
std::cout<<"Checking:"<<check<<"::"<<percent_int<<std::endl;
1366
1368
 
1367
1369
//get and set the actual icon now unless it hasn't changed, of course
1368
1370
INDICATOR->checkIcon(check);