]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlForks.C
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlForks.C
1 /**
2  * \file ControlForks.C
3  * Read COPYING
4  *
5  * \author Angus Leeming
6  *
7  * Full author contact details are available in file CREDITS
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "ControlForks.h"
17 #include "ViewBase.h"
18
19 #include "lyxfunc.h"
20 #include "funcrequest.h"
21
22 #include "support/forkedcontr.h"
23 #include "support/lstrings.h"
24
25 #include <boost/bind.hpp>
26
27 using std::vector;
28
29
30 ControlForks::ControlForks(LyXView & lv, Dialogs & d)
31         : ControlDialogBI(lv, d)
32 {}
33
34
35 vector<pid_t> const ControlForks::getPIDs() const
36 {
37         ForkedcallsController const & fcc = ForkedcallsController::get();
38         return fcc.getPIDs();
39 }
40
41
42 string const ControlForks::getCommand(pid_t pid) const
43 {
44         ForkedcallsController const & fcc = ForkedcallsController::get();
45         return fcc.getCommand(pid);
46 }
47
48
49 void ControlForks::kill(pid_t pid)
50 {
51         pids_.push_back(tostr(pid));
52 }
53
54
55 void ControlForks::apply()
56 {
57         if (!bufferIsAvailable())
58                 return;
59
60         view().apply();
61
62         // Nothing to apply?
63         if (pids_.empty())
64                 return;
65
66         for (vector<string>::const_iterator it = pids_.begin();
67              it != pids_.end(); ++it) {
68                 lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
69         }
70
71         pids_.clear();
72 }
73
74
75 void ControlForks::setParams()
76 {
77         if (childrenChanged_.connected())
78                 return;
79
80         pids_.clear();
81
82         ForkedcallsController & fcc = ForkedcallsController::get();
83         childrenChanged_ =
84                 fcc.childrenChanged.connect(boost::bind(&ControlForks::update, this));
85 }
86
87
88 void ControlForks::clearParams()
89 {
90         pids_.clear();
91         childrenChanged_.disconnect();
92 }