Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 20 Apr 2014, 19:26
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gtkdialog_menu-0.3
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: 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
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: Thu 16 Sep 2010, 14:19    Post subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1780
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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! Embarassed)
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
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1780
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 10 Sep 2011, 12:53    Post subject:  

Nobody to help me? Crying or Very sad
_________________

Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: Sat 10 Sep 2011, 13:09    Post subject:  

Argolance wrote:
Nobody to help me? Crying or Very sad
Very Happy 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
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1780
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 10 Sep 2011, 13:50    Post subject:  

Hello zigbert,
Quote:
Very Happy 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!) Wink...

Thank you.
Best regards.

_________________

Back to top
View user's profile Send private message Visit poster's website 
sc0ttman


Joined: 16 Sep 2009
Posts: 2364
Location: UK

PostPosted: 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 Smile
_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1780
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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
View user's profile Send private message Visit poster's website 
Argolance


Joined: 06 Jan 2008
Posts: 1780
Location: PORT-BRILLET (Mayenne - France)

PostPosted: 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!!! Shocked
I thought this should help!

Now all is right. Very Happy

Cordialement.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0636s ][ Queries: 12 (0.0077s) ][ GZIP on ]