/**
* \file FormForks.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
* \date 2001-10-22
*/
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
#include "xformsBC.h"
+#include "ButtonController.h"
#include "FormForks.h"
#include "ControlForks.h"
-#include "form_forks.h"
-#include "gettext.h"
+#include "forms/form_forks.h"
+#include "Tooltips.h"
#include "helper_funcs.h"
#include "xforms_helpers.h"
+#include "gettext.h"
#include "support/lstrings.h"
+#include FORMS_H_LOCATION
using std::vector;
using std::find;
using std::find_if;
-typedef FormCB<ControlForks, FormDB<FD_form_forks> > base_class;
+typedef FormCB<ControlForks, FormDB<FD_forks> > base_class;
-FormForks::FormForks(ControlForks & c)
- : base_class(c, _("Child processes"))
+FormForks::FormForks()
+ : base_class(_("Child processes"))
{}
void FormForks::build() {
- dialog_.reset(build_forks());
+ dialog_.reset(build_forks(this));
// It appears that the browsers aren't initialised properly.
// This fudge fixes tings.
fl_clear_browser(dialog_->browser_children);
fl_clear_browser(dialog_->browser_kill);
- // Manage the ok, apply, restore and cancel/close buttons
- bc().setOK(dialog_->button_ok);
- bc().setApply(dialog_->button_apply);
- bc().setCancel(dialog_->button_close);
- bc().invalid();
+ // Manage the ok, apply, restore and cancel/close buttons
+ bcview().setOK(dialog_->button_ok);
+ bcview().setApply(dialog_->button_apply);
+ bcview().setCancel(dialog_->button_close);
+ bc().valid(false);
// Set up the tooltip mechanism
- setTooltipHandler(dialog_->browser_children);
- setTooltipHandler(dialog_->browser_kill);
- setTooltipHandler(dialog_->button_all);
- setTooltipHandler(dialog_->button_add);
- setTooltipHandler(dialog_->button_remove);
+ string str = _("All currently running child processes forked by LyX.");
+ tooltips().init(dialog_->browser_children, str);
+ // Work-around xforms' bug; enable tooltips for browser widgets.
+ setPrehandler(dialog_->browser_children);
+
+ str = _("A list of all child processes to kill.");
+ tooltips().init(dialog_->browser_kill, str);
+ // Work-around xforms' bug; enable tooltips for browser widgets.
+ setPrehandler(dialog_->browser_kill);
+
+ str = _("Add all processes to the list of processes to kill.");
+ tooltips().init(dialog_->button_all, str);
+
+ str = _("Add the currently selected child process to the list of processes to kill.");
+ tooltips().init(dialog_->button_add, str);
+
+ str = _("Remove the currently selected item from the list of processes to kill.");
+ tooltips().init(dialog_->button_remove, str);
}
return;
string const current_pid_str =
- getSelectedStringFromBrowser(dialog_->browser_kill);
+ getString(dialog_->browser_kill);
pid_t const current_pid = strToInt(current_pid_str);
vector<pid_t> pids = controller().getPIDs();
for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_kill);
++i) {
string const pid_str =
- getStringFromBrowser(dialog_->browser_kill, i);
+ getString(dialog_->browser_kill, i);
pid_t const pid = strToInt(pid_str);
vector<pid_t>::const_iterator it =
find(pids.begin(), pids.end(), pid);
{
// Get the list of all processes to kill.
vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ getVector(dialog_->browser_kill);
if (kill_vec.empty())
return;
for (int i = 1; i <= fl_get_browser_maxline(dialog_->browser_children);
++i) {
string const selection =
- getStringFromBrowser(dialog_->browser_children, i);
+ getString(dialog_->browser_children, i);
string pid_str;
split(selection, pid_str, '\t');
if (ob == dialog_->browser_children) {
activate = input_browser_children();
-
+
} else if (ob == dialog_->browser_kill) {
activate = input_browser_kill();
// be added to this list if so desired.
string const selection =
- getSelectedStringFromBrowser(dialog_->browser_children);
+ getString(dialog_->browser_children);
string pid_str;
split(selection, pid_str, '\t');
- vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ vector<string> const kill_vec =
+ getVector(dialog_->browser_kill);
vector<string>::const_iterator it =
find(kill_vec.begin(), kill_vec.end(), pid_str);
private:
string pid_;
};
-
+
} // namespace anon
// 3. Disable the add button.
string const pid_str =
- getSelectedStringFromBrowser(dialog_->browser_kill);
+ getString(dialog_->browser_kill);
// Find this string in the list of all child processes
vector<string> const child_vec =
- getVectorFromBrowser(dialog_->browser_children);
+ getVector(dialog_->browser_children);
vector<string>::const_iterator it =
find_if(child_vec.begin(), child_vec.end(), FindPID(pid_str));
fl_select_browser_line(dialog_->browser_children, n+1);
fl_set_browser_topline(dialog_->browser_children, n+1);
}
-
+
setEnabled(dialog_->button_remove, true);
setEnabled(dialog_->button_add, false);
vector<string> const getPIDvector(FL_OBJECT * ob)
{
- vector<string> vec = getVectorFromBrowser(ob);
+ vector<string> vec = getVector(ob);
if (vec.empty())
return vec;
return vec;
}
-
+
} // namespace anon
ButtonPolicy::SMInput activate = ButtonPolicy::SMI_NOOP;
vector<string> const pid_vec = getPIDvector(dialog_->browser_children);
- if (fl_get_browser_maxline(dialog_->browser_kill) != pid_vec.size()) {
+
+ // to resolve a warning about comparison between signed and unsigned.
+ int const pid_vec_size = int(pid_vec.size());
+
+ if (fl_get_browser_maxline(dialog_->browser_kill) != pid_vec_size) {
activate = ButtonPolicy::SMI_VALID;
fl_clear_browser(dialog_->browser_kill);
// 3. Deactivate the "add" button.
- string const selection =
- getSelectedStringFromBrowser(dialog_->browser_children);
+ string const selection = getString(dialog_->browser_children);
string pid_str;
split(selection, pid_str, '\t');
- vector<string> const kill_vec =
- getVectorFromBrowser(dialog_->browser_kill);
+ vector<string> const kill_vec =
+ getVector(dialog_->browser_kill);
vector<string>::const_iterator it =
find(kill_vec.begin(), kill_vec.end(), pid_str);
return ButtonPolicy::SMI_VALID;
}
-
-
-string const FormForks::getVerboseTooltip(FL_OBJECT const * ob) const
-{
- string str;
-
- if (ob == dialog_->browser_children) {
- str = _("All currently running child processes forked by LyX.");
- } else if (ob == dialog_->browser_kill) {
- str = _("A list of all child processes to kill.");
- } else if (ob == dialog_->button_all) {
- str = _("Add all processes to the list of processes to kill.");
- } else if (ob == dialog_->button_add) {
- str = _("Add the currently selected child process to the list of processes to kill.");
- } else if (ob == dialog_->button_remove) {
- str = _("Remove the currently selected item from the list of processes to kill.");
- }
-
- return str;
-}
-
-