Program and Swallow problem (Solved)
Program and Swallow problem (Solved)
I've written my first tray applet in C and gtk which works fine in cli.
However, although it works fine and is Swallowed in the tray, if I restart JWM from menu it starts a second instance and so on for each restart.
What am I missing to stop the multiple instances?
However, although it works fine and is Swallowed in the tray, if I restart JWM from menu it starts a second instance and so on for each restart.
What am I missing to stop the multiple instances?
Last edited by tasmod on Thu 15 Jul 2010, 18:01, edited 1 time in total.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
are you killing the applet in main? ... probably right at the end ... something like gtk main quit as in this Vala tutorial http://www.vimeo.com/9617309
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
This is my 'main' code, all the code is heavily based on Barry's and others works. The only way to learn really I suppose.
I'm a real beginner with C, in my first week at moment.
Firestate is the function that does comparing at intervals to check a firewall state.
I'm a real beginner with C, in my first week at moment.
Firestate is the function that does comparing at intervals to check a firewall state.
Code: Select all
int main(int argc, char **argv) {
GtkStatusIcon *tray_icon;
gtk_init(&argc, &argv);
tray_icon = create_tray_icon();
gtk_timeout_add(interval, Firestate, NULL);
Firestate(NULL);
gtk_main();
return 0;
}
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I'm not sure the C equivalent, but in vala its
app.destroy.connect (Gtk.main_quit)
by the way i put some sample code for making a tray applet in vala in the vala/genie thread (based on nic's status icon example)
app.destroy.connect (Gtk.main_quit)
by the way i put some sample code for making a tray applet in vala in the vala/genie thread (based on nic's status icon example)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
Re: Program and Swallow problem
Hmmm .....
Rgds
I'm wild guessing that you're starting your app from jwmrc-tray as a swallow item ... Starting any gtk trayicon app as a swallow will not get into JWM swallow list and it won't be killed on restart. The swallow option is for normal windowed apps that you want to force into tray area (the swallow function relies on window name ID). Any apps that is written as a gtk trayicon should be started either in .xinitrc or the Startup folder.tasmod wrote:..... However, although it works fine and is Swallowed in the tray, if I restart JWM from menu it starts a second instance and so on for each restart.
What am I missing to stop the multiple instances?
Rgds
I'm just going through my code just now in conjunction with the Gtk reference Barry posted.
I think I'll stick with C as it is more universal than Vala and i don't want my poor aching brain to start again with new syntax. I have enough syntax problems already.
I'm closer now to getting my applet as I want it to work. The right click menu comes up and selecting the about generates the Gtk box but it is Swallowed. Need to find what I've changed to cause that, originally it worked OK but on exit it errored. It only showed error in cli but had no effect on applet operation. I knew it was the 'exit' that was unclean as I didn't know how to close and return from Gtk window. I used 'gtk_quit' which caused the error message.
Unfortunately I was so engrossed in the program I didn't have a backup of the 'nearly' working model. So now I'm looking for the change I must have made.
I'm not using anything special to code. I use Geany for the code and syntax highlighting features. Then I run a compile command in a cli.
Sometimes it is too easy in Geany to delete a word or section of code when in fact I intended to copy.
Probably could do with an IDE to use.
I think I'll stick with C as it is more universal than Vala and i don't want my poor aching brain to start again with new syntax. I have enough syntax problems already.
I'm closer now to getting my applet as I want it to work. The right click menu comes up and selecting the about generates the Gtk box but it is Swallowed. Need to find what I've changed to cause that, originally it worked OK but on exit it errored. It only showed error in cli but had no effect on applet operation. I knew it was the 'exit' that was unclean as I didn't know how to close and return from Gtk window. I used 'gtk_quit' which caused the error message.
Unfortunately I was so engrossed in the program I didn't have a backup of the 'nearly' working model. So now I'm looking for the change I must have made.
I'm not using anything special to code. I use Geany for the code and syntax highlighting features. Then I run a compile command in a cli.
Sometimes it is too easy in Geany to delete a word or section of code when in fact I intended to copy.
Probably could do with an IDE to use.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
Ahhh friend Patriot,
Many thanks for that. Yes I was swallowing in .jwm-tray. Now I know I can see what I can do to move it.
I'm puzzled slightly as to BKs freemem applet. Mine is based on that and Blinky as inspiration. They appear in .jwm-tray ?
Many thanks for that. Yes I was swallowing in .jwm-tray. Now I know I can see what I can do to move it.
I'm puzzled slightly as to BKs freemem applet. Mine is based on that and Blinky as inspiration. They appear in .jwm-tray ?
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
I would post what code I have here, but as it is probably very 'ugly' to a true C programmer then I'm very reluctant. More of a hack job really.
Edit
Removed code as app actually works
Will pet it up.
Edit
Removed code as app actually works
Will pet it up.
- Attachments
-
- mini-firewall1.xpm
- Firewall on icon
- (63.17 KiB) Downloaded 423 times
-
- firewall-off.xpm
- Firewall off icon.
- (21.84 KiB) Downloaded 395 times
Last edited by tasmod on Thu 15 Jul 2010, 15:02, edited 1 time in total.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
Oh joy, joy, joy !!
Removed it as a swallowed app in jwm-tray and it works spot on in system tray once it is added to Startup folder.
Even better that way. I can now write a simple remove from folder command to accompany it.
It was intended as a first run reminder for the new iso's. It would sit in tray as 'Firewall Off' with a left click run now or right click menu option to run the firewall setup program.
Once firewall is running, the tray icon menu could offer the option to remove it from tray.
Anyone care to improve the icon sizes ?? Or try the app if I post it ??
Removed it as a swallowed app in jwm-tray and it works spot on in system tray once it is added to Startup folder.
Even better that way. I can now write a simple remove from folder command to accompany it.
It was intended as a first run reminder for the new iso's. It would sit in tray as 'Firewall Off' with a left click run now or right click menu option to run the firewall setup program.
Once firewall is running, the tray icon menu could offer the option to remove it from tray.
Anyone care to improve the icon sizes ?? Or try the app if I post it ??
- Attachments
-
- firewallstatus.png
- Running in tray
- (6.3 KiB) Downloaded 894 times
Last edited by tasmod on Fri 16 Jul 2010, 08:45, edited 2 times in total.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
This is how glipper does it in .xinitrc (but it would work in any startup script)
if you want glipper to turn on just
if you want glipper to turn off just
Code: Select all
[ -f /root/.glipper_on ] && glipper &
Code: Select all
echo >/root/.glipper_on
Code: Select all
rm /root/.glipper_on
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
OK, I changed code slightly and have done away with external script.
It is now just the binary and icons.
EDIT
Now removed duplicate pet.
The latest version is now in Additional Software/Network
HERE
It is now just the binary and icons.
EDIT
Now removed duplicate pet.
The latest version is now in Additional Software/Network
HERE
Last edited by tasmod on Fri 16 Jul 2010, 10:03, edited 1 time in total.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
- Lobster
- Official Crustacean
- Posts: 15522
- Joined: Wed 04 May 2005, 06:06
- Location: Paradox Realm
- Contact:
Seems to be working very nicely for me - I am in 2.11 or 2.12 of Lucid
. . . in fact that would be a useful icon - telling which version of Puppy I am using. There is a version file kept somewhere but can not remember where . . .
What is your plan? Perhaps change to user spot as an option?
Anyway well done
. . . in fact that would be a useful icon - telling which version of Puppy I am using. There is a version file kept somewhere but can not remember where . . .
What is your plan? Perhaps change to user spot as an option?
Anyway well done
Hi Lobster,
Yes, I created and compiled it on Luci , now 212 with me.
It's basic operation is simple, when firewall wizard is run it appends lines to the rc.local file. I just check for the state of those lines. If 'start' is in the line, firewall is on, if 'stop' firewall is off, if no lines firewall also off.
Now up to version 0.3.
I've added the Network Setup wizard to menu and IP Information to menu.
Hmm, version info. OK will look at it but no promises, it requires parsing the info returned.
Maybe add to tooltip so when you hover over, it shows version as well as firewall status.
Yes, I created and compiled it on Luci , now 212 with me.
It's basic operation is simple, when firewall wizard is run it appends lines to the rc.local file. I just check for the state of those lines. If 'start' is in the line, firewall is on, if 'stop' firewall is off, if no lines firewall also off.
Now up to version 0.3.
I've added the Network Setup wizard to menu and IP Information to menu.
Hmm, version info. OK will look at it but no promises, it requires parsing the info returned.
Maybe add to tooltip so when you hover over, it shows version as well as firewall status.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)
Hey tasmond
you reminded me of trios fix for freememapplet
*a small delay script was required also in /usr/sbin
===========================
added to the /root/.jwmrc-tray
I had to modify it for the jwm in 4.12
but it was an easy fix to an annoying problem
Joe
thanksswallowed app in jwm-tray
you reminded me of trios fix for freememapplet
*a small delay script was required also in /usr/sbin
Code: Select all
#!/bin/sh
killall freememapplet
sleep 1
exec freememapplet
===========================
added to the /root/.jwmrc-tray
Code: Select all
<Swallow name="freememapplet" width="34">
freememappletdelayed
</Swallow>
but it was an easy fix to an annoying problem
Joe
Hi Joe,
Yes when I first 'Swallowed' the app in .jwm-tray I made a script firewallstateshell with just the small sleep value. That was before Patriot told me it wouldn't be swallowed anyway.
Now it's standalone.
Glad my antics jogged memory.
Yes when I first 'Swallowed' the app in .jwm-tray I made a script firewallstateshell with just the small sleep value. That was before Patriot told me it wouldn't be swallowed anyway.
Now it's standalone.
Glad my antics jogged memory.
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)
-
The moment after you press "Post" is the moment you actually see the typso 8)