freememapplet_tray v2.8.6 and v2.8.6f - includes source

Core libraries and systems
Message
Author
gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#31 Post by gyro »

Hi 01micko,
Sorry about the typo, and thanks for the effort.
gyro

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

updated versions v2.7.6 and v2.8.1

#32 Post by gyro »

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

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#33 Post by 01micko »

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: Select all

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#34 Post by gyro »

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

New version 2.8.2 available

#35 Post by gyro »

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Version that exits on error

#36 Post by gyro »

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, 09:08, edited 1 time in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#37 Post by 01micko »

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: Select all

htop -p `pidof freememapplet_tray`
Thanks
Attachments
freemem.jpg
(41.24 KiB) Downloaded 268 times
Puppy Linux Blog - contact me for access

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#38 Post by gyro »

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#39 Post by gyro »

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, 20:47, edited 1 time in total.

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#40 Post by gyro »

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Version 2.8.4 and 2.8.4x

#41 Post by gyro »

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, 05:23, edited 1 time in total.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#42 Post by MochiMoppel »

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: Select all

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'

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#43 Post by 01micko »

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: Select all

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#44 Post by gyro »

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: Select all

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

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#45 Post by 01micko »

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

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#46 Post by gyro »

Hi 01micko,

If a boolean was to be used in similar way to your suggested code, I would be considering using a single variable "use_root_as_dir" instead of both "fullInstall" and "firstRun";

gyro

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#47 Post by gyro »

Hi 01micko,

"save_file_dir" doesn't have to be a writeable directory, in fact it just has to be an existing file in the relevant partition.

I will produce another "x" version that has no special pupmode testing, but uses "/" if it can't get anything from "SAVE_LAYER".

gyro

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#48 Post by 01micko »

gyro wrote:Hi 01micko,

"save_file_dir" doesn't have to be a writeable directory, in fact it just has to be an existing file in the relevant partition.

I will produce another "x" version that has no special pupmode testing, but uses "/" if it can't get anything from "SAVE_LAYER".

gyro
That should work.

Thanks for your efforts.
Puppy Linux Blog - contact me for access

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

Version 2.8.5x

#49 Post by gyro »

This version exits if it can't find a PUPSTATE file.
It also exists if there is no SAVE_LAYER line or if there is a directory specified by the SAVE_LAYER line but it does not exist.

Note: In a frugal install if "/" is used, it shows the partition of "pup_rw". In pupmode=5 and pupmode=13 I think that this is the tempfs that contains "pup_rw".

gyro
Last edited by gyro on Sat 19 Sep 2015, 05:15, edited 1 time in total.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#50 Post by 01micko »

We just did a circle :lol:

Again now failing in full installs due to lack of "SAVE_LAYER" line.
Puppy Linux Blog - contact me for access

Post Reply