avec installeur intégré

This commit is contained in:
Yann LEBRUN
2025-08-14 22:45:04 +02:00
parent ef0568f846
commit 52484b87f5
26 changed files with 296 additions and 14 deletions

BIN
PBGitTheme.zip Normal file

Binary file not shown.

BIN
PBIDE-GitTool.exe Normal file

Binary file not shown.

View File

@@ -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 lintégration dans lIDE PureBasic :
; - copie le thème dicônes (zip) dans <IDE>\Themes\
; - lance lIDE 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 doutils 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 limport 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 dinstallation 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 lUI 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 dinstallation 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 lassistant
GadgetToolTip(#GStringIde, "Chemin de PureBasic.exe (IDE).")
GadgetToolTip(#GButtonIde, "Parcourir pour sélectionner lexécutable de lIDE PureBasic.")
GadgetToolTip(#GStringTools, "Fichier doutils externes à importer (/A).")
GadgetToolTip(#GButtonTools, "Parcourir le fichier 'git_tools.prefs'.")
GadgetToolTip(#GStringTheme, "Archive ZIP du thème dicônes pour la Toolbar.")
GadgetToolTip(#GButtonTheme, "Parcourir le fichier 'PBGitTheme.zip'.")
GadgetToolTip(#GInstallGo, "Lancer linstallation (copie du thème + import des outils).")
GadgetToolTip(#GInstallCancel, "Fermer lassistant 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 narrête pas forcément loutil si Git manque, pour lassistant dinstallation
; Mais on avertit : Git sera requis pour les opérations.
EndIf
; Emplacement pour les prefs (dossier utilisateur PBIDE-GitTool)
; Emplacement prefs locale de loutil
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 linstallation IDE ---
If argCount = 0
If MessageRequester("PBIDE-GitTool", "Aucun paramètre détecté." + #LF$ + "Souhaitez-vous installer linté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

BIN
PureBasic_Compilation0.exe Normal file

Binary file not shown.

BIN
git_icons_pack.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

110
git_tools.prefs Normal file
View File

@@ -0,0 +1,110 @@
[Tools]
Count = 9
[Tool_0]
Enabled = 1
Name = Git: Status (projet)
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" status -sb
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_1]
Enabled = 1
Name = Git: Init (projet)
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" init
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_2]
Enabled = 1
Name = Git: Add --all
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" add --all
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_3]
Enabled = 1
Name = Git: Pull
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" pull --ff-only
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_4]
Enabled = 1
Name = Git: Push
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" push
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_5]
Enabled = 1
Name = Git: Branche courante
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" branch --show-current
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_6]
Enabled = 1
Name = Git: Lister branches
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" branch -av
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_7]
Enabled = 1
Name = Git: Log (graph)
Program = C:\Program Files\Git\cmd\git.exe
Arguments = -C "%PROJECT%" log --oneline --graph --decorate -n 30
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 1
Wait = 1
HideFromMenu = 0
[Tool_8]
Enabled = 1
Name = PB-Git: Ouvrir linterface
Program = <chemin-vers-ton-exe-PBGit>
Arguments = "%PROJECT%"
WorkingDir =
Trigger = Menu
Shortcut =
RunHidden = 0
Wait = 1
HideFromMenu = 0