gtkdialog_menu-0.3

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

gtkdialog_menu-0.3

#1 Post by zigbert »

Gtkdialog_menu
Gtkdialog_menu allows the use of external menus in gtkdialog.

Image

Code: Select all

# gtkdialog_menu -h
Usage: gtkdialog_menu [OPTION] "stock-icon1,menuitem1" "stock-icon2,menuitem2" ...
example: gtkdialog_menu -m middle "gtk-open,Open file" "seperator" "gtk-quit,Quit"
Options
  -h         Show this information
  -m CLICK   Activate menu by clicking mousebutton
             This uses $BUTTON from main gtkdialog gui
                left
                middle
                right (default)
Download
username:puppy
password:linux

gtkdialog_menu-0.3.pet

Example how to use it: (line 4 makes the call to gtkdialog_menu)

Code: Select all

#!/bin/sh

external_menu(){
   OUTPUT="`gtkdialog_menu "gtk-apply,Set theme" "gtk-convert,Show JWM_switcher" "seperator" "gtk-quit,Quit"`"
   case $OUTPUT in
      'Set theme')
         cp -f /root/.jwm/themes/${JWM_THEME}-jwmrc /root/.jwm/jwmrc-theme
         cp -f /root/.jwm/themes/${JWM_THEME}-colors /root/.jwm/jwm_colors
         jwm -restart
         ;;
      'Show JWM_switcher')
         /usr/local/jwmconfig2/theme_switcher
         ;;
      'Quit')
         for I in `ps | grep -w "MAIN_DIALOG" | awk '{print $1}'`; do kill -9 $I; done
         exit 0
         ;;
   esac
}
export -f external_menu

#this builds the list for the <tree> widget
for THEME in `ls -1 /root/.jwm/themes/ | grep 'jwmrc' | sed -e 's/-jwmrc//' | tr '\n' ' '`; do
   THEME="`basename $THEME`"
   ITEMS="$ITEMS<item>$THEME</item>"
done

export MAIN_DIALOG='<vbox height-request="250">
  <text><label>Example of an right-click-menu with gtkdialog</label></text>
  <tree hover-selection="true">
    <label>JWM themes</label>
    <variable>JWM_THEME</variable>
    '$ITEMS'
    <action signal="button-press-event">external_menu</action>
  </tree>
  <hbox><button ok></button></hbox>
</vbox>'
gtkdialog3 -p MAIN_DIALOG 
Last edited by zigbert on Thu 04 Nov 2010, 17:37, edited 1 time in total.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#2 Post by zigbert »

Version 0.3
- uses active gtk-theme
- seperators
- autoscales width

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

Hello,
@zigbert
... Thanks for this very useful code lines.

Question:
I tried many combinations but didn't succeed in making variables working in the script! :oops:)
What is the right way to replace "Set theme" (and so on...) with variables ($VARIABLE) (calling, for example, translated words of a localization *.mo file?)
VARIABLE="Changer le thème"

external_menu(){
OUTPUT="`gtkdialog_menu "gtk-apply,=>?$VARIABLE" "gtk-convert,Show JWM_switcher" "seperator" "gtk-quit,Quit"`"
case $OUTPUT in
=>?$VARIABLE)
cp -f /root/.jwm/themes/${JWM_THEME}-jwmrc /root/.jwm/jwmrc-theme
cp -f /root/.jwm/themes/${JWM_THEME}-colors /root/.jwm/jwm_colors
jwm -restart
;;
'Show JWM_switcher')
/usr/local/jwmconfig2/theme_switcher
;;
'Quit')
for I in `ps | grep -w "MAIN_DIALOG" | awk '{print $1}'`; do kill -9 $I; done
exit 0
;;
esac
Thank you a lot for your attention.

Regards.
Last edited by Argolance on Sat 10 Sep 2011, 17:02, edited 4 times in total.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#4 Post by Argolance »

Nobody to help me? :cry:

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#5 Post by zigbert »

Argolance wrote:Nobody to help me? :cry:
:D Of course, but right now, I don't have much time......

It is a much better solution if you can hardcode the right-click-menu instead of using this code. Pmusic does it, and you'll find the code from line 126 in /usr/local/pmusic/func. This way you have full control and it will act faster. Also the code in Pmusic is better ... in the way that it uses the new features in the latest gtkdialog.


Sigmund

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#6 Post by Argolance »

Hello zigbert,
:D Of course, but right now, I don't have much time......
Sorry to be so impatient!
It is a much better solution if you can hardcode the right-click-menu instead of using this code...
That's OK! I will have a look and try to "hardcode" (though this "simple" code was working so well!) :wink:...

Thank you.
Best regards.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#7 Post by sc0ttman »

nice, I am gonna try using xdotool and this to create right click options for the VLC playback window, when loaded through VLC-GTK.. Then it'll be really nice :)
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#8 Post by Argolance »

Hello,
I guess I was a bit left wanting more. All the same, I would have liked to know if there is a way to set these variables for them to work properly inside this script: I missed here a good occasion to learn something I probably will encounter later elsewhere....

Cordialement.
Last edited by Argolance on Sun 11 Sep 2011, 17:00, edited 4 times in total.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#9 Post by Argolance »

Hello,
I found what was going wrong, with the original script... as well as with the part of the script of pmusic I finally adapted for mine: $OUTPUT variables calling more than one word won't work!!! :shock:
I thought this should help!

Now all is right. :D

Cordialement.

Scooby
Posts: 599
Joined: Sat 03 Mar 2012, 09:04

please help

#10 Post by Scooby »

Not solved

Actually when I exchange focus-out-event with leave-notify-event which I thought
worked I cannot select a menu item, the event is fired as soon as mouse leaves current widget and enters another label or icon

any input


------------- WORKS == SOLVED ------------------------------------------------------------
also I hacked in a parameter to be able to set wanted stock-icon-size
defaults to 1, I use 5 for icons and labels to line up nicely
-------------------------------------------------------------------------------------------------------

I'm using

Code: Select all

 > gtkdialog --version
gtkdialog version 0.8.4 release (C) 2003-2007 Laszlo Pere, 2011-2012 Thunor
Built with support for: GTK+ 3.
I'm on alphaOS

I tried this and it works however I don't seem to get the
focus out event so right-click menu doesn't exit of I move mousepointer
out of pop-up menu

Code: Select all

<action signal="focus-out-event">EXIT:exit</action>
any input on this?
doesn't it work with gtk3?

also icons don't line up with labels

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#11 Post by zigbert »

Scooby
This thread is really old, and codelines has changed since 2011.... Sorry about that.

pMusic uses many right-click menus, so if you can right-click on a track in the playqueue, you know it can work for you.
The menu-code is found in /usr/local/pmusic/menu_playqueue


Sigmund

Post Reply