.
[sfinx.git] / faraon / x11_ui.fl
blobea5d767427107d434ee0f08995892c16ea99b37d
1 # data file for the Fltk User Interface Designer (fluid)
2 version 1,0108 
3 i18n_type 1 
4 i18n_include <libintl.h> 
5 i18n_function gettext 
6 header_name {.H} 
7 code_name {.C}
8 decl {\#include <faraon.H>} {global
9
11 decl {\#include <FL/fl_ask.H>} {global
12
14 decl {\#include <FL/Fl_Preferences.H>} {global
15
17 decl {\#include <Flek/Fl_Toggle_Tree.H>} {global
18
20 decl {\#include <scroll.H>} {public global
21
23 decl {\#include "slice.xpm"} {} 
25 decl {\#include "note.xpm"} {} 
27 decl {\#include "file.xpm"} {} 
29 decl {Fl_Pixmap slice_pixmap(slice_xpm_data);} {} 
31 decl {Fl_Pixmap note_pixmap(note_xpm_data);} {} 
33 decl {Fl_Pixmap file_pixmap(file_xpm_data);} {} 
35 decl {Fl_Toggle_Tree *config_tree;} {global
36
38 decl {Fl_Toggle_Tree *slices_tree;} {global
39
41 decl {Fl_Toggle_Tree *select_slice_tree;} {global
42
44 decl {Fl_Toggle_Tree *notes_tree;} {global
45
47 decl {Fl_Toggle_Tree *files_tree;} {global
48
50 decl {Fl_Toggle_Tree *fill_tree;} {} 
52 decl {sfinx_slice_t *fill_tree_except;} {global
53
55 decl {u32_t fill_tree_mask;} {global
56
58 decl {sfinx_file_t current_file(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST);} {} 
60 Function {fill_objects_tree(Fl_Toggle_Tree *ft, u32_t m, sfinx_slice_t *except, bool force)} {private return_type void
61 } {
62   code {fill_tree = ft;
63 fill_tree_mask = m;
64 fill_tree_except = except;
65 app->refresh_slices(force);} {}
66
68 Function {relink_slice_action()} {private return_type void
69 } {
70   code {sfinx_slice_t slice(SFINX_SLICE_RELINK);
71 // slice to be relinked
72 Fl_Toggle_Node *node = slices_tree->selected();
73 if (!node)
74         return;
75 Fl_Toggle_Node *snode = select_slice_tree->selected();
76 if (!snode)
77         return;
78 sfinx_slice_t *selected = (sfinx_slice_t *)snode->user_data();
79 sfinx_slice_t *rslice = (sfinx_slice_t *)node->user_data();
80 slice.id = rslice->id;
81 // new parent id
82 slice.parent_id = selected->id;
83 debug("moving from %lld to %lld", rslice->parent_id, selected->id);
84 app->sfinx.send(slice);
85 fill_objects_tree(slices_tree, SFINX_SLICE_OBJECT, 0, 1); // force refresh} {}
86
88 Function {select_note_atag_action()} {private return_type void
89 } {
90   code {sfinx_object_t *obj;
91 Fl_Toggle_Node *node = slices_tree->selected();
92 if (!node)
93         return;
94 if (node->can_open()) // slice
95         obj = ((sfinx_slice_t *)node->user_data())->object();
96 else // object
97         obj = (sfinx_object_t *)node->user_data();
98 Fl_Toggle_Node *snode = notes_tree->selected();
99 sfinx_object_t *sobj = (sfinx_object_t *)snode->user_data();
100 if (sobj == obj) // try to self tag
101         return;
102 if (note_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)note_mtag_b->user_data())) // already set as main tag
103         return;
104 for (int i = 1; i <= note_tags_br->size(); i++) {
105         if (!obj->cmp((sfinx_object_t *)note_tags_br->data(i))) // already set as additional tag
106                 return;
108 string s = obj->name + " [ " + obj->description + " ]";
109 note_tags_br->add(s.c_str(), obj);
110 note_tags_br->redraw();} {}
113 Function {select_note_mtag_action()} {private return_type void
114 } {
115   code {sfinx_object_t *obj;
116 Fl_Toggle_Node *node = slices_tree->selected();
117 if (!node)
118         return;
119 if (node->can_open()) // slice
120         obj = ((sfinx_slice_t *)node->user_data())->object();
121 else // object
122         obj = (sfinx_object_t *)node->user_data();
123 Fl_Toggle_Node *snode = notes_tree->selected();
124 sfinx_object_t *sobj = (sfinx_object_t *)snode->user_data();
125 if (sobj == obj) // try to self tag
126         return;
127 note_mtag_b->user_data(obj);
128 note_mtag_b->copy_label((obj->name + " [ " + obj->description + " ]").c_str());
129 note_mtag_b->redraw();
130 // check for additional slices if it is here - remove it
131 for (int i = 1; i <= note_tags_br->size(); i++) {
132         if (!obj->cmp((sfinx_object_t *)note_tags_br->data(i))) {
133                 note_tags_br->remove(i);
134                 return;
135         }
136 }} {}
139 Function {select_file_mtag_action()} {open private return_type void
140 } {
141   code {sfinx_object_t *obj;
142 Fl_Toggle_Node *node = select_slice_tree->selected();
143 if (!node)
144         return;
145 if (node->can_open()) // slice
146         obj = ((sfinx_slice_t *)node->user_data())->object();
147 else // object
148         obj = (sfinx_object_t *)node->user_data();
149 file_mtag_b->user_data(obj);
150 file_mtag_b->copy_label((obj->name + " [ " + obj->description + " ]").c_str());
151 file_mtag_b->redraw();
152 // check for additional tags if it is here - remove it
153 for (int i = 1; i <= file_tags_br->size(); i++) {
154         if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) {
155                 file_tags_br->remove(i);
156                 return;
157         }
158 }} {}
161 Function {select_file_atag_action()} {open private return_type void
162 } {
163   code {sfinx_object_t *obj;
164 Fl_Toggle_Node *node = select_slice_tree->selected();
165 if (!node)
166         return;
167 string s;
168 if (node->can_open()) { // slice
169         obj = ((sfinx_slice_t *)node->user_data())->object();
170         s = obj->name + " [ " + obj->description + " ]";
171 } else { // object
172         obj = (sfinx_object_t *)node->user_data();
173         s = obj->name + obj->description;
175 if (file_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)file_mtag_b->user_data())) // already set as main tag
176         return;
177 for (int i = 1; i <= file_tags_br->size(); i++) {
178         if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) // already set as additional tag
179                 return;
181 file_tags_br->add(s.c_str(), obj);
182 file_tags_br->redraw();} {}
185 Function {search_add_slice_action()} {private return_type void
186 } {
187   code {for (int i = 1; i <= search_slices_br->size(); i++) {
188 //      if (search_slices_br->data(i) == to_voidp(current_slice_id))
189 //              return;
191 //sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data();
192 //search_slices_br->add(slice->name(), to_voidp(current_slice_id));
193 search_slices_br->redraw();} {}
196 Function {slices_tree_cb(Fl_Widget *, void *)} {private return_type void
197 } {
198   code {Fl_Toggle_Node *node = slices_tree->selected();
199 if (!node)
200         return;
201 if (!Fl::event_clicks())
202         return;
203 void (*select_slice_action)(void) = (void (*)())(slices_w->user_data());
204 if (select_slice_action) {
205         slices_w->hide();
206         slices_w->user_data(0);
207         select_slice_action();
208 }} {}
211 Function {notes_tree_cb(Fl_Widget *, void *)} {private return_type void
212 } {
213   code {Fl_Toggle_Node *node = notes_tree->selected();
214 if (!node)
215         return;
216 //current_note_id = from_voidp(node->user_data());
217 //current_slice_name = node->label();
218 if (!Fl::event_clicks())
219         return;
220 void (*select_note_action)(void) = (void (*)())(notes_w->user_data());
221 if (select_note_action) {
222         notes_w->user_data(0);
223         select_note_action();
224 }} {}
227 Function {files_tree_cb(Fl_Widget *, void *)} {private return_type void
228 } {
229   code {Fl_Toggle_Node *node = files_tree->selected();
230 if (!node)
231         return;
232 if (!Fl::event_clicks())
233         return;
234 void (*select_file_action)(void) = (void (*)())(files_module_w->user_data());
235 if (select_file_action) {
236         files_module_w->user_data(0);
237         select_file_action();
238 }} {}
241 Function {select_slice_tree_cb(Fl_Widget *, void *)} {private return_type void
242 } {
243   code {if (!Fl::event_clicks())
244         return;
245 select_slice_b->do_callback();} {}
248 Function {write_preferences()} {private return_type void
249 } {
250   code {app->server_name = config_sfinx_server_name_i->value();
251 app->files_module_conf.clear();
252 app->files_module_conf.add(FILES_MODULE_UNSORTED_PATH,
253         config_files_module_unsorted_path_i->value());
254 app->files_module_conf.add(FILES_MODULE_SORTED_TREE_PATH,
255         config_files_module_sorted_path_i->value());
256 app->files_module_conf.add(FILES_MODULE_DESC_FILE_NAME,
257         config_files_module_desc_file_name_i->value());
258 app->files_module_conf.add(FILES_MODULE_DESC_FILE_ENABLE,
259         gen_desc_files_b->value());
260 app->write_preferences();} {}
263 Function {config_tree_cb(Fl_Widget *, void *)} {private return_type void
264 } {
265   code {static Fl_Group *prev_group;
266 Fl_Toggle_Node *node = config_tree->selected();
267 if (node) {
268         Fl_Group *gr = *((Fl_Group **)(node->user_data()));
269         if (prev_group)
270                 prev_group->hide();
271         prev_group = gr;
272          gr->show();
273 //config_tree->unselect();
274  }} {}
277 Function {fill_config_tree()} {private return_type void
278 } {
279   code {config_tree->add_next("Connection", 0, 0, (void *)&config_connection_gr);
280 config_tree->add_next("Files Module", 0, 0, (void *)&config_files_module_gr);
281 config_tree->add_next("Confirmation", 0, 0, (void *)&config_confirmation_gr);
282 config_tree->callback(config_tree_cb);
283 config_tree->edit_on_reselect(0);} {}
286 Function {x11_ui::init()} {open return_type void
287 } {
288   Fl_Window main_w {
289     label Faraon
290     callback {if (fl_choice("Really quit ?", "No", "Yes", 0L))
291         F::shutdown(0);} open
292     xywh {171 126 945 365} type Double hide
293   } {
294     Fl_Menu_Bar {} {open
295       xywh {0 0 945 22}
296     } {
297       Submenu {} {
298         label Connection
299         xywh {0 0 67 22} labeltype ENGRAVED_LABEL
300       } {
301         MenuItem {} {
302           label {Connect to ...}
303           xywh {0 0 34 22} shortcut 0x80063 labeltype ENGRAVED_LABEL deactivate
304         }
305         MenuItem {} {
306           label {Connect to default server}
307           xywh {10 10 34 22} labeltype ENGRAVED_LABEL deactivate
308         }
309         MenuItem {} {
310           label {Disconnect from Sfinx}
311           xywh {10 10 34 22} labeltype ENGRAVED_LABEL deactivate
312         }
313         MenuItem {} {
314           label {Connection Info}
315           xywh {20 20 34 22} shortcut 0x80069 labeltype ENGRAVED_LABEL deactivate
316         }
317         MenuItem {} {
318           label {Sfinx Stat}
319           xywh {30 30 34 22} labeltype ENGRAVED_LABEL deactivate divider
320         }
321         MenuItem {} {
322           label Preferences
323           callback {app->read_preferences();
324 config_sfinx_server_name_i->value(app->server_name.c_str());
325 preferences_w->show();}
326           xywh {30 30 34 22} shortcut 0x80070 labeltype ENGRAVED_LABEL divider
327         }
328         MenuItem {} {
329           label Exit
330           callback {if (fl_choice("Really quit ?", "No", "Yes", 0L))
331         F::shutdown(0);}
332           xywh {20 20 34 22} shortcut 0x80078 labeltype ENGRAVED_LABEL
333         }
334       }
335       Submenu {} {
336         label Modules open
337         xywh {10 10 67 22} labeltype ENGRAVED_LABEL
338       } {
339         MenuItem {} {
340           label {AI Module}
341           callback {if (!app->connected()) {
342  fl_message("Not connected to Sfinx Server !");
343  return;
345           xywh {10 10 34 22} shortcut 0x61 labeltype ENGRAVED_LABEL deactivate
346         }
347         MenuItem {} {
348           label Slices
349           callback {if (!app->connected()) {
350  fl_message("Not connected to Sfinx Server !");
351  return;
353 fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 0); // fluid bugs if any default params exists !
354 slices_w->show();}
355           xywh {10 10 34 22} shortcut 0x73 labeltype ENGRAVED_LABEL
356         }
357         MenuItem {} {
358           label {Knowledge Module}
359           callback {if (!app->connected()) {
360  fl_message("Not connected to Sfinx Server !");
361  return;
363           xywh {40 40 34 22} shortcut 0x6b labeltype ENGRAVED_LABEL deactivate
364         }
365         MenuItem {} {
366           label Tasks
367           callback {if (!app->connected()) {
368  fl_message("Not connected to Sfinx Server !");
369  return;
371           xywh {40 40 34 22} shortcut 0x74 labeltype ENGRAVED_LABEL deactivate
372         }
373         MenuItem {} {
374           label Messages
375           callback {if (!app->connected()) {
376  fl_message("Not connected to Sfinx Server !");
377  return;
379           xywh {40 40 34 22} shortcut 0x6d labeltype ENGRAVED_LABEL deactivate
380         }
381         MenuItem {} {
382           label Contacts
383           callback {if (!app->connected()) {
384  fl_message("Not connected to Sfinx Server !");
385  return;
387           xywh {50 50 34 22} shortcut 0x63 labeltype ENGRAVED_LABEL deactivate
388         }
389         MenuItem {} {
390           label Events
391           callback {if (!app->connected()) {
392  fl_message("Not connected to Sfinx Server !");
393  return;
395           xywh {40 40 34 22} shortcut 0x65 labeltype ENGRAVED_LABEL deactivate
396         }
397         MenuItem {} {
398           label Files
399           callback {if (!app->connected()) {
400  fl_message("Not connected to Sfinx Server !");
401  return;
403 if (app->sfinx.send(current_file))
404   return;
405 files_module_w->show();}
406           xywh {20 20 34 22} shortcut 0x66 labeltype ENGRAVED_LABEL
407         }
408         MenuItem {} {
409           label Notes
410           callback {if (!app->connected()) {
411  fl_message("Not connected to Sfinx Server !");
412  return;
414 // ÒÉÓÕÅÍ ÄÅÒÅ×Ï ÚÁÍÅÔÏË
415 fill_objects_tree(notes_tree, 1 << SFINX_NOTE_OBJECT, 0, 0); // fluid bugs if any default params exists !
416 notes_w->show();}
417           xywh {30 30 34 22} shortcut 0x6e labeltype ENGRAVED_LABEL
418         }
419       }
420       Submenu {} {
421         label Tools open
422         xywh {20 20 67 22} labeltype ENGRAVED_LABEL
423       } {
424         MenuItem search_mi {
425           label {Browser && Searcher}
426           callback {if (!app->connected()) {
427  fl_message("Not connected to Sfinx Server !");
428  return;
430 search_i->take_focus();
431 search_w->show();}
432           xywh {30 30 34 22} shortcut 0x62 labeltype ENGRAVED_LABEL
433         }
434         MenuItem {} {
435           label Reader
436           callback {if (!app->connected()) {
437  fl_message("Not connected to Sfinx Server !");
438  return;
440           xywh {30 30 34 22} shortcut 0x72 labeltype ENGRAVED_LABEL deactivate divider
441         }
442         MenuItem {} {
443           label {AI Tracer}
444           callback {if (!app->connected()) {
445  fl_message("Not connected to Sfinx Server !");
446  return;
448           xywh {40 40 34 22} shortcut 0x40061 labeltype ENGRAVED_LABEL deactivate
449         }
450         MenuItem {} {
451           label {Knowledge Tracer}
452           callback {if (!app->connected()) {
453  fl_message("Not connected to Sfinx Server !");
454  return;
456           xywh {40 40 34 22} shortcut 0x4006b labeltype ENGRAVED_LABEL deactivate
457         }
458         MenuItem {} {
459           label {Indexing machine}
460           callback {if (!app->connected()) {
461  fl_message("Not connected to Sfinx Server !");
462  return;
464           xywh {30 30 34 22} shortcut 0x40069 labeltype ENGRAVED_LABEL deactivate
465         }
466         MenuItem {} {
467           label {Check Sfinx DB}
468           callback {if (!app->connected()) {
469  fl_message("Not connected to Sfinx Server !");
470  return;
472           xywh {40 40 34 22} shortcut 0x40064 labeltype ENGRAVED_LABEL deactivate
473         }
474         MenuItem {} {
475           label {DB Backups}
476           callback {if (!app->connected()) {
477  fl_message("Not connected to Sfinx Server !");
478  return;
480           xywh {30 30 34 22} shortcut 0x40062 labeltype ENGRAVED_LABEL deactivate divider
481         }
482         MenuItem {} {
483           label {Clear log window}
484           callback {log_br->clear();}
485           xywh {30 30 34 22} shortcut 0x10063 labeltype ENGRAVED_LABEL
486         }
487       }
488       Submenu {} {
489         label {                                                                                                                                                                 } open
490         xywh {20 20 67 22} labeltype ENGRAVED_LABEL deactivate
491       } {}
492       Submenu {} {
493         label Help
494         xywh {20 20 67 22} labeltype ENGRAVED_LABEL
495       } {
496         MenuItem {} {
497           label {Manual     }
498           xywh {30 30 34 22} shortcut 0xffbe labeltype ENGRAVED_LABEL deactivate divider
499         }
500         MenuItem {} {
501           label About
502           callback {about_w->show();}
503           xywh {30 30 34 22} shortcut 0x80061 labeltype ENGRAVED_LABEL
504         }
505       }
506     }
507     Fl_Output status_bar_o {
508       tooltip Status xywh {0 347 945 20} box PLASTIC_UP_BOX color 31 deactivate
509     }
510     Fl_Browser log_br {
511       xywh {-1 21 948 326} type Select color 31 labelfont 4 textfont 4
512     }
513   }
514   Fl_Window preferences_w {
515     label Preferences
516     xywh {215 308 742 373} type Double color 31 hide
517   } {
518     Fl_Button {} {
519       label Cancel
520       callback {preferences_w->hide();}
521       xywh {390 330 112 25} labeltype ENGRAVED_LABEL
522     }
523     Fl_Button {} {
524       label Apply
525       callback {write_preferences();
526 preferences_w->hide();}
527       xywh {572 330 112 25} labeltype ENGRAVED_LABEL
528     }
529     Fl_Scroll prefs_tree_scroll {
530       xywh {10 29 173 283} type VERTICAL_ALWAYS box ENGRAVED_FRAME color 28
531       code0 {config_tree = new Fl_Toggle_Tree(12, 12, prefs_tree_scroll->w() - prefs_tree_scroll->scrollbar.w(), 10);}
532       code1 {fill_config_tree();}
533     } {}
534     Fl_Group config_connection_gr {open
535       xywh {183 19 535 283} box ENGRAVED_FRAME hide
536     } {
537       Fl_Input config_sfinx_server_name_i {
538         label {Sfinx Server Name}
539         xywh {273 89 375 26} color 29 labeltype ENGRAVED_LABEL align 1
540       }
541       Fl_Choice {} {
542         label {Minimum Auth Level}
543         xywh {227 179 211 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 5 deactivate
544       } {
545         MenuItem {} {
546           label {User Name && Passsword}
547           xywh {0 0 35 22}
548         }
549         MenuItem {} {
550           label {RSA Key}
551           xywh {10 10 35 22}
552         }
553       }
554       Fl_Choice {} {
555         label {Minimum Debug Level}
556         xywh {227 230 211 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 5 deactivate
557       } {
558         MenuItem {} {
559           label {Debug Level}
560           xywh {10 10 35 22}
561         }
562         MenuItem {} {
563           label {Chat Level}
564           xywh {20 20 35 22}
565         }
566         MenuItem {} {
567           label {Info Level}
568           xywh {20 20 35 22}
569         }
570         MenuItem {} {
571           label {Notice Level}
572           xywh {30 30 35 22}
573         }
574         MenuItem {} {
575           label {Warning Level}
576           xywh {30 30 35 22}
577         }
578         MenuItem {} {
579           label {Error Level}
580           xywh {40 40 35 22}
581         }
582         MenuItem {} {
583           label {Alert Level}
584           xywh {40 40 35 22}
585         }
586         MenuItem {} {
587           label {Critical Level}
588           xywh {50 50 35 22}
589         }
590         MenuItem {} {
591           label {Fatal Level}
592           xywh {60 60 35 22}
593         }
594       }
595       Fl_Choice {} {
596         label {Minimum Crypt Level}
597         xywh {476 179 211 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 5 deactivate
598       } {
599         MenuItem {} {
600           label {Plain Stream}
601           xywh {10 10 35 22}
602         }
603         MenuItem {} {
604           label {AES Stream}
605           xywh {20 20 35 22}
606         }
607       }
608     }
609     Fl_Group config_files_module_gr {
610       xywh {193 29 535 283} box ENGRAVED_FRAME hide
611     } {
612       Fl_Input config_files_module_unsorted_path_i {
613         label {Unsorted files path on Sfinx server}
614         xywh {283 68 375 26} color 29 labeltype ENGRAVED_LABEL align 1
615       }
616       Fl_Input config_files_module_sorted_path_i {
617         label {Sorted file tree path on Sfinx server}
618         xywh {283 128 375 26} color 29 labeltype ENGRAVED_LABEL align 1
619       }
620       Fl_Check_Button gen_desc_files_b {
621         label {Generate description files}
622         xywh {209 233 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16
623       }
624       Fl_Input config_files_module_desc_file_name_i {
625         label {Description file name}
626         xywh {283 189 375 26} color 29 labeltype ENGRAVED_LABEL align 1
627       }
628       Fl_Check_Button process_files_mime_type_b {
629         label {Detect files MIME type}
630         xywh {472 233 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16
631       }
632     }
633     Fl_Group config_confirmation_gr {
634       xywh {183 19 535 283} box ENGRAVED_FRAME hide
635     } {
636       Fl_Check_Button exit_confirm_b {
637         label {Exit confirm}
638         xywh {216 45 204 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL deactivate
639       }
640     }
641   }
642   Fl_Window select_slice_w {
643     label {Select Sfinx Slice}
644     xywh {67 62 730 352} type Double color 31 hide modal
645   } {
646     Fl_Button {} {
647       label Cancel
648       callback {select_slice_w->hide();}
649       xywh {594 312 112 25} box PLASTIC_UP_BOX labeltype ENGRAVED_LABEL
650     }
651     Fl_Button select_slice_b {
652       label Select
653       callback {Fl_Toggle_Node *node = select_slice_tree->selected();
654 if (!node)
655         return;
656 void (*select_slice_action)() = (void (*)())(select_slice_w->user_data());
657 if (select_slice_action) {
658         select_slice_w->user_data(0);
659         select_slice_action();
661 select_slice_w->hide();}
662       xywh {16 312 548 25} box PLASTIC_UP_BOX labeltype ENGRAVED_LABEL
663     }
664     Fl_Scroll select_slice_tree_scroll {open
665       xywh {15 15 702 280} box ENGRAVED_FRAME color 28
666       code0 {select_slice_tree = new Fl_Toggle_Tree(12, 12, select_slice_tree_scroll->w(), 10);}
667       code1 {select_slice_tree->callback(select_slice_tree_cb);select_slice_tree->user_data((void *)select_slice_tree_scroll);}
668       code2 {select_slice_w->resizable(select_slice_tree_scroll);}
669       code3 {select_slice_tree_scroll->resizable(select_slice_tree);}
670       class Fl_Scroll_Resize
671     } {}
672   }
673   Fl_Window slices_w {
674     label {Sfinx Data}
675     xywh {200 315 866 370} type Double color 31 hide modal
676   } {
677     Fl_Button {} {
678       label Cancel
679       callback {slices_w->hide();}
680       xywh {734 312 112 25} labeltype ENGRAVED_LABEL
681     }
682     Fl_Button {} {
683       label {Delete slice}
684       callback {Fl_Toggle_Node *node = slices_tree->selected();
685 if (!node)
686         return;
687 sfinx_slice_t *slice = (sfinx_slice_t *)node->user_data();
688 if (slice->id == 1) // Root Slice can't be deleted
689         return;
690 // set safe deletion mode
691 slice_deletion_type_ch->value(0);
692 data_deletion_type_ch->value(0);
693 delete_sfinx_slice_to->value(slice->name());
694 delete_slice_w->show();}
695       xywh {454 312 128 25} labeltype ENGRAVED_LABEL
696     }
697     Fl_Scroll slices_tree_scroll {
698       xywh {15 13 837 280} box ENGRAVED_FRAME color 28
699       code0 {slices_tree = new Fl_Toggle_Tree(12, 12, slices_tree_scroll->w(), 10);}
700       code1 {slices_tree->callback(slices_tree_cb); slices_tree->user_data((void *)slices_tree_scroll);}
701       code2 {slices_w->resizable(slices_tree_scroll);}
702       code3 {slices_tree_scroll->resizable(slices_tree);}
703       class Fl_Scroll_Resize
704     } {}
705     Fl_Button {} {
706       label {Edit slice}
707       callback {Fl_Toggle_Node *node = slices_tree->selected();
708 if (!node)
709         return;
710 sfinx_slice_t *slice = (sfinx_slice_t *)node->user_data();
711 edit_slice_w->user_data((void *)slice);
712 app->sfinx.send(SFINX_EDIT_SLICE_REQUEST, (u32_t)slice->id);
713 edit_slice_w->label("Edit Sfinx Slice");}
714       xywh {305 312 128 25} labeltype ENGRAVED_LABEL
715     }
716     Fl_Output slices_status_to {
717       xywh {0 349 866 21} box PLASTIC_UP_BOX color 31 deactivate
718     }
719     Fl_Button {} {
720       label {New slice}
721       callback {Fl_Toggle_Node *node = slices_tree->selected();
722 if (!node) {
723         fl_alert("Please select slice connection point !");
724         return;
726 edit_slice_w->user_data(0); // new slice
727 slice_name_i->value(0);
728 slice_directory_i->value(0);
729 slice_name_i->take_focus();
730 slice_description_i->value(0);
731 sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data();
732 edit_slice_to->value(string(string("Parent slice: ") + slice->name()).c_str());
733 edit_slice_w->label("New Sfinx Slice");
734 edit_slice_w->show();}
735       xywh {21 312 112 25} labeltype ENGRAVED_LABEL
736     }
737     Fl_Button {} {
738       label {Relink slice}
739       callback {Fl_Toggle_Node *node = slices_tree->selected();
740 if (!node)
741         return;
742 sfinx_slice_t *slice = (sfinx_slice_t *)node->user_data();
743 if (slice->id == 1) // root slice can't be relinked
744         return;
745 fill_objects_tree(select_slice_tree, SFINX_SLICE_OBJECT, slice, 0);
746 select_slice_w->user_data((void *)relink_slice_action);
747 select_slice_w->show();}
748       xywh {155 312 128 25} labeltype ENGRAVED_LABEL
749     }
750     Fl_Button {} {
751       label Search
752       callback {search_mi->do_callback(0, (void *)0);}
753       xywh {600 312 119 25} labeltype ENGRAVED_LABEL
754     }
755   }
756   Fl_Window edit_slice_w {
757     label {Edit Sfinx Slice}
758     xywh {276 319 595 330} type Double color 31 hide modal
759   } {
760     Fl_Input slice_name_i {
761       label {Slice Name}
762       xywh {47 35 496 26} color 29 labeltype ENGRAVED_LABEL align 1
763     }
764     Fl_Input slice_directory_i {
765       label {Slice Directory}
766       xywh {47 93 496 26} color 29 labeltype ENGRAVED_LABEL align 1
767     }
768     Fl_Input slice_description_i {
769       label {Slice Description}
770       xywh {34 158 523 89} type Multiline color 29 labeltype ENGRAVED_LABEL align 1
771     }
772     Fl_Return_Button {} {
773       label Ok
774       callback {if (!slice_name_i->size()) {
775         fl_message("Missing slice name !");
776         return;
778 sfinx_slice_t *eslice = (sfinx_slice_t *)edit_slice_w->user_data();
779 sfinx_slice_t slice;
780 if (eslice) {
781         slice.tid(SFINX_EDIT_SLICE);
782         slice.id = eslice->id; // edited slice id
783         slice.parent_id = eslice->parent_id;
784 } else {
785         slice.tid(SFINX_NEW_SLICE);
786         sfinx_slice_t *s =  (sfinx_slice_t *)(slices_tree->selected()->user_data());
787         slice.parent_id = s->id; // parent id for new slice
789 slice.name(slice_name_i->value());
790 slice.directory(slice_directory_i->value());
791 slice.description(slice_description_i->value());
792 app->sfinx.send(slice);
793 edit_slice_w->hide();
794 fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 1); // force refresh}
795       xywh {111 270 112 25} labeltype ENGRAVED_LABEL
796     }
797     Fl_Button {} {
798       label Cancel
799       callback {edit_slice_w->hide();}
800       xywh {359 270 112 25} labeltype ENGRAVED_LABEL
801     }
802     Fl_Output edit_slice_to {
803       xywh {0 312 598 21} box PLASTIC_UP_BOX color 31 labelsize 10 textsize 10
804     }
805   }
806   Fl_Window delete_slice_w {
807     label {Delete Sfinx Slice}
808     xywh {350 43 388 223} type Double color 31 hide modal
809   } {
810     Fl_Button {} {
811       label Cancel
812       callback {delete_slice_w->hide();}
813       xywh {238 175 112 25} labeltype ENGRAVED_LABEL
814     }
815     Fl_Button {} {
816       label Delete
817       callback {// need to confirm deletion ?!
818 bool recursivly = slice_deletion_type_ch->value();
819 sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data();
820 app->sfinx.send(data_deletion_type_ch->value() ?
821         (recursivly ? SFINX_DELETE_SLICE_ASSOC_DATA_RECURSIVLY : SFINX_DELETE_SLICE_ASSOC_DATA) :
822         (recursivly ? SFINX_DELETE_SLICE_MARK_DATA_UNSORTED_RECURSIVLY : SFINX_DELETE_SLICE_MARK_DATA_UNSORTED),
823         (u32_t)slice->id);
824 app->sfinx.send(recursivly ? SFINX_DELETE_SLICE_RECURSIVLY : SFINX_DELETE_SLICE_WITH_REATTACH,
825         (u32_t)slice->id);
826 delete_slice_w->hide();
827 fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 1); // force refresh}
828       xywh {39 175 112 25} labeltype ENGRAVED_LABEL
829     }
830     Fl_Output delete_sfinx_slice_to {
831       label {Please confirm deletion of the slice}
832       xywh {35 31 330 26} box ENGRAVED_FRAME color 29 labeltype ENGRAVED_LABEL align 1
833     }
834     Fl_Choice slice_deletion_type_ch {
835       label {Slice && Data Deletion Action}
836       xywh {73 82 240 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 1
837     } {
838       MenuItem {} {
839         label {Attach subslices to parent}
840         xywh {10 10 35 22}
841       }
842       MenuItem {} {
843         label {Delete all subslices recursivly}
844         xywh {20 20 35 22}
845       }
846     }
847     Fl_Choice data_deletion_type_ch {
848       label {Associated Data Deletion Action}
849       xywh {73 132 240 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 1
850     } {
851       MenuItem {} {
852         label {Mark all data 'Unsorted'}
853         xywh {20 20 35 22}
854       }
855       MenuItem {} {
856         label {Delete all data}
857         xywh {30 30 35 22}
858       }
859     }
860   }
861   Fl_Window progress_w {
862     label Progress
863     xywh {286 302 464 98} type Double hide
864   } {
865     Fl_Progress progress_bar {
866       label {67 %}
867       xywh {22 46 422 27} box PLASTIC_DOWN_BOX selection_color 2
868     }
869     Fl_Box progress_l {
870       label {Doing some work ...}
871       xywh {66 10 330 25} box FLAT_BOX labeltype ENGRAVED_LABEL
872     }
873   }
874   Fl_Window files_module_w {
875     label {Files Module} open
876     xywh {87 152 730 370} type Double color 31 hide resizable
877   } {
878     Fl_Button {} {
879       label Cancel
880       callback {files_module_w->hide();}
881       xywh {605 312 112 25} labeltype ENGRAVED_LABEL
882     }
883     Fl_Output files_module_status_to {
884       xywh {0 349 733 21} box PLASTIC_UP_BOX color 31
885     }
886     Fl_Button classify_file_b {
887       label Classify
888       callback {int n = files_module_tree_br->value();
889 if (!n)
890         return;
891 sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1];
892 string path;
893 app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path);
894 char buf[256];
895 int eyear, emonth, eday, ehour, emin, esec, cyear, cmonth, cday, chour, cmin, csec;
896 file->etime.GetDate(eyear, emonth, eday);
897 file->etime.GetTime(ehour, emin, esec);
898 file->ctime.GetDate(cyear, cmonth, cday);
899 file->ctime.GetTime(chour, cmin, csec);
900 sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file->fsize, cday, cmonth,
901         cyear, chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec);
902 string t = "URL: " + path + current_file.name + "/" + file->name + " | " + file->mimetype + " | Size: " + buf;
903 classify_file_to->value(t.c_str());
904 file_title_i->value(0);
905 file_name_i->value(file->name.c_str());
906 // save orig file name
907 file->orig_name = file->name;
908 file->tid(SFINX_FILES_MODULE_CLASSIFY_REQUEST); // new file
909 file_title_i->take_focus();
910 file_authority_i->value(0);
911 file_description_i->value(0);
912 file_comments_i->value(0);
913 sorted_location_b->value(1);
914 file_compress_b->value(1);
915 file_gen_csum_b->value(1);
916 file_mtag_b->label("Main Slice (Not Set)");
917 file_mtag_b->user_data(0); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ mtag
918 file_tags_br->clear();
919 classify_file_w->user_data((void *)file);
920 classify_file_w->show();}
921       xywh {21 312 112 25} labeltype ENGRAVED_LABEL
922     }
923     Fl_Button {} {
924       label Edit
925       callback {Fl_Toggle_Node *node = files_tree->selected();
926 if (!node || node->can_open()) {
927         fl_alert("Please select file to edit !");
928         return;
930 sfinx_object_t *obj = (sfinx_object_t *) node->user_data();
931 if (obj->type != SFINX_FILE_OBJECT)
932         bug();
933 sfinx_file_t file(SFINX_FILES_MODULE_EDIT_REQUEST);
934 file.id = obj->id;
935 app->sfinx.send(file);}
936       xywh {154 312 128 25} labeltype ENGRAVED_LABEL
937     }
938     Fl_Browser files_module_tree_br {
939       callback {if (!Fl::event_clicks())
940         return;
941 sfinx_files_vector_t *tree = (sfinx_files_vector_t *) files_module_tree_br->user_data();
942 int n = files_module_tree_br->value();
943 //debug("selected %s file", tree->files[n - 1]->url.c_str());
944 if (tree->files[n - 1]->is_directory) { // ÀÚÅÒ ÓÍÅÎÉÌ ÄÉÒÅËÔÏÒÉÀ
945         // × file_id ÈÒÁÎÉÔÓÑ id ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ-ÓÌÁÊÓÁ × ËÏÔÏÒÏÊ ÎÁÈÏÄÉÍÓÑ/×ÙÂÒÁÌÉ
946         // × mtag_id - parent_id ÄÉÒÅËÔÏÒÉÉ
947         // ÚÁÈÏÄÉÍ × ÄÉÒÅËÔÏÒÉÀ - ÔÅËÕÝÁÑ ÓÔÁÎÏ×ÉÔÓÑ parent'ÏÍ
948         current_file.id = tree->files[n - 1]->id;
949         current_file.mtag.id = tree->files[n - 1]->mtag.id;
950         // × name ÈÒÁÎÉÔÓÑ ×ÅÓØ ÐÕÔØ ÏÔ root location
951         // × orig_name ÔÏÌØËÏ ÉÍÑ ÔÅËÕÝÅÊ
952         string t = current_file.name.c_str();
953 //      current_file.orig_name = tree->files[n - 1]->name;
954         t += ('/' + tree->files[n - 1]->name);
955         current_file.name = t;
956         //debug("requesting dir %s", current_file.c_str());
957         app->sfinx.send(current_file);
958 } else {
959         if (!(tree->files[n - 1]->id)) // classify file
960                 classify_file_b->do_callback();
961         else {
962                 // app->sfinx.send(SFINX_SLICES_MODULE_TREE_REQUEST, (u8_t)0); // prepare for slice_name() calls
963                 sfinx_file_t *file = tree->files[n - 1];
964                 file->tid(SFINX_FILES_MODULE_EDIT_REQUEST);
965                 app->sfinx.send(file);
966         }
968       xywh {7 45 716 255} type Multi color 31 resizable
969       code0 {static int widths[] = { 10, 450, 200, 200, 0};}
970       code1 {files_module_tree_br->column_widths(widths);}
971     }
972     Fl_Button {} {
973       label Delete
974       callback {if (current_file.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) { // unsorted tree
975         int n = files_module_tree_br->value();
976         if (!n)
977                 return;
978         sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1];
979         string path;    // sure ?
980         string message = "Deleting ";
981         if (file->is_directory)
982                 message += "directory";
983         else
984                 message += "file";
985         message += (" \\'" + file->name + "\\'. Are you sure ?");
986         if (fl_choice(message.c_str(), "Yes", "No", 0L))
987                 return;
988         file->tid(SFINX_FILES_MODULE_UNSORTED_DELETE);
989         app->sfinx.send(file); // check for errors ?
990         app->sfinx.send(current_file);
991 } else { // sorted tree
992         Fl_Toggle_Node *node = files_tree->selected();
993         if (!node || node->can_open())
994                 return;
995         sfinx_object_t *obj = (sfinx_object_t *) node->user_data();
996         string message = "Delete or Unsort \\'" + obj->name + "\\' ?";
997         int res = fl_choice(message.c_str(), "Cancel", "Unsort", "Delete");
998         sfinx_file_t file;
999         file.id = obj->id;
1000         file.mtag.slice_id = obj->slice_id; 
1001         if (!res)
1002                 return;
1003         if (res == 2) // delete
1004                 file.tid(SFINX_FILES_MODULE_SORTED_UNLINK);
1005         else
1006                 file.tid(SFINX_FILES_MODULE_UNSORT);
1007         app->sfinx.send(file);
1008         fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists !
1011       xywh {300 312 112 25} labeltype ENGRAVED_LABEL
1012     }
1013     Fl_Button select_files_tree_b {
1014       label {Sorted tree}
1015       callback {current_file.name.clear();
1016 current_file.orig_name.clear();
1017 if (select_files_tree_b->user_data()) {
1018         current_file.tid(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST);
1019         current_file.id = 0;
1020         app->sfinx.send(current_file);
1021 } else {
1022         select_files_tree_b->user_data((void *)1);
1023         select_files_tree_b->label("Show Unsorted");
1024         select_files_tree_b->redraw();
1025         current_file.tid(0);
1026         current_file.id = 1; // root id
1027         fill_objects_tree(files_tree, 1 << SFINX_FILE_OBJECT, 0, 0); // fluid bugs if any default params exists !
1028         files_module_tree_br->hide();
1029         files_tree_scroll->show();
1031       xywh {562 10 128 25} labeltype ENGRAVED_LABEL
1032     }
1033     Fl_Button {} {
1034       label {Up [ .. ]}
1035       callback {const char *p = strrchr(current_file.name.c_str(), '/');
1036 if (!p) {
1037         if (!current_file.name.size())
1038                 return;
1039         current_file.name.clear();
1040 } else {
1041         char path[1024];
1042         path[0] = 0;
1043         strncat(path, current_file.name.c_str(), p - current_file.name.c_str());
1044         current_file.name = path;
1045         current_file.id = current_file.mtag.id;
1047 app->sfinx.send(current_file);}
1048       xywh {35 10 112 25} labeltype ENGRAVED_LABEL
1049     }
1050     Fl_Button {} {
1051       label Reload
1052       callback {app->sfinx.send(current_file);}
1053       xywh {166 10 112 25} labeltype ENGRAVED_LABEL
1054     }
1055     Fl_Button {} {
1056       label {Select All}
1057       callback {//for (int i = 1; i <= files_module_tree_br->size(); i++)
1058 //      files_module_tree_br->select(i);}
1059       xywh {295 10 112 25} labeltype ENGRAVED_LABEL
1060     }
1061     Fl_Button {} {
1062       label {Unselect All}
1063       callback {files_module_tree_br->deselect();}
1064       xywh {428 10 112 25} labeltype ENGRAVED_LABEL
1065     }
1066     Fl_Scroll files_tree_scroll {
1067       xywh {7 45 716 255} box ENGRAVED_FRAME color 28 hide
1068       code0 {files_tree = new Fl_Toggle_Tree(12, 12, files_tree_scroll->w(), 10);}
1069       code1 {files_tree->callback(files_tree_cb); files_tree->user_data((void *)files_tree_scroll);}
1070       code2 {files_module_w->resizable(files_tree_scroll);}
1071       code3 {files_tree_scroll->resizable(files_tree);}
1072       class Fl_Scroll_Resize
1073     } {}
1074   }
1075   Fl_Window classify_file_w {
1076     label {Classify File} open
1077     xywh {84 298 1020 515} type Double color 31 hide modal
1078   } {
1079     Fl_Button {} {
1080       label Cancel
1081       callback {classify_file_w->hide();}
1082       xywh {612 454 112 25} labeltype ENGRAVED_LABEL
1083     }
1084     Fl_Input file_title_i {
1085       label Title
1086       xywh {16 27 496 26} color 29 labeltype ENGRAVED_LABEL align 1
1087     }
1088     Fl_Input file_authority_i {
1089       label Authority
1090       xywh {16 83 496 26} color 29 labeltype ENGRAVED_LABEL align 1
1091     }
1092     Fl_Input file_description_i {
1093       label Description
1094       xywh {549 78 447 101} type Multiline color 29 labeltype ENGRAVED_LABEL align 1
1095     }
1096     Fl_Input file_comments_i {
1097       label Comments
1098       xywh {582 220 416 212} type Multiline color 29 labeltype ENGRAVED_LABEL align 1
1099     }
1100     Fl_Output classify_file_to {
1101       xywh {0 497 1022 21} box PLASTIC_UP_BOX color 31 labelsize 10 textsize 10
1102     }
1103     Fl_Return_Button {} {
1104       label Ok
1105       callback {if (!file_mtag_b->user_data()) {
1106         fl_alert("You have to select Main Slice for file !");
1107         return;
1109 if (!file_name_i->size()) {
1110         fl_alert("File must have some name !");
1111         return;
1113 sfinx_file_t *file = (sfinx_file_t *)classify_file_w->user_data();
1114 file->name = file_name_i->value();
1115 file->title = file_title_i->value();
1116 file->authority = file_authority_i->value();
1117 file->description = file_description_i->value();
1118 file->comments = file_comments_i->value();
1119 file->sorted_location = sorted_location_b->value();
1120 file->store_compressed = file_compress_b->value();
1121 file->generate_csum = file_gen_csum_b->value();
1122 sfinx_object_t *obj = (sfinx_object_t *)file_mtag_b->user_data();
1123 file->mtag.id = obj->id;
1124 file->mtag.type = obj->type;
1125 file->mtag.slice_id = obj->slice_id;
1126 file_mtag_b->user_data(0);
1127 file->tags.clear();
1128 for (int i = 1; i <= file_tags_br->size(); i++) {
1129         obj = (sfinx_object_t *)file_tags_br->data(i);
1130         file->tags.push_back(*obj);
1131         file_tags_br->data(i, 0);
1133 app->sfinx.send(file);}
1134       xywh {243 454 112 25} labeltype ENGRAVED_LABEL
1135     }
1136     Fl_Check_Button sorted_location_b {
1137       label {Sorted Location}
1138       xywh {15 132 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16
1139     }
1140     Fl_Check_Button file_crypt_b {
1141       label Encrypt
1142       xywh {15 165 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16 deactivate
1143     }
1144     Fl_Check_Button file_compress_b {
1145       label {Store compressed}
1146       xywh {274 132 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16
1147     }
1148     Fl_Box {} {
1149       xywh {13 205 552 227} box ENGRAVED_FRAME
1150     }
1151     Fl_Button file_mtag_b {
1152       label {Main Slice (Not Set)}
1153       callback {fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists !
1154 select_slice_w->user_data((void *)select_file_mtag_action);
1155 select_slice_w->show();}
1156       tooltip {File Main Slice} xywh {45 226 489 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1157     }
1158     Fl_Browser file_tags_br {
1159       label {Additional Slices}
1160       xywh {26 275 525 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1
1161     }
1162     Fl_Button file_add_tag_b {
1163       label {Add Slice}
1164       callback {fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists !
1165 select_slice_w->user_data((void *)select_file_atag_action);
1166 select_slice_w->show();}
1167       xywh {82 391 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1168     }
1169     Fl_Button file_remove_tag_b {
1170       label {Remove Slice}
1171       callback {for (int i = file_tags_br->size(); i >= 1; i--) {
1172         if (file_tags_br->selected(i))
1173                 file_tags_br->remove(i);
1175       xywh {358 391 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1176     }
1177     Fl_Input file_name_i {
1178       label {File Name}
1179       xywh {549 26 447 26} color 29 labeltype ENGRAVED_LABEL align 1
1180     }
1181     Fl_Check_Button file_gen_csum_b {
1182       label {Generate CSUM}
1183       xywh {274 165 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16
1184     }
1185   }
1186   Fl_Window notes_w {
1187     label {Notes Module}
1188     xywh {272 69 730 370} type Double color 31 resizable visible
1189   } {
1190     Fl_Button {} {
1191       label Cancel
1192       callback {notes_w->hide();}
1193       xywh {605 312 112 25} labeltype ENGRAVED_LABEL
1194     }
1195     Fl_Output notes_module_status_to {
1196       xywh {0 349 733 21} box PLASTIC_UP_BOX color 31
1197     }
1198     Fl_Button {} {
1199       label New
1200       callback {Fl_Toggle_Node *node = notes_tree->selected();
1201 if (!node) {
1202         fl_alert("Please select slice connection point !");
1203         return;
1205 sfinx_note_t *note = new sfinx_note_t(SFINX_NOTES_MODULE_ADD);
1206 edit_note_w->user_data((void *)note);
1207 sfinx_object_t *obj;
1208 if (node->can_open()) // slice
1209         obj = ((sfinx_slice_t *)node->user_data())->object();
1210 else // object
1211         obj = (sfinx_object_t *) node->user_data();
1212 note_mtag_b->user_data(obj);
1213 note_mtag_b->copy_label((obj->name + " [ " + obj->description + " ]").c_str()); 
1214 note_mtag_b->redraw();
1215 note_name_i->value(0);
1216 note_url_i->value(0);
1217 note_text_i->value(0);
1218 note_name_i->take_focus();
1219 edit_note_w->show();}
1220       xywh {21 312 112 25} labeltype ENGRAVED_LABEL
1221     }
1222     Fl_Button {} {
1223       label Edit
1224       callback {Fl_Toggle_Node *node = notes_tree->selected();
1225 if (!node || node->can_open()) {
1226         fl_alert("Please select note to edit !");
1227         return;
1229 sfinx_object_t *obj = (sfinx_object_t *) node->user_data();
1230 if (obj->type != SFINX_NOTE_OBJECT)
1231         bug();
1232 sfinx_note_t note(SFINX_NOTES_MODULE_EDIT_REQUEST);
1233 note.id = obj->id;
1234 app->sfinx.send(note);}
1235       xywh {154 312 128 25} labeltype ENGRAVED_LABEL
1236     }
1237     Fl_Scroll notes_tree_scroll {
1238       xywh {13 10 705 289} box ENGRAVED_FRAME color 28
1239       code0 {notes_tree = new Fl_Toggle_Tree(12, 12, notes_tree_scroll->w(), 10);}
1240       code1 {notes_tree->callback(notes_tree_cb); notes_tree->user_data((void *)notes_tree_scroll);}
1241       code2 {notes_w->resizable(notes_tree_scroll);}
1242       code3 {notes_tree_scroll->resizable(notes_tree);}
1243       class Fl_Scroll_Resize
1244     } {}
1245     Fl_Button {} {
1246       label Delete
1247       callback {Fl_Toggle_Node *node = notes_tree->selected();
1248 if (!node || node->can_open())
1249         return;
1250 sfinx_object_t *obj = (sfinx_object_t *) node->user_data();
1251 delete_sfinx_note_to->value(obj->name.c_str());
1252 delete_note_w->user_data(obj);
1253 delete_note_w->show();}
1254       xywh {300 312 112 25} labeltype ENGRAVED_LABEL
1255     }
1256   }
1257   Fl_Window edit_note_w {
1258     label {Edit Note}
1259     xywh {212 174 1020 385} type Double color 31 hide modal
1260   } {
1261     Fl_Button {} {
1262       label Cancel
1263       callback {edit_note_w->hide();}
1264       xywh {648 321 112 25} labeltype ENGRAVED_LABEL
1265     }
1266     Fl_Input note_name_i {
1267       label Name
1268       xywh {16 27 496 26} color 29 labeltype ENGRAVED_LABEL align 1
1269     }
1270     Fl_Input note_url_i {
1271       label URL
1272       xywh {16 83 496 26} color 29 labeltype ENGRAVED_LABEL align 1
1273     }
1274     Fl_Input note_text_i {
1275       label Text
1276       xywh {16 141 496 158} type Multiline color 29 labeltype ENGRAVED_LABEL align 1
1277     }
1278     Fl_Output edit_note_to {
1279       xywh {0 364 1022 21} box PLASTIC_UP_BOX color 31 labelsize 10 textsize 10
1280     }
1281     Fl_Return_Button {} {
1282       label Ok
1283       callback {if (!note_mtag_b->user_data()) {
1284         fl_alert("You have to select Main Object for note !");
1285         return;
1287 if (!note_name_i->size()) {
1288         fl_alert("Note must have some name !");
1289         return;
1291 if (!note_text_i->size()) {
1292         fl_alert("Note must have some text !");
1293         return;
1295 sfinx_note_t *note = (sfinx_note_t *)edit_note_w->user_data();
1296 note->name = note_name_i->value();
1297 note->url = note_url_i->value();
1298 note->text = note_text_i->value();
1299 sfinx_object_t *obj = (sfinx_object_t *)note_mtag_b->user_data();
1300 note->mtag.id = obj->id;
1301 note->mtag.type = obj->type;
1302 note->mtag.slice_id = obj->slice_id;
1303 note_mtag_b->user_data(0);
1304 note->tags.clear();
1305 for (int i = 1; i <= note_tags_br->size(); i++) {
1306         obj = (sfinx_object_t *)note_tags_br->data(i);
1307         note->tags.push_back(*obj);
1308         note_tags_br->data(i, 0);
1310 app->sfinx.send(note);
1311 delete note;
1312 edit_note_w->user_data(0);}
1313       xywh {279 321 112 25} labeltype ENGRAVED_LABEL
1314     }
1315     Fl_Box {} {
1316       xywh {535 72 467 227} box ENGRAVED_FRAME
1317     }
1318     Fl_Button note_mtag_b {
1319       label {Main Note Tag (Not Set)}
1320       callback {fill_objects_tree(slices_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists !
1321 slices_w->user_data((void *)select_note_mtag_action);
1322 slices_w->show();}
1323       tooltip {Note Main Tag} xywh {594 93 348 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1324     }
1325     Fl_Browser note_tags_br {
1326       label {Additional Note Tags}
1327       xywh {559 146 420 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1
1328     }
1329     Fl_Button note_add_tag_b {
1330       label {Add Tag}
1331       callback {fill_objects_tree(slices_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists !
1332 slices_w->user_data((void *)select_note_atag_action);
1333 slices_w->show();}
1334       xywh {584 258 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1335     }
1336     Fl_Button note_remove_tag_b {
1337       label {Remove Tag}
1338       callback {for (int i = note_tags_br->size(); i >= 1; i--) {
1339         if (note_tags_br->selected(i))
1340                 note_tags_br->remove(i);
1342       xywh {811 258 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1343     }
1344     Fl_Choice note_secured_ch {
1345       label {Secure Level}
1346       xywh {536 27 211 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 5 deactivate
1347     } {
1348       MenuItem {} {
1349         label None
1350         xywh {10 10 35 22}
1351       }
1352       MenuItem {} {
1353         label {Crypted Text}
1354         xywh {20 20 35 22}
1355       }
1356     }
1357   }
1358   Fl_Window delete_note_w {
1359     label {Delete Note}
1360     xywh {44 182 388 168} type Double color 31 hide modal
1361   } {
1362     Fl_Button {} {
1363       label Cancel
1364       callback {delete_note_w->hide();}
1365       xywh {239 122 112 25} labeltype ENGRAVED_LABEL
1366     }
1367     Fl_Button {} {
1368       label Delete
1369       callback {sfinx_object_t *obj = (sfinx_object_t *) delete_note_w->user_data();
1370 sfinx_note_t note(note_deletion_type_ch->value() ? SFINX_NOTES_MODULE_UNLINK : SFINX_NOTES_MODULE_UNSORT);
1371 note.id = obj->id;
1372 note.mtag.slice_id = obj->slice_id;
1373 app->sfinx.send(note);
1374 delete_note_w->user_data(0);
1375 delete_note_w->hide();
1376 fill_objects_tree(notes_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 1); // force refresh}
1377       xywh {40 122 112 25} labeltype ENGRAVED_LABEL
1378     }
1379     Fl_Output delete_sfinx_note_to {
1380       label {Please confirm deletion of the note}
1381       xywh {31 26 330 26} box ENGRAVED_FRAME color 29 labeltype ENGRAVED_LABEL align 1
1382     }
1383     Fl_Choice note_deletion_type_ch {
1384       label {Associated Data Deletion Action}
1385       xywh {74 80 240 23} down_box BORDER_BOX color 48 labeltype ENGRAVED_LABEL align 1
1386     } {
1387       MenuItem {} {
1388         label {Mark all data 'Unsorted'}
1389         xywh {20 20 35 22}
1390       }
1391       MenuItem {} {
1392         label {Delete all data}
1393         xywh {30 30 35 22}
1394       }
1395     }
1396   }
1397   Fl_Window search_browser_w {
1398     label {Search Browser}
1399     xywh {217 305 854 476} type Double color 31 hide resizable modal
1400   } {
1401     Fl_Button {} {
1402       label Cancel
1403       callback {search_browser_w->hide();}
1404       xywh {638 449 187 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL
1405     }
1406     Fl_Browser search_browser_br {
1407       xywh {4 4 846 439} type Hold box GTK_THIN_UP_BOX color 44 resizable
1408     }
1409     Fl_Button {} {
1410       label {Previous Page}
1411       xywh {25 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL
1412     }
1413     Fl_Button {} {
1414       label {Next Page}
1415       xywh {231 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL
1416     }
1417     Fl_Choice goto_page_ch {
1418       label {Current Page }
1419       xywh {531 450 72 20} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX color 44 labeltype ENGRAVED_LABEL
1420     } {}
1421   }
1422   Fl_Window search_w {
1423     label Search
1424     xywh {169 380 749 389} type Double color 31 hide modal
1425   } {
1426     Fl_Button {} {
1427       label Cancel
1428       callback {search_w->hide();}
1429       xywh {182 347 363 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL
1430     }
1431     Fl_Return_Button {} {
1432       label Search
1433       callback {sfinx_search_query_t query;
1434 query.pattern = search_i->value();
1435 if (search_in_files_b->value())
1436         query.add_area(SFINX_SEARCH_IN_FILES);
1437 // add restrictions ...
1438 app->sfinx.send(query);}
1439       xywh {539 48 163 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL
1440     }
1441     Fl_Check_Button search_in_files_b {
1442       label {Search in Files}
1443       xywh {48 96 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16 deactivate
1444     }
1445     Fl_Box {} {
1446       xywh {87 141 561 189} box ROUNDED_FRAME
1447     }
1448     Fl_Browser search_slices_br {
1449       label {Restrict Search by Slices}
1450       xywh {105 173 525 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1
1451     }
1452     Fl_Button search_add_slice_b {
1453       label {Add Slice}
1454       callback {app->refresh_slices();
1455 slices_w->user_data((void *)search_add_slice_action);
1456 slices_w->show();}
1457       xywh {161 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1458     }
1459     Fl_Button {} {
1460       label {Remove Slice}
1461       callback {for (int i = search_slices_br->size(); i >= 1; i--) {
1462         if (search_slices_br->selected(i))
1463                 search_slices_br->remove(i);
1465       xywh {437 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL
1466     }
1467     Fl_Input search_i {
1468       label {Search for ...}
1469       xywh {46 47 447 26} color 29 labeltype ENGRAVED_LABEL align 1
1470     }
1471   }
1472   Fl_Window about_w {
1473     xywh {357 229 374 154} type Double hide
1474   } {
1475     Fl_Button {} {
1476       label Ok
1477       callback {about_w->hide();}
1478       xywh {72 122 226 20} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL
1479     }
1480     Fl_Box {} {
1481       image {../docs/sfinx.jpg} xywh {10 9 130 101}
1482     }
1483     Fl_Box {} {
1484       label Sfinx
1485       xywh {203 6 99 33} labeltype EMBOSSED_LABEL labelfont 9 labelsize 32
1486     }
1487     Fl_Box {} {
1488       label {Personal knowledge manager}
1489       xywh {150 40 214 22} labeltype EMBOSSED_LABEL labelcolor 64
1490     }
1491     Fl_Box {} {
1492       label {Copyright (C) 2007 Rus V. Brushkoff}
1493       xywh {150 58 214 22} labeltype EMBOSSED_LABEL labelfont 8 labelsize 11 labelcolor 56
1494     }
1495     Fl_Box {} {
1496       label {Email:  Rus@@Sfinx.Od.UA}
1497       xywh {150 75 214 22} labeltype EMBOSSED_LABEL labelfont 8 labelsize 11 labelcolor 56
1498     }
1499     Fl_Box {} {
1500       label {http://sfinx.od.ua/index.php?id=sfinx}
1501       xywh {150 93 214 22} labeltype EMBOSSED_LABEL labelfont 8 labelsize 11 labelcolor 56
1502     }
1503   }
1504   code {main_w->show();} {}
1507 Function {x11_ui::edit_slice(sfinx_slice_t *slice)} {return_type void
1508 } {
1509   code {// need locks
1510 Fl::lock();
1511 slice_name_i->value(slice->name());
1512 slice_directory_i->value(slice->directory());
1513 slice_name_i->take_focus();
1514 slice_description_i->value(slice->description());
1515 string status_line = "Parent slice: ";
1516 status_line += slice->parent_name();
1517 int cyear, cmonth, cday, eyear, emonth, eday, chour, cmin, csec, ehour, emin, esec;
1518 slice->ctime.GetDate(cyear, cmonth, cday);
1519 slice->etime.GetDate(eyear, emonth, eday);
1520 slice->ctime.GetTime(chour, cmin, csec);
1521 slice->etime.GetTime(ehour, emin, esec);
1522 char buf[128];
1523 sprintf(buf, " | Created at %02d/%02d/%02d %02d:%02d:%02d, Modified at %02d/%02d/%02d %02d:%02d:%02d", cyear, cmonth, cday, chour, cmin,
1524         csec, eyear, emonth, eday, ehour, emin, esec);
1525 status_line += buf;
1526 edit_slice_to->value(status_line.c_str());
1527 edit_slice_w->show();
1528 Fl::unlock();} {}
1531 Function {x11_ui::notes_module_edit(sfinx_note_t *n)} {open return_type void
1532 } {
1533   code {Fl::lock();
1534 sfinx_note_t *note = new sfinx_note_t;
1535 note->copy(n);
1536 note->tid(SFINX_NOTES_MODULE_EDIT);
1537 edit_note_w->user_data((void *)note);
1538 char buf[256];
1539 int eyear, emonth, eday, ehour, emin, esec, cyear, cmonth, cday, chour, cmin, csec;
1540 note->etime.GetDate(eyear, emonth, eday);
1541 note->etime.GetTime(ehour, emin, esec);
1542 note->ctime.GetDate(cyear, cmonth, cday);
1543 note->ctime.GetTime(chour, cmin, csec);
1544 sprintf(buf, "Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", cday, cmonth, cyear,
1545         chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec);
1546 edit_note_to->value(buf);
1547 note_name_i->value(note->name.c_str());
1548 note_name_i->take_focus();
1549 note_url_i->value(note->url.c_str());
1550 note_text_i->value(note->text.c_str());
1551 // main tag
1552 note_mtag_b->user_data(&(note->mtag));
1553 note_mtag_b->copy_label((note->mtag.name + " [ " + note->mtag.description + " ]").c_str());     
1554 note_mtag_b->redraw();
1555 // add tags
1556 note_tags_br->clear();
1557 for (u32_t i = 0; i < note->tags.size(); i++) {
1558         string s = note->tags[i].name + " [ " + note->tags[i].description + " ]";
1559         note_tags_br->add(s.c_str(), &(note->tags[i]));
1561 edit_note_w->show();
1562 Fl::unlock();} {}
1565 Function {x11_ui::notes_module_reply(sfinx_string_t *classify_error)} {return_type void
1566 } {
1567   code {Fl::lock();
1568 if (classify_error->size() == 1) {
1569         ::fill_objects_tree(notes_tree, 1 << SFINX_NOTE_OBJECT, 0, 1); // fluid bugs if any default params exists !
1570         edit_note_w->hide();
1571 } else
1572         fl_alert(classify_error->c_str());
1573 Fl::unlock();} {}
1576 Function {x11_ui::files_module_edit_reply(sfinx_string_t *classify_error)} {open return_type void
1577 } {
1578   code {Fl::lock();
1579 if (classify_error->size() == 1) {
1580         if (current_file.tid() != SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST)
1581                 ::fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists !
1582         else
1583                 app->sfinx.send(current_file);
1584         classify_file_w->hide();
1585 } else
1586         fl_alert(classify_error->c_str());
1587 Fl::unlock();} {}
1590 Function {x11_ui::files_module_edit(sfinx_file_t *f)} {return_type void
1591 } {
1592   code {Fl::lock();
1593 static sfinx_file_t file;
1594 file.copy(f);
1595 char buf[256];
1596 int eyear, emonth, eday, ehour, emin, esec, cyear, cmonth, cday, chour, cmin, csec;
1597 file.etime.GetDate(eyear, emonth, eday);
1598 file.etime.GetTime(ehour, emin, esec);
1599 file.ctime.GetDate(cyear, cmonth, cday);
1600 file.ctime.GetTime(chour, cmin, csec);
1601 sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file.fsize, cday, cmonth, cyear,
1602         chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec);
1603 string path;
1604 app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path);
1605 string t = "URL: " + path + current_file.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf;
1606 classify_file_to->value(t.c_str());
1607 file_title_i->value(file.title.c_str());
1608 file_name_i->value(file.name.c_str());
1609 // save orig file name
1610 file.orig_name = file.name;
1611 file.tid(SFINX_FILES_MODULE_EDIT_FILE); // edit file
1612 file_title_i->take_focus();
1613 file_authority_i->value(file.authority.c_str());
1614 file_description_i->value(file.description.c_str());
1615 file_comments_i->value(file.comments.c_str());
1616 sorted_location_b->value(file.sorted_location);
1617 file_compress_b->value(file.store_compressed);
1618 file_gen_csum_b->value(file.generate_csum);
1619 file_mtag_b->copy_label((file.mtag.name + " [ " + file.mtag.description + " ]").c_str());
1620 file_mtag_b->user_data(&file.mtag);
1621 file_tags_br->clear();
1622 for (u32_t i = 0; i < file.tags.size(); i++) {
1623         string s = file.tags[i].name + " [ " + file.tags[i].description + " ]";
1624         file_tags_br->add(s.c_str(), &(file.tags[i]));
1626 classify_file_w->user_data((void *)&file);
1627 classify_file_w->show();
1628 Fl::unlock();} {}
1631 Function {x11_ui::search_browser(sfinx_pair_vector_t *r)} {return_type void
1632 } {
1633   code {Fl::lock();
1634 search_browser_br->clear();
1635 if (!r->len()) {
1636         search_browser_br->add("Sfinx has no data for this query");
1637         goto out;
1639 goto_page_ch->clear();
1640 /*for (u32_t i = 1; i < 50; i++) {
1641         char b[32];
1642         sprintf(b, "%d", i);
1643         goto_page_ch->add(b, 0, 0, (void *)i);
1644 //      Fl_Menu_Item *item = (Fl_Menu_Item *)(goto_page_ch->menu() + n);
1645 //      item->color(FL_GREEN);
1646 } */
1647 goto_page_ch->value(0);
1648 //goto_page_ch->selection_color(FL_GREEN);
1650 // fill browser
1651 for (u32_t i = 0; i < r->len(); i++) {
1652         sfinx_pair_t *p = r->find(i);
1653         if (!p)
1654                 bug();
1655         sfinx_t *el;
1656         if (!p->get(i, &el))
1657                 bug();
1658         // adding element
1659         string inf;
1660         prepare_search_info(el, inf);
1661         string::size_type pos = 0, found;
1662         while ((found = inf.find('\\n', pos)) != string::npos) {
1663                 string line(inf, pos, found - pos);
1664                 search_browser_br->add(line.c_str());
1665                 pos = found + 1;
1666         }
1667         search_browser_br->add("@-");
1669 out:
1670 search_browser_w->show();
1671 Fl::unlock();} {}
1674 Function {x11_ui::prepare_search_info(sfinx_t *el, string &inf)} {return_type void
1675 } {
1676   code {sfinx_file_t *f;
1677 switch (el->tid()) {
1678       case SFINX_ELEMENT_FILE:
1679         f = (sfinx_file_t *)el;
1680         inf = "\\nType: File\\n";
1681         inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag.id) + "\\n");
1682 /*        if (f->slices.size()) {
1683           inf.append("Additional Slices : ");
1684           for (u32_t i = 0; i < f->slices.size(); i++) {
1685             if (i)
1686               inf.append(", ");
1687             inf.append(app->slice_name(f->slices[i]));
1688          }
1689           inf.append("\\n");
1690        }*/
1691         inf.append("Title: " + f->title + "\\n");
1692         inf.append("Authority: " + f->authority + "\\n");
1693         inf.append("Description: " + f->description + "\\n");
1694         inf.append("Comments: " + f->comments + "\\n");
1695         inf.append("Name: " + f->name + "\\n");
1696         char buf[64];
1697         sprintf(buf, "%llu bytes\\n", f->fsize);
1698         inf.append("Size: ");
1699         inf.append(buf);
1700         if (f->csum.size())
1701                 inf.append("Csum: " + f->csum + "\\n");
1702         sprintf(buf, "%llu bytes\\n", f->compressed_fsize);
1703         inf.append("Compressed Size: ");
1704         inf.append(buf);
1705         if (f->compressed_csum.size())
1706                 inf.append("Compressed Csum: " + f->compressed_csum + "\\n");
1707         int year, month, day, hour, min, sec;
1708         f->ctime.GetDate(year, month, day);
1709         f->ctime.GetTime(hour, min, sec);
1710         sprintf(buf, "Create Entry Time: %02d/%02d/%04d %02d:%02d:%02d\\n", day, month, year, hour, min, sec);
1711         inf.append(buf);
1712         f->etime.GetDate(year, month, day);
1713         f->etime.GetTime(hour, min, sec);
1714         sprintf(buf, "Edit Entry Time: %02d/%02d/%04d %02d:%02d:%02d\\n", day, month, year, hour, min, sec);
1715         inf.append(buf);
1716         inf.append("\\n");
1717         break;
1718       default:
1719         debug("Can't fill element info !");
1720         bug();
1721 }} {}
1724 Function {x11_ui::fill_objects_tree()} {return_type void
1725 } {
1726   code {Fl::lock();
1727 Fl_Toggle_Tree *tree = fill_tree;
1728 u32_t mask = fill_tree_mask;
1729 if (!tree) {
1730  tree = slices_tree;
1731  mask = SFINX_SLICE_OBJECT;
1733 tree->clear();
1734 tree->draw_lines(1);
1735 tree->alternate_color(FL_LIGHT2);
1736 tree->trim_color(FL_LIGHT1);
1737 tree->edit_on_reselect(0);
1738 sfinx_slice_t *slice;
1739 Fl_Toggle_Node *node;
1740 u32_t max_name_len = 0;
1741 for (u32_t i = 0; i < app->slices.len(); i++) {
1742         slice = app->slices.get(i);
1743         if (slice == fill_tree_except)
1744                 continue;
1745         //debug("slice name - %s, id - %lld, parent_id - %lld", slice->name(), slice->id, slice->parent_id);
1746         string name = slice->name() + string(" [ ") +
1747                 slice->description() + string(" ]");
1748         // replace \\n with spaces
1749         string filt_elems( "\\n");
1750         string::size_type pos = 0;
1751         while (( pos = name.find_first_of(filt_elems, pos)) != string::npos)
1752                 name.replace(pos, 1, string(" "));
1753         if (name.size() > max_name_len)
1754                 max_name_len = name.size();
1755         if (!slice->parent_id) {
1756                 node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice));
1757                 if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) {
1758                         tree->open(node);
1759                         // add notes
1760                         for (u32_t x = 0; x < slice->objs.size(); x++) {
1761                                 switch (slice->objs[x].type) {
1762                                         case SFINX_NOTE_OBJECT:
1763                                                 if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT))
1764                                                         tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &note_pixmap,
1765                                                                 to_voidp(&(slice->objs[x])));
1766                                                 break;
1767                                         case SFINX_FILE_OBJECT:
1768                                                 if (fill_tree_mask & (1 << SFINX_FILE_OBJECT))
1769                                                         tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap,
1770                                                                 to_voidp(&(slice->objs[x])));
1771                                                 break;
1772                                         default:
1773                                                 debug("unsupported fill tree type %d", slice->objs[x].type);
1774                                                 break;
1775                         } // switch
1776                                 tree->traverse_up();
1777                         } // for
1778                 }
1779         } else {
1780                 node = tree->traverse_start();
1781                 while (node) {
1782                         sfinx_slice_t *s = (sfinx_slice_t *) node->user_data();
1783                         if (s->id == slice->parent_id)
1784                                 break;
1785                         node = tree->traverse_forward();
1786                 }
1787                 if (node) {
1788                         tree->open(node);
1789                         node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice));
1790                 if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) {
1791                         tree->open(node);
1792                         // add notes
1793                         for (u32_t x = 0; x < slice->objs.size(); x++) {
1794                                 switch (slice->objs[x].type) {
1795                                         case SFINX_NOTE_OBJECT:
1796                                                 if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT))
1797                                                         tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &note_pixmap,
1798                                                                 to_voidp(&(slice->objs[x])));
1799                                                 break;
1800                                         case SFINX_FILE_OBJECT:
1801                                                 if (fill_tree_mask & (1 << SFINX_FILE_OBJECT))
1802                                                         tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap,
1803                                                                 to_voidp(&(slice->objs[x])));
1804                                                 break;
1805                                         default:
1806                                                 debug("unsupported fill tree type %d", slice->objs[x].type);
1807                                                 break;
1808                         } // switch
1809                                 tree->traverse_up();
1810                         } // for
1811                 }
1812                 } // node not found - just ignore
1813         }
1815 s32_t width = max_name_len * 8;
1816 // need to count depth for width update
1817 Fl_Scroll_Resize *tree_scroll = (Fl_Scroll_Resize *) tree->user_data();
1818 if (!tree_scroll) // he, forgot to set ;)
1819         bug();
1820 tree->resize(tree->x(), tree->y(), width > tree_scroll->w() ? width : tree_scroll->w(), tree->h());
1821 // try to select previous node
1822 //node = slices_tree->find(to_voidp(current_slice_id));
1823 //if (node)
1824 //      slices_tree->select_range(node, node);
1825 Fl::unlock();} {}
1828 Function {x11_ui::fill_unsorted_files_tree(sfinx_files_vector_t *tree_)} {open return_type void
1829 } {
1830   code {Fl::lock();
1831 static sfinx_files_vector_t tree;
1832 tree.copy(tree_);
1833 files_module_tree_br->user_data((void *)&tree);
1834 files_module_tree_br->clear();
1835 char buf[256];
1836 u32_t files = 0, dirs = 0;
1837 // set parent dir id
1838 if (tree.files.size())
1839         current_file.mtag.id = tree.files[0]->compressed_fsize;
1840 for (u32_t i = 0; i < tree.files.size(); i++) {
1841         if (tree.files[i]->is_directory)
1842                 strcpy(buf, "\\t@b@.");
1843         else
1844                 strcpy(buf, "\\t");
1845         strncat(buf, tree.files[i]->name.c_str(), 50);
1846         char dir_len[64];
1847         if (tree.files[i]->is_directory) {
1848                 strcpy(dir_len, "\\t@b@.< DIR >\\t");
1849                 dirs++;
1850         } else {
1851                 sprintf(dir_len, "\\t%llu\\t", tree.files[i]->fsize);
1852                 files++;
1853         }
1854         strcat(buf, dir_len);
1855         int cyear, cmonth, cday, chour, cmin, csec;
1856         tree.files[i]->ctime.GetDate(cyear, cmonth, cday);
1857         tree.files[i]->ctime.GetTime(chour, cmin, csec);
1858         sprintf(dir_len, "%02d/%02d/%04d %02d:%02d:%02d\\t", cday, cmonth, cyear, chour, cmin, csec);
1859         strcat(buf, dir_len);
1860         strcat(buf, tree.files[i]->mimetype.c_str());
1861         files_module_tree_br->add(buf);
1863 files_module_tree_br->redraw();
1864 string root;
1865 app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root);
1866 sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_file.name.c_str()).c_str(), files, (files == 1) ? "" : "s",  dirs,
1867         (dirs == 1) ? "y" : "ies");
1868 files_module_status_to->value(buf);
1869 files_module_status_to->redraw();
1870 // this is unsorted tree
1871 select_files_tree_b->user_data(0);
1872 select_files_tree_b->label("Show Sorted");
1873 select_files_tree_b->redraw();
1874 files_tree_scroll->hide();
1875 files_module_tree_br->show();
1876 Fl::unlock();} {selected
1877   }
1880 Function {x11_ui::fill_preferences()} {return_type void
1881 } {
1882   code {Fl::lock();
1883 string t;
1884 app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, t);
1885 config_files_module_unsorted_path_i->value(t.c_str());
1886 app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, t);
1887 config_files_module_sorted_path_i->value(t.c_str());
1888 app->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, t);
1889 config_files_module_desc_file_name_i->value(t.c_str());
1890 u32_t gen_desc_files;
1891 app->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files);
1892 gen_desc_files_b->value(gen_desc_files);
1893 Fl::unlock();} {}
1896 Function {x11_ui::log(int level, const char *fmt, ...)} {return_type void
1897 } {
1898   code {char buf[10240];
1899 const char *level_str;
1900 static Mutex log_m;
1901 log_m.enterMutex();
1902 Fl::lock();
1903 ::va_list args;
1904 ::va_start(args, fmt);
1905 ::va_end(args);
1906 switch (level) {
1907         case SFINX_LOG_NOTICE:
1908                 level_str = "NOTICE";
1909                 break;
1910         case SFINX_LOG_WARN:
1911                 level_str = "WARN";
1912                 break;
1913         case SFINX_LOG_ERROR:
1914                 level_str = "ERROR";
1915                 break;
1916         case SFINX_LOG_FATAL:
1917                 level_str = "FATAL";
1918                 break;
1919         default:
1920                 level_str = "UNKN_LEVEL";
1922 // add time ?
1923 strcpy(buf, level_str);
1924 strcat(buf, ": ");
1925 ::vsnprintf(buf + strlen(level_str) + 2, sizeof(buf) - (strlen(level_str) + 2), fmt, args);
1926 log_br->add(buf);
1927 Fl::unlock();
1928 log_m.leaveMutex();} {}
1931 Function {x11_ui::progress(sfinx_progress_t *p)} {return_type void
1932 } {
1933   code {Fl::lock();
1934 static char buf[128];
1935 switch (p->status()) {
1936         case SFINX_PROGRESS_START:
1937                 progress_l->label(p->label());
1938                 strcpy(buf, p->strvalue());
1939                 progress_bar->label(buf);
1940                 progress_bar->minimum(0);
1941                 progress_bar->maximum(p->max());
1942                 progress_bar->value(p->value());
1943                 progress_w->show();
1944                 progress_w->redraw();
1945                 break;
1946         case SFINX_PROGRESS_END:
1947                 progress_w->hide();
1948                 break;
1949         case SFINX_PROGRESS_NONE:
1950         default:
1951                 break;
1953 Fl::unlock();} {}
1956 Function {x11_ui::alert(sfinx_string_t *alert)} {return_type void
1957 } {
1958   code {Fl::lock();
1959 if (alert->size() != 1)
1960         fl_alert(alert->c_str());
1961 Fl::unlock();} {}