Recent

Author Topic: Path to application  (Read 27106 times)

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Path to application
« Reply #15 on: August 23, 2010, 12:19:40 am »
According to the Apple Human Iterface Guidelines, Preferences should be stored in the preferences folder of the user, i.e. ~/Library/Preferences/ in an XML file ending with .plist. Read for example these tutorials/docs: http://reviews.cnet.com/8301-13727_7-10332226-263.html and http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/UserPreferences.html and http://developer.apple.com/mac/library/documentation/CoreFoundation/Conceptual/CFPreferences/CFPreferences.html#//apple_ref/doc/uid/10000129i

First it seems difficult, but it boils down to simply using a small number of routines:

CFPreferencesCopyAppValue for reading
CFPreferencesSetAppValue and CFPreferencesAppSynchronize for saving preferences.

I hope I did not skip to much.

Your application should preferably also have a unique name. I would call mine:

de.schindler.myprogram

You may check this example with lots of error checking and alternative code for creating a similar XML file on windows and linux in my little programming exercise:

http://svn.berlios.de/svnroot/repos/heatwizard/trunk/UPreferenceData.pas
« Last Edit: August 23, 2010, 12:22:35 am by kamischi »
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Path to application
« Reply #16 on: August 23, 2010, 12:36:31 pm »
Does anybody have an alternative suggestion for storing preferences of a portable application (USB stickware)?

This should get you started: http://wiki.freepascal.org/Multiplatform_Programming_Guide#Data_and_resource_files

jwdietrich

  • Hero Member
  • *****
  • Posts: 1031
    • formatio reticularis
Re: Path to application
« Reply #17 on: August 23, 2010, 07:05:09 pm »
Unfortunatly, even when running on Mac OS X, Free Pascal does not support a behaviour that is compatible to the Apple Human Iterface Guidelines.

In order to cite kamischl's program and company name, the preferences file should have the name "de.schindler.myprogram.plist" in the User's Preferences directory (hence "~/Library/Preferences/de.schindler.myprogram.plist"), but rather, the standard Free pascal routines create a file like "~/.config/myprogram/myprogram.cfg".

Besides the fact that the preferences file has an unexpected name, it is located in an unexpected folder that is usually invisible from the Finder. This behaviour burdens the user unnecessarily.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.0.2 | FPC 3.0.4 | PPC, Intel, ARM | macOS, Windows, Linux

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Path to application
« Reply #18 on: August 23, 2010, 08:30:13 pm »
Unfortunatly, even when running on Mac OS X, Free Pascal does not support a behaviour that is compatible to the Apple Human Iterface Guidelines.
...
Besides the fact that the preferences file has an unexpected name, it is located in an unexpected folder that is usually invisible from the Finder. This behaviour burdens the user unnecessarily.

So why don't you send a patch with the fix?

kamischi

  • Full Member
  • ***
  • Posts: 177
Re: Path to application
« Reply #19 on: September 02, 2010, 09:17:00 am »
My 2 cents:

The storage of preferences is not the only point, where lazarus is not yet following the Apple Interface Guidelines. Other examples are the Lazarus menu, closing windows with Apple-W, all the stuff in the ~/.lazarus directory and probably many more. But from version to version it improved in huge steps even though man power is limited. Although it is not a perfect Mac application, Lazarus is already now a powerful tool for development on Mac OS X, in particular when it comes to cross-platform stuff.
fpc 2.6.4, lazarus 1.4.0, Mac OS X, fink