TrackGit
PushWindow.cpp
Go to the documentation of this file.
1 
7 #include "PushWindow.h"
8 #include "../GitCommand/Push.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), "TrackGit - Push",
28  B_DOCUMENT_WINDOW, 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("Pushing" B_UTF8_ELLIPSIS "\nRepository");
37  BButton* fCancel = new BButton("ok", "Cancel",
38  new BMessage(kCancelPush));
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 = Push::DoPush(this, repo.String());
51 }
52 
53 
58 void
59 PushWindow::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 kCancelPush:
77  if (fThreadId)
78  pthread_cancel(fThreadId);
79  Quit();
80  break;
81  default:
82  BWindow::MessageReceived(msg);
83  }
84 }
85 
virtual void Quit()
The function to Quit the window.
PushWindow(BString)
The PushWindow constructor.
Definition: PushWindow.cpp:25
void SetText(const char *)
This function sets texts of the textview within window.
Definition: PushWindow.cpp:59
pthread_t fThreadId
Pull thread id.
Definition: PushWindow.h:31
static pthread_t DoPush(PushWindow *, const char *)
This spawns thread to perform push over given repo.
Definition: Push.cpp:141
The TrackGit Window class.
BTextView * fTextView
The text view to show progress text.
Definition: PushWindow.h:27
Header file of Push window.
virtual void MessageReceived(BMessage *)
The handler to receive messages.
Definition: PushWindow.cpp:73