-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PR: Create a unique instance of the file switcher attached to the main window #4626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
142e820
46f9751
af1d76f
d4ce253
a30e6df
690645d
d317713
4a7c9b0
7f45c7b
461c6de
9aa3053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,7 @@ | |
from spyder.utils.introspection import module_completion | ||
from spyder.utils.programs import is_module_installed | ||
from spyder.utils.misc import select_port | ||
from spyder.widgets.fileswitcher import FileSwitcher | ||
|
||
#============================================================================== | ||
# Local gui imports | ||
|
@@ -322,6 +323,9 @@ def signal_handler(signum, frame=None): | |
# Tour # TODO: Should I consider it a plugin?? or? | ||
self.tour = None | ||
self.tours_available = None | ||
|
||
# File switcher | ||
self.fileswitcher_dlg = None | ||
|
||
# Check for updates Thread and Worker, refereces needed to prevent | ||
# segfaulting | ||
|
@@ -551,6 +555,25 @@ def setup(self): | |
"Use next layout") | ||
self.register_shortcut(self.toggle_previous_layout_action, "_", | ||
"Use previous layout") | ||
# File switcher shortcuts | ||
self.file_switcher_action = create_action( | ||
self, | ||
_('File switcher...'), | ||
icon=ima.icon('filelist'), | ||
tip=_('Fast switch between files'), | ||
triggered=self.open_fileswitcher_dlg, | ||
context=Qt.ApplicationShortcut) | ||
self.register_shortcut(self.file_switcher_action, context="_", | ||
name="File switcher") | ||
self.symbol_finder_action = create_action( | ||
self, _('Symbol finder...'), | ||
icon=ima.icon('symbol_find'), | ||
tip=_('Fast symbol search in file'), | ||
triggered=self.open_symbolfinder_dlg, | ||
context=Qt.ApplicationShortcut) | ||
self.register_shortcut(self.symbol_finder_action, context="_", | ||
name="symbol finder", add_sc_to_tip=True) | ||
|
||
|
||
def create_edit_action(text, tr_text, icon): | ||
textseq = text.split(' ') | ||
|
@@ -826,7 +849,9 @@ def create_edit_action(text, tr_text, icon): | |
context=Qt.ApplicationShortcut) | ||
self.register_shortcut(restart_action, "_", "Restart") | ||
|
||
self.file_menu_actions += [None, restart_action, quit_action] | ||
self.file_menu_actions += [self.file_switcher_action, | ||
self.symbol_finder_action, None, | ||
restart_action, quit_action] | ||
self.set_splash("") | ||
|
||
self.debug_print(" ..widgets") | ||
|
@@ -2720,6 +2745,36 @@ def show_tour(self, index): | |
self.tour.set_tour(index, frames, self) | ||
self.tour.start_tour() | ||
|
||
# ---- Global File Switcher | ||
def open_fileswitcher_dlg(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open_fileswitcher_dlg -> open_fileswitcher |
||
"""Open file list management dialog box.""" | ||
if self.fileswitcher_dlg is not None and \ | ||
self.fileswitcher_dlg.is_visible: | ||
self.fileswitcher_dlg.hide() | ||
self.fileswitcher_dlg.is_visible = False | ||
return | ||
self.fileswitcher_dlg.setup() | ||
self.fileswitcher_dlg.show() | ||
self.fileswitcher_dlg.is_visible = True | ||
|
||
def open_symbolfinder_dlg(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open_symbolfinder_dlg -> open_symbolfinder |
||
"""Open symbol list management dialog box.""" | ||
self.open_fileswitcher_dlg() | ||
self.fileswitcher_dlg.set_search_text('@') | ||
|
||
def add_to_fileswitcher(self, tabs, data, plugin): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say it's
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the Notebook There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, then let's change the signature anyway to be
|
||
"""Add a plugin to the File Switcher.""" | ||
if self.fileswitcher_dlg == None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The convention when comparing with
Please change it to be this way. |
||
self.fileswitcher_dlg = FileSwitcher(self, tabs, data, plugin) | ||
self.fileswitcher_dlg.sig_goto_file.connect( | ||
plugin.get_current_tab_manager().set_stack_index | ||
) | ||
else: | ||
self.fileswitcher_dlg.add_plugin(tabs, data, plugin) | ||
self.fileswitcher_dlg.sig_goto_file.connect( | ||
plugin.get_current_tab_manager().set_stack_index | ||
) | ||
|
||
# ---- Check for Spyder Updates | ||
def _check_updates_ready(self): | ||
"""Called by WorkerUpdates when ready""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -766,9 +766,9 @@ def open_fileswitcher_dlg(self): | |
self.fileswitcher_dlg.hide() | ||
self.fileswitcher_dlg.is_visible = False | ||
return | ||
self.fileswitcher_dlg = FileSwitcher(self, self.tabs, self.data) | ||
self.fileswitcher_dlg = FileSwitcher(self, self.tabs, self.data, self) | ||
self.fileswitcher_dlg.sig_goto_file.connect(self.set_stack_index) | ||
self.fileswitcher_dlg.sig_close_file.connect(self.close_file) | ||
self.fileswitcher_dlg.setup() | ||
self.fileswitcher_dlg.show() | ||
self.fileswitcher_dlg.is_visible = True | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need this instance of the file switcher here? I mean, can we remove it given that we have now a single and global instance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left this for the windows that the editor could create, but I think it is possible to attach that windows to the file switcher too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but how is the file switcher called for those windows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it is in this moment for those windows only by clicking in the action of the menu. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @goanpeca, what do you think? should we leave it or remove it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm not a strong opinion either way :-| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's leave it for now then ;-) |
||
|
||
|
@@ -782,6 +782,10 @@ def update_fileswitcher_dlg(self): | |
if self.fileswitcher_dlg: | ||
self.fileswitcher_dlg.setup() | ||
|
||
def get_current_tab_manager(self): | ||
"""Get the widget with the TabWidget attribute.""" | ||
return self | ||
|
||
def go_to_line(self): | ||
"""Go to line dialog""" | ||
if self.data: | ||
|
@@ -1104,8 +1108,9 @@ def get_current_editor(self): | |
def get_stack_count(self): | ||
return self.tabs.count() | ||
|
||
def set_stack_index(self, index): | ||
self.tabs.setCurrentIndex(index) | ||
def set_stack_index(self, index, instance=None): | ||
if instance == self or instance == None: | ||
self.tabs.setCurrentIndex(index) | ||
|
||
def set_tabbar_visible(self, state): | ||
self.tabs.tabBar().setVisible(state) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileswitcher_dlg -> fileswitcher