Gtkdialog right-click menu

gtkdialog does not include support for right-click menu, but like the knob, there has been some workarounds for right-click menus as well. Let's look at one of the existing...

The main structural solution has been around some years, and includes some basic knowledge of gtkdialog options.
<window decorated="false" skip_taskbar_hint="true">

<hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
<vbox spacing="2">

menuitem xml-code here

<action signal="focus-out-event">EXIT:exit</action>

  • Set decorated to false skips the window manager to draw window borders
  • skip_taskbar_hint avoids this app to show up in the tray/taskbar. After all this menu is a standalone app - but the user shouldn't notice it.
  • The signal focus-out-event exits the gui the focus is leaving the menu.
  • spacing is default 5 and will give a gap between the vertical widgets. To simulate a menu we want the highlight to move straight from one item to the next, so we don't want any spacing and set this to 0.
  • scrollable <hbox> gives us the 3D border. Other types of border can be set by the shadow-type option.
  • hscrollbar-policy avoids scrollbars.

  • This is much like any right-click menu works - so far, so good

    This is the minimal right-click menu in the tray manager (/usr/local/jwm_config/tray).
    The code for each menu-item is a combination of a <pixmap> and a <button> widget.
    <pixmap height-request="18" icon_size="1" space-expand="false" space-fill="false">
    <input file stock="gtk-edit"></input>
    <button height-request="18" xalign="0" can-focus="no" relief="2" space-expand="true" space-fill="true">
    <label>"'$(gettext 'Manual edit')'"</label>
    <action>echo edit > /tmp/menu_OUTPUT</action>

    The weaknesses shows up when using the default gtk-theme in Slacko-6.3.2, scaling the font, or using another language string that is longer than the default. This is critical when we move towards touch-screen layouts.

    Since the background color is similar to the 3D border in the menu, the menu 'melts' into the main gui, and we see only half of the border. The menu has a fixed size (defined in pixels), so it won't scale when needed. And why does it has a fixed size? The answer is because this is the way to avoid the menu to grey out parts of the main gui.
    Technical: Reducing the the default size of a button-widget (used in the menu) will grey out the main gui as long as the menu is run as a child of the background gui. We have to run it as a child process to keep the selection viewable in the main gui (see image below).

    The improvement process

    I have tested several solutions, and ended up with the following... for now. But the first thing to do is to define what criteria should be set for an optimal right-click menu?
    It should:
  • scale the gui depending on font size and NLS strings.
  • have a clear border defining its area.
  • show the selection in the main gui.
  • not grey out area in the main gui.
  • allow disabling of specific menu items.
  • highlight menuitem when hovering.
  • support icons.
  • be good looking, and follow the active gtk-theme.
  • allow embedded widgets for more complex menus (see image below).

  • Here follows my attempt for a better solution. Not 100%, but far closer than the previous one.

    The structural code in the first code snippet has not changed, but been extended to show the new border.

    <window decorated="false" skip_taskbar_hint="true" resizable="false" border-width="0" space-expand="true" space-fill="true">
    <eventbox name="rightclick_menu_frame" above-child="false">
    <vbox border-width="1">
    <vbox spacing="0" border-width="7">

    menuitem xml-code here

    <action signal="focus-out-event">EXIT:exit</action>

    The <eventbox> widget makes it possible for us to set a unique background color for this widget in the gtk-theme. We do this before executing gtkdialog. The name rightclick_menu_frame corresponds to our style for the extended gtk-theme. Color is set to black (#000), and border width to 1 px. The second <eventbox> is only to draw a new background with the color taken from the global gtk-theme.

    echo 'style "Rightclick_menu" { bg[NORMAL] = "#888" }
    style "Rightclick_menu_frame" { bg[NORMAL] = "#000" }
    widget "*rightclick_menu" style "Rightclick_menu"
    widget "*rightclick_menu_frame" style "Rightclick_menu_frame"
    ' > $WORKDIR/gtkrc_menu
    export GTK2_RC_FILES=$WORKDIR/gtkrc_menu:/root/.gtkrc-2.0

    The code for the menu-items differs more from the previous attempt (snippet above). This one does not use the <button> widget as the previous, but the <text> widget. Since the <text> widget does not has any internal spacing as the <button> (between text/icon and the gtk-button), it handles down-scaling perfect, and does not grey out any area in the main gui. Also, the <pixmap> here, does not use the gtk-stock, but a defined file. For some reason, this works better for down-scaling as well. As mentioned above, we downscale the gui to better simulate a menu rather than looking like a 'normal' gui.

    The <text> widget and the <pixmap> widget does not support any <action>, but that is easily solved by putting them inside an <eventbox>, and let that one handle actions. The corresponding code for this new menu-item looks like this.

    <eventbox above-child="true" visible-window="true">
    <hbox spacing="7" border-width="3">
    <pixmap space-expand="false" space-fill="false">
    <input file>/usr/share/pixmaps/puppy/remove.svg</input>
    <text xalign="0" space-expand="true" space-fill="true">
    <label>"'$(gettext 'Manual edit')'"</label>
    <action signal="enter-notify-event">hide:MENU_1</action>
    <action signal="enter-notify-event">show:MENU_1B</action>
    <eventbox name="rightclick_menu" above-child="true" visible-window="true" visible="false">
    <hbox spacing="7" border-width="3">
    <pixmap space-expand="false" space-fill="false">
    <input file>/usr/share/pixmaps/puppy/remove.svg</input>
    <text xalign="0" space-expand="true" space-fill="true">
    <label>"'$(gettext 'Manual edit')'"</label>
    <action signal="leave-notify-event">show:MENU_1</action>
    <action signal="leave-notify-event">hide:MENU_1B</action>
    <action signal="button-release-event">echo edit > '$WORKDIR'/tray_menu_OUTPUT</action>
    <action signal="button-release-event">EXIT:exit</action>

    As we see, it's actual 2 set of the same menu-item - one normal, and one highlighted. Switching between them (hide itself / show opponent) when getting the leave-notify-event signal. The highlight color is handled by the extended gtk-theme described above in the style Rightclick_menu. Truly, setting the highlight color to #888, does not follow the global gtk-theme. To do that, you have to grab the foreground color in the active theme. - Not to be described in this blogpost.

    The complete code is seen at github

    Posted on 4 Jul 2016, 08:09 by zigbert - Categories: Development
    Comments - Edit - Delete

    pMusic - Set playqueue

    pMusic is playqueue-oriented. It will only play tracks from the playqueue - nowhere else. The focus is how to add tracks to the queue. pMusic offers several ways:
  • From the internal sourcelist
  • From the smartadd dock
  • From the commandline
  • From an external file browser
  • From the Track info window
  • From the search field

  • The internal sourcelist

    In the default frontend, this is the big field to the left, and it shows output of
  • the search engine
  • the internal file browser
  • expanded playlist
  • radio-station browsing
  • webmusic browsing
  • The Favorites/Bookmarks system
  • CD-audio content
  • user history
  • Whatever music the sourcelist shows, this can be added to the playqueue by double-click on it. Single-click selects item(s) while right-click opens a menu. The combination of searching/selection makes the sourcelist the preferred place for complex adding. It supports multiple selections using CRTL and SHIFT key and selection by dragging an area (rubber banding).

    The Smartadd dock

    Show the Smartadd dock by pressing the button beside the search field - see image below. This is a tool adding tracks depending on your requests. You define how many tracks to be added (by sort order or randomly), and where the smartadd should look. Either in the sourcelist (image above) or the internal database (all audio files on system). This is all good, but it is the filters that make it 'smart'. From version 5.1.0, there are 3 filters:
    Each time you have played a song it is stored in the database, so pMusic 'knows' how many times you have played each song. I use this filter when I want some random music - but still, I want music I like. So, setting the rating filter to 3 - I only get songs I have heard 3 times earlier. I get different kind of music (I set it to random), but since I have played these songs 3 times before, I most likely enjoy them.
    The genre info is based on the meta-info stored in the database. If this info isn't present, this filter is useless and will lead to an error message. An interesting feature is the free search. - The string in the genre-field can be ie. 'eta' and will accept Metal/metal/Heavy metal/Black metal/...
    If info exist, this filter allows us to specify beats per minute of the songs we like to hear.

    The filter buttons shows quick info of the filter status. Here we see the rating filter is set to 3 while the tempo-button shows the minimum beats per minute - 120. Genre filter is not set, so button doesn't show any info.

    Technical (tempo)
    The pMusic indexer stores the tempo of the song to the database. It requires a full scan (Menu->Music Sources->My Music) or that you've listen the song. (See Witing to the DB for more info). The tempo detection is done in funcC via the trackinfo function (func_trackinfo --> stream_info) and the result is seen in the Stream tab in the Track info window. Tempo detection requires soundtouch to be installed on your system. There is a dependency checker in the Help menu. Tempo features is introduced in pMusic 5.1.0

    The commandline

    The basic command is pmusic /path/file, and it will start pmusic with an empty playqueue and play the requested song. If pMusic is already running, it will add the file to the existing playqueue. To override this dynamic behavior, use the switches:
    -a to ensure the file is added to the existing queue
    -P to ensure the file will start playing

    See pmusic --help for a full set of switches.

    External file browser

    The dynamic behavior of the commandline described above will all file browsers benefit of. As long as audio MIME types are associated with pMusic, you can click on an audio file in your file browser and pMusic will show up and start playing. The next files you click on, will nicely be added to the playqueue.

    If using the Rox file browser (used in most Puppy linux), there is an option to add all audio files in the selected directory. This is available from the right-click menu.

    Track info - Album tab

    There is also an option to add tracks from the Track info window - Album tab. Right-click in the list, and you get the option to add track(s) to the playqueue.

    The search field

    The search field gives of course input to the search-engine. You can also activate the internal file browser by enter a path here. But in addition, it lets us add music to the playqueue by entering the address - either a file path or an internet URL. Mostly, other solutions are preferable, but when you ie. want to add an internet URL to the playqueue, this is the most handy way to do it. Copy the address in a browser - paste it into the search field - press enter.

    Posted on 21 Jun 2016, 03:46 by zigbert - Categories: Development
    Comments - Edit - Delete

    pMusic sound processing

    The sound processing in pMusic contains options to manipulate both the input and the output sound stream. It's handy to understand this difference to get the best possible effect on your tuning.

    Output sound processing

    The output sound processing is done after the stream has left the pMusic play-engine. So, it will only affect the Linux sound driver (Alsa). This is a smooth processing, and most often the recommended choice. The downside is that it will affect the sound output of all other apps using the Alsa driver, and does not have all the capabilities of the input processing.

    pMusic offers a basic Volume and Balance controller. The Volume slider will work for mono as well as stereo, but the Balance does of course require a stereo channel. The default channel is Master, and this is most often a mono channel, and does not support different level for left and right speaker. You must specify correct channel for your system to get mixer volume to work as a balance controller. This is done in the preferences. Menu->File->Preferences. (See image below). There is also a mute-button in this basic sound processing module.

    In addition, the output sound processing includes the equalizer embedded from pEqualizer. This is a frontend to alsaequal made by 01micko. This gives easy access to tuning the sound fitting your speakers and ears. Be aware that you can save your equalizer settings to a preset for later use. Check out the pEqualizer manual

    When the equalizer is installed on your system, all sound is ported through it. Even if choosing the Flat preset the sound is filtered. It does not have a true bypass. If you are one of those wanting the raw output, the solution is to avoid using auto as your defined soundcard. This is the default setting, and to be changed in the preferences. Note that by setting the soundcard you also bound the Alsa driver to pMusic. This means other programs will not play audio as long as pMusic is active. On the other hand, pMusic will not play if sound driver is in use by other program.

    Input sound processing

    The input processing is tweaking the sound stream going into pMusic, so this gives more options to manipulate the streams structure (ie. tempo and fading). The downside of input processing is that it has to reload the stream setup, and it will give a tick/pause when changing the values.

    The input processing is put inside the generated playing command to the exec-file: $HOME/.pmusic/tmp/exec (check out the backend monitor plugin).
    ffmpeg -i "/mnt/sdb1/musikk/mp3/Yngwie Malmsteen - Mistreated.mp3" -ss 134 -af "volume=2,treble=gain=3,bass=gain=-7" -f rtp rtp:// -ss 134 -af "volume=2,treble=gain=3,bass=gain=-7" -f au - 2>> /root/.pmusic/tmp/ffmpeg_output | aplay  2> /root/.pmusic/tmp/aplay_error
    It is the -af (audiofilter) switch that defines the input sound processing, and we see here that volume is increased by 2dB, treble by 3dB while bass is decreased by 7dB. The -af values is grabbed from:
    $HOME/.pmusic/tmp/ffmpeg_filter - for internal use
    $HOME/.pmusic/tmp/ffmpeg_filter_basic - for plugin
    $HOME/.pmusic/tmp/ffmpeg_filter_EQ - for plugin
    So, the infrastructure are ready to test out your new sound processing plugin. If you want to look into how pMusic uses ffmpeg as its play engine it is described in the blogpost ffmpeg - the multimedia hub.

    Manipulate Export files

    The gui-module for input processing is also used when exporting files in the playqueue. This gives the abilities to convert the stream more radically than just changing the format. Since this is the same gui-module, all values stays active also when exporting the tracks. To avoid your exported files to be changed, keep the Bypass switch on.

    Input volume / Normalize

    Increasing the input volume should be used by caution, as it could give distortion to the sound. To optimize the input volume level, use the Normalizer. The normalizer will unify volume of all tracks, but never increase volume more than to a level without distortion. This is handy when your tracks comes from different sources, since the recording level was probably not the same. The normalizer uses resources on the volume calculation, and depending on your system, it will give a small gap before playing.

    The output volume will not distort.

    Posted on 27 Sep 2016, 07:48 by zigbert - Categories: Development
    Comments - Edit - Delete

    pMusic DB and file format

    pMusic is an audio-player using a database (DB) to keep track of meta-information of your music. This is info like:
  • ID3-tags (artist, title, album, ...) that are embedded into the file.
  • links to lyrics, albumart, ...
  • Stream info like format, samplerate, bpm, ...
  • User listening activity.

  • While most players depends on an external DB like Mysql or Mariadb, pMusic has its own, very simple, internal DB. Basically it is a textfile with 21 columns separated by a |, where each line contains info of one file. When reading from the DB (ie. when searching), we just grab the line(s) corresponding to our request.

    To make the infra-structure simple; the DB, the sourcelist (search-result-field) and the internal file format (*.pmd), uses the exact same formating. That means, we can dump the raw output of the DB to the gui, a favorite list, or ie. to the smart-add function. This helps a lot when it comes to speed. Sometimes you might forget that pMusic is not compiled binary, but just a bash script.

    GeekNote: To be technically correct, the sourcelist and *.pmd file contains only the first 15 columns of the DB format. They have no use of the last items of info.

    The DB structure

    Let's look at one line of my DB:
    /mnt/sdb1/musikk/Tindrum - Drums Of War.mp3|Tindrum|Drums Of War|Drums of war|1|1988|Hard Rock|Live||mp3|175|04:02|117|/mnt/sdb1/musikk/Tindrum - Drums Of War.mp3|gtk-audio|2aa59ada-3dd8-40b7-878a-bb682fca7b30|479933cd-d787-4126-8315-7749ca4781a1|Tindrum|/mnt/home/pmusic storage/albumart/Tindrum - Drums Of War.jpg||,1357415329,1357417187

    This line holds all info we got about this track. Instead of explaining what it all means, just open up the DB-editor found in Menu > Music sources > My Music. Here we can look at, and edit all info in the DB.

    Most of this is straightforward, but 3 things might not seem logical:

  • The Command (column 1) and the Path (column 14) is equal. The Command is executed when adding stuff to the playqueue. The Path is what it says - the local path. Because the example shows a local file taken from the DB textfile, the command is equal to the path. This is not the fact for an url pointing to a radio-station web address.

  • The last column, Timestamps, is not self explanatory. Each time you has played a song, the DB adds the given time in seconds since 1970 to the end of the line. This is used to provide better sorting depending on your preferred music. And, to search for your most played songs ie. in February.

  • Column 7 - Rate - is empty, and it is always empty in the DB textfile, but not in the sourcelist (left pane). The rating is equal to number of timestamps, and is calculated in func_rating. This calculation also change the icon depending on the song's rating. Geeknote: This is a great example of the blinding speed of awk.

  • Writing to the DB

    pMusic allows 2 major ways to write info to the DB. Either by (1) user interaction or the default (2) silent mode.

    (1) user interaction
    The static way is to start the indexer (Menu > Music sources > My Music) which scans your system for audio-files and adds the info to the DB. Depending on your music collection, this might take a long time, but place all available information (ID3-tags and stream info) to the DB at once.

    (2) silent mode
    The default dynamic behavior is to store info as you play. When you press the Play-button, pMusic
  • checks the file for ID3-tags and stream info.
  • searches the web for lyrics, albumart and artist info. (Must be activated in the preferences.)
  • tries to build an album-list if tracks are available on your system. (Must be activated in the preferences.)

  • If using mode (1), we still miss info from the web and album lists, so mode (2) will kick in anyway for missing info.

    All this info must be written to the DB - but that's not straightforward - we can't just start writing...
  • To avoid parallel writings to the DB, there exist a queue-system (DB is locked while writing).
  • To avoid a long queue (many locks are resource hungry), the info is passed to a DB-stack. The DB-stack can hold several info-capsules.
  • Writing to the DB, empties the stack in one operation. This avoids the queue to grow.

  • The stack is found at $HOME/.pmusic/tmp/mymusic_stack.
    The merging is done at func_index -merge_stack.

    Keep the DB in shape

    In addition, there are mechanisms to keep the DB in shape. When you add a file to the playqueue, pMusic checks it in func_add - functions check_source and fix_db.

    If the added file is not already in the DB, ask user to scan the source directory for new music. This message shows up embedded in the main window to not disturb the user too much. It could be that we don't want to respond to this message, and that is just ok.

    If the added file has its line in the DB, but not present in your system, something should probably be updated, and this message below will show up. But, if the filename is found in the DB with another path than the defined, pMusic will play the alternative source instead. Therefor, this box is not often seen in recent versions of pMusic.

    The Playlist file format

    I mentioned earlier the internal file format *.pmd used by ie. the favorites structure. But, for the user, the pMusic format is the *.pmu found in the save box. You can choose to save to an external format as *.m3u or *.pls, but to get the full power of pMusic, *.pmu is the recommended choice. This because it cooperates well with the DB.

    *.pmu contains the same info as in the playqueue. This makes it possible to dump a *.pmu into the playqueue, while a *.m3u has to be converted. Since all information in a *.pmu is grabbed from the DB, we can quickly revert, and grab the full track-info back from the DB. This is seen when expanding a *.pmu in the sourcelist (left pane). - We see full track-info including rating calculation. When expanding a m3u/pls we only see the actual info inside the file.

    When looking at the playqueue in the gui, you see 3 columns:
    Length | Track title | Path

    In fact there are 2 more hidden columns, and all are part of the *.pmu file:
    Icon | Length | Track title | Path | ID

    The Icon holds gtk-play when the play-icon is shown, else it's empty. This will of course always be empty inside a *.pmu file
    The ID holds an unique id-number together with the path. This is necessary to avoid conflict when playqueue contains several instances of the same song. The ID keeps track of which of the similar songs you are playing/moving/editing.

    Unlike *.m3u, the *.pmu playlist does not handle relative paths. This to stay close to the DB format. Instead pMusic will search for an alternative path if playing track is not found. The statusbar will show this information during search. Code found in func_progressbar.

    The short story of the pMusic file formats is:
    *.pmd mirrors the DB
    *.pmu mirrors the playqueue

    This is the basic structure of the pMusic data format.

    Posted on 9 Jul 2016, 18:54 by zigbert - Categories: Development
    Comments - Edit - Delete

    The gtkdialog lib

    Did you know about the gtkdialog lib?

    Puppies built from Woof-CE uses /usr/lib/gtkdialog/ to unify the look of builtin GUIs. Together with the new vector icon set (in /usr/share/pixmaps/puppy), the gtkdialog lib made it possible to give Puppy a facelift without adding any bloat to the core.

    The lib is simple and small. It is meant to reduce the code for repeating requests (as message-boxes), and unify the look for graphical widgets (as scalegrips and svgs). A complete guide how to use the different snippets are found inside each file (open in text-editor). It contains 3 different categories:

    1. BOX
    These return running gtkdialog boxes with requested info. Gtkdialog is not complex at all, but dead simple boxes often used by Puppy, can be set up with a oneliner. This is not meant as a replacement for Xdialog.

    There are atm 4 different types of boxes:

    /usr/lib/gtkdialog/box_ok Title error "This is an error"

    2. XML
    While the box-code produces a running gui, the xml-code is gtkdialog code meant to be embedded inside the parent gui. These are used to unify the look, and is cooperating with pTheme to follow the global theming.

    There are 4 xml-snippets available:

    Example: - Note the 'xml_info gtk' that activates the gtkdialog-theme set by pTheme.
    export GUI='
    <vbox space-expand="true" space-fill="true">
    '"`/usr/lib/gtkdialog/xml_info fixed puppy_config.svg 60 "This is the header used in Puppy these days. It handles <b>markups</b>."`"'
    <button ok></button>
    . /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
    gtkdialog -p GUI

    3. SVG
    The svg category returns svg-code to embed in the gtkdialog code. Today, there are 3, but the knob shown in previous post should probably be added here. As expected, the svg bars and text follows the global theming set by pTheme.

    echo '
    <timer visible="false">
    <action>/usr/lib/gtkdialog/svg_analogclock 300 > /tmp/clock.svg</action>
    <pixmap space-expand="false" space-fill="false">
    <input file>/tmp/clock.svg</input>
    </vbox>' | gtkdialog -s

    Posted on 19 May 2016, 20:19 by zigbert - Categories: Development
    Comments - Edit - Delete

    gtkdialog knob

    Some time ago mister_electronico on the Puppy forum started the discussion of using knobs in gtkdialog code. I gave some feedback but the code never entered a final state. I have now revisited the code, and plan to use it myself.

    So, here is a simple test-script to show how it works. All in all, it's just a svg that rotates the dot to show the changing value. Atm, the knob rotates when dragging mouse up/down on the knob. Maybe this should be extended to left/right actions as well. Please check out the code; it should be easy to understand with some basic bash/gtkdialog/svg knowledge.

    The code:
    export KNOB_WIDTH=120
    export KNOB_COLOR="#A5E8B1"
    export CARD_NR=0 #'aplay -l' shows your cards
    export SPEAKER=Master

    #initial audio level
    TMP="`amixer -c $CARD_NR get "$SPEAKER" | grep -m1 'Left:' | cut -d '%' -f 1 | cut -d '[' -f 2`" #volume level
    ANGLE=$(($TMP*250/100)) #convert from % to angle (0-250)
    echo $ANGLE > /tmp/knob_angle

    draw_knob (){ #$1=angle/value, $2=width, $3=color, $4=dot-color
    echo '
    <svg width="'${2}'" height="'${2}'">
    id="RG1" cx="'$((${2}*30/100))'" cy="'$((${2}*30/100))'" fx="'$((${2}*30/100))'" fy="'$((${2}*30/100))'" r="'$((${2}*45/100))'"
    <stop style="stop-color:#393939;stop-opacity:1;" offset="1"/>
    <stop style="stop-color:#888;stop-opacity:1;" offset="0"/>
    <circle style="fill:#222;" cx="'$(((${2}/2)+(${2}*4/100)))'" cy="'$(((${2}/2)+(${2}*4/100)))'" r="'$((${2}*46/100))'"/>
    <circle style="fill:#777;stroke:#444" cx="'$((${2}/2))'" cy="'$((${2}/2))'" r="'$((${2}*46/100))'"/>
    <circle style="fill:url(#RG1);stroke:'${3}';stroke-width:'$((${2}*2/100))'" cx="'$((${2}/2))'" cy="'$((${2}/2))'" r="'$((${2}*39/100))'"/>
    <circle style="fill:'${4}';" cx="'$((${2}*28/100))'" cy="'$((${2}*74/100))'" r="'$((${2}*4/100))'" transform="rotate('${1}' '$((${2}/2))' '$((${2}/2))')"/>

    update (){ #get current, relative position of cursor
    read ANGLE < /tmp/knob_angle
    Y="`getcurpos | awk '{print $2}'`"
    read Y2 < /tmp/cursor_y
    ANGLE=$(($ANGLE+(($Y2-$Y)*2))) #the knob's value range is equal to moving mouse up/down 125 px.
    [ $ANGLE -lt 1 ] && ANGLE=0; [ $ANGLE -gt 250 ] && ANGLE=250 #keep value inside range
    echo $Y > /tmp/cursor_y
    echo $ANGLE > /tmp/knob_angle
    draw_knob $ANGLE $KNOB_WIDTH "$KNOB_COLOR" "#eee" > /tmp/knob.svg
    amixer -c $CARD_NR set "$SPEAKER" $(($ANGLE*100/250))%

    export -f draw_knob update
    draw_knob $ANGLE $KNOB_WIDTH "$KNOB_COLOR" "#eee" > /tmp/knob.svg

    echo '
    <vbox margin="20">
    <timer visible="false" milliseconds="true" interval="100" sensitive="false">
    <input file>/tmp/knob.svg</input>
    <action signal="button-press-event">getcurpos | awk '"'"'{print $2}'"'"' > /tmp/cursor_y</action>
    <action signal="button-press-event">enable:TIMER</action>
    <action signal="button-release-event">disable:TIMER</action>
    </vbox>' | gtkdialog -s

    Be aware that this knob depends on the getcurpos command. This is included in all recent Puppies. But I doubt that you'll find getcurpos in most other distros, so I see this as Puppy-code. You should probably avoid this code if you plan to offer your gui outside the kennel.

    This info is added to the Tips and tricks post

    Posted on 10 May 2016, 04:09 by zigbert - Categories: Development
    Comments - Edit - Delete

    Pages: [1] [2] [3] [4]