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 Thu 31 Jul 2014, 05:51
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Program and Swallow problem (Solved)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
Author Message
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Wed 14 Jul 2010, 10:19    Post subject:  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?

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool

Last edited by tasmod on Thu 15 Jul 2010, 14:01; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4292

PostPosted: Wed 14 Jul 2010, 19:22    Post subject:  

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
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Wed 14 Jul 2010, 19:58    Post subject:  

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.

Code:

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 Cool
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4292

PostPosted: Wed 14 Jul 2010, 21:01    Post subject:  

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)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Patriot


Joined: 15 Jan 2009
Posts: 734

PostPosted: Thu 15 Jul 2010, 09:49    Post subject: Re: Program and Swallow problem  

Hmmm .....

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?

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.


Rgds
Back to top
View user's profile Send private message 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Thu 15 Jul 2010, 09:52    Post subject:  

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. Laughing

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. Crying or Very sad 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 Cool
Back to top
View user's profile Send private message Visit poster's website 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Thu 15 Jul 2010, 09:55    Post subject:  

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 ?

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Thu 15 Jul 2010, 10:01    Post subject:  

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. Cool


Edit
Removed code as app actually works Very Happy

Will pet it up.
mini-firewall1.xpm
Description  Firewall on icon
xpm

 Download 
Filename  mini-firewall1.xpm 
Filesize  63.17 KB 
Downloaded  248 Time(s) 
firewall-off.xpm
Description  Firewall off icon.
xpm

 Download 
Filename  firewall-off.xpm 
Filesize  21.84 KB 
Downloaded  247 Time(s) 

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool

Last edited by tasmod on Thu 15 Jul 2010, 11:02; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Thu 15 Jul 2010, 10:42    Post subject:  

Oh joy, joy, joy !! Very Happy Very Happy

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 ??
firewallstatus.png
 Description   Running in tray
 Filesize   6.3 KB
 Viewed   780 Time(s)

firewallstatus.png


_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool

Last edited by tasmod on Fri 16 Jul 2010, 04:45; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4292

PostPosted: Thu 15 Jul 2010, 18:18    Post subject:  

This is how glipper does it in .xinitrc (but it would work in any startup script)
Code:
[ -f /root/.glipper_on ] && glipper &


if you want glipper to turn on just
Code:
echo >/root/.glipper_on


if you want glipper to turn off just
Code:
rm /root/.glipper_on

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Fri 16 Jul 2010, 04:06    Post subject:  

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

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool

Last edited by tasmod on Fri 16 Jul 2010, 06:03; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Fri 16 Jul 2010, 05:52    Post subject:  

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 Very Happy

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Fri 16 Jul 2010, 06:01    Post subject:  

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.

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Fri 16 Jul 2010, 11:44    Post subject:  

Hey tasmond

Quote:
swallowed app in jwm-tray


thanks
you reminded me of trios fix for freememapplet

*a small delay script was required also in /usr/sbin
Code:


#!/bin/sh
killall freememapplet
sleep 1
exec freememapplet




===========================
added to the /root/.jwmrc-tray

Code:

<Swallow name="freememapplet" width="34">
         freememappletdelayed
      </Swallow>


I had to modify it for the jwm in 4.12
but it was an easy fix to an annoying problem

Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
tasmod


Joined: 04 Dec 2008
Posts: 1461
Location: North Lincolnshire. UK

PostPosted: Fri 16 Jul 2010, 12:00    Post subject:  

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.

_________________
Rob
-
The moment after you press "Post" is the moment you actually see the typso Cool
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
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.0870s ][ Queries: 13 (0.0096s) ][ GZIP on ]