| Author |
Message |
zigbert

Joined: 29 Mar 2006 Posts: 5295 Location: Valåmoen, Norway
|
Posted: Sun 05 Sep 2010, 02:06 Post subject:
gtkdialog_menu-0.3 Subject description: New widget for gtkdialog (right-click menu) |
|
Gtkdialog_menu
Gtkdialog_menu allows the use of external menus in gtkdialog.
| Code: | # 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: | #!/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 |
_________________ Stardust resources
Last edited by zigbert on Thu 04 Nov 2010, 13:37; edited 1 time in total
|
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 5295 Location: Valåmoen, Norway
|
Posted: Thu 16 Sep 2010, 14:19 Post subject:
|
|
Version 0.3
- uses active gtk-theme
- seperators
- autoscales width
_________________ Stardust resources
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1407 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sat 10 Sep 2011, 03:48 Post subject:
Subject description: Problem while integrating variables in the script... |
|
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! )
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?)
| Quote: | 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, 13:02; edited 4 times in total
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1407 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sat 10 Sep 2011, 12:53 Post subject:
|
|
Nobody to help me?
_________________

|
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 5295 Location: Valåmoen, Norway
|
Posted: Sat 10 Sep 2011, 13:09 Post subject:
|
|
| Argolance wrote: | Nobody to help me?  | 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
_________________ Stardust resources
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1407 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sat 10 Sep 2011, 13:50 Post subject:
|
|
Hello zigbert,
| Quote: | Of course, but right now, I don't have much time...... | Sorry to be so impatient!
| Quote: | | 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!) ...
Thank you.
Best regards.
_________________

|
|
Back to top
|
|
 |
sc0ttman

Joined: 16 Sep 2009 Posts: 2201 Location: UK
|
Posted: Sat 10 Sep 2011, 14:22 Post subject:
|
|
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
_________________ Akita Linux, VLC-GTK, Pup Search, Pup File Search
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1407 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sun 11 Sep 2011, 04:24 Post subject:
|
|
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, 13:00; edited 4 times in total
|
|
Back to top
|
|
 |
Argolance

Joined: 06 Jan 2008 Posts: 1407 Location: PORT-BRILLET (Mayenne - France)
|
Posted: Sun 11 Sep 2011, 05:00 Post subject:
|
|
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!!!
I thought this should help!
Now all is right.
Cordialement.
|
|
Back to top
|
|
 |
|