UpdateGadgetState() to Enable or Desable gadget from context
This commit is contained in:
317
main2.pb
317
main2.pb
@@ -1,5 +1,10 @@
|
|||||||
EnableExplicit
|
EnableExplicit
|
||||||
|
|
||||||
|
CompilerIf #PB_Compiler_Thread=0
|
||||||
|
MessageRequester("Compiler","You must to enable Create Threadsafe executable in Compiler Options",#PB_MessageRequester_Error|#PB_MessageRequester_Ok)
|
||||||
|
End
|
||||||
|
CompilerEndIf
|
||||||
|
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
;-MODULE TRANSLATE
|
;-MODULE TRANSLATE
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
@@ -11,7 +16,7 @@ EndDeclareModule
|
|||||||
|
|
||||||
Module Translate
|
Module Translate
|
||||||
; ===============================================
|
; ===============================================
|
||||||
; Système Multilingue Minimaliste pour PureBasic
|
; Système Multilingue
|
||||||
; ===============================================
|
; ===============================================
|
||||||
Global NewMap Translations.s()
|
Global NewMap Translations.s()
|
||||||
|
|
||||||
@@ -491,6 +496,38 @@ EndEnumeration
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
; SMALL HELPERS / AIDES UTILITAIRES
|
; SMALL HELPERS / AIDES UTILITAIRES
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
; Compte le nombre d’items cochés (#PB_ListIcon_Checked) dans un ListIcon
|
||||||
|
Procedure.i _ListCountChecked(gadget.i)
|
||||||
|
Protected i, c
|
||||||
|
For i = 0 To CountGadgetItems(gadget) - 1
|
||||||
|
If GetGadgetItemState(gadget, i) & #PB_ListIcon_Checked
|
||||||
|
c + 1
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
ProcedureReturn c
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
; Compte le nombre d’items sélectionnés (#PB_ListIcon_Selected) dans un ListIcon
|
||||||
|
Procedure.i _ListCountSelected(gadget.i)
|
||||||
|
Protected i, c
|
||||||
|
For i = 0 To CountGadgetItems(gadget) - 1
|
||||||
|
If GetGadgetItemState(gadget, i) & #PB_ListIcon_Selected
|
||||||
|
c + 1
|
||||||
|
EndIf
|
||||||
|
Next
|
||||||
|
ProcedureReturn c
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
; Petit helper pour activer/désactiver sans se tromper
|
||||||
|
Procedure _SetEnabled(gadget.i, enabled.i)
|
||||||
|
If enabled
|
||||||
|
DisableGadget(gadget, 0)
|
||||||
|
Else
|
||||||
|
DisableGadget(gadget, 1)
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Macro RightOf(g) : GadgetX(g) + GadgetWidth(g) : EndMacro
|
Macro RightOf(g) : GadgetX(g) + GadgetWidth(g) : EndMacro
|
||||||
Macro BottomOf(g) : GadgetY(g) + GadgetHeight(g) : EndMacro
|
Macro BottomOf(g) : GadgetY(g) + GadgetHeight(g) : EndMacro
|
||||||
|
|
||||||
@@ -669,9 +706,89 @@ Procedure ApplyToolTips()
|
|||||||
GadgetToolTip(#GID_HelpWeb, T("tip.help.web", "Zone d’aide (documentation / rendu HTML)"))
|
GadgetToolTip(#GID_HelpWeb, T("tip.help.web", "Zone d’aide (documentation / rendu HTML)"))
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure UpdateGadgetsState()
|
||||||
|
; --- État courant ---
|
||||||
|
Protected repo.b = main\IsRepository
|
||||||
|
Protected remoteURL$ = SupTrim(GetGadgetText(#GID_EdRemote))
|
||||||
|
Protected hasRemoteText.b = Bool(remoteURL$ <> "")
|
||||||
|
Protected hasRemoteCfg.b = Bool(repo And main\hasRemoteUrl) ; remote *réellement* configuré dans le dépôt
|
||||||
|
|
||||||
|
Protected locBr$ = SupTrim(GetGadgetText(#GID_CbLocalBranch))
|
||||||
|
Protected remBr$ = SupTrim(GetGadgetText(#GID_CbRemoteBranch))
|
||||||
|
Protected hasLocBr.b = Bool(locBr$ <> "")
|
||||||
|
Protected hasRemBr.b = Bool(remBr$ <> "")
|
||||||
|
|
||||||
|
Protected msg$ = SupTrim(GetGadgetText(#GID_EdMessage))
|
||||||
|
Protected hasMsg.b = Bool(msg$ <> "")
|
||||||
|
|
||||||
|
Protected checked.l = _ListCountChecked(#GID_ListStatus) ; pour Commit
|
||||||
|
Protected selected.l = _ListCountSelected(#GID_ListStatus) ; pour Restore/Rename/Delete/Ignore
|
||||||
|
|
||||||
|
Protected histSel.b = Bool(GetGadgetState(#GID_ListHistory) >= 0)
|
||||||
|
|
||||||
|
; --- Règles métier ---
|
||||||
|
Protected canInit.b = Bool(Not repo)
|
||||||
|
Protected canClone.b = Bool(Not repo And hasRemoteText) ; clone quand pas de repo et URL saisie
|
||||||
|
Protected canRefresh.b = repo
|
||||||
|
|
||||||
|
Protected canCommit.b = Bool(repo And hasMsg And (checked > 0))
|
||||||
|
Protected canFiles.b = Bool(repo And (selected > 0))
|
||||||
|
|
||||||
|
Protected canPull.b = Bool(repo And hasRemoteCfg And hasLocBr And hasRemBr)
|
||||||
|
Protected canPush.b = canPull ; même prérequis de base
|
||||||
|
Protected canVerifyRemote.b = Bool(repo And hasRemoteCfg)
|
||||||
|
|
||||||
|
; --- Toujours utiles ---
|
||||||
|
_SetEnabled(#GID_BtnBrowseRepo, #True)
|
||||||
|
_SetEnabled(#GID_EdRepo, #True)
|
||||||
|
|
||||||
|
; --- Local ---
|
||||||
|
_SetEnabled(#GID_BtnInit, canInit)
|
||||||
|
_SetEnabled(#GID_BtnRefresh, canRefresh)
|
||||||
|
_SetEnabled(#GID_CbLocalBranch, repo)
|
||||||
|
_SetEnabled(#GID_BtnNewLocalBranch, repo)
|
||||||
|
|
||||||
|
; --- Remote ---
|
||||||
|
_SetEnabled(#GID_EdRemote, #True) ; éditable tout le temps
|
||||||
|
_SetEnabled(#GID_CbRemoteBranch, hasRemoteCfg)
|
||||||
|
_SetEnabled(#GID_BtnNewRemoteBranch, hasRemoteCfg)
|
||||||
|
_SetEnabled(#GID_BtnClone, canClone)
|
||||||
|
_SetEnabled(#GID_BtnPull, canPull)
|
||||||
|
_SetEnabled(#GID_BtnPush, canPush)
|
||||||
|
_SetEnabled(#GID_BtnVerify, canVerifyRemote)
|
||||||
|
|
||||||
|
; --- Fichiers & commit ---
|
||||||
|
_SetEnabled(#GID_ListStatus, repo)
|
||||||
|
_SetEnabled(#GID_BtnRestore, canFiles)
|
||||||
|
_SetEnabled(#GID_BtnRename, canFiles)
|
||||||
|
_SetEnabled(#GID_BtnDelete, canFiles)
|
||||||
|
_SetEnabled(#GID_BtnIgnore, canFiles)
|
||||||
|
|
||||||
|
_SetEnabled(#GID_EdMessage, repo)
|
||||||
|
_SetEnabled(#GID_BtnCommit, canCommit)
|
||||||
|
|
||||||
|
; --- History ---
|
||||||
|
_SetEnabled(#GID_ListHistory, repo)
|
||||||
|
_SetEnabled(#GID_BtnRestoreCommit, Bool(repo And histSel))
|
||||||
|
_SetEnabled(#GID_TxtCommitInfo, repo)
|
||||||
|
|
||||||
|
; --- .gitignore ---
|
||||||
|
_SetEnabled(#GID_TxtGitIgnore, repo)
|
||||||
|
_SetEnabled(#GID_BtnSaveGitIgnore, repo)
|
||||||
|
|
||||||
|
; --- Config & Proxy : laissons-les actifs en permanence ---
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
; BUILD GUI / CONSTRUCTION DE L’INTERFACE
|
; BUILD GUI / CONSTRUCTION DE L’INTERFACE
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
Enumeration
|
||||||
|
#Panel_Repo
|
||||||
|
#Panel_History
|
||||||
|
#Panel_GitIgnore
|
||||||
|
#Panel_Config
|
||||||
|
EndEnumeration
|
||||||
Procedure OpenGUI()
|
Procedure OpenGUI()
|
||||||
UseModule Translate
|
UseModule Translate
|
||||||
Define repoDir$ = GetCurrentDirectory()
|
Define repoDir$ = GetCurrentDirectory()
|
||||||
@@ -685,9 +802,9 @@ Procedure OpenGUI()
|
|||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
; TAB 1: REPO / DÉPÔT
|
; TAB 1: REPO / DÉPÔT
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
AddGadgetItem(#GID_Panel, -1, T("Tab.Repo", "Dépôt"))
|
AddGadgetItem(#GID_Panel, #Panel_Repo, T("Tab.Repo", "Dépôt"))
|
||||||
|
|
||||||
; ---- Frame: Local repository ------------------------------------------------
|
; ---- Frame: Local repository ------------------------------------------------
|
||||||
FrameGadget(#GID_FrmLocal, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, #UI_FrameHeaderH + #UI_RowH*3 + #UI_Inset*3, T("Local.FrameTitle", "Dépôt local"), #PB_Frame_Container)
|
FrameGadget(#GID_FrmLocal, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, #UI_FrameHeaderH + #UI_RowH*3 + #UI_Inset*3, T("Local.FrameTitle", "Dépôt local"), #PB_Frame_Container)
|
||||||
|
|
||||||
TextGadget(#GID_LblRepo, #UI_Inset, #UI_FrameHeaderH, 70, #UI_RowH, T("Local.Label.Repo","Dépôt :"))
|
TextGadget(#GID_LblRepo, #UI_Inset, #UI_FrameHeaderH, 70, #UI_RowH, T("Local.Label.Repo","Dépôt :"))
|
||||||
@@ -738,45 +855,44 @@ Procedure OpenGUI()
|
|||||||
|
|
||||||
|
|
||||||
; ---- Frame: Files & changes -------------------------------------------------
|
; ---- Frame: Files & changes -------------------------------------------------
|
||||||
Define yFiles = BottomOf(#GID_FrmRemote) + #UI_Inset
|
Define yFiles = BottomOf(#GID_FrmRemote) + #UI_Inset
|
||||||
Define hFiles = panelH - yFiles - #UI_Inset
|
Define hFiles = panelH - yFiles - #UI_Inset
|
||||||
If hFiles < 260 : hFiles = 260 : EndIf ; hauteur mini du frame pour éviter valeurs négatives
|
If hFiles < 260 : hFiles = 260 : EndIf ; hauteur mini du frame pour éviter valeurs négatives
|
||||||
|
|
||||||
FrameGadget(#GID_FrmFiles, #UI_Inset, yFiles, GadgetWidth(#GID_Panel) - #UI_Inset*2, hFiles, T("Files.FrameTitle","Fichiers & modifications"), #PB_Frame_Container)
|
FrameGadget(#GID_FrmFiles, #UI_Inset, yFiles, GadgetWidth(#GID_Panel) - #UI_Inset*2, hFiles, T("Files.FrameTitle","Fichiers & modifications"), #PB_Frame_Container)
|
||||||
|
|
||||||
; Hauteur de la liste avec garde-fou (même logique que dans ResizeGUI)
|
; Hauteur de la liste avec garde-fou (même logique que dans ResizeGUI)
|
||||||
Define listH = hFiles - #UI_RowH*2 - #UI_Inset*4 - #UI_FrameHeaderH
|
Define listH = hFiles - #UI_RowH*2 - #UI_Inset*4 - #UI_FrameHeaderH
|
||||||
If listH < 100 : listH = 100 : EndIf
|
If listH < 100 : listH = 100 : EndIf
|
||||||
|
|
||||||
ListIconGadget(#GID_ListStatus, #UI_Inset, #UI_FrameHeaderH, GadgetWidth(#GID_FrmFiles) - #UI_Inset*2, listH, T("Files.List.Path","Path"), 300, #PB_ListIcon_CheckBoxes | #PB_ListIcon_MultiSelect | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
|
ListIconGadget(#GID_ListStatus, #UI_Inset, #UI_FrameHeaderH, GadgetWidth(#GID_FrmFiles) - #UI_Inset*2, listH, T("Files.List.Path","Path"), 300, #PB_ListIcon_CheckBoxes | #PB_ListIcon_MultiSelect | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
|
||||||
AddGadgetColumn(#GID_ListStatus, 1, T("Files.List.Status","Status"), 80)
|
AddGadgetColumn(#GID_ListStatus, 1, T("Files.List.Status","Status"), 80)
|
||||||
AddGadgetColumn(#GID_ListStatus, 2, T("Files.List.Description","Description"), 300)
|
AddGadgetColumn(#GID_ListStatus, 2, T("Files.List.Description","Description"), 300)
|
||||||
|
|
||||||
; Ligne boutons sous la liste
|
; Ligne boutons sous la liste
|
||||||
Define yLocalActions = #UI_FrameHeaderH + listH + #UI_Inset
|
Define yLocalActions = #UI_FrameHeaderH + listH + #UI_Inset
|
||||||
ButtonGadget(#GID_BtnRestore, #UI_Inset + 10, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Restore","Restaurer"))
|
ButtonGadget(#GID_BtnRestore, #UI_Inset + 10, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Restore","Restaurer"))
|
||||||
ButtonGadget(#GID_BtnRename, #UI_Inset + 130, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Rename","Renommer"))
|
ButtonGadget(#GID_BtnRename, #UI_Inset + 130, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Rename","Renommer"))
|
||||||
ButtonGadget(#GID_BtnDelete, #UI_Inset + 250, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Delete","Supprimer"))
|
ButtonGadget(#GID_BtnDelete, #UI_Inset + 250, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Delete","Supprimer"))
|
||||||
ButtonGadget(#GID_BtnIgnore, #UI_Inset + 370, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Ignore","Ignorer"))
|
ButtonGadget(#GID_BtnIgnore, #UI_Inset + 370, yLocalActions, 110, #UI_RowH, T("LocalActions.Button.Ignore","Ignorer"))
|
||||||
|
|
||||||
; Message de commit
|
; Message de commit
|
||||||
Define yMsg = yLocalActions + #UI_RowH + #UI_Inset
|
Define yMsg = yLocalActions + #UI_RowH + #UI_Inset
|
||||||
TextGadget(#GID_LblMessage, #UI_Inset + 10, yMsg + 4, 80, 22, T("Commit.Label.Message","Message :"))
|
TextGadget(#GID_LblMessage, #UI_Inset + 10, yMsg + 4, 80, 22, T("Commit.Label.Message","Message :"))
|
||||||
StringGadget(#GID_EdMessage, #UI_Inset + 95, yMsg, GadgetWidth(#GID_FrmFiles) - #UI_Inset*2 - 95 - 110, #UI_RowH, "")
|
StringGadget(#GID_EdMessage, #UI_Inset + 95, yMsg, GadgetWidth(#GID_FrmFiles) - #UI_Inset*2 - 95 - 110, #UI_RowH, "")
|
||||||
ButtonGadget(#GID_BtnCommit, GadgetWidth(#GID_FrmFiles) - #UI_Inset - 100, yMsg - 2, 100, #UI_RowH, T("Commit.Button.Commit","Commit"))
|
ButtonGadget(#GID_BtnCommit, GadgetWidth(#GID_FrmFiles) - #UI_Inset - 100, yMsg - 2, 100, #UI_RowH, T("Commit.Button.Commit","Commit"))
|
||||||
CloseGadgetList()
|
CloseGadgetList()
|
||||||
|
|
||||||
|
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
; TAB 2: HISTORY
|
; TAB 2: HISTORY
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
AddGadgetItem(#GID_Panel, -1, T("Tabs.History","History"))
|
AddGadgetItem(#GID_Panel, #Panel_History, T("Tabs.History","History"))
|
||||||
|
|
||||||
ListIconGadget(#GID_ListHistory, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, panelH - #UI_Inset*2 - #UI_RowH - 10 - 150 - 10, T("History.Headers.Header","Header"), 220, #PB_ListIcon_FullRowSelect)
|
ListIconGadget(#GID_ListHistory, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, panelH - #UI_Inset*2 - #UI_RowH - 10 - 150 - 10, T("History.Headers.Header","Header"), 70, #PB_ListIcon_FullRowSelect)
|
||||||
AddGadgetColumn(#GID_ListHistory, 1, T("History.Headers.Date","Date"), 150)
|
AddGadgetColumn(#GID_ListHistory, 1, T("History.Headers.Date","Date"), 200)
|
||||||
AddGadgetColumn(#GID_ListHistory, 2, T("History.Headers.Author","Auteur"), 180)
|
AddGadgetColumn(#GID_ListHistory, 2, T("History.Headers.Author","Auteur"), 100)
|
||||||
AddGadgetColumn(#GID_ListHistory, 3, T("History.Headers.Files","Fichiers"), 120)
|
AddGadgetColumn(#GID_ListHistory, 4, T("History.Headers.Message","Message"), 300)
|
||||||
AddGadgetColumn(#GID_ListHistory, 4, T("History.Headers.Message","Message"), (GadgetWidth(#GID_Panel) - 2*#UI_Inset) - (220 + 150 + 180 + 120) - 20)
|
|
||||||
|
|
||||||
ButtonGadget(#GID_BtnRestoreCommit, #UI_Inset, panelH - #UI_Inset - #UI_RowH - 150 - 10, 180, #UI_RowH, T("History.Button.RestoreCommit","Restore This Commit"))
|
ButtonGadget(#GID_BtnRestoreCommit, #UI_Inset, panelH - #UI_Inset - #UI_RowH - 150 - 10, 180, #UI_RowH, T("History.Button.RestoreCommit","Restore This Commit"))
|
||||||
|
|
||||||
@@ -785,14 +901,14 @@ CloseGadgetList()
|
|||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
; TAB 3: .gitignore
|
; TAB 3: .gitignore
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
AddGadgetItem(#GID_Panel, -1, T("Tabs.Gitignore",".gitignore file"))
|
AddGadgetItem(#GID_Panel, #Panel_GitIgnore, T("Tabs.Gitignore",".gitignore file"))
|
||||||
EditorGadget(#GID_TxtGitIgnore, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, panelH - #UI_Inset*4 - #UI_RowH)
|
EditorGadget(#GID_TxtGitIgnore, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, panelH - #UI_Inset*4 - #UI_RowH)
|
||||||
ButtonGadget(#GID_BtnSaveGitIgnore, #UI_Inset, GadgetY(#GID_TxtGitIgnore) + GadgetHeight(#GID_TxtGitIgnore) + #UI_Inset, 100, #UI_RowH, T("Gitignore.Button.SaveFile","Save File"))
|
ButtonGadget(#GID_BtnSaveGitIgnore, #UI_Inset, GadgetY(#GID_TxtGitIgnore) + GadgetHeight(#GID_TxtGitIgnore) + #UI_Inset, 100, #UI_RowH, T("Gitignore.Button.SaveFile","Save File"))
|
||||||
|
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
; TAB 4: CONFIG
|
; TAB 4: CONFIG
|
||||||
; ===========================================================================
|
; ===========================================================================
|
||||||
AddGadgetItem(#GID_Panel, -1, T("Tabs.Config","Config"))
|
AddGadgetItem(#GID_Panel, #Panel_Config, T("Tabs.Config","Config"))
|
||||||
|
|
||||||
; --- Frame: Paramètres de l’application (LANGUE, etc.) ---
|
; --- Frame: Paramètres de l’application (LANGUE, etc.) ---
|
||||||
FrameGadget(#GID_FrmApp, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, 90, T("App.FrameTitle","Paramètres de l’application"), #PB_Frame_Container)
|
FrameGadget(#GID_FrmApp, #UI_Inset, #UI_Inset, GadgetWidth(#GID_Panel) - #UI_Inset*2, 90, T("App.FrameTitle","Paramètres de l’application"), #PB_Frame_Container)
|
||||||
@@ -895,13 +1011,6 @@ Procedure.i GetGitVersion()
|
|||||||
ProcedureReturn #False
|
ProcedureReturn #False
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure.i DoGitFetch(remote.s="origin",branch.s="main")
|
|
||||||
If Git("fetch "+remote+" "+branch) = 0
|
|
||||||
ProcedureReturn #True
|
|
||||||
EndIf
|
|
||||||
ProcedureReturn #False
|
|
||||||
EndProcedure
|
|
||||||
|
|
||||||
Procedure.i DoCommit()
|
Procedure.i DoCommit()
|
||||||
Protected code.i,nb.l=0,i.l
|
Protected code.i,nb.l=0,i.l
|
||||||
Protected args.s = "add"
|
Protected args.s = "add"
|
||||||
@@ -945,6 +1054,58 @@ Procedure.i DoCommit()
|
|||||||
ProcedureReturn #True
|
ProcedureReturn #True
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure DoRename()
|
||||||
|
Protected i.l,count.l=0
|
||||||
|
For i = 0 To CountGadgetItems(#GID_ListStatus) - 1
|
||||||
|
If GetGadgetItemState(#GID_ListStatus, i) & #PB_ListIcon_Selected
|
||||||
|
Protected filepath.s=StringField(GetGadgetItemText(#GID_ListStatus, i),1,Chr(10))
|
||||||
|
Protected newfilepath.s=InputRequester("Git mv","Rename This File",filepath,0,WindowID(#WinMain))
|
||||||
|
If newfilepath<>"" And filepath<>newfilepath
|
||||||
|
Protected sucess.b=#False
|
||||||
|
If LCase(filepath)=LCase(newfilepath) And (#PB_Compiler_OS=#PB_OS_Windows Or #PB_Compiler_OS=#PB_OS_MacOS)
|
||||||
|
; 2 time to renome on Windows and MacOs
|
||||||
|
If git("mv "+Chr(34)+filepath+Chr(34)+" "+Chr(34)+filepath+".tmp"+Chr(34))=0
|
||||||
|
git("mv "+Chr(34)+filepath+".tmp"+Chr(34)+" "+Chr(34)+newfilepath+Chr(34))
|
||||||
|
count=count+1
|
||||||
|
sucess=#True
|
||||||
|
EndIf
|
||||||
|
Else
|
||||||
|
If git("mv "+Chr(34)+filepath+Chr(34)+" "+Chr(34)+newfilepath+Chr(34))=0
|
||||||
|
count=count+1
|
||||||
|
sucess=#True
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
If sucess=#True
|
||||||
|
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
EndIf
|
||||||
|
Next i
|
||||||
|
Protected message.s
|
||||||
|
If count>0
|
||||||
|
If count=1
|
||||||
|
message=T("","Renommage de %1 en %2")
|
||||||
|
message=ReplaceString(message,"%1",filepath)
|
||||||
|
message=ReplaceString(message,"%2",newfilepath)
|
||||||
|
ElseIf count>1
|
||||||
|
message=T("","Renommage de %1 fichiers")
|
||||||
|
message=ReplaceString(message,"%1",Str(count))
|
||||||
|
EndIf
|
||||||
|
If Git("commit -m " + Chr(34)+message+Chr(34))<>0
|
||||||
|
MessageRequester("Git commit", "Échec ou rien à valider: " + #LF$ + main\GitCall\errors + #LF$ + main\GitCall\output, #PB_MessageRequester_Warning)
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure.i DoGitFetch(remote.s="origin",branch.s="main")
|
||||||
|
If Git("fetch "+remote+" "+branch) = 0
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndIf
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure AddRemoteRepo(Url.s,name.s="origin")
|
Procedure AddRemoteRepo(Url.s,name.s="origin")
|
||||||
Url=SupTrim(Url)
|
Url=SupTrim(Url)
|
||||||
name=SupTrim(name)
|
name=SupTrim(name)
|
||||||
@@ -1475,6 +1636,41 @@ Procedure.s RefreshRemoteBranchesList(Gdt.i)
|
|||||||
Next
|
Next
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure GetCommitHistory()
|
||||||
|
Protected i.l,n.l,line.s
|
||||||
|
|
||||||
|
; %H: Commit hash (full)
|
||||||
|
; %h: Commit hash (abbreviated)
|
||||||
|
; %an: Author name
|
||||||
|
; %ae: Author email
|
||||||
|
; %ad: Author date
|
||||||
|
; %cn: Committer name
|
||||||
|
; %ce: Committer email
|
||||||
|
; %cd: Committer date
|
||||||
|
; %s: Subject line
|
||||||
|
; %b: Body of the commit message
|
||||||
|
; %n: Newline character
|
||||||
|
If git(~"log --pretty=format:\"%H|%cd|%an|%s\" --date=iso")=0
|
||||||
|
ClearGadgetItems(#GID_ListHistory)
|
||||||
|
n.l = CountString(main\Gitcall\output, #LF$) + 1
|
||||||
|
Debug "Nombre de ligne :"+Str(n)
|
||||||
|
For i = 1 To n
|
||||||
|
line = SupTrim(StringField(main\Gitcall\output, i, #LF$))
|
||||||
|
line=ReplaceString(line,"|",Chr(10))
|
||||||
|
AddGadgetItem(#GID_ListHistory,-1,line)
|
||||||
|
Next
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure GetCommitInfo()
|
||||||
|
If GetGadgetState(#GID_ListHistory)>-1
|
||||||
|
Protected hash.s=GetGadgetItemText(#GID_ListHistory, GetGadgetState(#GID_ListHistory), 0)
|
||||||
|
If git("show --pretty=fuller --stat --name-status --no-patch --show-signature "+hash)=0
|
||||||
|
SetGadgetText(#GID_TxtCommitInfo,SupTrim(main\gitCall\output)+SupTrim(main\gitCall\errors))
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
; --- Helper interne : scanne un dossier et alimente la liste
|
; --- Helper interne : scanne un dossier et alimente la liste
|
||||||
Procedure _ScanFiles(path$, root$="")
|
Procedure _ScanFiles(path$, root$="")
|
||||||
If root$="":root$=path$:EndIf
|
If root$="":root$=path$:EndIf
|
||||||
@@ -1521,7 +1717,8 @@ Procedure readDirectory()
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure RefreshFiles()
|
|
||||||
|
Procedure RefreshGUI(null.i)
|
||||||
DoGitFetch() ;TODO add Branch
|
DoGitFetch() ;TODO add Branch
|
||||||
ClearGadgetItems(#GID_ListStatus)
|
ClearGadgetItems(#GID_ListStatus)
|
||||||
ClearList(main\Files())
|
ClearList(main\Files())
|
||||||
@@ -1564,6 +1761,10 @@ Procedure RefreshFiles()
|
|||||||
Next
|
Next
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure Refresh()
|
||||||
|
CreateThread(@RefreshGUI(),0)
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
;-MAIN
|
;-MAIN
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
@@ -1619,7 +1820,7 @@ Procedure Main()
|
|||||||
SetWindowTitle(#WinMain,#AppTitle$+" (with "+main\gitVersion$+")")
|
SetWindowTitle(#WinMain,#AppTitle$+" (with "+main\gitVersion$+")")
|
||||||
SetGadgetText(#GID_EdRepo, GetCurrentDirectory())
|
SetGadgetText(#GID_EdRepo, GetCurrentDirectory())
|
||||||
|
|
||||||
RefreshFiles()
|
Refresh()
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
;-EVENT LOOP / BOUCLE D'ÉVÉNEMENTS
|
;-EVENT LOOP / BOUCLE D'ÉVÉNEMENTS
|
||||||
@@ -1627,6 +1828,7 @@ Procedure Main()
|
|||||||
Protected.i ev, gid
|
Protected.i ev, gid
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
|
UpdateGadgetsState()
|
||||||
ev = WaitWindowEvent()
|
ev = WaitWindowEvent()
|
||||||
Select ev
|
Select ev
|
||||||
|
|
||||||
@@ -1636,6 +1838,18 @@ Procedure Main()
|
|||||||
Case #PB_Event_Gadget
|
Case #PB_Event_Gadget
|
||||||
gid = EventGadget()
|
gid = EventGadget()
|
||||||
Select gid
|
Select gid
|
||||||
|
|
||||||
|
Case #GID_Panel
|
||||||
|
If EventType()=#PB_EventType_Change
|
||||||
|
Select GetGadgetState(#GID_Panel)
|
||||||
|
Case #Panel_Repo
|
||||||
|
Case #Panel_History
|
||||||
|
GetCommitHistory()
|
||||||
|
Case #Panel_GitIgnore
|
||||||
|
Case #Panel_Config
|
||||||
|
EndSelect
|
||||||
|
EndIf
|
||||||
|
|
||||||
Case #GID_BtnBrowseRepo
|
Case #GID_BtnBrowseRepo
|
||||||
; FR: Sélection dossier / EN: select folder
|
; FR: Sélection dossier / EN: select folder
|
||||||
Protected path$ = PathRequester(T("Dlg.SelectRepo","Sélectionnez le dépôt local..."), GetCurrentDirectory(),WindowID(#WinMain))
|
Protected path$ = PathRequester(T("Dlg.SelectRepo","Sélectionnez le dépôt local..."), GetCurrentDirectory(),WindowID(#WinMain))
|
||||||
@@ -1645,7 +1859,7 @@ Procedure Main()
|
|||||||
SetCurrentDirectory(path$)
|
SetCurrentDirectory(path$)
|
||||||
main\IsRepository=IsGitRepository()
|
main\IsRepository=IsGitRepository()
|
||||||
If main\IsRepository=#True
|
If main\IsRepository=#True
|
||||||
RefreshFiles()
|
Refresh()
|
||||||
EndIf
|
EndIf
|
||||||
;CreateThread(@RefreshFileList(),0) ;TODO refresh list
|
;CreateThread(@RefreshFileList(),0) ;TODO refresh list
|
||||||
EndIf
|
EndIf
|
||||||
@@ -1655,7 +1869,7 @@ Procedure Main()
|
|||||||
; TODO: call your Git init logic
|
; TODO: call your Git init logic
|
||||||
|
|
||||||
Case #GID_BtnRefresh
|
Case #GID_BtnRefresh
|
||||||
RefreshFiles()
|
Refresh()
|
||||||
|
|
||||||
Case #GID_BtnClone
|
Case #GID_BtnClone
|
||||||
SetGadgetText(#GID_TxtAction, T("Action.Clone","Clone demandé"))
|
SetGadgetText(#GID_TxtAction, T("Action.Clone","Clone demandé"))
|
||||||
@@ -1678,16 +1892,20 @@ Procedure Main()
|
|||||||
Case #GID_BtnRestore
|
Case #GID_BtnRestore
|
||||||
; TODO: restore
|
; TODO: restore
|
||||||
Case #GID_BtnRename
|
Case #GID_BtnRename
|
||||||
; TODO: rename
|
DoRename()
|
||||||
|
Refresh()
|
||||||
Case #GID_BtnDelete
|
Case #GID_BtnDelete
|
||||||
; TODO: delete
|
; TODO: delete
|
||||||
|
|
||||||
|
Case #GID_ListHistory
|
||||||
|
GetCommitInfo()
|
||||||
Case #GID_BtnIgnore
|
Case #GID_BtnIgnore
|
||||||
; TODO: ignore
|
; TODO: ignore
|
||||||
|
|
||||||
Case #GID_BtnCommit
|
Case #GID_BtnCommit
|
||||||
If DoCommit()=#True
|
If DoCommit()=#True
|
||||||
SetGadgetText(#GID_EdMessage,"")
|
SetGadgetText(#GID_EdMessage,"")
|
||||||
RefreshFiles()
|
Refresh()
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Case #GID_BtnSaveGitIgnore
|
Case #GID_BtnSaveGitIgnore
|
||||||
@@ -1706,8 +1924,9 @@ EndProcedure
|
|||||||
Main()
|
Main()
|
||||||
|
|
||||||
; IDE Options = PureBasic 6.21 (Windows - x64)
|
; IDE Options = PureBasic 6.21 (Windows - x64)
|
||||||
; CursorPosition = 986
|
; CursorPosition = 771
|
||||||
; FirstLine = 974
|
; FirstLine = 752
|
||||||
; Folding = ----f--
|
; Folding = ---------
|
||||||
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; DPIAware
|
; DPIAware
|
Reference in New Issue
Block a user