mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
remove UI for setting default kernel
can be set with: IPython.new_notebook_widget.set_default_kernel('kernel_name')
This commit is contained in:
parent
8eb6ec00d8
commit
fbaae651ad
@ -130,6 +130,7 @@ require([
|
|||||||
IPython.session_list = session_list;
|
IPython.session_list = session_list;
|
||||||
IPython.kernel_list = kernel_list;
|
IPython.kernel_list = kernel_list;
|
||||||
IPython.login_widget = login_widget;
|
IPython.login_widget = login_widget;
|
||||||
|
IPython.new_notebook_widget = nnw;
|
||||||
|
|
||||||
events.trigger('app_initialized.DashboardApp');
|
events.trigger('app_initialized.DashboardApp');
|
||||||
|
|
||||||
|
@ -58,17 +58,12 @@ define([
|
|||||||
var li = $("<li>")
|
var li = $("<li>")
|
||||||
.attr("id", "kernel-" +ks.name)
|
.attr("id", "kernel-" +ks.name)
|
||||||
.data('kernelspec', ks).append(
|
.data('kernelspec', ks).append(
|
||||||
$('<a>').attr('href', '#').append($('<i>')
|
$('<a>')
|
||||||
.addClass('kernel-menu-icon fa')
|
|
||||||
.attr('href', '#')
|
|
||||||
.click($.proxy(this.select_kernel, this, ks.name))
|
|
||||||
).append($('<span>')
|
|
||||||
.attr('href', '#')
|
.attr('href', '#')
|
||||||
.click($.proxy(this.new_notebook, this, ks.name))
|
.click($.proxy(this.new_notebook, this, ks.name))
|
||||||
.text(ks.display_name)
|
.text(ks.display_name)
|
||||||
.attr('title', 'Create a new notebook with ' + ks.display_name)
|
.attr('title', 'Create a new notebook with ' + ks.display_name)
|
||||||
)
|
);
|
||||||
);
|
|
||||||
menu.append(li);
|
menu.append(li);
|
||||||
}
|
}
|
||||||
this.config.loaded.then(function () {
|
this.config.loaded.then(function () {
|
||||||
@ -77,17 +72,17 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
NewNotebookWidget.prototype._load_default_kernelspec = function (default_name) {
|
NewNotebookWidget.prototype._load_default_kernelspec = function (default_name) {
|
||||||
/** load default kernelspec name from localStorage, if defined */
|
/** load default kernelspec name from config, if defined */
|
||||||
if (this.config.data.NewNotebookWidget &&
|
if (this.config.data.NewNotebookWidget &&
|
||||||
this.config.data.NewNotebookWidget.current_selection &&
|
this.config.data.NewNotebookWidget.current_selection &&
|
||||||
this.kernelspecs[this.config.data.NewNotebookWidget.current_selection] !== undefined
|
this.kernelspecs[this.config.data.NewNotebookWidget.current_selection] !== undefined
|
||||||
) {
|
) {
|
||||||
default_name = this.config.data.NewNotebookWidget.current_selection;
|
default_name = this.config.data.NewNotebookWidget.current_selection;
|
||||||
}
|
}
|
||||||
this.select_kernel(default_name);
|
this.set_default_kernel(default_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
NewNotebookWidget.prototype.select_kernel = function (kernel_name) {
|
NewNotebookWidget.prototype.set_default_kernel = function (kernel_name) {
|
||||||
/** select the current default kernel */
|
/** select the current default kernel */
|
||||||
this.current_selection = kernel_name;
|
this.current_selection = kernel_name;
|
||||||
this.config.update({
|
this.config.update({
|
||||||
@ -99,33 +94,13 @@ define([
|
|||||||
var display_name;
|
var display_name;
|
||||||
if (spec) {
|
if (spec) {
|
||||||
display_name = spec.display_name;
|
display_name = spec.display_name;
|
||||||
localStorage.default_kernel_name = kernel_name;
|
|
||||||
this.element.find("#current-kernel").text(display_name);
|
this.element.find("#current-kernel").text(display_name);
|
||||||
} else {
|
} else {
|
||||||
display_name = 'default kernel';
|
display_name = 'default kernel';
|
||||||
delete localStorage.default_kernel_name;
|
|
||||||
}
|
}
|
||||||
this.element.find("#new_notebook").attr('title',
|
this.element.find("#new_notebook").attr('title',
|
||||||
'Create a new notebook with ' + display_name
|
'Create a new notebook with ' + display_name
|
||||||
);
|
);
|
||||||
this.element.find("li").map(function (i, li) {
|
|
||||||
li = $(li);
|
|
||||||
var ks = li.data('kernelspec');
|
|
||||||
if (ks.name == kernel_name) {
|
|
||||||
li.find(".kernel-menu-icon")
|
|
||||||
.attr('title', display_name + ' is the default kernel')
|
|
||||||
.addClass("kernel-menu-icon-current");
|
|
||||||
} else {
|
|
||||||
li.find(".kernel-menu-icon")
|
|
||||||
.attr('title', 'Make ' + ks.display_name + ' the default kernel')
|
|
||||||
.removeClass("kernel-menu-icon-current");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
NewNotebookWidget.prototype.new_with_kernel = function (kernel_name) {
|
|
||||||
/** record current selection and open a new notebook */
|
|
||||||
this.new_notebook(kernel_name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
|
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user