Subversion Repositories Kolibri OS

Rev

Rev 5499 | Go to most recent revision | 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\file_system.h"
  10. #include "..\lib\dll.h"
  11. #include "..\lib\gui.h"
  12.  
  13. #include "..\lib\obj\libio_lib.h"
  14. #include "..\lib\obj\libini.h"
  15. #include "..\lib\obj\box_lib.h"
  16.  
  17. #include "..\lib\patterns\libimg_load_skin.h"
  18.  
  19. #define WINDOW_TITLE "Taskbar and Docky configuration"
  20.  
  21. #ifdef LANG_RUS
  22.         ?define MIN_LEFT_BUTTON "Š­®¯ª  áªàëâ¨ï á«¥¢ "
  23.         ?define MIN_RIGHT_BUTTON "Š­®¯ª  áªàëâ¨ï á¯à ¢ "
  24.         ?define SOFTEN_UP   "‘£« ¦¨¢ ­¨¥ ᢥàåã"
  25.         ?define SOFTEN_DOWN "‘£« ¦¨¢ ­¨¥ á­¨§ã"
  26.         ?define CLOCK    "— áë"
  27.         ?define CPU_USAGE "‡ £à㧪  –"
  28.         ?define CHANGE_LANG "Ÿ§ëª ¢¢®¤ "
  29.         ?define MENU_BUTTON "Š­®¯ª  ¬¥­î"
  30.         ?define PANEL_HEIGHT "‚ëá®â  ¯ ­¥«¨"
  31.         ?define SOFTEN_HEIGHT "‚ëá®â  ᣫ ¦¨¢ ­¨ï"
  32.         ?define BUTTON_OFFSET "®«¥ ¢®ªà㣠ª­®¯®ª"
  33.         ?define FSIZE "¥¦¨¬ ¯ ­¥«¨"
  34.         ?define ASHOW "¥ áªà뢠âì"
  35.         ?define CHANGE_POS " ¦¬¨â¥ ­  ¨§®¡à ¦¥­¨¥ ¤«ï ᬥ­ë ¯®§¨æ¨¨"
  36.         ?define ERROR_1 "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/box_lib.obj"
  37.         ?define ERROR_2 "Žè¨¡ª  ¯à¨ § £à㧪¥ ¡¨¡«¨®â¥ª¨ /rd/1/lib/libini.obj"
  38. #else
  39.         ?define MIN_LEFT_BUTTON "Min Left Button"
  40.         ?define MIN_RIGHT_BUTTON "Min Right Button"
  41.         ?define SOFTEN_UP   "Soften Up"
  42.         ?define SOFTEN_DOWN "Soften Down"
  43.         ?define CLOCK    "Clock"
  44.         ?define CPU_USAGE "Cpu Usage"
  45.         ?define CHANGELANG "Change Language"
  46.         ?define MENU_BUTTON "Menu Button"
  47.         ?define PANEL_HEIGHT "Panel Height"
  48.         ?define SOFTEN_HEIGHT "Soften Height"
  49.         ?define BUTTON_OFFSET "Button Offset"
  50.         ?define FSIZE "Full width"
  51.         ?define ASHOW "Always show"
  52.         ?define CHANGE_POS "Click on image to change position"
  53.         ?define ERROR_1 "Error while loading library /rd/1/lib/box_lib.obj"
  54.         ?define ERROR_2 "Error while loading library /rd/1/lib/libini.obj"
  55. #endif
  56.  
  57.  
  58. frame taskbar_frame = { 0, 000, 10, 188, 14, 0x000111, 0xFFFfff, 1, " Taskbar ", 0, 0, 6, 0x000111, 0xCCCccc };
  59. frame docky_frame = { 0, 000, 10, 73, 217, 0x000111, 0xFFFfff, 1, " Docky ", 0, 0, 6, 0x000111, 0xCCCccc };
  60.  
  61. char taskbar_ini_path[] = "/sys/settings/taskbar.ini";
  62. char taskbar_c_flags[] = "Flags";
  63. char taskbar_c_variables[] = "Variables";
  64. char docky_ini_path[] = "/sys/settings/docky.ini";
  65.  
  66. unsigned char panels_img_data[] = FROM "panels_image.raw";
  67. raw_image panels_img = { 37, 27, #panels_img_data };
  68.  
  69. system_colors sc;
  70. proc_info Form;
  71.  
  72. struct docky_cfg {
  73.         word fsize;
  74.         byte location, ashow;
  75. } docky_cfg;
  76.  
  77. struct taskbar_cfg {
  78.         byte Attachment;
  79.         byte PanelHeight, SoftenHeight, ButtonOffset;
  80.         byte SoftenUp, SoftenDown, MinLeftButton, MinRightButton, MenuButton,
  81.              RunApplButton, ClnDeskButton, Clock, CpuUsage, ChangeLang;
  82. } taskbar_cfg;
  83.  
  84. enum {
  85.         TASKBAR,
  86.         DOCKY
  87. };
  88.  
  89.  
  90. void main()
  91. {
  92.         dword id, key;
  93.  
  94.         mem_Init();
  95.         if (load_dll2(libini, #lib_init,1)!=0) notify(ERROR_2);
  96.         if (load_dll2(boxlib, #box_lib_init,0)!=0) notify(ERROR_1);
  97.  
  98.         LoadCfg();
  99.  
  100.         loop() switch(WaitEvent())
  101.         {
  102.                 case evButton:
  103.                                 id=GetButtonID();
  104.                                 if (id==1) ExitProcess();
  105.                                 //taskbar buttons
  106.                                 if (id>=100) && (id<200)
  107.                                 {
  108.                                         if (id==100) taskbar_cfg.Attachment ^= 1;
  109.                                         if (id==105) taskbar_cfg.SoftenUp ^= 1;
  110.                                         if (id==106) taskbar_cfg.SoftenDown ^= 1;
  111.                                         if (id==107) taskbar_cfg.MinLeftButton ^= 1;
  112.                                         if (id==108) taskbar_cfg.MinRightButton ^= 1;
  113.                                         if (id==109) taskbar_cfg.RunApplButton ^= 1;
  114.                                         if (id==110) taskbar_cfg.ClnDeskButton ^= 1;
  115.                                         if (id==111) taskbar_cfg.Clock ^= 1;
  116.                                         if (id==112) taskbar_cfg.CpuUsage ^= 1;
  117.                                         if (id==113) taskbar_cfg.ChangeLang ^= 1;
  118.                                         if (id==114) taskbar_cfg.MenuButton ^= 1;
  119.                                         if (id==120) taskbar_cfg.PanelHeight++;
  120.                                         if (id==121) && (taskbar_cfg.PanelHeight>6) taskbar_cfg.PanelHeight--;
  121.                                         if (id==122) taskbar_cfg.SoftenHeight++;
  122.                                         if (id==123) && (taskbar_cfg.SoftenHeight>0) taskbar_cfg.SoftenHeight--;
  123.                                         if (id==124) taskbar_cfg.ButtonOffset++;
  124.                                         if (id==125) && (taskbar_cfg.ButtonOffset>0) taskbar_cfg.ButtonOffset--;
  125.                                         DrawWindowContent(TASKBAR);
  126.                                         SaveCfg(TASKBAR);
  127.                                         RestartProcess(TASKBAR);
  128.                                 }
  129.                                 //docky buttons                
  130.                                 if (id>=200)
  131.                                 {
  132.                                         if (id==200)
  133.                                         {
  134.                                                      if (docky_cfg.location==1) docky_cfg.location = 2;
  135.                                                 else if (docky_cfg.location==2) docky_cfg.location = 3;
  136.                                                 else if (docky_cfg.location==3) docky_cfg.location = 1;
  137.                                         }
  138.                                         if (id==201) docky_cfg.fsize ^= 1;
  139.                                         if (id==202) docky_cfg.ashow ^= 1;
  140.                                         DrawWindowContent(DOCKY);
  141.                                         SaveCfg(DOCKY);
  142.                                         RestartProcess(DOCKY);
  143.                                 }
  144.                                 break;
  145.                                
  146.                 case evKey:
  147.                                 key = GetKey();
  148.                                 if (key==27) ExitProcess();
  149.                                 break;
  150.                        
  151.                 case evReDraw:
  152.                                 sc.get();
  153.                                 DefineAndDrawWindow(130, 150, 400, 300+GetSkinHeight(),0x34,sc.work,WINDOW_TITLE);
  154.                                 GetProcessInfo(#Form, SelfInfo);
  155.                                 if (Form.status_window>2) break;
  156.                                 taskbar_frame.size_x = docky_frame.size_x = - taskbar_frame.start_x * 2 + Form.cwidth;
  157.                                 taskbar_frame.font_color = docky_frame.font_color = sc.work_text;
  158.                                 taskbar_frame.font_backgr_color = docky_frame.font_backgr_color = sc.work;
  159.                                 taskbar_frame.ext_col = docky_frame.ext_col = sc.work_graph;
  160.                                 DrawWindowContent();
  161.         }
  162. }
  163.  
  164.  
  165. void DrawWindowContent()
  166. {
  167.         word win_center_x;
  168.  
  169.   frame_draw stdcall (#taskbar_frame);
  170.         DefineButton(22, taskbar_frame.start_y + 12, panels_img.w-1, 27-1, 100 + BT_HIDE, 0);
  171.         _PutImage(22, taskbar_frame.start_y + 12,  37, 27, taskbar_cfg.Attachment * 37 * 27 * 3 + panels_img.data);
  172.         WriteText(68, taskbar_frame.start_y + 20, 0x80, 0x333222, CHANGE_POS);
  173.         PanelCfg_CheckBox(22, taskbar_frame.start_y +  48, 105, SOFTEN_UP, taskbar_cfg.SoftenUp);
  174.         PanelCfg_CheckBox(22, taskbar_frame.start_y +  68, 106, SOFTEN_DOWN, taskbar_cfg.SoftenDown);
  175.         PanelCfg_CheckBox(22, taskbar_frame.start_y +  88, 107, MIN_LEFT_BUTTON, taskbar_cfg.MinLeftButton);
  176.         PanelCfg_CheckBox(22, taskbar_frame.start_y + 108, 108, MIN_RIGHT_BUTTON, taskbar_cfg.MinRightButton);
  177.         win_center_x = Form.cwidth / 2;
  178.         PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  48, 111, CLOCK, taskbar_cfg.Clock);
  179.         PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  68, 112, CPU_USAGE, taskbar_cfg.CpuUsage);
  180.         PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y +  88, 113, CHANGE_LANG, taskbar_cfg.ChangeLang);
  181.         PanelCfg_CheckBox(win_center_x, taskbar_frame.start_y + 108, 114, MENU_BUTTON, taskbar_cfg.MenuButton);
  182.         PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 131, 120, 121, taskbar_cfg.PanelHeight, PANEL_HEIGHT);
  183.         PanelCfg_MoreLessBox(win_center_x, taskbar_frame.start_y + 131, 122, 123, taskbar_cfg.SoftenHeight, SOFTEN_HEIGHT);
  184.         PanelCfg_MoreLessBox(22, taskbar_frame.start_y + 159, 124, 125, taskbar_cfg.ButtonOffset, BUTTON_OFFSET);
  185.  
  186.   frame_draw stdcall (#docky_frame);
  187.         DefineButton(22, docky_frame.start_y + 12, panels_img.w-1, 27-1, 200 + BT_HIDE, 0);
  188.         _PutImage(22, docky_frame.start_y + 12,  37, 27, docky_cfg.location + 1 * 37 * 27 * 3 + panels_img.data);
  189.         WriteText(68, docky_frame.start_y + 20, 0x80, 0x333222, CHANGE_POS);
  190.  
  191.         PanelCfg_CheckBox(22, docky_frame.start_y + 48, 201, FSIZE,  docky_cfg.fsize);
  192.         PanelCfg_CheckBox(win_center_x, docky_frame.start_y + 48, 202, ASHOW, docky_cfg.ashow);
  193. }
  194.  
  195. void LoadCfg()
  196. {
  197.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", 1);     taskbar_cfg.Attachment = EAX;
  198.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", 1);       taskbar_cfg.SoftenUp = EAX;
  199.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", 1);     taskbar_cfg.SoftenDown = EAX;
  200.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", 1);  taskbar_cfg.MinLeftButton = EAX;
  201.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", 1); taskbar_cfg.MinRightButton = EAX;
  202.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", 1);          taskbar_cfg.Clock = EAX;
  203.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", 1);       taskbar_cfg.CpuUsage = EAX;
  204.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", 1);     taskbar_cfg.ChangeLang = EAX;
  205.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", 1);     taskbar_cfg.MenuButton = EAX;
  206.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", 18);    taskbar_cfg.PanelHeight = EAX;
  207.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", 4);    taskbar_cfg.SoftenHeight = EAX;
  208.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", 3); taskbar_cfg.ButtonOffset = EAX;
  209.         ini_get_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBotOffset", 3); taskbar_cfg.ButtonOffset = EAX;
  210.  
  211.         ini_get_int stdcall (#docky_ini_path, "@", "location", 0);  docky_cfg.location = EAX;
  212.         ini_get_int stdcall (#docky_ini_path, "@", "fsize", 0);     docky_cfg.fsize = EAX;
  213.         ini_get_int stdcall (#docky_ini_path, "@", "ashow", 0);     docky_cfg.ashow = EAX;
  214. }
  215.  
  216. void SaveCfg(byte panel_type)
  217. {
  218.         if (panel_type==TASKBAR) {
  219.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment);
  220.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenUp", taskbar_cfg.SoftenUp);
  221.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "SoftenDown", taskbar_cfg.SoftenDown);
  222.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinLeftButton", taskbar_cfg.MinLeftButton);
  223.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MinRightButton", taskbar_cfg.MinRightButton);
  224.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "RunApplButton", taskbar_cfg.RunApplButton);
  225.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ClnDeskButton", taskbar_cfg.ClnDeskButton);
  226.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Clock", taskbar_cfg.Clock);
  227.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "CpuUsage", taskbar_cfg.CpuUsage);
  228.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "ChangeLang", taskbar_cfg.ChangeLang);
  229.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "MenuButton", taskbar_cfg.MenuButton);
  230.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "PanelHeight", taskbar_cfg.PanelHeight);
  231.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "SoftenHeight", taskbar_cfg.SoftenHeight);
  232.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonTopOffset", taskbar_cfg.ButtonOffset);
  233.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_variables, "ButtonBottOffset", taskbar_cfg.ButtonOffset);
  234.         }
  235.         if (panel_type==DOCKY) {
  236.                 ini_set_int stdcall (#taskbar_ini_path, #taskbar_c_flags, "Attachment", taskbar_cfg.Attachment);
  237.                 ini_set_int stdcall (#docky_ini_path, "@", "location", docky_cfg.location);
  238.                 ini_set_int stdcall (#docky_ini_path, "@", "fsize", docky_cfg.fsize);
  239.                 ini_set_int stdcall (#docky_ini_path, "@", "ashow", docky_cfg.ashow);
  240.         }
  241. }
  242.  
  243. void RestartProcess(byte panel_type)
  244. {
  245.         int i;
  246.         dword proc_name;
  247.         proc_info Process;
  248.         if (panel_type == TASKBAR) proc_name = "@taskbar";
  249.         if (panel_type == DOCKY) proc_name = "@docky";
  250.         for (i=0; i<1000; i++;)
  251.         {
  252.                 GetProcessInfo(#Process, i);
  253.                 if (strcmpi(#Process.name, proc_name)==0) { KillProcess(Process.ID); break; }
  254.         }
  255.         RunProgram(proc_name, "");
  256.  
  257.         if (panel_type == TASKBAR) pause(50);
  258.         if (panel_type == DOCKY) pause(120);
  259.         GetProcessInfo(#Form, SelfInfo);
  260.         ActivateWindow(GetProcessSlot(Form.ID));
  261. }
  262.  
  263.  
  264.  
  265. void PanelCfg_CheckBox(dword x, y, id, text, byte value) {
  266.         CheckBox(x, y, 14, 14, id, text, sc.work_graph, sc.work_text, value);
  267. }
  268.  
  269. void PanelCfg_MoreLessBox(dword x, y, id_more, id_less; byte value; dword text) {
  270.         MoreLessBox(x, y, 18, id_more, id_less, sc.work_graph, sc.work_button, sc.work_button_text, value, text);
  271. }
  272.  
  273.  
  274. stop: