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