TrackGit
PullWindow.cpp
Go to the documentation of this file.
1 
7 #include "PullWindow.h"
8 #include "../GitCommand/Pull.h"
9 
10 #include <stdio.h>
11 
12 #include <AppKit.h>
13 #include <Catalog.h>
14 #include <LayoutBuilder.h>
15 #include <SupportKit.h>
16 
17 enum {
19 };
20 
26  :
27  TrackGitWindow(repo, BRect(0, 0, 300, 150), "", B_MODAL_WINDOW,
28  B_NOT_CLOSABLE | B_NOT_RESIZABLE)
29 {
30  fTextView = new BTextView(BRect(0, 0, 280, 80), "_clone_",
31  BRect(0, 0, 280, 80), B_FOLLOW_LEFT_RIGHT);
32  fTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
33  fTextView->MakeEditable(false);
34  fTextView->MakeSelectable(false);
35  fTextView->SetWordWrap(true);
36  fTextView->SetText("Pulling" B_UTF8_ELLIPSIS "\nRepository");
37  BButton* fCancel = new BButton("ok", "Cancel",
38  new BMessage(kCancelPull));
39 
40  BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
41  .SetInsets(10)
42  .Add(fTextView)
43  .AddGroup(B_HORIZONTAL, 0)
44  .AddGlue()
45  .Add(fCancel)
46  .End();
47 
48  CenterOnScreen();
49  Show();
50  fThreadId = Pull::DoPull(this, repo.String());
51 }
52 
53 
58 void
59 PullWindow::SetText(const char* text)
60 {
61  if (LockLooper()) {
62  fTextView->SetText(text);
63  UnlockLooper();
64  }
65 }
66 
67 
72 void
74 {
75  switch (msg->what) {
76  case kCancelPull:
77  if (fThreadId)
78  pthread_cancel(fThreadId);
79  Quit();
80  break;
81  default:
82  BWindow::MessageReceived(msg);
83  }
84 }
85 
PullWindow(BString)
The PullWindow constructor.
Definition: PullWindow.cpp:25
virtual void Quit()
The function to Quit the window.
virtual void MessageReceived(BMessage *)
The handler to receive messages.
Definition: PullWindow.cpp:73
static pthread_t DoPull(PullWindow *, const char *)
This spawns thread to perform pull over given repo.
Definition: Pull.cpp:195
pthread_t fThreadId
Pull thread id.
Definition: PullWindow.h:31
The TrackGit Window class.
BTextView * fTextView
The text view to show progress text.
Definition: PullWindow.h:27
void SetText(const char *)
This function sets texts of the textview within window.
Definition: PullWindow.cpp:59
Header file of Pull window.