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