]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlForks.C
* Constify Buffer::getLabelList.
[lyx.git] / src / frontends / controllers / ControlForks.C
1 /**
2  * \file ControlForks.C
3  * Copyright 2001 The LyX Team
4  * Read COPYING
5  *
6  * \author Angus Leeming
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include "ControlForks.h"
16 #include "ViewBase.h"
17
18 #include "lyxfunc.h"
19 #include "funcrequest.h"
20
21 #include "support/forkedcontr.h"
22 #include "support/lstrings.h"
23
24 #include <boost/bind.hpp>
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         ForkedcallsController const & fcc = ForkedcallsController::get();
37         return fcc.getPIDs();
38 }
39
40
41 string const ControlForks::getCommand(pid_t pid) const
42 {
43         ForkedcallsController const & fcc = ForkedcallsController::get();
44         return fcc.getCommand(pid);
45 }
46
47
48 void ControlForks::kill(pid_t pid)
49 {
50         pids_.push_back(tostr(pid));
51 }
52
53
54 void ControlForks::apply()
55 {
56         if (!bufferIsAvailable())
57                 return;
58
59         view().apply();
60
61         // Nothing to apply?
62         if (pids_.empty())
63                 return;
64
65         for (vector<string>::const_iterator it = pids_.begin();
66              it != pids_.end(); ++it) {
67                 lyxfunc().dispatch(FuncRequest(LFUN_FORKS_KILL, *it));
68         }
69
70         pids_.clear();
71 }
72
73
74 void ControlForks::setParams()
75 {
76         if (childrenChanged_.connected())
77                 return;
78
79         pids_.clear();
80
81         ForkedcallsController & fcc = ForkedcallsController::get();
82         childrenChanged_ =
83                 fcc.childrenChanged.connect(boost::bind(&ControlForks::update, this));
84 }
85
86
87 void ControlForks::clearParams()
88 {
89         pids_.clear();
90         childrenChanged_.disconnect();
91 }