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