Skip to content

Commit 1b16db7

Browse files
committed
fixed slider
1 parent 57ad27c commit 1b16db7

File tree

4 files changed

+40
-18
lines changed

4 files changed

+40
-18
lines changed

LFSDock/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.2.1
2+
Fixed slider.
23
Fixed dock spuriously reappearing after iconizing.
34
Adjusted dock window context menu position.
45
Added context menu to main dock window.

LFSDock/LFSDock/src/slider.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,23 @@ int iconSize=48;
3737

3838
void setLabel(void)
3939
{
40-
int value=(int)(((double)vsb->LFSTK_getValue()/64.0)*100.0);
40+
double maxvolume=double(atoi(dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|grep \"Limits\"|awk '{print $NF}'").c_str()));
41+
int value=(int)(((double)vsb->LFSTK_getValue()/(double)maxvolume)*100.0);
42+
43+
//int value=(int)(((double)vsb->LFSTK_getValue()/64.0)*100.0);
4144
sprintf(label,"Vol %i%%",value);
4245
volumeButton->LFSTK_setLabel((const char*)label);
4346
setIcon();
4447
}
48+
/*
49+
double maxvolume=double(atoi(mainwind->globalLib->LFSTK_oneLiner("amixer get Master|grep \"Limits\"|awk '{print $NF}'").c_str()));
50+
int value=(int)(((double)vsb->LFSTK_getValue()/(double)maxvolume)*100.0);
51+
sprintf(label,"Vol %i%%",value);
52+
volumeButton->LFSTK_setLabel(label);
53+
setIcon();
54+
volumeButton->LFSTK_clearWindow();
4555
56+
*/
4657
int getAlsaVolume(bool setvol,int volume)
4758
{
4859
long value=-1;
@@ -132,7 +143,7 @@ bool valChanged(void *p,void* ud)
132143
sb=static_cast<LFSTK_scrollBarClass*>(p);
133144
if(sb!=NULL)
134145
{
135-
getAlsaVolume(true,sb->LFSTK_getValue());
146+
getAlsaVolume(true,sb->LFSTK_getValue()+1);
136147
setLabel();
137148
}
138149
}
@@ -153,7 +164,21 @@ void updateSlider(void)
153164
XFlush(apc->display);
154165
}
155166
}
167+
/*
168+
void updateSlider(void)
169+
{
170+
int volume;
156171
172+
volume=getAlsaVolume(false,-1);
173+
if(oldVolVal!=volume)
174+
{
175+
vsb->LFSTK_setValue(volume);
176+
oldVolVal=vsb->LFSTK_getValue();
177+
setLabel();
178+
}
179+
}
180+
181+
*/
157182
bool volExitCB(LFSTK_gadgetClass*p,void* ud)
158183
{
159184
geometryStruct geom2;
@@ -183,6 +208,8 @@ int addSlider(int x,int y,int grav)
183208
{
184209
char *vol=strdup(dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print $3}'").c_str());//TODO//
185210
char *label=strdup(dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL).c_str());//TODO//
211+
int maxvolume=atoi(dockWindow->globalLib->LFSTK_oneLiner("amixer get Master|grep \"Limits\"|awk '{print $NF}'").c_str());
212+
186213
windowInitStruct *win=new windowInitStruct;
187214
int w,h;
188215
bool direction=false;
@@ -217,7 +244,7 @@ int addSlider(int x,int y,int grav)
217244
vsb=new LFSTK_scrollBarClass(scwindow,direction,0,0,w,h,BUTTONGRAV);
218245

219246
vsb->LFSTK_setMouseCallBack(NULL,valChanged,NULL);
220-
vsb->LFSTK_setScale(0,64);
247+
vsb->LFSTK_setScale(0,maxvolume);
221248
vsb->LFSTK_setValue(atoi(vol));
222249
vsb->reverse=direction;
223250
volumeButton->LFSTK_setImageFromPath(iconL,TOOLBAR,true);

LFSPanel/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
0.2.0
2+
Fixed slider.
23
Removed "%u/%U/%f/%F" from command when launching from app menu.
34
Fixed sending empty "%u" to launchers.
45
Fixed dropping text on launchers.

LFSPanel/LFSPanel/src/slider.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ char label[32];
3838

3939
void setLabel(void)
4040
{
41-
int value=(int)(((double)vsb->LFSTK_getValue()/64.0)*100.0);
41+
double maxvolume=double(atoi(mainwind->globalLib->LFSTK_oneLiner("amixer get Master|grep \"Limits\"|awk '{print $NF}'").c_str()));
42+
int value=(int)(((double)vsb->LFSTK_getValue()/(double)maxvolume)*100.0);
4243
sprintf(label,"Vol %i%%",value);
4344
volumeButton->LFSTK_setLabel(label);
4445
setIcon();
@@ -48,11 +49,11 @@ void setLabel(void)
4849
int getAlsaVolume(bool setvol,int volume)
4950
{
5051
long value=-1;
51-
snd_mixer_t *handle;
52+
snd_mixer_t *handle;
5253
snd_mixer_selem_id_t *sid;
5354
snd_mixer_elem_t *elem;
54-
const char *card="default";
55-
const char *selem_name="Master";
55+
const char *card="default";
56+
const char *selem_name="Master";
5657

5758
snd_mixer_open(&handle,0);
5859
snd_mixer_attach(handle,card);
@@ -140,7 +141,7 @@ bool valChanged(void *p,void* ud)
140141
LFSTK_scrollBarClass *sb=NULL;
141142
char *command;
142143
char *vol;
143-
int volume=-1;
144+
int volume=-1;
144145

145146
if(p!=NULL)
146147
{
@@ -180,6 +181,7 @@ int addSlider(int x,int y,int grav,bool fromleft)
180181
char *vol;
181182
bool direction=false;
182183
char *label=strdup(mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL).c_str());//TODO//
184+
int maxvolume=atoi(mainwind->globalLib->LFSTK_oneLiner("amixer get Master|grep \"Limits\"|awk '{print $NF}'").c_str());
183185
getAlsaVolume(false,-1);
184186
setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);
185187

@@ -215,25 +217,16 @@ int addSlider(int x,int y,int grav,bool fromleft)
215217
direction=false;
216218
}
217219

218-
//win->x=100;
219-
//win->y=100;
220-
//w=w;
221-
//h=h;
222220
win->w=w;
223221
win->h=h;
224222
win->app=apc;
225223
apc->LFSTK_addToolWindow(win);
226224
scwindow=apc->windows->back().window;
227225

228-
// win->w=w;
229-
// win->h=h;
230-
// apc->LFSTK_addToolWindow(win);
231-
// scwindow=apc->windows->back().window;
232-
233226
vsb=new LFSTK_scrollBarClass(scwindow,direction,0,0,w,h,BUTTONGRAV);
234227

235228
vsb->LFSTK_setMouseCallBack(NULL,valChanged,NULL);
236-
vsb->LFSTK_setScale(0,64);
229+
vsb->LFSTK_setScale(0,maxvolume);
237230

238231
vsb->LFSTK_setValue(atoi(vol));
239232
vsb->reverse=direction;

0 commit comments

Comments
 (0)