]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlForks.C
dont use pragma impementation and interface anymore
[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
14 #include "ControlForks.h"
15 #include "ViewBase.h"
16
17 #include "lyxfunc.h"
18 #include "funcrequest.h"
19
20 #include "support/forkedcontr.h"
21 #include "support/lstrings.h"
22
23 #include <boost/bind.hpp>
24
25 using std::vector;
26
27
28 ControlForks::ControlForks(LyXView & lv, Dialogs & d)
29         : ControlDialogBI(lv, d)
30 {}
31
32
33 vector<pid_t> const ControlForks::getPIDs() const
34 {
35         ForkedcallsController const & fcc = ForkedcallsController::get();
36         return fcc.getPIDs();
37 }
38
39
40 string const ControlForks::getCommand(pid_t pid) const
41 {
42         ForkedcallsController const & fcc = ForkedcallsController::get();
43         return fcc.getCommand(pid);
44 }
45
46
47 void ControlForks::kill(pid_t pid)
48 {
49         pids_.push_back(tostr(pid));
50 }
51
52
53 void ControlForks::apply()
54 {
55         if (!bufferIsAvailable())
56                 return;
57
58         view().apply();
59
60         // Nothing to apply?
61         if (pids_.empty())
62                 return;
63
64         for (vector<string>::const_iterator it = pids_.begin();
65              it != pids_.end(); ++it) {
66                 lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
67         }
68
69         pids_.clear();
70 }
71
72
73 void ControlForks::setParams()
74 {
75         if (childrenChanged_.connected())
76                 return;
77
78         pids_.clear();
79
80         ForkedcallsController & fcc = ForkedcallsController::get();
81         childrenChanged_ =
82                 fcc.childrenChanged.connect(boost::bind(&ControlForks::update, this));
83 }
84
85
86 void ControlForks::clearParams()
87 {
88         pids_.clear();
89         childrenChanged_.disconnect();
90 }