Subversion Repositories Kolibri OS

Rev

Rev 7243 | Blame | 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. raw_image panels_img = { 37, 27, #panels_img_data };
  65.  
  66. proc_info Form;
  67.  
  68. enum { BTN_TB_ATTACHEMENT=100, BTN_DOCKY_ATTACHEMENT=200 };
  69. enum { TASKBAR, DOCKY };
  70.  
  71. more_less_box tbPanelHeight  = { NULL, 6, 99, PANEL_HEIGHT };
  72. more_less_box tbSoftenHeight = { NULL, 0, 99, SOFTEN_HEIGHT };
  73. more_less_box tbButtonOffset = { NULL, 0, 99, BUTTON_OFFSET };
  74.  
  75. int tbAttachment;
  76. checkbox tbSoftenUp = { SOFTEN_UP };
  77. checkbox tbClock = { CLOCK };
  78. checkbox tbSoftenDown = { SOFTEN_DOWN };
  79. checkbox tbCpuUsage = { CPU_USAGE };
  80. checkbox tbMinLeftButton = { MIN_LEFT_BUTTON };
  81. checkbox tbChangeLang = { CHANGE_LANG };
  82. checkbox tbMinRightButton = { MIN_RIGHT_BUTTON };
  83. checkbox tbMenuButton = { MENU_BUTTON };
  84. checkbox dkFsize = { FSIZE };
  85. checkbox dkAshow = { ASHOW };
  86.  
  87. int dkLocation;
  88. checkbox tbRunApplButton;
  89. checkbox tbClnDeskButton;
  90.  
  91.  
  92. void main()
  93. {
  94.         dword id, key;
  95.  
  96.         load_dll(libini, #lib_init,1);
  97.         load_dll(boxlib, #box_lib_init,0);
  98.  
  99.         LoadCfg();
  100.  
  101.         loop() switch(WaitEvent())
  102.         {
  103.                 case evButton:
  104.                                 id=GetButtonID();
  105.                                 if (1==id) ExitProcess();
  106.                                 //taskbar buttons
  107.                                 if (BTN_TB_ATTACHEMENT == id) {
  108.                                         tbAttachment ^= 1;
  109.                                         DrawWindowContent();
  110.                                         SaveSettingsAndRestartProcess(TASKBAR);
  111.                                 }
  112.  
  113.                                 if (tbSoftenUp.click(id))      || (tbSoftenDown.click(id))
  114.                                 || (tbMinLeftButton.click(id)) || (tbMinRightButton.click(id))
  115.                                 || (tbRunApplButton.click(id)) || (tbClnDeskButton.click(id)) {
  116.                                         SaveSettingsAndRestartProcess(TASKBAR);
  117.                                 }
  118.  
  119.                                 if (tbClock.click(id))       || (tbCpuUsage.click(id))
  120.                                 || (tbChangeLang.click(id))  || (tbMenuButton.click(id))
  121.                                 || (tbPanelHeight.click(id)) || (tbSoftenHeight.click(id))
  122.                                 || (tbButtonOffset.click(id)) {
  123.                                         SaveSettingsAndRestartProcess(TASKBAR);
  124.                                 }
  125.                                 //docky buttons
  126.                                 if (id==200) {
  127.                                         dkLocation++;
  128.                                         if (dkLocation>3) dkLocation=1;
  129.                                         DrawWindowContent();
  130.                                         SaveSettingsAndRestartProcess(DOCKY);
  131.                                 }
  132.                                 if (dkFsize.click(id)) SaveSettingsAndRestartProcess(DOCKY);
  133.                                 if (dkAshow.click(id)) SaveSettingsAndRestartProcess(DOCKY);
  134.                                 break;
  135.                                
  136.                 case evKey:
  137.                                 key = GetKey();
  138.                                 if (key==27) ExitProcess();
  139.                                 break;
  140.                        
  141.                 case evReDraw:
  142.                                 system.color.get();
  143.                                 DefineAndDrawWindow(130, 150, 465, 398 + skin_height, 0x34, system.color.work, WINDOW_TITLE, 0);
  144.                                 GetProcessInfo(#Form, SelfInfo);
  145.                                 if (Form.status_window>2) break;
  146.                                 DrawWindowContent();
  147.         }
  148. }
  149.  
  150. void DrawWindowContent()
  151. {
  152.         #define PD 10
  153.         dword frame_y;
  154.         word win_center_x = Form.cwidth / 2 + 20;
  155.         incn y;
  156.  
  157.         frame_y = 15;
  158.         y.n = frame_y;
  159.         DefineButton(22, y.inc(18), panels_img.w-1, 27-1, 100 + BT_HIDE, 0);
  160.         _PutImage(22, y.n, 37, 27, tbAttachment * 37 * 27 * 3 + panels_img.data);
  161.         WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS);
  162.         tbSoftenUp.draw(22, y.inc(35));
  163.         tbClock.draw(win_center_x, y.n);
  164.         tbSoftenDown.draw(22, y.inc(24));
  165.         tbCpuUsage.draw(win_center_x, y.n);
  166.         tbMinLeftButton.draw(22, y.inc(24));
  167.         tbChangeLang.draw(win_center_x, y.n);
  168.         tbMinRightButton.draw(22, y.inc(24));
  169.         tbMenuButton.draw(win_center_x, y.n);
  170.         tbPanelHeight.draw(22, y.inc(28));
  171.         tbSoftenHeight.draw(22, y.inc(32));
  172.         tbButtonOffset.draw(22, y.inc(32));
  173.         DrawFrame(PD, frame_y, Form.cwidth-PD-PD, y.inc(32)-frame_y, TASK_FRAME_T);
  174.         //DOCKY
  175.         frame_y = calc(y.inc(20));
  176.         DefineButton(22, y.inc(18), panels_img.w-1, 27-1, 200 + BT_HIDE, 0);
  177.         _PutImage(22, y.n,  37, 27, dkLocation + 1 * 37 * 27 * 3 + panels_img.data);
  178.         WriteText(68, y.inc(7), 0x90, system.color.work_text, CHANGE_POS);
  179.         dkFsize.draw(22, y.inc(35));
  180.         dkAshow.draw(win_center_x, y.n);
  181.         DrawFrame(PD, frame_y, Form.cwidth-PD-PD, Form.cheight-frame_y-PD, DOCK_FRAME_T);
  182. }
  183.  
  184. void LoadCfg()
  185. {
  186.         tbAttachment = taskbar_flags_ini.GetInt("Attachment", 1);    
  187.         tbSoftenUp.checked       = taskbar_flags_ini.GetInt("SoftenUp", 1);      
  188.         tbSoftenDown.checked     = taskbar_flags_ini.GetInt("SoftenDown", 1);    
  189.         tbMinLeftButton.checked  = taskbar_flags_ini.GetInt("MinLeftButton", 1);
  190.         tbMinRightButton.checked = taskbar_flags_ini.GetInt("MinRightButton", 1);
  191.         tbClock.checked          = taskbar_flags_ini.GetInt("Clock", 1);        
  192.         tbCpuUsage.checked       = taskbar_flags_ini.GetInt("CpuUsage", 1);      
  193.         tbChangeLang.checked     = taskbar_flags_ini.GetInt("ChangeLang", 1);    
  194.         tbMenuButton.checked     = taskbar_flags_ini.GetInt("MenuButton", 1);    
  195.         tbPanelHeight.value  = taskbar_vars_ini.GetInt("PanelHeight", 28);
  196.         tbSoftenHeight.value = taskbar_vars_ini.GetInt("SoftenHeight", 4);  
  197.         tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonTopOffset", 3);
  198.         tbButtonOffset.value = taskbar_vars_ini.GetInt("ButtonBotOffset", 3);
  199.  
  200.         dkLocation = docky_ini.GetInt("location", 0);
  201.         dkFsize.checked = docky_ini.GetInt("fsize", 0);  
  202.         dkAshow.checked = docky_ini.GetInt("ashow", 0);  
  203. }
  204.  
  205. void SaveSettingsAndRestartProcess(byte panel_type)
  206. {
  207.         if (panel_type==TASKBAR) {
  208.                 taskbar_flags_ini.SetInt("Attachment", tbAttachment);
  209.                 taskbar_flags_ini.SetInt("SoftenUp", tbSoftenUp.checked);
  210.                 taskbar_flags_ini.SetInt("SoftenDown", tbSoftenDown.checked);
  211.                 taskbar_flags_ini.SetInt("MinLeftButton", tbMinLeftButton.checked);
  212.                 taskbar_flags_ini.SetInt("MinRightButton", tbMinRightButton.checked);
  213.                 taskbar_flags_ini.SetInt("RunApplButton", tbRunApplButton.checked);
  214.                 taskbar_flags_ini.SetInt("ClnDeskButton", tbClnDeskButton.checked);
  215.                 taskbar_flags_ini.SetInt("Clock", tbClock.checked);
  216.                 taskbar_flags_ini.SetInt("CpuUsage", tbCpuUsage.checked);
  217.                 taskbar_flags_ini.SetInt("ChangeLang", tbChangeLang.checked);
  218.                 taskbar_flags_ini.SetInt("MenuButton", tbMenuButton.checked);
  219.                 taskbar_vars_ini.SetInt("PanelHeight", tbPanelHeight.value);
  220.                 taskbar_vars_ini.SetInt("SoftenHeight", tbSoftenHeight.value);
  221.                 taskbar_vars_ini.SetInt("ButtonTopOffset", tbButtonOffset.value);
  222.                 taskbar_vars_ini.SetInt("ButtonBottOffset", tbButtonOffset.value);
  223.         }
  224.         if (panel_type==DOCKY) {
  225.                 docky_ini.SetInt("location", dkLocation);
  226.                 docky_ini.SetInt("fsize", dkFsize.checked);
  227.                 docky_ini.SetInt("ashow", dkAshow.checked);
  228.         }
  229.         RestartProcess(panel_type);
  230. }
  231.  
  232. void RestartProcess(byte panel_type)
  233. {
  234.         dword proc_name1;
  235.         if (panel_type == TASKBAR)
  236.         {
  237.                 RestartProcessByName("@taskbar", SINGLE);
  238.                 pause(50);
  239.         }
  240.         else
  241.         {
  242.                 RestartProcessByName("@docky", SINGLE);
  243.                 pause(120);
  244.         }
  245.         GetProcessInfo(#Form, SelfInfo);
  246.         ActivateWindow(GetProcessSlot(Form.ID));
  247. }
  248.  
  249.  
  250.  
  251. stop: