Subversion Repositories Kolibri OS

Rev

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

  1. //11.03.12 - start!
  2.  
  3. #define MEMSIZE 0xFE800
  4. #include "..\lib\kolibri.h"
  5. #include "..\lib\mem.h"
  6. #include "..\lib\file_system.h"
  7. #include "..\lib\strings.h"
  8. #include "..\lib\list_box.h"
  9. #include "..\lib\figures.h"
  10.  
  11. #define WINDOW_HEADER "Appearance"
  12.  
  13. #define PANEL_H 30
  14. #define SKINS_STANDART_PATH "/sys/skins/"
  15. #define WALP_STANDART_PATH "/sys/wallpapers/"
  16.  
  17. llist list[2];
  18. int active;
  19. enum { SKINS, WALLPAPERS };
  20.  
  21. char folder_path[4096];
  22. char cur_file_path[4096];
  23. char temp_filename[4096];
  24. int files_mas[100];
  25. dword buf;
  26.  
  27. int cur;
  28.  
  29. system_colors sc;
  30. proc_info Form;
  31.  
  32. #include "other.h"
  33.  
  34. //ADD PaNEL
  35.  
  36.  
  37. //skins direktory,    configurate, delete from list, delete from disk, make default
  38.  
  39. void Open_Dir()
  40. {
  41.         int j, filesnum;
  42.  
  43.         list[active].count = 0;
  44.         free(buf);
  45.         if (GetDir(#buf, #filesnum, #folder_path, DIRS_ONLYREAL)!=0) return;
  46.  
  47.         for (j=0; j<filesnum; j++)
  48.         {
  49.                 strlwr(j*304 + buf+72);
  50.                 strcpy(#temp_filename, j*304 + buf+72);
  51.                 if (active==SKINS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".skn")!=0) continue;
  52.                 if (active==WALLPAPERS) if (strcmp(#temp_filename+strlen(#temp_filename)-4,".txt")==0) continue;
  53.                 cur = list[active].count;
  54.                 files_mas[cur]=j;
  55.                 if (!strcmp("default.skn",#temp_filename)) files_mas[0]><files_mas[list[active].count];
  56.                 list[active].count++;
  57.         }
  58.         Sort_by_Name(0, list[active].count-1);
  59. }
  60.  
  61. void Draw_List()
  62. {
  63.         int i;
  64.         list[SKINS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
  65.         list[WALLPAPERS].SetSizes(0, PANEL_H, Form.cwidth, Form.cheight-PANEL_H, 40, 20);
  66.        
  67.         for (i=0; i<list[active].visible; i++;)
  68.         {
  69.                 cur = list[active].first;
  70.                 strcpy(#temp_filename, files_mas[i+cur]*304 + buf+72);
  71.                
  72.                 if (list[active].current-list[active].first==i)
  73.                 {
  74.                         if (sc.work_button<>sc.work)
  75.                         {
  76.                                 DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.work_button);
  77.                                 WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.work_button_text, #temp_filename);
  78.                         }
  79.                         else
  80.                         {
  81.                                 DrawBar(0, i*list[active].line_h+list[active].y, list[active].w, list[active].line_h, sc.grab_button);
  82.                                 WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,sc.grab_button_text, #temp_filename);
  83.                         }      
  84.                 }
  85.                 else
  86.                 {
  87.                         DrawBar(0,i*list[active].line_h+list[active].y,list[active].w, list[active].line_h, 0xFFFfff);
  88.                         WriteText(11,i*list[active].line_h+list[active].text_y+list[active].y,0x80,0, #temp_filename);
  89.                 }
  90.         }
  91.         DrawBar(0,list[active].visible*list[active].line_h+list[active].y, list[active].w, -list[active].visible*list[active].line_h+ list[active].h, 0xFFFfff);
  92. }
  93.  
  94. void GetFiles(int set_active)
  95. {
  96.         active = set_active;
  97.         if (active==SKINS)
  98.         {
  99.                 strcpy(#folder_path, SKINS_STANDART_PATH);
  100.                 Open_Dir();
  101.                 if (!list[active].count) notify("No skins were found");
  102.         }
  103.         if (active==WALLPAPERS)
  104.         {
  105.                 strcpy(#folder_path, WALP_STANDART_PATH);
  106.                 Open_Dir();
  107.                 if (!list[active].count) notify("No wallpapers were found");
  108.         }
  109. }
  110.  
  111. void Apply()
  112. {
  113.         if (active==SKINS)
  114.         {
  115.                 strcpy(#cur_file_path, #folder_path);
  116.                 cur = list[active].current;
  117.                 strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
  118.                 SetSystemSkin(#cur_file_path);
  119.         }
  120.         if (active==WALLPAPERS)
  121.         {
  122.                 strcpy(#cur_file_path, "\\S__");
  123.                 strcat(#cur_file_path, #folder_path);
  124.                 cur = list[active].current;
  125.                 strcat(#cur_file_path, files_mas[cur]*304 + buf+72);
  126.                 RunProgram("/sys/media/kiv", #cur_file_path);
  127.                 Draw_List();
  128.         }
  129. }
  130.  
  131. OpenFile()
  132. {
  133.         if (active==SKINS) RunProgram("/sys/desktop", #cur_file_path);
  134.         if (active==WALLPAPERS) RunProgram("/sys/media/kiv", #cur_file_path);
  135. }
  136.  
  137.  
  138. void main()
  139. {  
  140.         int id, key, mouse_clicked;
  141.         mouse mm;
  142.  
  143.         mem_Init();
  144.         if (param) strcpy(#folder_path, #param);
  145.         list[SKINS].current = list[WALLPAPERS].current = -1;
  146.         list[SKINS].first = list[WALLPAPERS].first = 0;
  147.         GetFiles(WALLPAPERS);
  148.         list[active].SetSizes(0, 230, 350, 400-PANEL_H, 40, 18);
  149.         SetEventMask(0x27);
  150.         loop()
  151.         {
  152.           switch(WaitEvent())
  153.           {
  154.                 case evMouse:
  155.                         mm.get();
  156.                         if (mm.vert) && (list[active].MouseScroll(mm.vert)) Draw_List();
  157.                         if (mouse_clicked)
  158.                         {
  159.                                 if (!mm.lkm) && (active==SKINS) && (list[SKINS].ProcessMouse(mm.x, mm.y)) Apply();
  160.                                 if (!mm.lkm) && (active==WALLPAPERS) && (list[WALLPAPERS].ProcessMouse(mm.x, mm.y)) Apply();
  161.                                 mouse_clicked=0;
  162.                         }
  163.                         if (mm.lkm) && (list[SKINS].MouseOver(mm.x, mm.y)) mouse_clicked=1;
  164.                         break;
  165.  
  166.                 case evButton:
  167.                         id=GetButtonID();
  168.                         if (id==1) ExitProcess();
  169.                         if (id==2) TabClick(SKINS);
  170.                         if (id==3) TabClick(WALLPAPERS);
  171.                         break;
  172.          
  173.                 case evKey:
  174.                         key = GetKey();
  175.                         if (active==SKINS) && (list[SKINS].ProcessKey(key)) Apply();
  176.                         if (active==WALLPAPERS) && (list[WALLPAPERS].ProcessKey(key)) Apply();
  177.                         IF (key==013) OpenFile();
  178.                         if (key==9) //Tab
  179.                         {
  180.                                 if (active==SKINS)
  181.                                         TabClick(WALLPAPERS);
  182.                                 else
  183.                                         TabClick(SKINS);
  184.                         }
  185.                         IF (key==182) //Del
  186.                         {
  187.                                 DeleteFile(#cur_file_path);
  188.                                 Open_Dir();
  189.                                 Apply();
  190.                         }
  191.                         break;
  192.                  
  193.                  case evReDraw:
  194.                         sc.get();                      
  195.                         DefineAndDrawWindow(30,80,list[active].w+9,list[active].h+4+GetSkinHeight(),0x73,0xE4DFE1,WINDOW_HEADER);
  196.                         GetProcessInfo(#Form, SelfInfo);
  197.                         IF (Form.status_window>=2) break;
  198.                         DrawTabs();
  199.                         Draw_List();
  200.           }
  201.    }
  202. }
  203.  
  204.  
  205. void DrawTabs()
  206. {
  207.         dword col_bg, col_text;
  208.         DrawBar(0,0, Form.cwidth, PANEL_H-1, sc.work);
  209.  
  210.         if (active==SKINS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;}
  211.         DrawRectangle(10-1,7-1, 65+2, 21+2, sc.work_graph);
  212.         DrawCaptButton(10,7, 65, 21, 2, col_bg, col_text, "Skins"); //вокруг рисовать пмятоуг
  213.         if (active==WALLPAPERS) {col_bg=sc.work_button; col_text=sc.work_button_text;} else {col_bg=sc.work; col_text=sc.work_text;}
  214.         DrawRectangle(90-1,7-1, 95+2, 21+2, sc.work_graph);
  215.         DrawCaptButton(90,7, 95, 21, 3, col_bg, col_text, "Wallpappers");
  216.  
  217.         DrawBar(0,PANEL_H-2, Form.cwidth, 1, sc.work_graph);
  218.         DrawBar(0,PANEL_H-1, Form.cwidth, 1, 0xEEEeee);
  219. }
  220.  
  221. void TabClick(int N)
  222. {
  223.         GetFiles(N);
  224.         DrawTabs();
  225.         Draw_List();
  226. }
  227.  
  228.  
  229.  
  230.  
  231. stop:
  232.