Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Declare Create_ini(ini$)
- UsePNGImageDecoder()
- If OpenWindow(0, 100, 150, 300, 100, "SaveFolders - SysTray", #PB_Window_SystemMenu | #PB_Window_Invisible)
- ; CompilerIf #PB_Compiler_OS = #PB_OS_Linux
- ; some Linux and x86 specific code.
- ; CompilerEndIf
- CatchImage(0, ?folder24_png)
- CatchImage(1, ?folder_png)
- AddSysTrayIcon(0, WindowID(0), ImageID(0)) ; иконка в трее
- SysTrayIconToolTip(0, "SaveFolders") ; Название проги в подсказке
- ArrSize = 100
- Dim ArrPath.s(ArrSize)
- Repeat
- CreatePopupImageMenu(0)
- ; получаем путь к ини по имени программы
- ini$ = GetPathPart(ProgramFilename()) + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + ".ini"
- ; Debug ini$
- If FileSize(ini$) = -1 And Not Create_ini(ini$)
- MessageRequester("Ошибка", "Не найден файл и не удаётся создать" + #CRLF$ + ini$)
- End
- EndIf
- ; заполнение массива
- OpenPreferences(ini$)
- i=0
- ExaminePreferenceGroups()
- While NextPreferenceGroup()
- tmp$ = PreferenceGroupName()
- OpenSubMenu(tmp$, ImageID(1))
- ; Debug tmp$
- ExaminePreferenceKeys()
- While NextPreferenceKey()
- ; Param.s = PreferenceKeyValue()
- ; If Param<>""
- ; Param = " - параметры: "+Param
- ; EndIf
- tmp$ = PreferenceKeyName()
- If Not FileSize(tmp$) = -2 ; Если путь не является существующим каталогом, то игнор и следующий
- Continue
- EndIf
- i+1
- If i > ArrSize
- ArrSize + 100
- ReDim ArrPath(ArrSize)
- EndIf
- MenuItem(i, tmp$, ImageID(1))
- ArrPath(i) = tmp$
- ; Debug tmp$
- Wend
- CloseSubMenu()
- Wend
- ClosePreferences()
- MenuBar()
- OpenSubMenu("Меню")
- MenuItem(997, "Перезапуск ini")
- MenuItem(998, "Открыть ini")
- MenuItem(999, "Выход")
- CloseSubMenu()
- ; MenuItem(998, "Инфа")
- ; Q = 0
- ; Dim ArrProg.s(3)
- ; ArrProg(1) = "geany"
- Prog.s = ""
- If FileSize("geany")
- Prog.s = "geany"
- ElseIf FileSize("xed")
- Prog.s = "xed"
- ElseIf FileSize("gedit")
- Prog.s = "gedit"
- EndIf
- tmp$ = ""
- Repeat
- Event = WaitWindowEvent()
- If Event = #PB_Event_SysTray
- Select EventType()
- Case #PB_EventType_LeftClick, #PB_EventType_RightClick
- DisplayPopupMenu(0, WindowID(0)) ; показ вспывающего меню
- EndSelect
- EndIf
- If Event = #PB_Event_Menu
- em = EventMenu()
- If em >= 1 And em <= i
- ; If FindString(ArrPath(em) , " ")
- ; tmp$ = ReplaceString(ArrPath(em) , "/" , Chr(34)+"/"+Chr(34), #PB_String_NoCase)+Chr(34)
- ; tmp$ = LTrim(tmp$, Chr(34))
- ; ; tmp$ = RTrim(tmp$, Chr(34))
- ; Else
- ; tmp$ = ArrPath(em)
- ; EndIf
- ; RunProgram("nemo", ArrPath(em), "")
- RunProgram("nemo", Chr(34)+ArrPath(em)+Chr(34), "")
- ; RunProgram("nemo", tmp$, "")
- ; Debug "nemo " + ArrPath(em)
- ; Debug tmp$
- ElseIf em = 997
- Break
- ElseIf em = 998
- If Prog.s <> ""
- RunProgram(Prog.s, ini$, "")
- EndIf
- ElseIf em = 999
- FreeMenu(0)
- FreeArray(ArrPath())
- CloseWindow(0)
- End
- EndIf
- EndIf
- ForEver
- FreeMenu(0)
- FreeArray(ArrPath())
- ArrSize = 100
- Dim ArrPath(ArrSize)
- ForEver
- EndIf
- End
- Procedure Create_ini(ini$)
- Protected hfile, Text$
- Text$ = "[System]" + #CRLF$ + GetHomeDirectory() + #CRLF$ + "/usr/share/backgrounds" + #CRLF$ + "/usr/share/icons" + #CRLF$ + "/usr/share/themes" + #CRLF$ + "/usr/share/applications" + #CRLF$ + #CRLF$ + "[PureBasic]" + #CRLF$ + GetCurrentDirectory() + #CRLF$ + #PB_Compiler_Home
- hfile = OpenFile(#PB_Any, ini$, #PB_UTF8)
- If hfile
- If WriteStringFormat(hfile, #PB_UTF8)
- WriteString(hfile, Text$, #PB_UTF8)
- CloseFile(hfile)
- ProcedureReturn 1
- EndIf
- CloseFile(hfile)
- EndIf
- ProcedureReturn 0
- EndProcedure
- DataSection
- folder_png:
- IncludeBinary "images/folder.png"
- folder_pngend:
- folder24_png:
- IncludeBinary "images/folder24.png"
- folder24_pngend:
- EndDataSection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement