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