Description Preferences

A .edc. file contains a collection with one or several page, holding items.

A page is a group of preferences. It has a name, a version number, a title and subtitle, and has a graphical representation (widget).

   page {
      name: "main";
      version: 1;
      title: "Main preferences";
      subtitle: "Some preferences";
      widget: "elm/vertical_box";

In this example, there is a page called ā€œmainā€, with a version code of 1, holding the preferences in a vertical box.

Then, a preference that holds an integer is added.

         item {
            name: "universe";
            type: INT;
            label: "Ultimate Answer of Life, the Universe and Everything";
            editable: 1;
            int {
               min: 0;
               max: 100;
               default: 42;
            }
         }

Here, an editable integer contains a value between 0 and 100, with a default value of 42. A label is attached to it.

The type of graphical interface presented to the user can be specified:

         item {
            name: "another";
            type: INT;
            label: "Spinner";
            widget: "elm/spinner";
            int {
               min: -50;
               max: 200;
            }
         }

If wanted, float values can be added too.

         item {
            name: "floating";
            type: FLOAT;
            editable: 1;
            label: "floating value";
            float {
               default: 0.6;
               min: 0;
               max: 1;
            }
         }

Boolean preferences can be represented as checkboxes.

         item {
            name: "boolean";
            type: BOOL;
            label: "Check here";
            bool {
               default: true;
            }
         }

Adding graphical-only items such as separators or label works the same way.

         item {
            name: "sep";
            type: SEPARATOR;
         }
         item {
            name: "label";
            type: LABEL;
            label: "Some other preferencesā€¦";
         }

It is possible to add a text entry. In the following example, we will have a placeholder text, and a default value. The deny section is filled with a regular expression that specifies what the user entered text should not match, otherwise refusing the entry.

         item {
            name: "text";
            type: TEXT;
            editable: 1;
            text {
               placeholder: "Enter some text here.";
               default: "default";
               deny: "^[0-9]*$";
            }
         }

For adding a date section, a minimum and maximum date can be set.

         item {
            name: "date";
            type: DATE;
            label: "First EFL Developer Day";
            date {
               default: 2012 11 05;
               min: 1980 11 1;
               max: 2200 12 2;
            }
         }

Let's say that display buttons are wanted to be displayed such as one to save, another one to reset the form back, and the last one to do some action. They are wanted to be shown in a horizontal box. A new page needs to be created to hold those items.

   page {
      name: "buttons";
      version: 1;
      title: "Actions";
      widget: "elm/horizontal_box";
      items {
         item {
            name: "save";
            type: SAVE;
            label: "Save";
         }
         item {
            name: "reset";
            type: RESET;
            label: "Reset";
         }
         item {
            name: "action";
            type: ACTION;
            label: "Action!";
         }
      }
   }

This page needs to be added to the main one.

         item {
            name: "buttons";
            type: PAGE;
            source: "buttons";
         }

Our preference collection is now complete, we now have to compile it using elm_prefs_cc preference.epc, which will generate a compiled preference.epb file. Our preference collenction is now complete, to compile it use elm_prefs_cc preference.epc which will generate a compiled preference.epb file.

The whole code__: preference.epc
next page__:
Preferences Code