WOWthunor wrote:Added hscale and vscale widgets
Gtkdialog Development
vscale
Dear Thunor,
Here is a screen shot. The last hslider (4) and vslider (4) show this behaviour. Is that intended?
With kind regards,
vovchik
Here is a screen shot. The last hslider (4) and vslider (4) show this behaviour. Is that intended?
With kind regards,
vovchik
- Attachments
-
- v-h-scales.jpg
- (35.15 KiB) Downloaded 1396 times
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Hi guys
I'm guessing it's a theme issue.
See "fill-level", "restrict-to-fill-level" and "show-fill-level" if you want to know more about it.
Nice (or actually not nice) to see that your vertical markup is all over the place, similar to mine You also seem to have missing marks.
[EDIT] I've just noticed that my Polished-Blue screenshot has missing marks too, so I'm guessing that that's a theme issue also (there should be three marks on the 2nd and 3rd scales only, the 3rd scale being staggered top/bottom, left/right).
I think it's possible that currently the markup isn't very stable which would explain why I haven't yet found an application that's using it.
Regards,
Thunor
I'm guessing it's a theme issue.
See "fill-level", "restrict-to-fill-level" and "show-fill-level" if you want to know more about it.
Nice (or actually not nice) to see that your vertical markup is all over the place, similar to mine You also seem to have missing marks.
[EDIT] I've just noticed that my Polished-Blue screenshot has missing marks too, so I'm guessing that that's a theme issue also (there should be three marks on the 2nd and 3rd scales only, the 3rd scale being staggered top/bottom, left/right).
I think it's possible that currently the markup isn't very stable which would explain why I haven't yet found an application that's using it.
Regards,
Thunor
- Attachments
-
- sscrux.jpg
- lupu-520, GTK+ 2.20.0, Crux theme
- (32.89 KiB) Downloaded 1364 times
-
- sspolished-blue.jpg
- lupu-520, GTK+ 2.20.0, Polished-Blue theme
- (31.72 KiB) Downloaded 1223 times
My window looks like this and the marks are there on the sliders.
But I think the question was to why the function Type3Create does not let the slider pointer go from top to bottom of the slide.
But I think the question was to why the function Type3Create does not let the slider pointer go from top to bottom of the slide.
- Attachments
-
- image-1.png
- (42.83 KiB) Downloaded 717 times
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
I posted a link to explain it: See "fill-level", "restrict-to-fill-level" and "show-fill-level" if you want to know more about it.8-bit wrote:But I think the question was to why the function Type3Create does not let the slider pointer go from top to bottom of the slide.
It's a "fill-level (e.g. prebuffering of a network stream)". It stops somewhere near the middle because that's where the fill-level is If you set restrict-to-fill-level="false" it won't stop at the fill-level. Admittedly possibly of limited use as we can't adjust the fill-level, but I didn't make this stuff up, they're GTK+ properties and I'm just illustrating what you can do.
Anyway 8-bit, thanks for the screenshot as I can see we're all having the same vertical scale markup problems. Normally I have two distros installed but at the moment I've only got Puppy, so it would be nice to see what it looks like on a non-Puppy distro.
BTW for anyone who's interested in what I'm going to tackle next, I've been reviewing the menu system but it's not designed to cope with submenus -- comparable to the differences between listing a folder and listing a folder recursively -- so I'm going to have a think about it and at the same time hack away at some easier things.
Regards,
Thunor
thunor,
thank you for the explanation.
As a test, I changed restrict-to-fill-level in the type3create function from true to false and was able to achieve a full range slider that still remembered it's original position when the refresh button was clicked.
So thank you again.
Understanding helps greatly in writing scripts that utilize these new features you are working on.
thank you for the explanation.
As a test, I changed restrict-to-fill-level in the type3create function from true to false and was able to achieve a full range slider that still remembered it's original position when the refresh button was clicked.
So thank you again.
Understanding helps greatly in writing scripts that utilize these new features you are working on.
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Somebody asked me how to use the new features whilst still maintaining compatibility with older versions of Gtkdialog. I guess the way to do it is to check the version of the binary, but it's complicated by the fact that it went from 0.59.8 to 0.6.0, so I came up with this:
If you have something more efficient then please share
[EDIT] This is much better using arrays:
[EDIT2] I think that this is as good as it gets. ${GTKDV[1]}${GTKDV[2]} will equal "5908" for gtkdialog2, "7020" for gtkdialog3 and "7021" and up for gtkdialog. You can easily construct your XML for different gtkdialog versions by testing against ${GTKDV[1]}${GTKDV[2]}.
Regards,
Thunor
Code: Select all
#Change this to gtkdialog2 and gtkdialog3 to test.
GTKDIALOG=gtkdialog
GTKDIALOG_VERSION=$($GTKDIALOG -v | cut -d " " -f 3)
GTKDIALOG_MAJOR=$(echo $GTKDIALOG_VERSION | cut -d "." -f 1)
GTKDIALOG_MINOR=$(echo $GTKDIALOG_VERSION | cut -d "." -f 2)
GTKDIALOG_MICRO=$(echo $GTKDIALOG_VERSION | cut -d "." -f 3)
if [ $GTKDIALOG_MINOR -lt 10 ]; then
GTKDIALOG_MINOR=$(($GTKDIALOG_MINOR * 10))
fi
echo "$GTKDIALOG_MAJOR $GTKDIALOG_MINOR $GTKDIALOG_MICRO"
[EDIT] This is much better using arrays:
Code: Select all
#Change this to gtkdialog2 and gtkdialog3 to test.
GTKDIALOG=gtkdialog
GTKDIALOG_VERSION=( $($GTKDIALOG -v) )
GTKDIALOG_VERSION=${GTKDIALOG_VERSION[2]}
GTKDIALOG_VERSION=( ${GTKDIALOG_VERSION//./ } )
if [ ${GTKDIALOG_VERSION[1]} -lt 10 ]; then
GTKDIALOG_VERSION[1]=${GTKDIALOG_VERSION[1]}0
fi
echo ${GTKDIALOG_VERSION[*]}
Code: Select all
#Change this to gtkdialog2 and gtkdialog3 to test.
GTKDIALOG=gtkdialog
GTKDV=( $($GTKDIALOG -v) )
GTKDV=${GTKDV[2]}
echo Found gtkdialog-$GTKDV
GTKDV=( ${GTKDV//./ } )
if [ ${GTKDV[1]} -lt 10 ]; then GTKDV[1]=${GTKDV[1]}0; fi
if [ ${GTKDV[2]} -lt 10 ]; then GTKDV[2]=0${GTKDV[2]}; fi
if [ ${GTKDV[1]}${GTKDV[2]} -lt "7021" ]; then
echo "This example requires at least gtkdialog-0.7.21"
exit
fi
Thunor
Last edited by thunor on Sun 17 Jul 2011, 13:10, edited 4 times in total.
The hscale and vscale widget example has been driving my crazy getting it to display right.
So in my usual bunbling way, I added an item to the type2 function.
My result although not correct, does display correctly. Why does it work? Evidently the last item in the type2 function gets placed incorrectly.
So in my usual bunbling way, I added an item to the type2 function.
My result although not correct, does display correctly. Why does it work? Evidently the last item in the type2 function gets placed incorrectly.
Code: Select all
#!/bin/sh
# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). Additionally if you are using
# Puppy Linux then you may find that an historical version of gtkdialog
# already exists in /usr/sbin, and if that is the case then you should
# modify the shell variable below to point to the new gtkdialog binary.
GTKDIALOG=gtkdialog
function funcbtnCreate() {
echo '<button image-position="'$3'">
<label>"'"$2"'"</label>
<input file stock="'$4'"></input>
<action>echo "'"$5"' '$1'"</action>
<action type="'"$6"'">'$1'</action>
</button>'
}
function funcscaType0Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'" scale-value="4">
<variable>'$1'</variable>
<action>echo "'$1' changed to $'$1'"</action>
</'$2'scale>
<'$2'separator></'$2'separator>'
}
function funcscaType1Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
scale-min="0" scale-max="1" scale-step="0.1"
value-pos="3" digits="2" inverted="true">
<default>0.20</default>
<variable>'$1'</variable>
<action>echo "'$1' changed to $'$1'"</action>
<item>"0.25 | '$5'"</item>
<item>"0.5 | '$6'"</item>
<item>"0.75 | '$7'"</item>
</'$2'scale>
<'$2'separator></'$2'separator>'
}
function funcscaType2Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
scale-min="0" scale-max="255" scale-step="8" value-pos="1">
<variable>'$1'</variable>
<input>echo 18</input>
<action>echo "'$1' changed to $'$1'"</action>
<item>"64 |'$5'|<span fgcolor='"'white'"' bgcolor='"'darkred'"'> 64 </span>"</item>
<item>"128|'$6'|<span fgcolor='"'white'"' bgcolor='"'darkgreen'"'> 128 </span>"</item>
<item>"192|'$7'|<span fgcolor='"'white'"' bgcolor='"'darkblue'"'> 192 </span>"</item>
<item>"255|'$8'|"</item>
<output file>outputfile</output>
</'$2'scale>
<'$2'box homogeneous="true">
'"$(funcbtnCreate $1 Disable $8 gtk-no Disabling disable)"'
'"$(funcbtnCreate $1 Enable $8 gtk-yes Enabling enable)"'
'"$(funcbtnCreate $1 Refresh $8 gtk-refresh Reloading refresh)"'
'"$(funcbtnCreate $1 Save $8 gtk-save Saving save)"'
</'$2'box>
<'$2'separator></'$2'separator>'
}
function funcscaType3Create() {
echo '<'$2'scale width-request="'$3'" height-request="'$4'"
scale-min="0" scale-max="123" scale-step="1"
draw-value="false" show-fill-level="true" fill-level="56"
restrict-to-fill-level="false" update-policy="0">
<variable>'$1'</variable>
<input file>inputfile</input>
<action signal="value_changed">echo "'$1' changed to $'$1'"</action>
<output file>outputfile</output>
</'$2'scale>
<'$2'box homogeneous="true">
'"$(funcbtnCreate $1 Disable $5 gtk-no Disabling disable)"'
'"$(funcbtnCreate $1 Enable $5 gtk-yes Enabling enable)"'
'"$(funcbtnCreate $1 Refresh $5 gtk-refresh Reloading refresh)"'
'"$(funcbtnCreate $1 Save $5 gtk-save Saving save)"'
</'$2'box>'
}
if [ ! -f inputfile ]; then
echo "44" > inputfile
fi
export MAIN_DIALOG='
<window title="scaScales" resizable="false">
<vbox>
<hbox>
<frame hscale widget>
<vbox>
'"$(funcscaType0Create hscHScale0 h 360 80)"'
'"$(funcscaType1Create hscHScale1 h 360 80 2 2 2)"'
'"$(funcscaType2Create hscHScale2 h 360 -1 3 2 3 0)"'
'"$(funcscaType3Create hscHScale3 h 360 80 0)"'
</vbox>
</frame>
<frame vscale widget>
<hbox>
'"$(funcscaType0Create vscVScale0 v 50 400)"'
'"$(funcscaType1Create vscVScale1 v 50 400 1 1 1)"'
'"$(funcscaType2Create vscVScale2 v -1 400 3 1 3 2 3)"'
'"$(funcscaType3Create vscVScale3 v 50 400 2)"'
</hbox>
</frame>
</hbox>
<hbox homogeneous="true">
<button ok></button>
</hbox>
</vbox>
<action signal="hide">exit:Exit</action>
</window>
'
$GTKDIALOG --center --program=MAIN_DIALOG
I am testing the <hscale> widget in Pmusic 2, and I am having some trouble.
The default signal is "value_changed" which activates itself when slider is moving. My problem is that it does run <action> both when it is refreshed (<action>refresh:HSCALE</action>) from another widget, and when user moves it. My hope is to show progress when refreshing, and jump-in-track-time if user moves the slider. Is this possible? I checked the gtk-scales signals, but couldn't find any answer.
Thank you
Sigmund
The default signal is "value_changed" which activates itself when slider is moving. My problem is that it does run <action> both when it is refreshed (<action>refresh:HSCALE</action>) from another widget, and when user moves it. My hope is to show progress when refreshing, and jump-in-track-time if user moves the slider. Is this possible? I checked the gtk-scales signals, but couldn't find any answer.
Thank you
Sigmund
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
8-bit: congratulations for finding a usable workaround
The "value_changed" signal is emitted when the "value" changes regardless of how. It's getting late and I need to go to bed now, but how about having a custom tag attribute to block signals on refreshes Sounds sensible. I can do it in the morning.
Regards,
Thunor
Hi Sigmundzigbert wrote:I am testing the <hscale> widget in Pmusic 2, and I am having some trouble.
The default signal is "value_changed" which activates itself when slider is moving. My problem is that it does run <action> both when it is refreshed (<action>refresh:HSCALE</action>) from another widget, and when user moves it. My hope is to show progress when refreshing, and jump-in-track-time if user moves the slider. Is this possible? I checked the gtk-scales signals, but couldn't find any answer.
The "value_changed" signal is emitted when the "value" changes regardless of how. It's getting late and I need to go to bed now, but how about having a custom tag attribute to block signals on refreshes Sounds sensible. I can do it in the morning.
Regards,
Thunor
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Done and committed Use block-function-signals="true".zigbert wrote:Sounds wonderful to me and Pmusic.
You might also be interested in the GTK+ property "update-policy" which enables you to control the update frequency.
I've updated the example too and applied it to the scales with the markup if anybody wants to try it out.
Regards,
Thunor
I want to make sure I understand the parameters passed to the type2 function in the hscales and vscales example.
What I have come up with is
$2 is the scale type being either h for horizontal or v for vertical
$3 is the slider width of the scale
$4 is the height of the scale
$5-$7 are the position of the markup left, right, top, bottom, on the slider
For a vertical slider, markup position parameter values passed to function type2 are
0 being left of slider, 1 being right of slider
And for a horizontal slider, markup position parameter vales passed to function type 2 are
2 being top of slider, and 3 being bottom of slider.
Now if this is right, why are the markup tags on the vertical scale being displayed in the wrong place on the slider?
Could it be that gtk2 or pango are not receiving the parameters in a format they expect?
Also, if one plays with the example I posted that displays right and changes any of the parameters for the vscale, it will not display correctly.
I guess I will have to dig deep to solve it.
What I have come up with is
$2 is the scale type being either h for horizontal or v for vertical
$3 is the slider width of the scale
$4 is the height of the scale
$5-$7 are the position of the markup left, right, top, bottom, on the slider
For a vertical slider, markup position parameter values passed to function type2 are
0 being left of slider, 1 being right of slider
And for a horizontal slider, markup position parameter vales passed to function type 2 are
2 being top of slider, and 3 being bottom of slider.
Now if this is right, why are the markup tags on the vertical scale being displayed in the wrong place on the slider?
Could it be that gtk2 or pango are not receiving the parameters in a format they expect?
Also, if one plays with the example I posted that displays right and changes any of the parameters for the vscale, it will not display correctly.
I guess I will have to dig deep to solve it.
thunor
I am making progress
block-function-signals="true" works great - thank you.
But I still have some issues
I am trying to control the <action> of hscale.
1.)
With the code below I have to click the mouse-middle-button to get the correct value of $PROGRESS. Left click always return 0 or 100.
2.)
The action is executed when mouse is pressed down (not released as I expected). This makes it impossible to drag the slider to a given position and then execute the <action>. I tried to include <action signal="released"> as in the <button> widget, but it failed.
Sigmund
I am making progress
block-function-signals="true" works great - thank you.
But I still have some issues
I am trying to control the <action> of hscale.
1.)
With the code below I have to click the mouse-middle-button to get the correct value of $PROGRESS. Left click always return 0 or 100.
2.)
The action is executed when mouse is pressed down (not released as I expected). This makes it impossible to drag the slider to a given position and then execute the <action>. I tried to include <action signal="released"> as in the <button> widget, but it failed.
Code: Select all
<hscale height-request="15" draw-value="false" block-function-signals="true" update-policy="100">
<variable>PROGRESS</variable>
<input file>'$WORKDIR'/PERCENT_BAR</input>
<action>. '$APPDIR'/func_player -jump_to_percent</action>
</hscale>
Sigmund
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Hi Sigmund
I've just got back from a trip into London and I've had a few pints, so don't expect too much from me
But I can see that "update-policy" (GtkUpdateType) is supposed to be 0, 1 or 2:
0=GTK_UPDATE_CONTINUOUS - Notify updates whenever the value changed.
1=GTK_UPDATE_DISCONTINUOUS - Notify updates when the mouse button has been released.
2=GTK_UPDATE_DELAYED - Space out updates with a small timeout .
Try modifying it and see what happens. Let me know if you have further problems.
Regards,
Thunor
I've just got back from a trip into London and I've had a few pints, so don't expect too much from me
But I can see that "update-policy" (GtkUpdateType) is supposed to be 0, 1 or 2:
0=GTK_UPDATE_CONTINUOUS - Notify updates whenever the value changed.
1=GTK_UPDATE_DISCONTINUOUS - Notify updates when the mouse button has been released.
2=GTK_UPDATE_DELAYED - Space out updates with a small timeout .
Try modifying it and see what happens. Let me know if you have further problems.
Regards,
Thunor
Thunor
Welcome home, a few pints doesn't harm you.
Thank you for explaining the settings for "update-policy". I tried various values, but nothing happened until I raised the value. I then got a delay... but still it only works when clicking middle mouse button.
I could add a delay in the bash code to wait for the value is stable (user has settled on a new value) before executing the rest on the function. This would be a bad substitute since it wouldn't act snappy.
edit:
I must add that I refresh the <hscale> every second by executing <actions> of a <progressbar>. Maybe this conflicts with "update-policy".
........
Ok, I removed the "update-policy" in my code, but nothing changed. Also removed the block-function-signals="true", but no go.
Sigmund
Welcome home, a few pints doesn't harm you.
Thank you for explaining the settings for "update-policy". I tried various values, but nothing happened until I raised the value. I then got a delay... but still it only works when clicking middle mouse button.
I could add a delay in the bash code to wait for the value is stable (user has settled on a new value) before executing the rest on the function. This would be a bad substitute since it wouldn't act snappy.
edit:
I must add that I refresh the <hscale> every second by executing <actions> of a <progressbar>. Maybe this conflicts with "update-policy".
........
Ok, I removed the "update-policy" in my code, but nothing changed. Also removed the block-function-signals="true", but no go.
Sigmund
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Ok, I'm looking at your post again. Let's start with 1zigbert wrote:1.)
With the code below I have to click the mouse-middle-button to get the correct value of $PROGRESS. Left click always return 0 or 100.
I've been playing with my example and middle-clicking the bar and it instantly moves the slider under the mouse. Left clicking the bar is similar to paging up and down and the page size depends on, well I'm not sure really, but scale-step="1" seems to give it some precision. I have also noticed that you are using the default 0 to 100 step 10. Is that OK? You can use scale-min="0" scale-max="240" scale-step="1" or something if you want.
[EDIT] I've been testing my example again and the page size when left-clicking the bar is in units of 10x the step, so if you use the defaults of scale-min=0, scale-max=100 and scale-step=10 then left-clicking the bar will go from 0 to 100 to 0. Is this what you mean?
[EDIT2] OK, I think I know what's going on You are refreshing the value every second, and because you are using 0 to 100 step 10, when you left-click the bar the slider goes right to the ends and returns either 0 or 100, and then refreshing restores its value Right? If that is the case then you need to use scale-step="1" or something. If you are playing music, shouldn't you be setting scale-max to the length of the track in seconds or have you decided to use 100%.
Cheers,
Thunor
Code: Select all
<hscale height-request="12" draw-value="false" block-function-signals="true" update-policy="1" scale-step="1" scale-min="0" scale-max="100">
Thanks a lot. I am feeling like an idiot
Pmusic 2 is joining the full-featured players - thanks to you !!!!!
Good night
Sigmund
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
The value_changed signal is emitted when the value changes. If you use scale-step="1" and left-click the bar somewhere, the slider will move and repeat-move and as the value is changing it will emit value_changed signals. Using the update-policy="1" will enable you to left-click the bar or drag the slider and no signal will be emmitted until you release the mouse (I just tried it). I think though that you may now be aware of this one.zigbert wrote:2.)
The action is executed when mouse is pressed down (not released as I expected). This makes it impossible to drag the slider to a given position and then execute the <action>. I tried to include <action signal="released"> as in the <button> widget, but it failed.
[EDIT] Ok, I think we were posting at the same time. It's great that you got it to work Well done. I'm looking forward to seeing it in action
Cheers,
Thunor