From 80b82338de00b2899fa0b4e77edc0b377cc9ef3c Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 19 Feb 2015 07:42:42 +0000 Subject: [PATCH] Eolite 2.46: code clean and reorganize, translate settings, apply settings changes directly without restarting program git-svn-id: svn://kolibrios.org@5428 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 27 ++---- programs/cmm/eolite/include/about.h | 1 - programs/cmm/eolite/include/ini.h | 30 ------- programs/cmm/eolite/include/left_panel.h | 5 +- programs/cmm/eolite/include/settings.h | 108 ++++++++++++++++------- 5 files changed, 81 insertions(+), 90 deletions(-) delete mode 100644 programs/cmm/eolite/include/ini.h diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 1015af54fa..d079cb9eab 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -83,8 +83,8 @@ enum {ONLY_SHOW, WITH_REDRAW, ONLY_OPEN}; //OpenDir -#define TITLE "Eolite File Manager v2.45" -#define ABOUT_TITLE "Eolite v2.45" +#define TITLE "Eolite File Manager v2.46" +#define ABOUT_TITLE "Eolite v2.46" dword col_padding, col_selec, col_lpanel; int toolbar_buttons_x[7]={9,46,85,134,167,203}; @@ -131,30 +131,12 @@ PathShow_data FileShow = {0, 56,215, 6, 100, 0, 0, 0x0, 0xFFFfff, #file_name, #t #include "include\other.h" #include "include\sorting.h" #include "include\icons.h" -#include "include\ini.h" #include "include\left_panel.h" #include "include\history.h" #include "include\menu.h" #include "include\about.h" #include "include\settings.h" -void SetAppColors() -{ - sc.work = 0xE4DFE1; - sc.work_text = 0; - sc.work_graph = 0x9098B0; //A0A0B8; //0x819FC5; - sc.work_button_text = 0x000000; - col_padding = 0xC8C9C9; - //col_selec = 0x94AECE; - col_lpanel = 0x00699C; - /* - sc.get(); - for (i=0; i<=14; i++) col_palette[i] = sc.work; - toolbar_pal[0]= goto_about_pal[0] = sc.work = sc.work; - col_lpanel = sc.work_graph; - for (i=0; i<=99; i++) blue_hl_pal[i] = sc.work_graph; - */ -} void main() { @@ -168,7 +150,7 @@ void main() if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1); if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini"); SystemDiscsGet(); - GetIni(1); + GetIni(); SetAppColors(); if (param) { @@ -477,6 +459,7 @@ void menu_action(dword id) if (id==207) FnProcess(2); if (id==108) Del_Form(); if (id==109) FnProcess(5); + if (id==300) { FnProcess(5); List_ReDraw(); } } @@ -963,7 +946,7 @@ void FnProcess(char N) Tip(56, T_DEVICES, 55, "-"); Open_Dir(#path,WITH_REDRAW); pause(10); - GetIni(1); + GetIni(); SystemDiscsGet(); Open_Dir(#path,WITH_REDRAW); DrawLeftPanel(); diff --git a/programs/cmm/eolite/include/about.h b/programs/cmm/eolite/include/about.h index f7e0530c40..9a796c3daa 100644 --- a/programs/cmm/eolite/include/about.h +++ b/programs/cmm/eolite/include/about.h @@ -1,6 +1,5 @@ //Leency 2008-2013 -#define EDITOR_PATH "/sys/tinypad" #define BROWSER_PATH "/sys/htmlv" #define BROWSER_LINK "http://kolibri-n.org/index.php" diff --git a/programs/cmm/eolite/include/ini.h b/programs/cmm/eolite/include/ini.h deleted file mode 100644 index a328c62705..0000000000 --- a/programs/cmm/eolite/include/ini.h +++ /dev/null @@ -1,30 +0,0 @@ -//INI parser in C--, GPL licence. -//Leency - 2012 - -void GetIni(byte onload) -{ - dword eolite_ini_path = abspath("Eolite.ini"); - ini_get_color stdcall (eolite_ini_path, "Config", "SelectionColor", 0x94AECE); - edit2.shift_color = EAX; - col_selec = EAX; - ini_get_int stdcall (eolite_ini_path, "Config", "LineHeight", 18); - files.line_h = EAX; - ini_get_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 1); - show_dev_name = EAX; - ini_get_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 0); - real_files_names_case = EAX; -} - - -void Write_Error(int error_number) -{ - char error_message[500]; - dword ii; - if (files.current>=0) Line_ReDraw(0xFF0000, files.current); - pause(5); - strcpy(#error_message, "\"Eolite\n"); - ii = get_error(error_number); - strcat(#error_message, ii); - strcat(#error_message, "\" -tE"); - notify(#error_message); -} diff --git a/programs/cmm/eolite/include/left_panel.h b/programs/cmm/eolite/include/left_panel.h index 64e88e3aef..9a075f4f65 100644 --- a/programs/cmm/eolite/include/left_panel.h +++ b/programs/cmm/eolite/include/left_panel.h @@ -24,7 +24,7 @@ char *actions[] = { 57, "New file", "F7", 56, "New folder", "F6", - 60, "Options", "F10", + 60, "Settings", "F10", 0,0,0 }; #endif @@ -51,7 +51,6 @@ void SystemDiscsGet() { char dev_name[10], sys_discs[10]; int i1, j1, dev_num, dev_disc_num; - int nullbuf[32]; disc_num=0; if (devbuf) free(devbuf); devbuf = malloc(10000); //сєЇхЁ уфх-Єю эр 10 фхтрщёют т ыхтющ ярэхыш @@ -75,7 +74,7 @@ void SystemDiscsGet() } if (strcmp(#sys_discs, "/rd/1/")==0) { - if (GetDir(#nullbuf, #nullbuf, "/kolibrios/", DIRS_ALL)==0) + if (isdir("/kolibrios")) { strcpy(#disk_list[disc_num].Item, "/kolibrios/"); kolibrios_drive = true; diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index 3568f931a1..ebc2e6a47e 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -1,44 +1,35 @@ -//Leency 2008-2013 +//Leency 2008-2015 #define EDITOR_PATH "/sys/tinypad" -#define BROWSER_PATH "/sys/htmlv" -#define BROWSER_LINK "http://kolibri-n.org/index.php" #ifdef LANG_RUS ?define TITLE_SETT "Настройки" - ?define SET_1 "Показывать имена устройств" - ?define SET_2 "Реальные имена" - ?define SET_3 "Высота выделения" - ?define CANCEL_T "Отмена" - ?define APPLY_T "Применить" -#elif LANG_EST - ?define TITLE_SETT "Настройки" - ?define SET_1 "Показывать имена устройств" - ?define SET_2 "Реальные имена" - ?define SET_3 "Высота выделения" + ?define SET_1 "Выводить названия класса устройств" + ?define SET_2 "Показывать имена файлов не меняя регистр" + ?define SET_3 "Высота строки в списке" ?define CANCEL_T "Отмена" ?define APPLY_T "Применить" #else - ?define TITLE_SETT "Настройки" - ?define SET_1 "Показывать имена устройств" - ?define SET_2 "Реальные имена" - ?define SET_3 "Высота выделения" - ?define CANCEL_T "Отмена" - ?define APPLY_T "Применить" + ?define TITLE_SETT "Settings" + ?define SET_1 "Show device class name" + ?define SET_2 "Show real file names without changing case" + ?define SET_3 "List line height" + ?define CANCEL_T "Cancel" + ?define APPLY_T "Apply" #endif int mouse_ddd; char lineh_s[30]="18\0"; -edit_box LineHeight_ed = {50,10,70,0xffffff,0x94AECE,0x000000,0x000000,2,4,#lineh_s,#mouse_ddd, 1000000000000010b,2,2}; -checkbox2 ShowDeviceName_chb = {10*65536+15, 10*65536+15, 5, 0xffffff, 0x000000, 0x80000000, SET_1, 110b}; -checkbox2 RealFileNamesCase_chb = {10*65536+15, 30*65536+15, 5, 0xffffff, 0x000000, 0x80000000, SET_2, 100b}; +edit_box LineHeight_ed = {50,10,70,0xffffff,0x94AECE,0x9098B0,0x9098B0,2,4,#lineh_s,#mouse_ddd, 1000000000000010b,2,2}; +checkbox2 ShowDeviceName_chb = {10*65536+15, 10*65536+15, 5, 0xffffff, 0x9098B0, 0x80000000, SET_1, 110b}; +checkbox2 RealFileNamesCase_chb = {10*65536+15, 30*65536+15, 5, 0xffffff, 0x9098B0, 0x80000000, SET_2, 100b}; void settings_dialog() { byte id; unsigned int key; dword eolite_ini_path = abspath("Eolite.ini"); - IF (active_about) ExitProcess(); + if (active_about) ExitProcess(); active_about=1; SetEventMask(0x27); loop() switch(WaitEvent()) @@ -47,27 +38,28 @@ void settings_dialog() id=GetButtonID(); if (id==10) { - IF ( asm test ShowDeviceName_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 1); + if ( asm test ShowDeviceName_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 1); ELSE ini_set_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 0); - IF ( asm test RealFileNamesCase_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 1); + if ( asm test RealFileNamesCase_chb.flags, 2) ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 1); ELSE ini_set_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 0); - IF (LineHeight_ed.size) ini_set_int stdcall (eolite_ini_path, "Config", "LineHeight", atoi(#lineh_s)); + if (LineHeight_ed.size) ini_set_int stdcall (eolite_ini_path, "Config", "LineHeight", atoi(#lineh_s)); active_about=0; + action_buf = 300; ExitProcess(); } - IF (id==1) || (id==11) + if (id==1) || (id==11) { active_about=0; ExitProcess(); } - IF (id==23) RunProgram(BROWSER_PATH, BROWSER_LINK); break; case evKey: key = GetKey(); - IF (key==27) + if (key==27) { active_about=0; + action_buf = 300; ExitProcess(); } EAX=key<<8; @@ -81,12 +73,12 @@ void settings_dialog() break; case evReDraw: - DefineAndDrawWindow(600,150,281,228+GetSkinHeight(),0x34,sc.work,TITLE_SETT); + DefineAndDrawWindow(Form.left + 100, 150, 300, 200+GetSkinHeight(),0x34,sc.work,TITLE_SETT); - IF (show_dev_name) ShowDeviceName_chb.flags = 110b; + if (show_dev_name) ShowDeviceName_chb.flags = 110b; ELSE ShowDeviceName_chb.flags = 100b; - IF (real_files_names_case) RealFileNamesCase_chb.flags = 110b; + if (real_files_names_case) RealFileNamesCase_chb.flags = 110b; ELSE RealFileNamesCase_chb.flags = 100b; key = itoa(files.line_h); @@ -96,7 +88,55 @@ void settings_dialog() check_box_draw stdcall (#RealFileNamesCase_chb); edit_box_draw stdcall (#LineHeight_ed); WriteText(10, 55, 0x80, 0x000000, SET_3); - DrawFlatButton(115,190,70,22,10,0xE4DFE1, APPLY_T); - DrawFlatButton(195,190,70,22,11,0xE4DFE1, CANCEL_T); + DrawFlatButton(128,160,70,22,10,0xE4DFE1, APPLY_T); + DrawFlatButton(208,160,70,22,11,0xE4DFE1, CANCEL_T); } +} + + +void GetIni() +{ + dword eolite_ini_path = abspath("Eolite.ini"); + ini_get_color stdcall (eolite_ini_path, "Config", "SelectionColor", 0x94AECE); + edit2.shift_color = EAX; + col_selec = EAX; + ini_get_int stdcall (eolite_ini_path, "Config", "LineHeight", 18); + files.line_h = EAX; + ini_get_int stdcall (eolite_ini_path, "Config", "ShowDeviceName", 1); + show_dev_name = EAX; + ini_get_int stdcall (eolite_ini_path, "Config", "RealFileNamesCase", 0); + real_files_names_case = EAX; +} + + +void Write_Error(int error_number) +{ + char error_message[500]; + dword ii; + if (files.current>=0) Line_ReDraw(0xFF0000, files.current); + pause(5); + strcpy(#error_message, "\"Eolite\n"); + ii = get_error(error_number); + strcat(#error_message, ii); + strcat(#error_message, "\" -tE"); + notify(#error_message); +} + + +void SetAppColors() +{ + sc.work = 0xE4DFE1; + sc.work_text = 0; + sc.work_graph = 0x9098B0; //A0A0B8; //0x819FC5; + sc.work_button_text = 0x000000; + col_padding = 0xC8C9C9; + //col_selec = 0x94AECE; + col_lpanel = 0x00699C; + /* + sc.get(); + for (i=0; i<=14; i++) col_palette[i] = sc.work; + toolbar_pal[0]= goto_about_pal[0] = sc.work = sc.work; + col_lpanel = sc.work_graph; + for (i=0; i<=99; i++) blue_hl_pal[i] = sc.work_graph; + */ } \ No newline at end of file