The time now is Thu 19 Apr 2018, 12:16
All times are UTC - 4 |
Author |
Message |
Mobeus

Joined: 26 Aug 2010 Posts: 94
|
Posted: Tue 31 Aug 2010, 10:36 Post subject:
|
|
Hi Nicolas
Quote: | You don't need to specify to close the file because it is automatically closed! |
Oh that's quite awkward. That makes Vala the only language I have ever used that decides when the file can be closed instead of the programmer.
Consider:
Open a file for writing
Write a bash script to it.
Flush the file
chmod it
try to execute the new script from within your vala program
Error: File is busy!
I can code around this by putting the file writing in a sub-routine, the file is closed when the routine finishes and goes out of scope.
FileStream.close(fp) would be so much better.
Mobeus
|
Back to top
|
|
 |
nikobordx
Joined: 23 May 2009 Posts: 84 Location: Bordeaux, France
|
Posted: Tue 31 Aug 2010, 11:11 Post subject:
|
|
Try this:
Code: |
[indent=4]
// Build with valac --pkg gio-2.0 yourfile.gs
init
create_new_file()
// Use this function when file is not exist
def static create_new_file ()
var file = File.new_for_path("test.sh")
var thefile_stream = file.create (FileCreateFlags.NONE, null)
var data_stream = new DataOutputStream (thefile_stream)
data_stream.put_string ("echo \"hello\"", null) // Write something in file
FileUtils.chmod ("test.txt", 0755) // Chmod the file to executable
Process.spawn_command_line_async("sh test.sh") // Exec the file
// Use this function when file already exist
def static use_file ()
var file = File.new_for_path("test.sh")
var renamed = file.set_display_name ("samplefile.bak", null)
var thefile_stream = file.create (FileCreateFlags.NONE, null)
var data_stream = new DataOutputStream (thefile_stream)
data_stream.put_string ("echo \"hello\"", null) // Write something in file
renamed.delete(null)
FileUtils.chmod ("test.txt", 0755) // Chmod the file to executable
Process.spawn_command_line_async("sh test.sh") // Exec the file
|
Nicolas.
|
Back to top
|
|
 |
Mobeus

Joined: 26 Aug 2010 Posts: 94
|
Posted: Tue 31 Aug 2010, 19:53 Post subject:
|
|
Hi Nicolas,
I appreciate your help and examples. I never would have thought to even try something like that. This is an example of what I used that “Failed to execute child process “/tmp/test.sh” (Text file busy)”
Code: | [indent=4]
init
fn : string = "/tmp/test.sh"
doit(fn)
def doit (filename : string)
fp0 : FileStream
fp0 = FileStream.open (filename, "w")
fp0.puts ("ls /root")
fp0.flush()
FileUtils.chmod (filename, 0750)
try
Process.spawn_command_line_async (filename)
except ex : GLib.Error
print ("%s", ex.message) |
And this is an example of what I did to fix it
Code: | [indent=4]
init
fn : string = "/tmp/test.sh"
doit(fn)
exec_async (fn)
def doit (filename : string)
fp0 : FileStream
fp0 = FileStream.open (filename, "w")
fp0.puts ("ls /root")
fp0.flush()
FileUtils.chmod (filename, 0750)
def exec_async (command : string)
try
Process.spawn_command_line_async (command)
except ex : GLib.Error
print ("%s", ex.message) |
fp0.close() would still be a good thing to have.
This stuff is great fun
Mobeus
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Wed 01 Sep 2010, 18:43 Post subject:
XML-RPC |
|
I think I took your example as the base - it looks like you converted from Evan Nemmerson's vala example. I posted the code I have been working with - slightly modified version of your code in this thread above. I did post it almost at the same time as the sqlite code I was playing with that you already figured out for me!
I was hoping that the xmlrpc_extract_method_response of the libsoup library might be the method to call to parse the xml returned from the response into an array of structs but I am at a complete loss as to how to call this. What is GValue? and how do we get at the **error parameter presumably an out array - seems to be an int and a string - perhaps a dict or a struct. There is something funny going on with the number of parameters as the /usr/share/vala/valide/libsoup.val or something like that file shows I think 5 parameters for xmlrpc_parse_method_response from memory (which is dangerously bad) and if I give any more than 4 I get compile errors. What does that method do anyway?
Many thanks again for your help Nicolas
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 05 Sep 2010, 23:05 Post subject:
|
|
Hi guys and gals
I know next to nought about genie programming but using Nicolas' template for tray icons I came up with something useful.. mainly coded in bash , depending on 2 tray icons compiled in genie.
It's a little daemon to monitor RAM usage and it actually works! It gives warnings when RAM usage is high and critical and offers to start pprocess (if installed) or top.
I just tried it out on my XO-1 and it worked a charm, with mavrothal's xopup based on lupu-510. Xo's only have 256M of RAM and I have no swap file. Once Puppy is loaded there is about 40M free, then you load Chromium and there is less than 5M left.. enter my program.
I called it freeramdaemon and it has a simple config gui too.
There is a menu entry under 'system'
Maybe the technosaur might want to expand on this..
Sources are included and I commented here and there.
Enjoy
Cheers
Edit1: just removed some useless code so now it's 0.1.1 (not changed in script tho )
Edit2: updated to 0.2. It seemed more logical to give warnings when the actual amount of RAM becomes critical, not the percentage. . I found this out on my fast box when I was getting the warning when I still had 200M of free RAM! Now the 'warning' kicks in at 32M and the critical warning kicks in at 8M, giving the user enough chance to do something about the situation without losing their work.
 |
Description |
latest, commented old stuff
|

Download |
Filename |
freeramdaemon-0.2.pet |
Filesize |
8.64 KB |
Downloaded |
984 Time(s) |
Description |
leaving older version up
|

Download |
Filename |
freeramdaemon-0.1.1.pet |
Filesize |
8.39 KB |
Downloaded |
982 Time(s) |
Description |
|
Filesize |
11.95 KB |
Viewed |
2271 Time(s) |

|
Description |
|
Filesize |
11.25 KB |
Viewed |
2246 Time(s) |

|
_________________ Puppy Linux Blog - contact me for access
Last edited by 01micko on Tue 07 Sep 2010, 02:39; edited 2 times in total
|
Back to top
|
|
 |
Mobeus

Joined: 26 Aug 2010 Posts: 94
|
Posted: Mon 06 Sep 2010, 14:40 Post subject:
|
|
I too am new to Genie and have just posted my first utility written with it. It’s a tiny GUI firewall installer and configuration tool. The source code is available there too. http://www.murga-linux.com/puppy/viewtopic.php?p=448608#448608
Thanks go to Barry for his Genie pages and to Nicolas and everyone else in this thread for the help and examples.
Mobeus
Description |
|
Filesize |
48.34 KB |
Viewed |
2162 Time(s) |

|
|
Back to top
|
|
 |
growler

Joined: 24 Mar 2008 Posts: 209 Location: Kapiti - New Zealand
|
Posted: Mon 06 Sep 2010, 19:28 Post subject:
GValueArray |
|
Getting some great looking little apps coming together - judging by Mobeus's firewall config GUI and Mickos memory usage tray icon. Nice work guys.
I am struggling with this XML-RPC thing.
It seems that xmlprc_parse_method_response is meant to return the values from the message into a GValueArray. However, it seems that I can't iterate through the GValueArray in a for loop - the compiler complains that there is no iterable method for a GValueArray - How then to enumerate the values returned from the GValueArray - when the values could be different data types?
Appreicate any ideas as always.
I have found it hard to start with genie due to the lack of documentation and it would have been completely impossible to even approach without Barry's docs and Nicolas's patience so once again I am indebted to the puppy team.
Trying to figure out how to call the library functions from examiniation of the bindings /usr/share/vala/vapi files and valadoc.org is pretty hit and miss for me too. In some ways a knowlege of C seems to be required to get anywhere with genie. Ironic really as why I was trying to learn genie was to avoid C/C++/Java type syntax!! I am making progress ... I think.
I hope I can produce something worthwhile to give back - but certainly having fun learning.
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Tue 07 Sep 2010, 01:29 Post subject:
|
|
Congrats Mobeus on a proper genie app, it might be a good replacement for our tired looking firewall app . I like the look of it and will give you feedback once I have tested.
I updated the freeramdaemon app, see the comments in "Edit 2" in my post above.
Thanks growler, but credit for the genie part must go to Nicolas. . I put his and my forum names in the info window.
Cheers
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
Lobster
Official Crustacean

Joined: 04 May 2005 Posts: 15238 Location: Paradox Realm
|
Posted: Tue 07 Sep 2010, 01:48 Post subject:
|
|
Great stuff guys
Mobeus you might like to add some of my GROWL code to your firewall app
http://murga-linux.com/puppy/viewtopic.php?p=335216#335216
_________________ YinYana AI Buddhism
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Fri 10 Sep 2010, 18:04 Post subject:
|
|
Further to Nicolas' work with tray icons, I figured out how you can use any icon (well I only tried .xpm, but I guess .png might work, perhaps .gif).
It uses gtk and gdk. I made a working battery monitor for the XO-1 olpc machine, using 12 of these compiled execs and a small bash daemon tying them together. Not very orthodox, but nonetheless useful. (and small.. 10K compressed .. will post in XO thread at a later date)
Here it is: Code: | /*power applet, 01micko 20100910*/
/*thanks to technosaurus and nikobordx*/
/*icons must be in /usr/share/icons*/
[indent=4]
/* Build with valac --pkg gtk+-2.0 --pkg gdk-x11-2.0 eightychg.gs */
uses
Gtk
Gdk
init
Gtk.init (ref args)
var test = new StatusIconTest ()
Gdk.init (ref args)
test.show_all ()
Gtk.main ()
class StatusIconTest : Widget
trayicon : StatusIcon
menu : Menu
init
/* Create tray icon */
trayicon = new StatusIcon.from_file("/usr/share/icons/eightychg.xpm")
trayicon.set_tooltip_text ("Bat 80%")
trayicon.set_visible(true)
trayicon.activate += icon_clicked
create_menu()
/* Create menu */
def private create_menu ()
menu = new Menu()
var menuItem = new ImageMenuItem.from_stock(STOCK_INFO, null)
menuItem.activate += about_clicked
menu.append(menuItem)
var menuItem2 = new ImageMenuItem.from_stock(STOCK_QUIT, null)
menuItem2.activate += exit_app
menu.append(menuItem2)
menu.show_all()
trayicon.popup_menu += def (button, time)
show_popup(button, time)
/* Show popup menu */
def private show_popup (button : uint, time : uint)
menu.popup(null, null, null, button, time)
def private icon_clicked ()
print("I know you have clicked on the icon !!")
def private about_clicked ()
var about = new AboutDialog ()
about.set_version("0.2")
about.set_program_name("Battery Widget")
about.set_comments("Your battery is 80% charging")
about.set_copyright("Copyright (c)01micko, GPL 2010")
about.run()
about.hide()
def private exit_app ()
Gtk.main_quit(); |
Have fun!
Cheers
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 4785 Location: Kingwood, TX
|
Posted: Fri 10 Sep 2010, 23:31 Post subject:
|
|
@micko - I posted almost the same thing a couple pages back, but seeing it again after adding a loop to iterate each parameter for a minimp3 player to play multiple files it sparked an idea that could greatly reduce resource usage if the same tray app worked for all the various status updates
this is what I used in C to loop through passed parameters:
Code: | int w = 0;
for(w = 1; w < (argc) ;w++){
//argv[w] will be the Nth parameter passed to the program
} |
I know vala can but can genie even use argv and argc?
if so it could make it possible to use an ash script to act as a daemon to periodically update the changing parameters in a file that is read by the program or in the case of icons change a symlink
for icons something like
Code: | trayicon = new StatusIcon.from_file(HOME, "/.trayapp/", argv[w], ".png")
//the ash script will change the symlink in /root/.trayapp/current_parameter.png
|
I can't recall the code to read from a file in vala/genie but it would resemble something like
Code: | string infobox = read_contents_of_file(HOME, "/.trayapp/", argv[w], ".nfo")
//the ash script will update /root/.trayapp/current_parameter.nfo with current status info |
The possibilities are endless here (I previously posted a script that will read info for battery status in jemimah's vattery thread as well as an ash script that will generate a basic percentage bar as an xpm icon)
here are some basics that could be used:
Code: | #!/bin/ash
getprocinfo() {
#/proc/file string_number_in_line string_always_in_line_but_not_others
grep $3 $1 |sed "s/: */ /" |cut -d " " -f $2
}
BATREMAIN=`getprocinfo /proc/acpi/battery/BAT1/state 3 remaining`
BATFULL=`getprocinfo /proc/acpi/battery/BAT1/info 4 last`
echo mAh remaining $BATREMAIN
echo mAh capacity $BATFULL
BATPERCENT=$((100*$BATREMAIN/$BATFULL))
BATSTATE=`getprocinfo /proc/acpi/battery/BAT1/state 3 charging`
echo percent charged $BATPERCENT
echo the battery is $BATSTATE
CPU0TEMP=`getprocinfo /proc/acpi/thermal_zone/TZ00/temperature 2 temp`
echo CPU Temperature is $CPU0TEMP C
LIDSTATUS=`getprocinfo /proc/acpi/button/lid/LID/state 2 state`
echo Lid is $LIDSTATUS
PLUGSTATUS=`getprocinfo /proc/acpi/ac_adapter/ACAD/state 2 state`
echo AC adapter is $PLUGSTATUS
KERNVER=`getprocinfo /proc/version 3 Linux`
echo Your Kernel is version $KERNVER
UPTIMESECS=`getprocinfo /proc/uptime 1 "."`
echo Your computer has been running for $UPTIMESECS seconds
IDLETIMESECS=`getprocinfo /proc/uptime 2 "."`
echo Your computer has been idle for $IDLETIMESECS seconds
MEMTOT=`getprocinfo /proc/meminfo 2 MemTotal`
echo Total RAM is $MEMTOT kb
MEMFREE=`getprocinfo /proc/meminfo 2 MemFree`
echo Total free RAM is $MEMFREE kb
SWPTOT=`getprocinfo /proc/meminfo 2 SwapTotal`
echo Total Swap is $SWPTOT kb
SWPFREE=`getprocinfo /proc/meminfo 2 SwapFree`
echo Total free Swap is $SWPFREE kb |
and the xpm percent bar generator: Code: |
#!/bin/ash
FILENAME=barimage
FGCOLOR=\#000
BGCOLOR=None
PERCENT=50
WIDTH=100
HEIGHT=24
BARSTRING=""
q=0 #should have used for loops
y=0 #not while loops - oops
#get values from input
for x in $@; do
case $x in
width*)WIDTH=`echo $x |cut -d = -f 2`;;
height*)HEIGHT=`echo $x |cut -d = -f 2`;;
fg*)FGCOLOR=`echo $x |cut -d = -f 2`
[ "$FGCOLOR" != "None" ] && FGCOLOR=\#$FGCOLOR;;
bg*)BGCOLOR=`echo $x |cut -d = -f 2`
[ "$BGCOLOR" != "None" ] && BGCOLOR=\#$BGCOLOR;;
name*)FILENAME=`echo $x |cut -d = -f 2`;;
*%)PERCENT=`echo $x |cut -d % -f 1`;;
vert*)VERTICAL="true";;
*) echo "usage "$0" XX% name=filename fgcolor=XXX bgcolor=XXX height=XXX width=XXX [vertical]
colors can be 3 or 6 digit hexadecimal or None ... default is horizontal bars" && exit
;;
esac
done
#write header to file
echo '/* XPM */' >${FILENAME}.xpm
echo 'static char *'$FILENAME'_xpm[] = {' >>${FILENAME}.xpm
echo '"'$WIDTH $HEIGHT '2 1",' >>${FILENAME}.xpm
echo '"0 c '$BGCOLOR'",' >>${FILENAME}.xpm
echo '"1 c '$FGCOLOR'",' >>${FILENAME}.xpm
if [ "$VERTICAL" == "true" ];then #vertical bars
BARTOP=$(($HEIGHT*$PERCENT/100))
#generate each line of the image
while [ "$q" -lt $HEIGHT ]; do
q=$(($q + 1))
if [ "$q" -lt $BARTOP ];then
while [ "$z" -lt $WIDTH ]; do
BARSTRING=${BARSTRING}0
z=$(($z + 1))
done
else
while [ "$z" -lt $WIDTH ]; do
BARSTRING=${BARSTRING}1
z=$(($z + 1))
done
fi
echo '"'$BARSTRING'"' >>${FILENAME}.xpm
BARSTRING=""
z=0
done
else #horizontal bars
#generate one line of the image
BARMAX=$(($WIDTH*$PERCENT/100))
while [ "$q" -lt $BARMAX ]; do
q=$(($q + 1))
BARSTRING=${BARSTRING}1
done
while [ "$q" -le $WIDTH ]; do
BARSTRING=${BARSTRING}0
q=$(($q + 1))
done
#write a line for each pixel of height
while [ "$y" -le $HEIGHT ]; do
echo '"'$BARSTRING'"' >>${FILENAME}.xpm
y=$(($y + 1))
done
fi
echo '};' >>${FILENAME}.xpm
#defaultimageeditor ${FILENAME}.xpm |
_________________ Check out my github repositories. I may eventually get around to updating my blogspot.
|
Back to top
|
|
 |
nikobordx
Joined: 23 May 2009 Posts: 84 Location: Bordeaux, France
|
Posted: Sat 11 Sep 2010, 05:09 Post subject:
|
|
Hi Micko,
I made some changes in your code to avoid warnings !
Code: |
/*power applet, 01micko 20100910*/
/*thanks to technosaurus and nikobordx*/
/*icons must be in /usr/share/icons*/
[indent=4]
/* Build with valac --pkg gtk+-2.0 --pkg gdk-x11-2.0 eightychg.gs */
uses
Gtk
Gdk
init
Gtk.init (ref args)
var test = new StatusIconTest ()
Gdk.init (ref args)
test.show_all ()
Gtk.main ()
class StatusIconTest : Widget
trayicon : StatusIcon
menu : Menu
init
/* Create tray icon */
trayicon = new StatusIcon.from_file("/usr/share/icons/eightychg.xpm")
trayicon.set_tooltip_text ("Bat 80%")
trayicon.set_visible(true)
trayicon.activate.connect(icon_clicked) // Changed
create_menu()
/* Create menu */
def private create_menu ()
menu = new Menu()
var menuItem = new ImageMenuItem.from_stock(Stock.INFO, null) // Changed
menuItem.activate.connect(about_clicked) // Changed
menu.append(menuItem)
var menuItem2 = new ImageMenuItem.from_stock(Stock.QUIT, null) // Changed
menuItem2.activate.connect(exit_app) // Changed
menu.append(menuItem2)
menu.show_all()
trayicon.popup_menu.connect(show_popup) // Changed
/* Show popup menu */
def private show_popup (button : uint, time : uint)
menu.popup(null, null, null, button, time)
def private icon_clicked ()
print("I know you have clicked on the icon !!")
def private about_clicked ()
var about = new AboutDialog ()
about.set_version("0.2")
about.set_program_name("Battery Widget")
about.set_comments("Your battery is 80% charging")
about.set_copyright("Copyright (c)01micko, GPL 2010")
about.run()
about.hide()
def private exit_app ()
Gtk.main_quit()
|
Nicolas.
|
Back to top
|
|
 |
paulhomebus

Joined: 21 Jan 2010 Posts: 120 Location: New Zealand
|
Posted: Sun 12 Sep 2010, 07:18 Post subject:
Trying to add small launcher program to the status icon... Subject description: Based on puppymartin's monkeyserver |
|
What I would like to know, is there any way to stop it loading multiple windows of xampp_start.sh??
xampp_start.sh
Code: |
#!/bin/sh
export MAIN_DIALOG="
<window title=\"XAMPP Webserver\" icon-name=\"xampp\" window-position=\"1\">
<vbox>
<vbox>
<hbox>
<frame Start Webserver>
<button>
<input file>/usr/share/midi-icons/go48.png</input>
<action>/opt/lampp/lampp start &</action>
</button>
</frame>
<frame Stop Webserver>
<button>
<input file>/usr/share/midi-icons/shutdown48.png</input>
<action>/opt/lampp/lampp stop &</action>
</button>
</frame>
<frame XAMPP Config>
<button>
<input file>/usr/share/midi-icons/setup48.png</input>
<action>geany /opt/lampp/etc/httpd.conf &</action>
</button>
</frame>
</hbox>
</vbox>
<vbox>
<hbox>
<frame Start Mysql>
<button>
<input file>/usr/share/midi-icons/go48.png</input>
<action>/opt/lampp/lampp startmysql &</action>
</button>
</frame>
<frame Stop Mysql>
<button>
<input file>/usr/share/midi-icons/shutdown48.png</input>
<action>/opt/lampp/lampp stopmysql &</action>
</button>
</frame>
<frame Mysql Config>
<button>
<input file>/usr/share/midi-icons/setup48.png</input>
<action>geany /opt/lampp/etc/my.cnf &</action>
</button>
</frame>
</hbox>
</vbox>
<vbox>
<hbox>
<frame Start Apache>
<button>
<input file>/usr/share/midi-icons/go48.png</input>
<action>/opt/lampp/lampp startapache &</action>
</button>
</frame>
<frame Stop Apache>
<button>
<input file>/usr/share/midi-icons/shutdown48.png</input>
<action>/opt/lampp/lampp stopapache &</action>
</button>
</frame>
<frame PHP Config>
<button>
<input file>/usr/share/midi-icons/setup48.png</input>
<action>geany /opt/lampp/etc/php.ini &</action>
</button>
</frame>
</hbox>
</vbox>
<vbox>
<hbox>
<frame Start ProFTP>
<button>
<input file>/usr/share/midi-icons/go48.png</input>
<action>/opt/lampp/lampp startftp &</action>
</button>
</frame>
<frame Stop ProFTP>
<button>
<input file>/usr/share/midi-icons/shutdown48.png</input>
<action>rxvt -e /opt/lampp/lampp stopftp &</action>
</button>
</frame>
<frame ProFTP config>
<button>
<input file>/usr/share/midi-icons/setup48.png</input>
<action>geany /opt/lampp/etc/proftpd.conf &</action>
</button>
</frame>
</hbox>
</vbox>
<vbox>
<hbox>
<frame View Log>
<button>
<input file>/usr/local/lib/X11/pixmaps/edit48.png</input>
<action>geany /opt/lampp/logs/access_log &</action>
</button>
</frame>
<frame View Errors>
<button>
<input file>/usr/local/lib/X11/pixmaps/edit48.png</input>
<action>geany /opt/lampp/logs/error_log &</action>
</button>
</frame>
<frame Open WWW folder>
<button>
<input file>/usr/local/lib/X11/pixmaps/folder48.png</input>
<action>rox /opt/lampp/htdocs &</action>
</button>
</frame>
<frame Start Security>
<button>
<input file>/usr/share/midi-icons/security64.png</input>
<action>rxvt -e /opt/lampp/lampp security &</action>
</button>
</frame>
<frame Start ApacheSSL>
<button>
<input file>/usr/share/midi-icons/security64.png</input>
<action>/opt/lampp/lampp startssl &</action>
</button>
</frame>
</hbox>
</vbox>
</vbox>
</window>
"
gtkdialog3 --program=MAIN_DIALOG
unset MAIN_DIALOG
|
xampp.gs
using the statusicon example code..
Code: |
[indent=4]
/* Build with valac --pkg gtk+-2.0 yourfile.gs */
uses
Gtk
init
Gtk.init (ref args)
var test = new StatusIconTest ()
test.show_all ()
Gtk.main ()
class StatusIconTest : Widget
trayicon : StatusIcon
menu : Menu
init
/* Create tray icon */
trayicon = new StatusIcon.from_file("/usr/share/icons/hicolor/64x64/apps/xampp.png")
trayicon.set_tooltip_text ("Click to activate XAMPP Webserver Menu")
trayicon.set_visible(true)
trayicon.activate.connect(icon_clicked)
create_menu()
/* Create menu */
def private create_menu ()
menu = new Menu()
var menuItem0 = new ImageMenuItem.from_stock("Open XAMPP Webserver Menu", null)
menuItem0.activate.connect(icon_clicked)
menu.append(menuItem0)
var menuItem = new ImageMenuItem.from_stock(STOCK_ABOUT, null)
menuItem.activate.connect(about_clicked)
menu.append(menuItem)
var menuItem2 = new ImageMenuItem.from_stock(STOCK_QUIT, null)
menuItem2.activate.connect(exit_app)
menu.append(menuItem2)
menu.show_all()
trayicon.popup_menu.connect(show_popup)
/* Show popup menu */
def private show_popup (button : uint, time : uint)
menu.popup(null, null, null, button, time)
def private icon_clicked ()
Process.spawn_command_line_async("sh /usr/sbin/xampp_start.sh") // Exec the file
def private about_clicked ()
var about = new AboutDialog ()
about.set_version("1.0")
about.set_program_name("XAMPP MENU 1.0")
about.set_comments("by paulhomebus 4 Puppylinux")
about.set_copyright("Copyright (c)paulhomebus, GPL 2010")
about.run()
about.hide()
def private exit_app ()
Gtk.main_quit();
|
|
Back to top
|
|
 |
01micko

Joined: 11 Oct 2008 Posts: 8670 Location: qld
|
Posted: Sun 12 Sep 2010, 08:25 Post subject:
|
|
At the top of the bash script you can find the process ID and kill it if it's running I guess before the gtkdialog is executed, I've done this before with gtkdialog apps.
HTH
Cheers
PS, oh yeah, as a habit of mine I name the gtkdialog variable anything but 'MAIN_DIALOG', usually giving it a unique name.. the command ps will find it and you can grep it out.
_________________ Puppy Linux Blog - contact me for access
|
Back to top
|
|
 |
paulhomebus

Joined: 21 Jan 2010 Posts: 120 Location: New Zealand
|
Posted: Sun 12 Sep 2010, 18:26 Post subject:
|
|
Got it....
bottom of my bash script...
Code: |
</window>
"
if [[ "`which XAMPP`" != "" && "`ps | grep XAMPP | wc -l`" != 2 ]]; then
unset XAMPP &
else
gtkdialog3 --program=XAMPP
fi
|
Man that was simple, pity it took me 2hrs to figure it out! doh - lol
|
Back to top
|
|
 |
|
|
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
|