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 Sun 22 Oct 2017, 06:32
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
freememapplet_tray v2.8.6 and v2.8.6f - includes source
Post new topic   Reply to topic View previous topic :: View next topic
Page 3 of 5 [69 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Author Message
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Sun 13 Sep 2015, 09:02    Post subject:  

Hi 01micko,
Sorry about the typo, and thanks for the effort.
gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Sun 13 Sep 2015, 09:10    Post subject: updated versions v2.7.6 and v2.8.1  

Again taking on board 01micko's contribution.
Version 2.8.1 includes 01micko's improved right click menu, and it now supports pupmode=2.
Version 2.7.5 is a version with no functional change from the earlier v2.7.3 freememapplet_tray and hence is the smaller of the two. The new version simply changes the code inline with the corresponding code of 2.8.1.

gyro
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8656
Location: qld

PostPosted: Sun 13 Sep 2015, 16:35    Post subject:  

Hi gyro

Thanks for including my changes.

I like this change too that you added, keeps things consistent:

#define STORAGE_MSG _(" personal storage, free space ")


All that's left now I think is a bit of soak testing to see if there are any bugs or leaks, then call for translations.

Cheers

EDIT:

As an afterthought, perhaps there should be one cosmetic change, just to save confusion for translators. It's very minor, just involving formatting of the tooltip. It's best explained in the diff:

Code:
--- freememapplet_tray281.c   2015-09-14 06:48:01.718666372 +1000
+++ freememapplet_tray.c   2015-09-14 06:46:45.081997558 +1000
@@ -29,7 +29,7 @@
 
 #define QUIT _("Quit")
 #define RESIZE _("Resize personal storage")
-#define STORAGE_MSG _(" personal storage, free space ")
+#define STORAGE_MSG _("personal storage, free space")
 #define RIGHT_MENU _("Resize personal storage, right click for menu.")
 
 GtkStatusIcon *tray_icon;
@@ -99,9 +99,9 @@ gboolean Update(gpointer ptr) {
     
     //update tooltip...
     if (pupSavefile)
-      g_snprintf(memdisplaylong, MAXCHARMSG, "%s%s%s\n%s", memdisplaytotal, STORAGE_MSG, memdisplayfree, RIGHT_MENU);
+      g_snprintf(memdisplaylong, MAXCHARMSG, "%s %s %s\n%s", memdisplaytotal, STORAGE_MSG, memdisplayfree, RIGHT_MENU);
     else
-      g_snprintf(memdisplaylong, MAXCHARMSG, "%s%s%s", memdisplaytotal, STORAGE_MSG, memdisplayfree);
+      g_snprintf(memdisplaylong, MAXCHARMSG, "%s %s %s", memdisplaytotal, STORAGE_MSG, memdisplayfree);
     gtk_status_icon_set_tooltip(tray_icon, memdisplaylong);
 
     //update icon... (sizefree,sizetotal are in MB)


This would affect v2.7.6 as well I suspect.

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Mon 14 Sep 2015, 09:56    Post subject:  

Hi 01micko,

I'm about provide an updated version 2.8.2, this is mostly redoing some of the code, but also changing what happens when there are problems with PUPSTATE.
Instead of simply exiting, it shows the flashing critical icon and the tooltip says "PUPSTATE file missing or badly formated".
It's a bit annoying, (as perhaps it should be), but easily gotten rid of with the "Quit" menu item.

I will include your suggestion re messages in this new version.

Edit: I've also changed the storage message to use "MiB" and "GiB" to make it clear that the numbers represent 1024*1024, and 1024*1024*1024, respectively.

I might backport some of this to a 2.7.7 later.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Mon 14 Sep 2015, 11:03    Post subject: New version 2.8.2 available  

This version focuses on robustness in even unlikely cases.
Changes:
1) In the previous code there was a possibility that an attempt to "free" an uninitilased pointer. Fixed.
2) In the previous code, it the PUPSTATE file is missing, it exits cleanly, but if the PUPSTATE file does not contain a "SAVE_LAYER" entry then it crashed.
In this code in both cases it continues to run showing the flashing "critical" icon and the tooltip shows an error message.
3) As per 01mico's latest suggestion, no translatable messages have spaces at the beginning or end.
4) Some code rewriting that does not change functionality.

See first post for download.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Mon 14 Sep 2015, 20:17    Post subject: Version that exits on error  

I have attached a cut-down freememapplet-2.8.2ex.tar.gz file.

This is the same code except that instead of running and producing an error tootltip, it exits gracefully if either PUPSTATE is missing or it doesn't contain a SAVE_LAYER line.

This is not a full release, it contains only the source and the compile script.
So to test, you will need to extract and run compile script.

NOTES for folk who want to fiddle with this code:
1) If you provide an error mechanism to cope with the 'have PUPSTATE but no SAVE_LAYER' situation, it's then fairly easy to get the 'missing PUPSTATE' situation to do the same.
2) If ever pupmode=2 provides a PUPSTATE file that contains a "SAVE_LAYER='/'" line, there should be no need for special coding for pupmode=2.

Edit: Replaced freememapplet-2.8.2x.tar.gz with freememapplet-2.8.2ex.tar.gz

Edit2: withdrawn.

gyro

Last edited by gyro on Wed 16 Sep 2015, 05:08; edited 1 time in total
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8656
Location: qld

PostPosted: Tue 15 Sep 2015, 02:29    Post subject:  

Hi gyro

v2.8.2ex works as expected in the 3 install types I have. I will let it run a few days and see how the cpu/memory usage goes.

I'm just using htop like so:

Code:
htop -p `pidof freememapplet_tray`


Thanks
freemem.jpg
 Description   
 Filesize   41.24 KB
 Viewed   237 Time(s)

freemem.jpg


_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Tue 15 Sep 2015, 06:08    Post subject:  

Hi 01micko,

Just to let you know, I have no intention of doing a full release of 2.8.2ex. I just put it out there as an example of how it might be done

My little play with gtk really finishes with v2.8.2.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Wed 16 Sep 2015, 05:07    Post subject:  

Hi 01micko,

If you are determined to use a freememapplet_tray that exits on error, then I suggest that you use this one.
At least you see an error message when it is run from a console.

Some might assume that the error conditions will never happen.
But I have learned that assumptions can return to bite.
This is what happened to a significant number of programs when savefolder was introduced. There was nothing particularly wrong with these programs, except that they made assumptions, that eventually proved to be sometimes incorrect.

gyro

Last edited by gyro on Thu 17 Sep 2015, 16:47; edited 1 time in total
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Thu 17 Sep 2015, 16:45    Post subject:  

There's a bug in the code in version 2.8.2exm which can result in a blank icon in the tray if the "SAVE_LAYER" line contains only a single "'".
I have attached a version that is better.

Actually, only version 2.8.3 has a chance of working properly no matter what is in the "SAVE_LAYER" line of PUPSTATE, because it checks for "sizetotal == 0" after "statfs" has been called, i.e. if "statfs" could not find a valid partition matching the input.

Edit: changed name to match version 2.8.3 which contains the same mod.

gyro
Back to top
View user's profile Send private message 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Thu 17 Sep 2015, 21:11    Post subject: Version 2.8.4 and 2.8.4x  

Added more validation of input from PUPSTATE to both.

Also added check for file existence to v2.8.4x, this brings its resilience to be on a par with v2.8.4.

V2.8.4x contains binaries this time. The other files can easily be copied from v2.8.4, if required.

Hopefully this is the end, well at least until someone else finds a bug.

gyro

Last edited by gyro on Sat 19 Sep 2015, 01:23; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1370
Location: Japan

PostPosted: Thu 17 Sep 2015, 22:08    Post subject:  

gyro, I don't know if I did something wrong, but when I try to run freememapplet_tray32 in Slacko5.6 I get a "SAVE_LAYER line is missing or badly formated." error.

I have no need for a SAVE_LAYER.
My /etc/rc.d/PUPSTATE reads
Code:
PUPMODE=5
PDEV1='sdb1'
DEV1FS='vfat'
PUPSFS='sdb1,vfat,/pup_slacko/puppy_slacko_5.6.sfs'
PUPSAVE=''
PMEDIA='usbflash'
#ATADRIVES is all internal ide/pata/sata drives, excluding optical, excluding usb...
ATADRIVES='sda '
#ATAOPTICALDRIVES is list of non-usb optical drives...
ATAOPTICALDRIVES='sr0 sr1 '
#these directories are unionfs/aufs layers in /initrd...
SAVE_LAYER=''
PUP_LAYER='/pup_ro2'
#The partition that has the slackosave file is mounted here...
PUP_HOME=''
#(in /initrd) ...note, /mnt/home is a link to it.
#this file has extra kernel drivers and firmware...
ZDRV=''
#complete set of modules in the initrd (moved to main f.s.)...
ZDRVINIT='no'
#Partition no. override on boot drive to which session is (or will be) saved...
PSAVEMARK=''
PSUBDIR='/pup_slacko'
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8656
Location: qld

PostPosted: Thu 17 Sep 2015, 23:52    Post subject:  

Hi MochiMoppel

Indeed it looks all along as if the case for pupmode=5 has just been testing '/initrd' without adding anything in the concatenation (nothing to add). Of course testing any valid writeable directory in the system would give the same amount of space available (which when running fully in RAM would be whatever RAM is left).

I propose this patch to add a case for pupmode=5 (this is against 2.8.4x)

Code:
--- freememapplet_tray.c.x   2015-09-18 10:18:30.000000000 +1000
+++ freememapplet_tray.c   2015-09-18 15:32:37.853326180 +1000
@@ -55,6 +55,7 @@
 
 gboolean pupSavefile = FALSE;
 gboolean fullInstall = FALSE;
+gboolean firstRun = FALSE;
 
 gboolean Update(gpointer ptr);
 
@@ -79,7 +80,7 @@
 gboolean Update(gpointer ptr) {
    
     //read free personal storage...
-   if (fullInstall)
+   if ((fullInstall) || (firstRun))
       getFileSystemData("/");
    else
       getFileSystemData(save_layer_dir);
@@ -220,6 +221,10 @@
                fullInstall = TRUE;
                haveSaveLayer = TRUE;
             }
+            else if (g_str_has_suffix(curLine, "=5"))
+            {
+               firstRun = TRUE;
+            }
          }
          else if (g_str_has_prefix(curLine, "PUPSAVE="))
          {
@@ -262,7 +267,7 @@
    g_free(linesString);
    g_strfreev(linesArray);
 
-   if ((havePupstate) && (haveSaveLayer))
+   if ((havePupstate) && ((haveSaveLayer) || (firstRun)))
    {
       gtk_init(&argc, &argv);
       tray_icon = create_tray_icon();

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
gyro

Joined: 28 Oct 2008
Posts: 1401
Location: Brisbane, Australia

PostPosted: Fri 18 Sep 2015, 07:07    Post subject:  

Hi MochiMoppel,

Yes it's complaining that there's nothing in "SAVE_LAYER". It won't do just "/initrd" anymore.

Would it make sense to set "save_layer_dir" to "/" if there is a PUPSTATE file but the SAVE_LAYER value is empty?

Note: The exit versions have a problem if "getFileSystemData" returns 0, the following code:
Code:
if (sizefreeprev == sizefree)
      return TRUE; //unchanged.
means that the icon is never setup, so the program is in the tray, but it's just a blank. A right click on the spot it should be in produces a menu. Not good.
So it's quite important to make sure that there is always a valid value for "save_layer_dir" before it is decided not to exit.

gyro
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 8656
Location: qld

PostPosted: Fri 18 Sep 2015, 07:19    Post subject:  

gyro wrote:
Would it make sense to set "save_layer_dir" to "/" if there is a PUPSTATE file but the SAVE_LAYER value is empty?


Yes.

I wrote:
Of course testing any valid writeable directory(snip)

Which would by definition exclude any mount points.

_________________
Puppy Linux Blog - contact me for access
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 3 of 5 [69 Posts]   Goto page: Previous 1, 2, 3, 4, 5 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
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.0579s ][ Queries: 12 (0.0062s) ][ GZIP on ]