]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlForks.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[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 namespace lyx::support;
25
26 using std::vector;
27
28
29 ControlForks::ControlForks(LyXView & lv, Dialogs & d)
30         : ControlDialogBI(lv, d)
31 {}
32
33
34 vector<pid_t> const ControlForks::getPIDs() const
35 {
36         return ForkedcallsController::get().getPIDs();
37 }
38
39
40 string const ControlForks::getCommand(pid_t pid) const
41 {
42         return ForkedcallsController::get().getCommand(pid);
43 }
44
45
46 void ControlForks::kill(pid_t pid)
47 {
48         pids_.push_back(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<pid_t>::const_iterator it = pids_.begin();
64              it != pids_.end(); ++it) {
65                 lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, tostr(*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 }