##// END OF EJS Templates
Merge pull request #6537 from takluyver/kernelspec-logos...
Min RK -
r19398:cbecd94e merge
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -85,6 +85,7 define([
85 this.events.on('spec_changed.Kernel', function(event, data) {
85 this.events.on('spec_changed.Kernel', function(event, data) {
86 that.current_selection = data.name;
86 that.current_selection = data.name;
87 that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
87 that.element.find("#current_kernel_spec").find('.kernel_name').text(data.display_name);
88 that.element.find("#current_kernel_logo").attr("src", "/kernelspecs/"+data.name+"/logo-64x64.png");
88 });
89 });
89
90
90 this.events.on('kernel_created.Session', function(event, data) {
91 this.events.on('kernel_created.Session', function(event, data) {
@@ -96,6 +97,14 define([
96 that.events.trigger('spec_changed.Kernel', ks);
97 that.events.trigger('spec_changed.Kernel', ks);
97 }
98 }
98 });
99 });
100
101 var logo_img = this.element.find("#current_kernel_logo")
102 logo_img.on("load", function() {
103 logo_img.show();
104 });
105 logo_img.on("error", function() {
106 logo_img.hide();
107 });
99 };
108 };
100
109
101 return {'KernelSelector': KernelSelector};
110 return {'KernelSelector': KernelSelector};
@@ -9,4 +9,9
9 margin-top:0px;
9 margin-top:0px;
10 }
10 }
11 }
11 }
12
13 & > img#current_kernel_logo {
14 width: 32px;
15 height: 32px;
16 }
12 }
17 }
@@ -9685,6 +9685,10 fieldset[disabled] #kernel_selector_widget > button.active {
9685 #kernel_selector_widget > button > span.caret {
9685 #kernel_selector_widget > button > span.caret {
9686 margin-top: 0px;
9686 margin-top: 0px;
9687 }
9687 }
9688 #kernel_selector_widget > img#current_kernel_logo {
9689 width: 32px;
9690 height: 32px;
9691 }
9688 #menubar {
9692 #menubar {
9689 box-sizing: border-box;
9693 box-sizing: border-box;
9690 -moz-box-sizing: border-box;
9694 -moz-box-sizing: border-box;
@@ -42,6 +42,7 class="notebook_app"
42 </span>
42 </span>
43
43
44 <span id="kernel_selector_widget" class="pull-right dropdown">
44 <span id="kernel_selector_widget" class="pull-right dropdown">
45 <img id="current_kernel_logo"/>
45 <button class="dropdown-toggle btn btn-sm navbar-btn" data-toggle="dropdown" type='button' id="current_kernel_spec">
46 <button class="dropdown-toggle btn btn-sm navbar-btn" data-toggle="dropdown" type='button' id="current_kernel_spec">
46 <span class='kernel_name'>Kernel</span>
47 <span class='kernel_name'>Kernel</span>
47 <span class="caret"></span>
48 <span class="caret"></span>
@@ -109,8 +109,7 class KernelSpecManager(HasTraits):
109
109
110 @property
110 @property
111 def _native_kernel_resource_dir(self):
111 def _native_kernel_resource_dir(self):
112 # TODO: This may be different when we actually have any resources
112 return pjoin(os.path.dirname(__file__), 'resources')
113 return os.path.dirname(__file__)
114
113
115 def find_kernel_specs(self):
114 def find_kernel_specs(self):
116 """Returns a dict mapping kernel names to resource directories."""
115 """Returns a dict mapping kernel names to resource directories."""
@@ -128,7 +127,8 class KernelSpecManager(HasTraits):
128 Raises :exc:`NoSuchKernel` if the given kernel name is not found.
127 Raises :exc:`NoSuchKernel` if the given kernel name is not found.
129 """
128 """
130 if kernel_name in {'python', NATIVE_KERNEL_NAME}:
129 if kernel_name in {'python', NATIVE_KERNEL_NAME}:
131 return KernelSpec(self._native_kernel_resource_dir, **self._native_kernel_dict)
130 return KernelSpec(resource_dir=self._native_kernel_resource_dir,
131 **self._native_kernel_dict)
132
132
133 d = self.find_kernel_specs()
133 d = self.find_kernel_specs()
134 try:
134 try:
@@ -187,7 +187,9 class KernelSpecManager(HasTraits):
187 os.makedirs(path, mode=0o755)
187 os.makedirs(path, mode=0o755)
188 with open(pjoin(path, 'kernel.json'), 'w') as f:
188 with open(pjoin(path, 'kernel.json'), 'w') as f:
189 json.dump(self._native_kernel_dict, f, indent=1)
189 json.dump(self._native_kernel_dict, f, indent=1)
190 # TODO: Copy icons into directory
190 copy_from = self._native_kernel_resource_dir
191 for file in os.listdir(copy_from):
192 shutil.copy(pjoin(copy_from, file), path)
191 return path
193 return path
192
194
193 def find_kernel_specs():
195 def find_kernel_specs():
General Comments 0
You need to be logged in to leave comments. Login now