avec installeur intégré
This commit is contained in:
200
PBIDE-GitTool.pb
200
PBIDE-GitTool.pb
@@ -43,6 +43,8 @@ Declare.i DoCommit(repoDir$, message$, doPush.i, remote$, branch$)
|
||||
Declare.i DoPush(repoDir$, remote$, branch$)
|
||||
Declare.i DoPull(repoDir$, remote$, branch$)
|
||||
Declare.i ListBranches(repoDir$, List branchesList.s())
|
||||
Declare.i InstallPBGitInIDE(ideExe$, toolsPrefs$, themeZip$)
|
||||
Declare.i OpenInstallWizard()
|
||||
|
||||
; ====== Utils ======
|
||||
Procedure.s TrimNewlines(text$)
|
||||
@@ -374,6 +376,22 @@ Procedure.i OpenGUI(initialDir$, prefsPath$)
|
||||
ButtonGadget(#GPush, 140, 410, 120, 30, "Push")
|
||||
ButtonGadget(#GPull, 270, 410, 120, 30, "Pull")
|
||||
|
||||
; --------- Infobulles (tooltips) ---------
|
||||
GadgetToolTip(#GStringRepo, "Dossier du dépôt Git. Utilisez 'Parcourir…' pour le sélectionner.")
|
||||
GadgetToolTip(#GButtonBrowse, "Choisir le répertoire du dépôt.")
|
||||
GadgetToolTip(#GListStatus, "État des fichiers (git status --porcelain).")
|
||||
GadgetToolTip(#GRefresh, "Rafraîchir l’état du dépôt.")
|
||||
GadgetToolTip(#GInit, "Initialiser un dépôt Git ici (git init).")
|
||||
GadgetToolTip(#GStringMsg, "Message de commit.")
|
||||
GadgetToolTip(#GCheckPush, "Activer pour pousser après le commit (git push).")
|
||||
GadgetToolTip(#GStringRemote, "Nom du remote (ex: origin).")
|
||||
GadgetToolTip(#GLabelRemote, "Nom du remote par défaut.")
|
||||
GadgetToolTip(#GComboBranch, "Branche cible (ex: main).")
|
||||
GadgetToolTip(#GSavePrefs, "Sauver remote/branche comme valeurs par défaut.")
|
||||
GadgetToolTip(#GCommit, "git add -A puis git commit -m "+Chr(34)+"message"+Chr(34)+" (et push si coché).")
|
||||
GadgetToolTip(#GPush, "Pousser la branche (git push).")
|
||||
GadgetToolTip(#GPull, "Récupérer les changements distants (git pull).")
|
||||
|
||||
; Remplir branches via la LISTE
|
||||
NewList branchItems.s()
|
||||
ListBranches(repoDir$, branchItems())
|
||||
@@ -408,8 +426,6 @@ Procedure.i OpenGUI(initialDir$, prefsPath$)
|
||||
If newDir$ <> ""
|
||||
repoDir$ = newDir$
|
||||
SetGadgetText(#GStringRepo, repoDir$)
|
||||
|
||||
; Recharger la liste des branches
|
||||
ClearList(branchItems())
|
||||
ListBranches(repoDir$, branchItems())
|
||||
ClearGadgetItems(#GComboBranch)
|
||||
@@ -478,31 +494,184 @@ Procedure.i OpenGUI(initialDir$, prefsPath$)
|
||||
ProcedureReturn 0
|
||||
EndProcedure
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; Installe l’intégration dans l’IDE PureBasic :
|
||||
; - copie le thème d’icônes (zip) dans <IDE>\Themes\
|
||||
; - lance l’IDE avec /A "<fichier_tools>" pour importer les outils
|
||||
; Retourne 1 si OK, 0 sinon.
|
||||
; ------------------------------------------------------------------
|
||||
Procedure.i InstallPBGitInIDE(ideExe$, toolsPrefs$, themeZip$)
|
||||
Protected ok.i = 1
|
||||
Protected ideHome$, themesDir$, destZip$, args$, prg.i, copyOk.i
|
||||
|
||||
If FileSize(ideExe$) <= 0 Or FileSize(toolsPrefs$) <= 0 Or FileSize(themeZip$) <= 0
|
||||
MessageRequester("Installation", "Chemins invalides. Merci de sélectionner PureBasic.exe, le fichier d’outils et le thème.", #PB_MessageRequester_Error)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
ideHome$ = GetPathPart(ideExe$)
|
||||
themesDir$ = ideHome$ + "Themes" + #PathSep$
|
||||
destZip$ = themesDir$ + GetFilePart(themeZip$)
|
||||
|
||||
; Créer le dossier Themes si besoin
|
||||
If FileSize(themesDir$) <> -2
|
||||
If CreateDirectory(themesDir$) = 0
|
||||
MessageRequester("Installation", "Impossible de créer le dossier Themes : " + themesDir$, #PB_MessageRequester_Error)
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
; Copier le thème
|
||||
copyOk = CopyFile(themeZip$, destZip$)
|
||||
If copyOk = 0
|
||||
MessageRequester("Installation", "Échec de copie du thème vers : " + destZip$, #PB_MessageRequester_Error)
|
||||
ok = 0
|
||||
EndIf
|
||||
|
||||
; Importer les outils via /A "<toolsPrefs$>"
|
||||
If ok
|
||||
args$ = "/A " + Chr(34) + toolsPrefs$ + Chr(34)
|
||||
prg = RunProgram(ideExe$, args$, "", #PB_Program_Hide | #PB_Program_Wait)
|
||||
If prg = 0
|
||||
MessageRequester("Installation", "Échec de l’import des outils (/A).", #PB_MessageRequester_Error)
|
||||
ok = 0
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
If ok
|
||||
MessageRequester("Installation", "Intégration importée !" + #LF$ +
|
||||
"- Thème copié dans: " + destZip$ + #LF$ +
|
||||
"- Outils importés via /A", #PB_MessageRequester_Info)
|
||||
EndIf
|
||||
|
||||
ProcedureReturn ok
|
||||
EndProcedure
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; Assistant d’installation graphique quand PBIDE-GitTool est lancé sans paramètre.
|
||||
; - Permet de choisir PureBasic.exe, git_tools.prefs et PBGitTheme.zip
|
||||
; - Appelle InstallPBGitInIDE()
|
||||
; Retourne 1 si installation OK, 0 sinon.
|
||||
; ------------------------------------------------------------------
|
||||
|
||||
; Gadgets de la fenêtre d'installation (évite toute collision avec l’UI principale)
|
||||
#WInstall = 100
|
||||
#GLabelIde = 110
|
||||
#GStringIde = 111
|
||||
#GButtonIde = 112
|
||||
#GLabelTools = 113
|
||||
#GStringTools = 114
|
||||
#GButtonTools = 115
|
||||
#GLabelTheme = 116
|
||||
#GStringTheme = 117
|
||||
#GButtonTheme = 118
|
||||
#GInstallGo = 119
|
||||
#GInstallCancel = 120
|
||||
#GInstallNote = 121
|
||||
|
||||
Procedure.i OpenInstallWizard()
|
||||
Protected exeDefault$ = ""
|
||||
Protected dirExe$ = GetPathPart(ProgramFilename())
|
||||
Protected prefsDefault$ = dirExe$ + "git_tools.prefs"
|
||||
Protected themeDefault$ = dirExe$ + "PBGitTheme.zip"
|
||||
|
||||
If OpenWindow(#WInstall, 0, 0, 680, 240, "PBIDE-GitTool — Assistant d’installation IDE", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
|
||||
TextGadget(#GLabelIde, 10, 16, 140, 22, "PureBasic.exe :")
|
||||
StringGadget(#GStringIde,160, 14, 420, 24, exeDefault$)
|
||||
ButtonGadget(#GButtonIde,590, 14, 80, 24, "Parcourir…")
|
||||
|
||||
TextGadget(#GLabelTools, 10, 56, 140, 22, "Fichier outils :")
|
||||
StringGadget(#GStringTools,160, 54, 420, 24, prefsDefault$)
|
||||
ButtonGadget(#GButtonTools,590, 54, 80, 24, "Parcourir…")
|
||||
|
||||
TextGadget(#GLabelTheme, 10, 96, 140, 22, "Thème icônes :")
|
||||
StringGadget(#GStringTheme,160, 94, 420, 24, themeDefault$)
|
||||
ButtonGadget(#GButtonTheme,590, 94, 80, 24, "Parcourir…")
|
||||
|
||||
ButtonGadget(#GInstallGo, 380, 150, 140, 30, "Installer")
|
||||
ButtonGadget(#GInstallCancel, 530, 150, 140, 30, "Annuler")
|
||||
|
||||
TextGadget(#GInstallNote, 10, 190, 660, 40,
|
||||
"Conseil : placez 'git_tools.prefs' et 'PBGitTheme.zip' à côté de PBIDE-GitTool.exe pour auto-renseignement." + #LF$ +
|
||||
"Après import, choisissez le thème dans Préférences → General → Themes, puis ajoutez des boutons 'Run tool' dans la Toolbar.")
|
||||
|
||||
; Infobulles de l’assistant
|
||||
GadgetToolTip(#GStringIde, "Chemin de PureBasic.exe (IDE).")
|
||||
GadgetToolTip(#GButtonIde, "Parcourir pour sélectionner l’exécutable de l’IDE PureBasic.")
|
||||
GadgetToolTip(#GStringTools, "Fichier d’outils externes à importer (/A).")
|
||||
GadgetToolTip(#GButtonTools, "Parcourir le fichier 'git_tools.prefs'.")
|
||||
GadgetToolTip(#GStringTheme, "Archive ZIP du thème d’icônes pour la Toolbar.")
|
||||
GadgetToolTip(#GButtonTheme, "Parcourir le fichier 'PBGitTheme.zip'.")
|
||||
GadgetToolTip(#GInstallGo, "Lancer l’installation (copie du thème + import des outils).")
|
||||
GadgetToolTip(#GInstallCancel, "Fermer l’assistant sans rien modifier.")
|
||||
|
||||
Repeat
|
||||
Protected ev.i = WaitWindowEvent()
|
||||
If ev = #PB_Event_Gadget
|
||||
Select EventGadget()
|
||||
Case #GButtonIde
|
||||
Protected pickExe$ = OpenFileRequester("Choisir PureBasic.exe", GetPathPart(GetGadgetText(#GStringIde)), "Exécutable|*.exe;*|Tous|*.*", 0)
|
||||
If pickExe$ <> "" : SetGadgetText(#GStringIde, pickExe$) : EndIf
|
||||
|
||||
Case #GButtonTools
|
||||
Protected pickPrefs$ = OpenFileRequester("Choisir le fichier d'outils", GetGadgetText(#GStringTools), "Prefs|*.prefs;*.txt|Tous|*.*", 0)
|
||||
If pickPrefs$ <> "" : SetGadgetText(#GStringTools, pickPrefs$) : EndIf
|
||||
|
||||
Case #GButtonTheme
|
||||
Protected pickZip$ = OpenFileRequester("Choisir le thème (zip)", GetGadgetText(#GStringTheme), "Zip|*.zip|Tous|*.*", 0)
|
||||
If pickZip$ <> "" : SetGadgetText(#GStringTheme, pickZip$) : EndIf
|
||||
|
||||
Case #GInstallGo
|
||||
Protected ok.i = InstallPBGitInIDE(GetGadgetText(#GStringIde), GetGadgetText(#GStringTools), GetGadgetText(#GStringTheme))
|
||||
If ok
|
||||
CloseWindow(#WInstall)
|
||||
ProcedureReturn 1
|
||||
EndIf
|
||||
|
||||
Case #GInstallCancel
|
||||
CloseWindow(#WInstall)
|
||||
ProcedureReturn 0
|
||||
EndSelect
|
||||
EndIf
|
||||
Until ev = #PB_Event_CloseWindow
|
||||
|
||||
ProcedureReturn 0
|
||||
EndIf
|
||||
|
||||
ProcedureReturn 0
|
||||
EndProcedure
|
||||
|
||||
; ====== Entrée ======
|
||||
If EnsureGitAvailable() = 0
|
||||
End
|
||||
; On n’arrête pas forcément l’outil si Git manque, pour l’assistant d’installation
|
||||
; Mais on avertit : Git sera requis pour les opérations.
|
||||
EndIf
|
||||
|
||||
; Emplacement pour les prefs (dossier utilisateur PBIDE-GitTool)
|
||||
; Emplacement prefs locale de l’outil
|
||||
Define baseDoc$ = GetUserDirectory(#PB_Directory_Documents)
|
||||
If Right(baseDoc$, 1) <> #PathSep$
|
||||
baseDoc$ + #PathSep$
|
||||
EndIf
|
||||
|
||||
Define prefsDir$ = baseDoc$ + "PBIDE-GitTool" + #PathSep$
|
||||
If FileSize(prefsDir$) <> -2
|
||||
CreateDirectory(prefsDir$)
|
||||
EndIf
|
||||
If FileSize(prefsDir$) <> -2 : CreateDirectory(prefsDir$) : EndIf
|
||||
Define prefsPath$ = prefsDir$ + "settings.prefs"
|
||||
|
||||
; Mode CLI (optionnel):
|
||||
; --repo <dir> --status | --init | --commit "message" [--push] [--remote <r>] [--branch <b>] | --push [--remote <r>] [--branch <b>] | --pull [...]
|
||||
; Paramètres CLI
|
||||
Define argCount.i = CountProgramParameters()
|
||||
Define useGui.i = 1
|
||||
Define repoArg$ = "", msgArg$ = "", remoteArg$ = "", branchArg$ = ""
|
||||
Define wantStatus.i = 0, wantInit.i = 0, wantCommit.i = 0, wantPush.i = 0, wantPull.i = 0
|
||||
Define w.i
|
||||
|
||||
; --- Si aucun paramètre : proposer l’installation IDE ---
|
||||
If argCount = 0
|
||||
If MessageRequester("PBIDE-GitTool", "Aucun paramètre détecté." + #LF$ + "Souhaitez-vous installer l’intégration IDE (outils + thème) maintenant ?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
|
||||
OpenInstallWizard()
|
||||
End
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
; Parsing arguments
|
||||
For w = 0 To argCount - 1
|
||||
Define a$ = ProgramParameter(w)
|
||||
Select LCase(a$)
|
||||
@@ -514,6 +683,7 @@ For w = 0 To argCount - 1
|
||||
Case "--pull" : wantPull = 1 : useGui = 0
|
||||
Case "--remote" : If w + 1 < argCount : remoteArg$ = ProgramParameter(w + 1) : EndIf
|
||||
Case "--branch" : If w + 1 < argCount : branchArg$ = ProgramParameter(w + 1) : EndIf
|
||||
Case "--project" : If w + 1 < argCount : repoArg$ = ProgramParameter(w + 1) : EndIf
|
||||
EndSelect
|
||||
Next w
|
||||
|
||||
@@ -527,11 +697,11 @@ Else
|
||||
LoadPrefs(prefsPath$, remote$, branch$)
|
||||
If remoteArg$ <> "" : remote$ = remoteArg$ : EndIf
|
||||
If branchArg$ <> "" : branch$ = branchArg$ : EndIf
|
||||
|
||||
|
||||
Define baseDir$ = repoArg$
|
||||
If baseDir$ = "" : baseDir$ = DirFromArgOrFallback() : EndIf
|
||||
baseDir$ = DetectRepoRoot(baseDir$)
|
||||
|
||||
|
||||
If wantStatus
|
||||
Define st$, ok.i = DoStatus(baseDir$, st$)
|
||||
If ok : PrintN(st$) : EndIf
|
||||
@@ -548,8 +718,10 @@ Else
|
||||
EndIf
|
||||
|
||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||
; CursorPosition = 32
|
||||
; CursorPosition = 390
|
||||
; FirstLine = 386
|
||||
; Folding = ---
|
||||
; EnableXP
|
||||
; DPIAware
|
||||
; Executable = ..\PBIDE-GitTool.exe
|
||||
; Executable = ..\PBIDE-GitTool.exe
|
||||
; CompileSourceDirectory
|
Reference in New Issue
Block a user