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 Wed 22 Oct 2014, 05:51
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 Posts_count  
Author Message
zigbert


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

PostPosted: Sun 05 Sep 2010, 02:06    Post_subject:  gtkdialog_menu-0.3
Sub_title: 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

Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
zigbert


Joined: 29 Mar 2006
Posts: 5753
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_website 
Argolance


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

PostPosted: Sat 10 Sep 2011, 03:48    Post_subject:
Sub_title: 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.

_________________


Edited_times_total
Back to top
View user's profile Send_private_message Visit_website 
Argolance


Joined: 06 Jan 2008
Posts: 1835
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_website 
zigbert


Joined: 29 Mar 2006
Posts: 5753
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_website 
Argolance


Joined: 06 Jan 2008
Posts: 1835
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_website 
sc0ttman


Joined: 16 Sep 2009
Posts: 2385
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: 1835
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.

_________________


Edited_times_total
Back to top
View user's profile Send_private_message Visit_website 
Argolance


Joined: 06 Jan 2008
Posts: 1835
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_website 
Scooby

Joined: 03 Mar 2012
Posts: 319

PostPosted: Wed 13 Aug 2014, 18:13    Post_subject: please help  

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:
 > 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:
<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
Back to top
View user's profile Send_private_message 
zigbert


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

PostPosted: Thu 14 Aug 2014, 12:15    Post_subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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