]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlForks.C
non-templated tostr in separate files
[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         ForkedcallsController const & fcc = ForkedcallsController::get();
35         return fcc.getPIDs();
36 }
37
38
39 string const ControlForks::getCommand(pid_t pid) const
40 {
41         ForkedcallsController const & fcc = ForkedcallsController::get();
42         return fcc.getCommand(pid);
43 }
44
45
46 void ControlForks::kill(pid_t pid)
47 {
48         pids_.push_back(tostr(pid));
49 }
50
51
52 void ControlForks::apply()
53 {
54         if (!bufferIsAvailable())
55                 return;
56
57         view().apply();
58
59         // Nothing to apply?
60         if (pids_.empty())
61                 return;
62
63         for (vector<string>::const_iterator it = pids_.begin();
64              it != pids_.end(); ++it) {
65                 lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
66         }
67
68         pids_.clear();
69 }
70
71
72 void ControlForks::setParams()
73 {
74         if (childrenChanged_.connected())
75                 return;
76
77         pids_.clear();
78
79         ForkedcallsController & fcc = ForkedcallsController::get();
80         childrenChanged_ =
81                 fcc.childrenChanged.connect(boost::bind(&ControlForks::update, this));
82 }
83
84
85 void ControlForks::clearParams()
86 {
87         pids_.clear();
88         childrenChanged_.disconnect();
89 }