Subversion Repositories Kolibri OS

Rev

Rev 7628 | Rev 7636 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef AUTOBUILD
  2. #include "lang.h--"
  3. #endif
  4.  
  5. #define MEMSIZE 0x23E80
  6. #include "..\lib\kolibri.h"
  7. #include "..\lib\strings.h"
  8. #include "..\lib\mem.h"
  9. #include "..\lib\fs.h"
  10. #include "..\lib\dll.h"
  11. #include "..\lib\gui.h"
  12.  
  13. #include "..\lib\obj\libio.h"
  14. #include "..\lib\obj\libini.h"
  15. #include "..\lib\obj\box_lib.h"
  16.  
  17. #include "..\lib\patterns\restart_process.h"
  18.  
  19. #ifdef LANG_RUS
  20.         ?define WINDOW_TITLE " áâனª¨ ¯ ­¥«¨ § ¤ ç ¨ „®ª "
  21.     ?define TASK_FRAME_T "  ­¥«ì § ¤ ç "
  22.         ?define DOCK_FRAME_T " „®ª "
  23.         ?define MIN_LEFT_BUTTON "Š­®¯ª  áªàëâ¨ï á«¥¢ "
  24.         ?define MIN_RIGHT_BUTTON "Š­®¯ª  áªàëâ¨ï á¯à ¢ "
  25.         ?define SOFTEN_UP   "‘£« ¦¨¢ ­¨¥ ᢥàåã"
  26.         ?define SOFTEN_DOWN "‘£« ¦¨¢ ­¨¥ á­¨§ã"
  27.         ?define CLOCK    "— áë"
  28.         ?define CPU_USAGE "‡ £à㧪  –"
  29.         ?define CHANGE_LANG "Ÿ§ëª ¢¢®¤ "
  30.         ?define MENU_BUTTON "Š­®¯ª  ¬¥­î"
  31.         ?define PANEL_HEIGHT "‚ëá®â  ¯ ­¥«¨"
  32.         ?define SOFTEN_HEIGHT "‚ëá®â  ᣫ ¦¨¢ ­¨ï"
  33.         ?define BUTTON_OFFSET "®«¥ ¢®ªà㣠ª­®¯®ª"
  34.         ?define FSIZE "¥¦¨¬ ¯ ­¥«¨"
  35.         ?define ASHOW "¥ áªà뢠âì"
  36.         ?define CHANGE_POS " ¦¬¨â¥ ­  ¨§®¡à ¦¥­¨¥ ¤«ï ᬥ­ë ¯®§¨æ¨¨"
  37. #else
  38.         ?define WINDOW_TITLE "Taskbar and Docky configuration"
  39.     ?define TASK_FRAME_T " Taskbar "
  40.         ?define DOCK_FRAME_T " Docky "
  41.         ?define MIN_LEFT_BUTTON "Min Left Button"
  42.         ?define MIN_RIGHT_BUTTON "Min Right Button"
  43.         ?define SOFTEN_UP   "Soften Up"
  44.         ?define SOFTEN_DOWN "Soften Down"
  45.         ?define CLOCK    "Clock"
  46.         ?define CPU_USAGE "Cpu Usage"
  47.         ?define CHANGE_LANG "Change Language"
  48.         ?define MENU_BUTTON "Menu Button"
  49.         ?define PANEL_HEIGHT "Panel Height"
  50.         ?define SOFTEN_HEIGHT "Soften Height"
  51.         ?define BUTTON_OFFSET "Button Offset"
  52.         ?define FSIZE "Full width"
  53.         ?define ASHOW "Always show"
  54.         ?define CHANGE_POS "Click on image to change position"
  55. #endif
  56.  
  57. char taskbar_ini_path[] = "/sys/settings/taskbar.ini";
  58. _ini taskbar_flags_ini = { #taskbar_ini_path, "Flags" };
  59. _ini taskbar_vars_ini = { #taskbar_ini_path, "Variables" };
  60.  
  61. _ini docky_ini = { "/sys/settings/docky.ini", "@" };
  62.  
  63. unsigned char panels_img_data[] = FROM "panels_image.raw";
  64. #define PIMG_W 37
  65. #define PIMG_H 27 //27*5
  66.  
  67. proc_info Form;
  68.  
  69. enum { BTN_TB_ATTACHEMENT=100, BTN_DOCKY_ATTACHEMENT=200 };
  70. enum { TASKBAR, DOCKY };
  71.  
  72. more_less_box tbPanelHeight  = { NULL, 6, 99, PANEL_HEIGHT };
  73. more_less_box tbSoftenHeight = { NULL, 0, 99, SOFTEN_HEIGHT };
  74. more_less_box tbButtonOffset = { NULL, 0, 99, BUTTON_OFFSET };
  75.  
  76. int tbAttachment;
  77. checkbox tbSoftenUp = { SOFTEN_UP };
  78. checkbox tbClock = { CLOCK };
  79. checkbox tbSoftenDown = { SOFTEN_DOWN };
  80. checkbox tbCpuUsage = { CPU_USAGE };
  81. checkbox tbMinLeftButton = { MIN_LEFT_BUTTON };
  82. checkbox tbChangeLang = { CHANGE_LANG };
  83. checkbox tbMinRightButton = { MIN_RIGHT_BUTTON };
  84. checkbox tbMenuButton = { MENU_BUTTON };
  85. checkbox dkFsize = { FSIZE };
  86. checkbox dkAshow = { ASHOW };
  87.  
  88. int dkLocation;
  89. checkbox tbRunApplButton;
  90. checkbox tbClnDeskButton;
  91.  
  92.  
  93. void main()
  94. {
  95.         dword id, key;
  96.  
  97.         load_dll(libini, #lib_init,1);
  98.         load_dll(boxlib, #box_lib_init,0);
  99.  
  100.         LoadCfg();
  101.  
  102.         loop() switch(WaitEvent())
  103.         {
  104.                 case evButton:
  105.                                 id=GetButtonID();
  106.                                 if (1==id) ExitProcess();
  107.                                 //taskbar buttons
  108.                                 if (BTN_TB_ATTACHEMENT == id) {
  109.                                         tbAttachment ^= 1;
  110.                                         DrawWindowContent();
  111.                                         SaveSettingsAndRestartProcess(TASKBAR);
  112.                                 }
  113.  
  114.                                 if (tbSoftenUp.click(id))      || (tbSoftenDown.click(id))
  115.                                 || (tbMinLeftButton.click(id)) || (tbMinRightButton.click(id))
  116.                                 || (tbRunApplButton.click(id)) || (tbClnDeskButton.click(id)) {
  117.                                         SaveSettingsAndRestartProcess(TASKBAR);
  118.                                 }
  119.  
  120.                                 if (tbClock.click(id))       || (tbCpuUsage.click(id))
  121.                                 || (tbChangeLang.click(id))  || (tbMenuButton.click(id))
  122.                                 || (tbPanelHeight.click(id)) || (tbSoftenHeight.click(id))
  123.                                 || (tbButtonOffset.click(id)) {
  124.                                         SaveSettingsAndRestartProcess(TASKBAR);
  125.                                 }
  126.                                 //docky buttons
  127.                                 if (id==200) {
  128.                                         dkLocation++;
  129.                                         if (dkLocation>3) dkLocation=1;
  130.                                         DrawWindowContent();
  131.                                         SaveSettingsAndRestartProcess(DOCKY);
  132.                                 }
  133.                                 if (dkFsize.click(id)) SaveSettingsAndRestartProcess(DOCKY);
  134.                                 if (dkAshow.click(id)) SaveSettingsAndRestartProcess(DOCKY);
  135.                                 break;
  136.                                
  137.                 case evKey:
  138.                                 GetKeys();
  139.                                 if (key_scancode == SCAN_CODE_ESC) ExitProcess();
  140.                                 break;
  141.                        
  142.                 case evReDraw:
  143.                                 system.color.get();
  144.                                 DefineAndDrawWindow(130, 150, 465, 398 + skin_height, 0x34, system.color.work, WINDOW_TITLE, 0);
  145.                                 GetProcessInfo(#Form, SelfInfo);
  146.                                 if (Form.status_window>2) break;
  147.                                 DrawWindowContent();
  148.         }
  149. }
  150.  
  151. void DrawPanelsImage(dword y, n)
  152. {
  153.         _PutImage(22, y, PIMG_W, PIMG_H, n * PIMG_W * PIMG_H * 3 + #panels_img_data);
  154. }
  155.  
  156. void DrawWindowContent()
  157. {
  158.         #define PD 10
  159.         dword frame_y;
  160.         word win_center_x = Form.cwidth / 2 + 20;
  161.         incn y;
  162.  
  163.         frame_y = 15;
  164.         y.n = frame_y;
  165.         DefineButton(22, y.inc(18), PIMG_W-1, PIMG_H-1, 100 + BT_HIDE, 0);
  166.         DrawPanelsImage(y.n, tbAttachment);
  167.         WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS);
  168.         tbSoftenUp.draw(22, y.inc(35));
  169.         tbClock.draw(win_center_x, y.n);
  170.         tbSoftenDown.draw(22, y.inc(24));
  171.         tbCpuUsage.draw(win_center_x, y.n);
  172.         tbMinLeftButton.draw(22, y.inc(24));
  173.         tbChangeLang.draw(win_center_x, y.n);
  174.         tbMinRightButton.draw(22, y.inc(24));
  175.         tbMenuButton.draw(win_center_x, y.n);
  176.         tbPanelHeight.draw(22, y.inc(28));
  177.         tbSoftenHeight.draw(22, y.inc(32));
  178.         tbButtonOffset.draw(22, y.inc(32));
  179.         DrawFrame(PD, frame_y, Form.cwidth-PD-PD, y.inc(32)-frame_y, TASK_FRAME_T);
  180.         //DOCKY
  181.         frame_y = calc(y.inc(20));
  182.         DefineButton(22, y.inc(18), PIMG_W-1, PIMG_H-1, 200 + BT_HIDE, 0);
  183.         DrawPanelsImage(y.n, dkLocation+1);
  184.         WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS);
  185.         dkFsize.draw(22, y.inc(35));
  186.         dkAshow.draw(win_center_x, y.n);
  187.         DrawFrame(PD, frame_y, Form.cwidth-PD-PD, Form.cheight-frame_y-PD, DOCK_FRAME_T);
  188. }
  189.  
  190. void LoadCfg()
  191. {
  192.         tbAttachment = taskbar_flags_ini.GetInt("Attachment", 1);    
  193.         tbSoftenUp.checked       = taskbar_flags_ini.GetInt("SoftenUp", 1);      
  194.         tbSoftenDown.checked     = taskbar_flags_ini.GetInt("SoftenDown", 1);    
  195.         tbMinLeftButton.checked  = taskbar_flags_ini.GetInt("MinLeftButton", 1);
  196.         tbMinRightButton.checked = taskbar_flags_ini.GetInt("MinRightButton", 1);
  197.         tbClock.checked          = taskbar_flags_ini.GetInt("Clock", 1);        
  198.         tbCpuUsage.checked       = taskbar_flags_ini.GetInt("CpuUsage", 1);      
  199.         tbChangeLang.checked     = taskbar_flags_ini.GetInt("ChangeLang", 1);    
  200.         tbMenuButton.checked     = taskbar_flags_ini.GetInt("MenuButton", 1);    
  201.         tbPanelHeight.value  = taskbar_vars_ini.GetInt("PanelHeight", 28);
  202.         tbSoftenHeight.value = taskbar_vars_ini.GetInt("SoftenHeight", 4);  
  203.         tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonTopOffset", 3);
  204.         tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonBotOffset", 3);
  205.  
  206.         dkLocation = docky_ini.GetInt("location", 0);
  207.         dkFsize.checked = docky_ini.GetInt("fsize", 0);  
  208.         dkAshow.checked = docky_ini.GetInt("ashow", 0);  
  209. }
  210.  
  211. void SaveSettingsAndRestartProcess(byte panel_type)
  212. {
  213.         if (panel_type==TASKBAR) {
  214.                 taskbar_flags_ini.SetInt("Attachment", tbAttachment);
  215.                 taskbar_flags_ini.SetInt("SoftenUp", tbSoftenUp.checked);
  216.                 taskbar_flags_ini.SetInt("SoftenDown", tbSoftenDown.checked);
  217.                 taskbar_flags_ini.SetInt("MinLeftButton", tbMinLeftButton.checked);
  218.                 taskbar_flags_ini.SetInt("MinRightButton", tbMinRightButton.checked);
  219.                 taskbar_flags_ini.SetInt("RunApplButton", tbRunApplButton.checked);
  220.                 taskbar_flags_ini.SetInt("ClnDeskButton", tbClnDeskButton.checked);
  221.                 taskbar_flags_ini.SetInt("Clock", tbClock.checked);
  222.                 taskbar_flags_ini.SetInt("CpuUsage", tbCpuUsage.checked);
  223.                 taskbar_flags_ini.SetInt("ChangeLang", tbChangeLang.checked);
  224.                 taskbar_flags_ini.SetInt("MenuButton", tbMenuButton.checked);
  225.                 taskbar_vars_ini.SetInt("PanelHeight", tbPanelHeight.value);
  226.                 taskbar_vars_ini.SetInt("SoftenHeight", tbSoftenHeight.value);
  227.                 taskbar_vars_ini.SetInt("ButtonTopOffset", tbButtonOffset.value);
  228.                 taskbar_vars_ini.SetInt("ButtonBottOffset", tbButtonOffset.value);
  229.         }
  230.         if (panel_type==DOCKY) {
  231.                 docky_ini.SetInt("location", dkLocation);
  232.                 docky_ini.SetInt("fsize", dkFsize.checked);
  233.                 docky_ini.SetInt("ashow", dkAshow.checked);
  234.         }
  235.         RestartProcess(panel_type);
  236. }
  237.  
  238. void RestartProcess(byte panel_type)
  239. {
  240.         dword proc_name1;
  241.         if (panel_type == TASKBAR)
  242.         {
  243.                 RestartProcessByName("@taskbar", SINGLE);
  244.                 pause(50);
  245.         }
  246.         else
  247.         {
  248.                 RestartProcessByName("@docky", SINGLE);
  249.                 pause(120);
  250.         }
  251.         GetProcessInfo(#Form, SelfInfo);
  252.         ActivateWindow(GetProcessSlot(Form.ID));
  253. }
  254.  
  255.  
  256.  
  257. stop: