##// END OF EJS Templates
Eliminate main window logic from MagicHelper....
Dimitry Kloper -
Show More
@@ -25,6 +25,7 b' class MagicHelper(QtGui.QDockWidget):'
25
25
26 pasteRequested = QtCore.pyqtSignal(str, name = 'pasteRequested')
26 pasteRequested = QtCore.pyqtSignal(str, name = 'pasteRequested')
27 runRequested = QtCore.pyqtSignal(str, name = 'runRequested')
27 runRequested = QtCore.pyqtSignal(str, name = 'runRequested')
28 readyForUpdate = QtCore.pyqtSignal(name = 'readyForUpdate')
28
29
29 #---------------------------------------------------------------------------
30 #---------------------------------------------------------------------------
30 # 'object' interface
31 # 'object' interface
@@ -34,11 +35,6 b' class MagicHelper(QtGui.QDockWidget):'
34
35
35 super(MagicHelper, self).__init__(name, parent)
36 super(MagicHelper, self).__init__(name, parent)
36
37
37 # this is a hack. The main_window reference will be used for
38 # explicit interface to kernel that must be hidden by signal/slot
39 # mechanism in the future
40 self.main_window = parent
41
42 self.data = None
38 self.data = None
43
39
44 class MinListWidget(QtGui.QListWidget):
40 class MinListWidget(QtGui.QListWidget):
@@ -94,21 +90,9 b' class MagicHelper(QtGui.QDockWidget):'
94 self.data = {}
90 self.data = {}
95 self.search_class.clear()
91 self.search_class.clear()
96 self.search_class.addItem("Populating...")
92 self.search_class.addItem("Populating...")
97 self.main_window.active_frontend._silent_exec_callback(
93 self.readyForUpdate.emit()
98 'get_ipython().magic("lsmagic")',
99 self.populate_magic_helper
100 )
101
94
102 def populate_magic_helper(self, data):
95 def populate_magic_helper(self, data):
103 if not data:
104 return
105
106 if data['status'] != 'ok':
107 self.main_window.log.warn(
108 "%%lsmagic user-expression failed: {}".format(data)
109 )
110 return
111
112 self.search_class.clear()
96 self.search_class.clear()
113 self.search_list.clear()
97 self.search_list.clear()
114
98
@@ -713,6 +713,9 b' class MainWindow(QtGui.QMainWindow):'
713 self.magic_helper.runRequested[str].connect(
713 self.magic_helper.runRequested[str].connect(
714 self.magic_helper_run_requested
714 self.magic_helper_run_requested
715 )
715 )
716 self.magic_helper.readyForUpdate.connect(
717 self.magic_helper_update_requested
718 )
716
719
717 self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.magic_helper)
720 self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.magic_helper)
718
721
@@ -732,8 +735,23 b' class MainWindow(QtGui.QMainWindow):'
732 self.active_frontend.execute(text)
735 self.active_frontend.execute(text)
733 self._set_active_frontend_focus()
736 self._set_active_frontend_focus()
734
737
738 def magic_helper_update_requested(self):
739 def _handle_data(data):
740 if not data:
741 return
742
743 if data['status'] != 'ok':
744 self.log.warn(
745 "%%lsmagic user-expression failed: {}".format(data)
746 )
747 return
748 self.magic_helper.populate_magic_helper(data)
749
750 self.active_frontend._silent_exec_callback(
751 'get_ipython().magic("lsmagic")',
752 _handle_data
753 )
735
754
736
737 # minimize/maximize/fullscreen actions:
755 # minimize/maximize/fullscreen actions:
738
756
739 def toggle_menu_bar(self):
757 def toggle_menu_bar(self):
General Comments 0
You need to be logged in to leave comments. Login now