9 #include "../GitCommand/SwitchBranch.h" 14 #include <LayoutBuilder.h> 25 TrackGitWindow(repo, BRect(0, 0, 300, 100),
"TrackGit - Switch Branch",
26 B_DOCUMENT_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
28 vector<BString> branches;
31 const git_error* err = giterr_last();
32 printf(
"Error %d : %s\n", err->klass, err->message);
33 BString buffer(
"Error : %s");
34 buffer.ReplaceFirst(
"%s", err->message);
35 BAlert* alert =
new BAlert(
"", buffer.String(),
"Cancel",
36 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
44 BButton* fSwitch =
new BButton(
"switch",
"Switch",
46 BButton* fCancel =
new BButton(
"cancel",
"Cancel",
49 for (
int i=0; i<branches.size(); i++) {
51 msg->AddString(
"branch", branches[i]);
52 fSwitchMenu->AddItem(
new BMenuItem(branches[i].String(), msg));
55 BMenuField* switchMenuField =
new BMenuField(
"Branch: ",
fSwitchMenu);
57 BLayoutBuilder::Group<>(
this, B_VERTICAL, 0)
60 .AddGroup(B_HORIZONTAL, 0)
83 const git_error* err = giterr_last();
85 BString buffer(
"Error : %s");
86 buffer.ReplaceFirst(
"%s", err->message);
87 alert =
new BAlert(
"", buffer.String(),
"Cancel",
88 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
90 BString buffer(
"Switched to branch %b.");
92 alert =
new BAlert(
"", buffer.String(),
"OK",
93 0, 0, B_WIDTH_AS_USUAL);
102 if (msg->FindString(
"branch", &branchName) == B_OK)
106 BWindow::MessageReceived(msg);
BString fSelectedBranch
The branch to be switched to.
static int GetBranches(BString, vector< BString > &)
This function gets all the branche names in given repository.
virtual void Quit()
The function to Quit the window.
SwitchBranchWindow(BString)
SwitchBranchWindow Constructor.
virtual void MessageReceived(BMessage *)
Handler to received messages.
static int DoSwitchBranch(BString, BString)
This function creates a new branch in repo with given name.
Header file of Switch Branch window.
BPopUpMenu * fSwitchMenu
The Switch Branch pop up menu.
The TrackGit Window class.
BString fRepo
The repo/directory where the command is called.