efl

Форк
0
/
elm_prefs_cc_handlers.c 
1217 строк · 28.9 Кб
1
/*
2
    Concerning the EPC reference:
3

4
    The formatting for blocks and properties has been implemented as a table
5
    which is filled using ALIASES.
6
    For maximum flexibility I implemented them in the \@code/\@encode style,
7
    this means that missing one or changing the order most certainly cause
8
    formatting errors.
9

10
    \@block
11
        block name
12
    \@context
13
        code sample of the block
14
    \@description
15
        the block's description
16
    \@endblock
17

18
    \@property
19
        property name
20
    \@parameters
21
        property's parameter list
22
    \@effect
23
        the property description (lol)
24
    \@endproperty
25
*/
26

27
#ifdef HAVE_CONFIG_H
28
# include "elementary_config.h"
29
#endif
30

31
#include <string.h>
32
#include <errno.h>
33
#include <sys/stat.h>
34
#include <fcntl.h>
35
#include <unistd.h>
36

37
#include "elm_prefs_cc.h"
38

39
void check_min_arg_count(int min_required_args);
40
int params_min_check(int n);
41

42
/**
43
 * @page epcref Elementary Prefs Data Collection Reference
44
 * An Elementary Prefs Collection is a plain text file (normally
45
 * identified with the .epc extension), consisting of instructions for the
46
 * Elm Prefs Compiler.
47
 *
48
 * The syntax for the elementary prefs data files follows a simple structure of
49
 * "blocks { .. }" that can contain "properties: ..", more blocks, or both.
50
 *
51
 * @anchor sec_quickaccess Quick access to block descriptions:
52
 * <ul>
53
 *    <li>@ref sec_page "Page"</li>
54
 *    <li>@ref sec_items "Items"</li>
55
 *    <ul>
56
 *      <li>@ref sec_items_bool "Bool"</li>
57
 *      <li>@ref sec_items_int "Int"</li>
58
 *      <li>@ref sec_items_float "Float"</li>
59
 *      <li>@ref sec_items_date "Date"</li>
60
 *      <li>@ref sec_items_text "Text"</li>
61
 *      <li>@ref sec_items_textarea "Text Area"</li>
62
 *    </ul>
63
 * </ul>
64
 *
65
 * @author Ricardo de Almeida Gonzaga (ricardotk) ricardo@profusion.mobi
66
 *
67
 * <table class="edcref" border="0">
68
 */
69

70
static Elm_Prefs_Page_Node *current_page = NULL;
71
static Elm_Prefs_Item_Node *current_item = NULL;
72

73
/* objects and statments */
74

75
/* Collection */
76
static void ob_collection(void);
77

78
/**
79
   @epcsection{page,Page}
80
 */
81

82
/**
83
    @page epcref
84
    @block
85
        page
86
    @context
87
        collection {
88
            ..
89
            page {
90
                name: "main";
91
                version: 1;
92
                title: "Preference Widgets";
93
                subtitle: "Subtitle";
94
                widget: "elm/vertical_frame";
95

96
                items { }
97
            }
98
            ..
99
        }
100
    @description
101
        A "page" block is a grouping of prefs items together. A prefs widget
102
        must always be bound to a page, that can address other pages in the
103
        collection too as @b sub-pages.
104
    @endblock
105

106
    @property
107
        name
108
    @parameters
109
        [page name]
110
    @effect
111
        The name of the page (to be referred by the application). It must be
112
        unique within the collection.
113
    @endproperty
114

115
    @property
116
        version
117
    @parameters
118
        [page version]
119
    @effect
120
        The page's version.
121
    @endproperty
122

123
    @property
124
        title
125
    @parameters
126
        [page title]
127
    @effect
128
        Set page's title.
129
    @endproperty
130

131
    @property
132
        subtitle
133
    @parameters
134
        [page subtitle]
135
    @effect
136
        Set page's subtitle.
137
    @endproperty
138

139
    @property
140
        widget
141
    @parameters
142
        [page widget]
143
    @effect
144
        Set the widget from among the available page widgets. Valid, built-in
145
        page widgets are:
146
            @li elm/horizontal_box
147
            @li elm/vertical_box
148
            @li elm/horizontal_frame
149
            @li elm/vertical_frame
150
    @endproperty
151

152
    @property
153
        style
154
    @parameters
155
        [page style]
156
    @effect
157
        Set page's style.
158
    @endproperty
159

160
    @property
161
        icon
162
    @parameters
163
        [page icon]
164
    @effect
165
        Set page's icon.
166
    @endproperty
167

168
    @property
169
        autosave
170
    @parameters
171
        [1 or 0]
172
    @effect
173
        Takes a boolean value specifying whether page is autosaved (1)
174
        or not (0). The default value is 1.
175
    @endproperty
176
*/
177

178
/* Page */
179
static void ob_collection_page(void);
180
static void st_collection_page_name(void);
181
static void st_collection_page_version(void);
182
static void st_collection_page_title(void);
183
static void st_collection_page_subtitle(void);
184
static void st_collection_page_widget(void);
185
static void st_collection_page_style(void);
186
static void st_collection_page_icon(void);
187
static void st_collection_page_autosave(void);
188

189
/**
190
   @epcsection{items,Items}
191
 */
192

193
/**
194
    @page epcref
195
    @block
196
        items
197
    @context
198
        page {
199
            ..
200
            items {
201
                name: "item";
202
                type: INT;
203
                label: "Just a item label...";
204

205
                type { }
206
            }
207
            ..
208
        }
209

210
    @description
211
        An "item" block declares a new Prefs item, along with its properties.
212
    @endblock
213

214
    @property
215
        name
216
    @parameters
217
        [item name]
218
    @effect
219
        The item's name, to be referred by the application. It must be unique
220
        within the page.
221
    @endproperty
222

223
    @property
224
        type
225
    @parameters
226
        [TYPE]
227
    @effect
228
        Set the type (all types must be entered in capitals) from among the
229
        available types, that are:
230
            @li BOOL - Checkbox.
231
            @li INT - Slider.
232
            @li FLOAT - Slider.
233
            @li DATE - Date/time display and input widget.
234
            @li TEXT - Single-line text entry.
235
            @li TEXTAREA - Text entry.
236
            @li LABEL - Read-only label.
237
            @li PAGE - Prefs subpage object.
238
            @li SEPARATOR - Line that serves only to divide and organize prefs
239
            item.
240
            @li SWALLOW - Swallows an Evas_Object.
241
            @li SAVE - Button that will get all the values bounded to items and
242
            save it on CFG file.
243
            @li ACTION - Button that will emit a signal to .C file and call a
244
            smart callback.
245
            @li RESET - Button that will return all the values bounded to items
246
            as default declared on .EPC file.
247
    @endproperty
248

249
    @property
250
        label
251
    @parameters
252
        [a string to label]
253
    @effect
254
        Set a string to item's label.
255
    @endproperty
256

257
    @property
258
        icon
259
    @parameters
260
        [item icon]
261
    @effect
262
        This is the item icon.
263
    @endproperty
264

265
    @property
266
        persistent
267
    @parameters
268
        [1 or 0]
269
    @effect
270
        Takes a boolean value specifying whether item is persistent (1) or
271
        not (0). The default value is 1. A non persistent item doesn't save
272
        its values when saved.
273
    @endproperty
274

275
    @property
276
        editable
277
    @parameters
278
        [1 or 0]
279
    @effect
280
        Takes a boolean value specifying whether item is editable (1)
281
        or not (0). The default value is 1.
282
    @endproperty
283

284
    @property
285
        visible
286
    @parameters
287
        [1 or 0]
288
    @effect
289
        Takes a boolean value specifying whether item is visible (1) or not (0).
290
        The default value is 1.
291
    @endproperty
292

293
    @property
294
        style
295
    @parameters
296
        [item style]
297
    @effect
298
        This is the item's style.
299
    @endproperty
300

301
    @property
302
        widget
303
    @parameters
304
        [item widget]
305
    @effect
306
        This is the item's widget, for cases where a widget differs than the
307
        default assigned to the type is desired.
308
    @endproperty
309
*/
310
/* Items */
311

312
static void ob_collection_page_items(void);
313

314
static void ob_collection_page_items_item(void);
315
static void st_collection_page_items_item_name(void);
316
static void st_collection_page_items_item_type(void);
317
static void st_collection_page_items_item_label(void);
318
static void st_collection_page_items_item_icon(void);
319
static void st_collection_page_items_item_persistent(void);
320
static void st_collection_page_items_item_editable(void);
321
static void st_collection_page_items_item_visible(void);
322
static void st_collection_page_items_item_source(void);
323
static void st_collection_page_items_item_style(void);
324
static void st_collection_page_items_item_widget(void);
325

326
/**
327
   @epcsection{items_bool,Bool item sub blocks}
328
 */
329

330
/**
331
    @page epcref
332

333
    @block
334
        bool
335
    @context
336
        item {
337
          ..
338
            bool {
339
                default: true;
340
            }
341
          ..
342
        }
343
    @description
344
    @endblock
345

346
    @property
347
        default
348
    @parameters
349
        [true or false]
350
    @effect
351
        Takes a boolean value specifying whether item is checked (true)
352
        or not (false).
353
    @endproperty
354
*/
355

356
/* Item: Bool */
357
static void ob_collection_page_items_item_bool(void);
358
static void st_collection_page_items_item_bool_default(void);
359

360
/**
361
   @epcsection{items_int,Int item sub blocks}
362
 */
363

364
/**
365
    @page epcref
366

367
    @block
368
        int
369
    @context
370
        item {
371
          ..
372
            int {
373
                default: 150;
374
                min: 0;
375
                max: 300;
376
            }
377
          ..
378
        }
379
    @description
380
    @endblock
381

382
    @property
383
        default
384
    @parameters
385
        [value]
386
    @effect
387
        Set a default (initial) value to the item.
388
    @endproperty
389

390
    @property
391
        min
392
    @parameters
393
        [value]
394
    @effect
395
        Set a minimum value to the item. Note that, without a minimum
396
        value, the widget implementing the item visually will get an
397
        available range of values bound to the minimum of the least
398
        integer number representable, and it might not be what you
399
        want.
400

401
    @endproperty
402

403
    @property
404
        max
405
    @parameters
406
        [value]
407
    @effect
408
        Set a maximum value to the item. Note that, without a maximum
409
        value, the widget implementing the item visually will get an
410
        available range of values bound to the maximum of the least
411
        integer number representable, and it might not be what you
412
        want.
413
    @endproperty
414
*/
415

416
/* Item: Integer */
417
static void ob_collection_page_items_item_int(void);
418
static void st_collection_page_items_item_int_default(void);
419
static void st_collection_page_items_item_int_max(void);
420
static void st_collection_page_items_item_int_min(void);
421

422
/**
423
   @epcsection{items_float,Float item sub blocks}
424
 */
425

426
/**
427
    @page epcref
428

429
    @block
430
        float
431
    @context
432
        item {
433
          ..
434
            float {
435
                default: 0.5;
436
                min: 0;
437
                max: 1;
438
            }
439
          ..
440
        }
441
    @description
442
    @endblock
443

444
    @property
445
        default
446
    @parameters
447
        [value]
448
    @effect
449
        Set a default (initial) value to the item.
450
    @endproperty
451

452
    @property
453
        min
454
    @parameters
455
        [value]
456
    @effect
457
        Set a minimum value to the item. Note that, without a minimum
458
        value, the widget implementing the item visually will get an
459
        available range of values bound to the minimum of the least
460
        floating point number representable, and it might not be what you
461
        want.
462
    @endproperty
463

464
    @property
465
        max
466
    @parameters
467
        [value]
468
    @effect
469
        Set a maximum value to the item. Note that, without a maximum
470
        value, the widget implementing the item visually will get an
471
        available range of values bound to the maximum of the least
472
        floating point number representable, and it might not be what you
473
        want.
474
    @endproperty
475
*/
476

477
/* Item: Float */
478
static void ob_collection_page_items_item_float(void);
479
static void st_collection_page_items_item_float_default(void);
480
static void st_collection_page_items_item_float_max(void);
481
static void st_collection_page_items_item_float_min(void);
482

483
/**
484
   @epcsection{items_date,Date item sub blocks}
485
 */
486

487
/**
488
    @page epcref
489

490
    @block
491
        date
492
    @context
493
        item {
494
          ..
495
            date {
496
                default: 2012 11 05;
497
                min: 1900 1 1;
498
                max: 2200 12 31;
499
            }
500
          ..
501
        }
502
    @description
503
    @endblock
504

505
    @property
506
        default
507
    @parameters
508
        [year month date] or "today"
509
    @effect
510
        Set a default (initial) date to the item. "today" will translate
511
        to current date.
512
    @endproperty
513

514
    @property
515
        min
516
    @parameters
517
        [year month date] or "today"
518
    @effect
519
        Set a minimum date to the item. "today" will translate
520
        to current date.
521
    @endproperty
522

523
    @property
524
        max
525
    @parameters
526
        [year month date] or "today"
527
    @effect
528
        Set a maximum date to the item. "today" will translate
529
        to current date.
530
    @endproperty
531
*/
532

533
/* Item: Date */
534
static void ob_collection_page_items_item_date(void);
535
static void st_collection_page_items_item_date_default(void);
536
static void st_collection_page_items_item_date_max(void);
537
static void st_collection_page_items_item_date_min(void);
538

539
/**
540
   @epcsection{items_text,Text item sub blocks}
541
 */
542

543
/**
544
    @page epcref
545

546
    @block
547
        text
548
    @context
549
        item {
550
          ..
551
            text {
552
                default: "Default text";
553
                placeholder: "Text:";
554
                accept: "^[a-zA-Z ]$";
555
                deny: "";
556
            }
557
          ..
558
        }
559
    @description
560
    @endblock
561

562
    @property
563
        default
564
    @parameters
565
        [a string of text]
566
    @effect
567
        Set a default text.
568
    @endproperty
569

570
    @property
571
        placeholder
572
    @parameters
573
        [a string of text]
574
    @effect
575
        Set a placeholder.
576
    @endproperty
577

578
    @property
579
        accept
580
    @parameters
581
        [regular expression]
582
    @effect
583
        Set an acceptance regular expression. It must be a valid one.
584
    @endproperty
585

586
    @property
587
        deny
588
    @parameters
589
        [regular expression]
590
    @effect
591
        Set a denial regular expression. It must be a valid one.
592
    @endproperty
593
*/
594

595
/**
596
   @epcsection{items_textarea,Text Area item sub blocks}
597
 */
598

599
/**
600
    @page epcref
601

602
    @block
603
        textarea
604
    @context
605
        item {
606
          ..
607
            textarea {
608
                default: "Default text";
609
                placeholder: "No Numbers!";
610
                accept: "";
611
                deny: "^[0-9]*$";
612
            }
613
          ..
614
        }
615
    @description
616
    @endblock
617

618
    @property
619
        default
620
    @parameters
621
        [a string of text]
622
    @effect
623
        Set a default text.
624
    @endproperty
625

626
    @property
627
        placeholder
628
    @parameters
629
        [a string of text]
630
    @effect
631
        Set a placeholder.
632
    @endproperty
633

634
    @property
635
        accept
636
    @parameters
637
        [regular expression]
638
    @effect
639
        Set an acceptance regular expression. It must be a valid one.
640
    @endproperty
641

642
    @property
643
        deny
644
    @parameters
645
        [regular expression]
646
    @effect
647
        Set a denial regular expression. It must be a valid one.
648
    @endproperty
649
*/
650

651
/* Item: Text and Text Area */
652
static void ob_collection_page_items_item_text(void);
653
static void ob_collection_page_items_item_textarea(void);
654

655
/* String shared statements */
656
static void st_collection_page_items_item_string_default(void);
657
static void st_collection_page_items_item_string_placeholder(void);
658
static void st_collection_page_items_item_string_accept(void);
659
static void st_collection_page_items_item_string_deny(void);
660
static void st_collection_page_items_item_string_max(void);
661
static void st_collection_page_items_item_string_min(void);
662

663
/* Statement Array */
664
New_Statement_Handler statement_handlers[] =
665
{
666
   {"collection.page.name", st_collection_page_name},
667
   {"collection.page.name", st_collection_page_name},
668
   {"collection.page.version", st_collection_page_version},
669
   {"collection.page.title", st_collection_page_title},
670
   {"collection.page.subtitle", st_collection_page_subtitle},
671
   {"collection.page.widget", st_collection_page_widget},
672
   {"collection.page.style", st_collection_page_style},
673
   {"collection.page.icon", st_collection_page_icon},
674
   {"collection.page.autosave", st_collection_page_autosave},
675

676
   {"collection.page.items.item.name", st_collection_page_items_item_name},
677
   {"collection.page.items.item.type", st_collection_page_items_item_type},
678
   {"collection.page.items.item.label", st_collection_page_items_item_label},
679
   {"collection.page.items.item.icon", st_collection_page_items_item_icon},
680
   {"collection.page.items.item.persistent", st_collection_page_items_item_persistent},
681
   {"collection.page.items.item.editable", st_collection_page_items_item_editable},
682
   {"collection.page.items.item.visible", st_collection_page_items_item_visible},
683
   {"collection.page.items.item.source", st_collection_page_items_item_source},
684
   {"collection.page.items.item.style", st_collection_page_items_item_style},
685
   {"collection.page.items.item.widget", st_collection_page_items_item_widget},
686

687
   {"collection.page.items.item.bool.default", st_collection_page_items_item_bool_default},
688

689
   {"collection.page.items.item.int.default", st_collection_page_items_item_int_default},
690
   {"collection.page.items.item.int.max", st_collection_page_items_item_int_max},
691
   {"collection.page.items.item.int.min", st_collection_page_items_item_int_min},
692

693
   {"collection.page.items.item.float.default", st_collection_page_items_item_float_default},
694
   {"collection.page.items.item.float.max", st_collection_page_items_item_float_max},
695
   {"collection.page.items.item.float.min", st_collection_page_items_item_float_min},
696

697
   {"collection.page.items.item.date.default", st_collection_page_items_item_date_default},
698
   {"collection.page.items.item.date.max", st_collection_page_items_item_date_max},
699
   {"collection.page.items.item.date.min", st_collection_page_items_item_date_min},
700

701
   {"collection.page.items.item.text.placeholder", st_collection_page_items_item_string_placeholder},
702
   {"collection.page.items.item.text.default", st_collection_page_items_item_string_default},
703
   {"collection.page.items.item.text.accept", st_collection_page_items_item_string_accept},
704
   {"collection.page.items.item.text.deny", st_collection_page_items_item_string_deny},
705
   {"collection.page.items.item.text.max", st_collection_page_items_item_string_max},
706
   {"collection.page.items.item.text.min", st_collection_page_items_item_string_min},
707

708
   {"collection.page.items.item.textarea.placeholder", st_collection_page_items_item_string_placeholder},
709
   {"collection.page.items.item.textarea.default", st_collection_page_items_item_string_default},
710
   {"collection.page.items.item.textarea.accept", st_collection_page_items_item_string_accept},
711
   {"collection.page.items.item.textarea.deny", st_collection_page_items_item_string_deny},
712
   {"collection.page.items.item.textarea.max", st_collection_page_items_item_string_max},
713
   {"collection.page.items.item.textarea.min", st_collection_page_items_item_string_min}
714
};
715

716
/* Object Array */
717
New_Object_Handler object_handlers[] =
718
{
719
   {"collection", ob_collection},
720
   {"collection.page", ob_collection_page},
721

722
   {"collection.page.items", ob_collection_page_items},
723
   {"collection.page.items.item", ob_collection_page_items_item},
724
   {"collection.page.items.item.bool", ob_collection_page_items_item_bool},
725
   {"collection.page.items.item.int", ob_collection_page_items_item_int},
726
   {"collection.page.items.item.float", ob_collection_page_items_item_float},
727
   {"collection.page.items.item.date", ob_collection_page_items_item_date},
728
   {"collection.page.items.item.text", ob_collection_page_items_item_text},
729
   {"collection.page.items.item.textarea", ob_collection_page_items_item_textarea}
730
};
731

732
int
733
object_handler_num(void)
734
{
735
   return (sizeof(object_handlers) / sizeof (New_Object_Handler));
736
}
737

738
int
739
statement_handler_num(void)
740
{
741
   return (sizeof(statement_handlers) / sizeof (New_Statement_Handler));
742
}
743

744
static void
745
ob_collection(void)
746
{
747
   // NULL
748
}
749

750
static void
751
ob_collection_page(void)
752
{
753
   current_page = mem_alloc(SZ(Elm_Prefs_Page_Node));
754
   if (current_page)
755
     elm_prefs_file->pages =
756
        eina_list_append(elm_prefs_file->pages, current_page);
757
}
758

759
static void
760
st_collection_page_name(void)
761
{
762
   check_arg_count(1);
763

764
   current_page->name = parse_str(0);
765

766
   //TODO: check for duplicated name entries.
767
}
768

769
static void
770
st_collection_page_version(void)
771
{
772
   check_arg_count(1);
773

774
   current_page->version = parse_int(0);
775
}
776

777
static void
778
st_collection_page_title(void)
779
{
780
   check_arg_count(1);
781

782
   current_page->title = parse_str(0);
783
}
784

785
static void
786
st_collection_page_subtitle(void)
787
{
788
   check_arg_count(1);
789

790
   current_page->sub_title = parse_str(0);
791
}
792

793
static void
794
st_collection_page_widget(void)
795
{
796
   check_arg_count(1);
797

798
   current_page->widget = parse_str(0);
799
}
800

801
static void
802
st_collection_page_style(void)
803
{
804
   check_arg_count(1);
805

806
   current_page->style = parse_str(0);
807
}
808

809
static void
810
st_collection_page_icon(void)
811
{
812
   check_arg_count(1);
813

814
   current_page->icon = parse_str(0);
815
}
816

817
static void
818
st_collection_page_autosave(void)
819
{
820
   check_arg_count(1);
821

822
   current_page->autosave = parse_bool(0);
823
}
824

825
static void
826
ob_collection_page_items(void)
827
{
828
   // NULL
829
}
830

831
static void
832
ob_collection_page_items_item(void)
833
{
834
   current_item = mem_alloc(SZ(Elm_Prefs_Item_Node));
835
   if (current_item)
836
     {
837
        current_item->visible = EINA_TRUE;
838
        current_item->persistent = EINA_TRUE;
839
        current_item->editable = EINA_TRUE;
840
        current_page->items =
841
          eina_list_append(current_page->items, current_item);
842
     }
843
}
844

845
static void
846
st_collection_page_items_item_name(void)
847
{
848
   check_arg_count(1);
849

850
   current_item->name = parse_str(0);
851
}
852

853
static void
854
st_collection_page_items_item_type(void)
855
{
856
   check_arg_count(1);
857

858
   current_item->type = parse_enum(0,
859
                                   "ACTION", ELM_PREFS_TYPE_ACTION,
860
                                   "BOOL", ELM_PREFS_TYPE_BOOL,
861
                                   "INT", ELM_PREFS_TYPE_INT,
862
                                   "FLOAT", ELM_PREFS_TYPE_FLOAT,
863
                                   "DATE", ELM_PREFS_TYPE_DATE,
864
                                   "LABEL", ELM_PREFS_TYPE_LABEL,
865
                                   "PAGE", ELM_PREFS_TYPE_PAGE,
866
                                   "TEXT", ELM_PREFS_TYPE_TEXT,
867
                                   "TEXTAREA", ELM_PREFS_TYPE_TEXTAREA,
868
                                   "RESET", ELM_PREFS_TYPE_RESET,
869
                                   "SAVE", ELM_PREFS_TYPE_SAVE,
870
                                   "SEPARATOR", ELM_PREFS_TYPE_SEPARATOR,
871
                                   "SWALLOW", ELM_PREFS_TYPE_SWALLOW,
872
                                   NULL);
873

874
   switch (current_item->type)
875
     {
876
      case ELM_PREFS_TYPE_ACTION:
877
      case ELM_PREFS_TYPE_LABEL:
878
      case ELM_PREFS_TYPE_RESET:
879
      case ELM_PREFS_TYPE_SEPARATOR:
880
      case ELM_PREFS_TYPE_SWALLOW:
881
        current_item->editable = EINA_FALSE;
882
        current_item->persistent = EINA_FALSE;
883
        break;
884

885
      case ELM_PREFS_TYPE_INT:
886
        current_item->spec.i.max = INT_MAX;
887
        current_item->spec.i.min = INT_MIN;
888
        break;
889

890
      case ELM_PREFS_TYPE_FLOAT:
891
        current_item->spec.f.max = FLT_MAX;
892
        current_item->spec.f.min = -FLT_MAX;
893
        break;
894

895
      case ELM_PREFS_TYPE_DATE:
896
      {
897
         time_t t = time(NULL);
898
         struct tm *lt = localtime(&t);
899

900
         current_item->spec.d.def.y = lt->tm_year + 1900;
901
         current_item->spec.d.def.m = lt->tm_mon + 1;
902
         current_item->spec.d.def.d = lt->tm_mday;
903

904
         current_item->spec.d.min.y = 1900;
905
         current_item->spec.d.min.m = 1;
906
         current_item->spec.d.min.d = 1;
907

908
         current_item->spec.d.max.y = 10000 - 1900;
909
         current_item->spec.d.max.m = 1;
910
         current_item->spec.d.max.d = 1;
911
      }
912
      break;
913

914
      case ELM_PREFS_TYPE_TEXT:
915
      case ELM_PREFS_TYPE_TEXTAREA:
916
        current_item->spec.s.length.max = INT_MAX;
917
        break;
918

919
      default:
920
        break;
921
     }
922
}
923

924
static void
925
st_collection_page_items_item_label(void)
926
{
927
   check_arg_count(1);
928

929
   current_item->label = parse_str(0);
930
}
931

932
static void
933
st_collection_page_items_item_icon(void)
934
{
935
   check_arg_count(1);
936

937
   current_item->icon = parse_str(0);
938
}
939

940
static void
941
st_collection_page_items_item_persistent(void)
942
{
943
   check_arg_count(1);
944

945
   current_item->persistent = parse_bool(0);
946
}
947

948
static void
949
st_collection_page_items_item_editable(void)
950
{
951
   check_arg_count(1);
952

953
   current_item->editable = parse_bool(0);
954
}
955

956
static void
957
st_collection_page_items_item_visible(void)
958
{
959
   check_arg_count(1);
960

961
   current_item->visible = parse_bool(0);
962
}
963

964
static void
965
st_collection_page_items_item_source(void)
966
{
967
   check_arg_count(1);
968

969
   current_item->spec.p.source = parse_str(0);
970
}
971

972
static void
973
st_collection_page_items_item_style(void)
974
{
975
   check_arg_count(1);
976

977
   current_item->style = parse_str(0);
978
}
979

980
static void
981
st_collection_page_items_item_widget(void)
982
{
983
   check_arg_count(1);
984

985
   current_item->widget = parse_str(0);
986
}
987

988
static void
989
ob_collection_page_items_item_bool(void)
990
{
991
   //TODO: check if current item type match
992
}
993

994
static void
995
st_collection_page_items_item_bool_default(void)
996
{
997
   check_arg_count(1);
998

999
   current_item->spec.b.def = parse_bool(0);
1000
}
1001

1002
static void
1003
ob_collection_page_items_item_int(void)
1004
{
1005
   //TODO: check if current item type match
1006
}
1007

1008
static void
1009
st_collection_page_items_item_int_default(void)
1010
{
1011
   check_arg_count(1);
1012

1013
   current_item->spec.i.def = parse_int(0);
1014
}
1015

1016
static void
1017
st_collection_page_items_item_int_max(void)
1018
{
1019
   check_arg_count(1);
1020

1021
   current_item->spec.i.max = parse_int(0);
1022
}
1023

1024
static void
1025
st_collection_page_items_item_int_min(void)
1026
{
1027
   check_arg_count(1);
1028

1029
   current_item->spec.i.min = parse_int(0);
1030
}
1031

1032
static void
1033
ob_collection_page_items_item_float(void)
1034
{
1035
   //TODO: check if current item type match
1036
}
1037

1038
static void
1039
st_collection_page_items_item_float_default(void)
1040
{
1041
   check_arg_count(1);
1042

1043
   current_item->spec.f.def = parse_float(0);
1044
}
1045

1046
static void
1047
st_collection_page_items_item_float_max(void)
1048
{
1049
   check_arg_count(1);
1050

1051
   current_item->spec.f.max = parse_float(0);
1052
}
1053

1054
static void
1055
st_collection_page_items_item_float_min(void)
1056
{
1057
   check_arg_count(1);
1058

1059
   current_item->spec.f.min = parse_float(0);
1060
}
1061

1062
static void
1063
ob_collection_page_items_item_date(void)
1064
{
1065
   //TODO: check if current item type match
1066
}
1067

1068
static void
1069
st_collection_page_items_item_date_default(void)
1070
{
1071
   check_min_arg_count(1);
1072

1073
   if (params_min_check(1))
1074
     {
1075
        check_arg_count(3);
1076

1077
        current_item->spec.d.def.y = parse_int_range(0, 1900, 10000);
1078
        current_item->spec.d.def.m = parse_int_range(1, 1, 12);
1079
        current_item->spec.d.def.d = parse_int_range(2, 1, 31);
1080
     }
1081
   else
1082
     {
1083
        const char *date = parse_str(0);
1084
        if (!strcasecmp(date, "today"))
1085
          {
1086
             time_t t = time(NULL);
1087
             struct tm *lt = localtime(&t);
1088

1089
             current_item->spec.d.def.y = lt->tm_year + 1900;
1090
             current_item->spec.d.def.m = lt->tm_mon + 1;
1091
             current_item->spec.d.def.d = lt->tm_mday;
1092
          }
1093
        free((void *)date);
1094
     }
1095
}
1096

1097
static void
1098
st_collection_page_items_item_date_max(void)
1099
{
1100
   check_min_arg_count(1);
1101

1102
   if (params_min_check(1))
1103
     {
1104
        check_arg_count(3);
1105

1106
        current_item->spec.d.max.y = parse_int_range(0, 1900, 10000);
1107
        current_item->spec.d.max.m = parse_int_range(1, 1, 12);
1108
        current_item->spec.d.max.d = parse_int_range(2, 1, 31);
1109
     }
1110
   else
1111
     {
1112
        const char *date = parse_str(0);
1113
        if (!strcasecmp(date, "today"))
1114
          {
1115
             time_t t = time(NULL);
1116
             struct tm *lt = localtime(&t);
1117

1118
             current_item->spec.d.max.y = lt->tm_year + 1900;
1119
             current_item->spec.d.max.m = lt->tm_mon + 1;
1120
             current_item->spec.d.max.d = lt->tm_mday;
1121
          }
1122
        free((void *)date);
1123
     }
1124
}
1125

1126
static void
1127
st_collection_page_items_item_date_min(void)
1128
{
1129
   check_min_arg_count(1);
1130

1131
   if (params_min_check(1))
1132
     {
1133
        check_arg_count(3);
1134

1135
        current_item->spec.d.min.y = parse_int_range(0, 1900, 10000);
1136
        current_item->spec.d.min.m = parse_int_range(1, 1, 12);
1137
        current_item->spec.d.min.d = parse_int_range(2, 1, 31);
1138
     }
1139
   else
1140
     {
1141
        const char *date = parse_str(0);
1142
        if (!strcasecmp(date, "today"))
1143
          {
1144
             time_t t = time(NULL);
1145
             struct tm *lt = localtime(&t);
1146

1147
             current_item->spec.d.min.y = lt->tm_year + 1900;
1148
             current_item->spec.d.min.m = lt->tm_mon + 1;
1149
             current_item->spec.d.min.d = lt->tm_mday;
1150
          }
1151
        free((void *)date);
1152
     }
1153
}
1154

1155
static void
1156
ob_collection_page_items_item_text(void)
1157
{
1158
   //TODO: check if current item type match
1159
}
1160

1161
static void
1162
ob_collection_page_items_item_textarea(void)
1163
{
1164
   //todo: check if current item type match
1165
}
1166

1167
static void
1168
st_collection_page_items_item_string_placeholder(void)
1169
{
1170
   check_arg_count(1);
1171

1172
   current_item->spec.s.placeholder = parse_str(0);
1173
}
1174

1175
static void
1176
st_collection_page_items_item_string_default(void)
1177
{
1178
   check_arg_count(1);
1179

1180
   current_item->spec.s.def = parse_str(0);
1181
}
1182

1183
static void
1184
st_collection_page_items_item_string_accept(void)
1185
{
1186
   check_arg_count(1);
1187

1188
   current_item->spec.s.accept = parse_str(0);
1189

1190
   check_regex(current_item->spec.s.accept);
1191
}
1192

1193
static void
1194
st_collection_page_items_item_string_deny(void)
1195
{
1196
   check_arg_count(1);
1197

1198
   current_item->spec.s.deny = parse_str(0);
1199

1200
   check_regex(current_item->spec.s.deny);
1201
}
1202

1203
static void
1204
st_collection_page_items_item_string_max(void)
1205
{
1206
   check_arg_count(1);
1207

1208
   current_item->spec.s.length.max = parse_int(0);
1209
}
1210

1211
static void
1212
st_collection_page_items_item_string_min(void)
1213
{
1214
   check_arg_count(1);
1215

1216
   current_item->spec.s.length.min = parse_int(0);
1217
}
1218

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.