PopMenu utility for multi. popup menus from a simple script.

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
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

PopMenu utility for multi. popup menus from a simple script.

#1 Post by sunburnt »

I`m fairly proud of this. I thought of putting it in "Cutting Edge", but here seems better.
Many thanks to zigbert for the direction to make it possible and many others for all the help.

A data script can contain and run many different popmenus. There can be many data scripts.
The script has event action functions, the popmenu button items list, and 7 variables ( so far...).
Many of these popmenu groups of data can be in the one script allowing many different menus.
The script runs another script with the shell code and the gtkdialog code for the popmenu.
The data script variables do: Center Screen, Dock Left or Right, and Show Over the main GUI,
TreeBox text Header or not, and Window Decorated ( border and title bar ) or not.
There`s 4 other variables: popW, popH, and offX, offY. This is all that`s needed to control it.
Here`s a section of the data script that defines one popmenu:

Code: Select all

DM1)
ROX() { echo ROX
} ; export -f ROX
Mount() { echo Mount
} ; export -f Mount
Exit_App() { echo Exit_App.
} ; export -f Exit_App
Exit_Menu() { echo Exit_Menu
} ; export -f Exit_Menu
 
MENU_ITEMS='
ROX
Mount
Exit_App
'
#WINDECO=true
WINDECO=false
POSITION=over
#POSITION=dock
#POSITION=center
HEADER=
popW=102
popH=188
offX=10			# for "over" offset positioning
offY=29
;;
Could be a start on making gtkdialog really usable.
Compared to wrestling with the gtkdialog code, this is really simple!

### Usage: (popmenu file: /path/file) (popmenu ID) [calling app. Xwin. title] [context item]
Attachments
popmenu_b-1.zip
Zip file contains 2 files, unzip them in: /root/my-applications/bin
The data script can be anywhere, the popmenu.gtk3 script must be in the path.
(2.46 KiB) Downloaded 332 times
Last edited by sunburnt on Fri 23 Apr 2010, 01:00, edited 3 times in total.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#2 Post by 8-bit »

I put both files in the zip in /root/my-applications/bin.
When I ran popmenu, I got a popup menu with only one entry.
That was Exit Menu.
The remaining selections were not displayed in the menu.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

Did you read the top of either script for the Usage example?
PopMenu requires at least 1 argument usually ( but doesn`t have to ), and can take up to 3.
Also you may notice that it`s the data script that you run with arguments, not popmenu.gtk

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#4 Post by 8-bit »

OK, I jumped the gun on that.
What you are saying then is if I create a program and have the functions I want to use in popmenu, I can call it with my program by using a routine like clkMENU in the driveman script.
I understand that the routines one would want to use must be included in the popup script.

Am I correct in this assumption?

I am not going into the particulars here, but I assume that is how it would work.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#5 Post by sunburnt »

Having the functions in the PopMenu data script makes them available because the script popmenu.gtk is run in the same shell: . popmenu.gtk3 $1 $2 $3
You can have the functions in a separate file if you include the file at the beginning of the data script like this:
. (your file)
Or this:
source (your file)
Or you can call them directly with your command like this:
(your file) (function name)
This is how I do it in driveman.gtk3
driveman.gtk3 executes the functions in driveman. Example: driveman btnMNT /dev/sda1
But popmenu.gtk3 has the functions and variables passed to it when it`s run by the data script.
So the functions could be a function library or your own function file or in the data script. T.

I`m going to have the data script do info. reporting of the popmenus that it contains.

Post Reply