Skip to content

Commit 70315cb

Browse files
Improve re-size in File Explorer
1 parent 8aa6166 commit 70315cb

File tree

3 files changed

+22
-29
lines changed

3 files changed

+22
-29
lines changed

src/robotide/ui/fileexplorerplugin.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..pluginapi import Plugin
2424
from ..pluginapi.plugin import ActionInfo
2525
from ..preferences import PreferenceEditor
26-
from ..publish import RideSettingsChanged, PUBLISHER
26+
from ..publish import RideSettingsChanged, RideOpenSuite, PUBLISHER
2727
from ..widgets import PopupCreator, PopupMenuItems, VerticalSizer, HorizontalSizer, ButtonWithHandler, RIDEDialog
2828

2929
_ = wx.GetTranslation # To keep linter/code analyser happy
@@ -75,6 +75,7 @@ def __init__(self, application, controller=None):
7575
# self.font = self.file_explorer.GetFont()
7676
self.font = None
7777
self._popup_creator = PopupCreator()
78+
self.subscribe(self.on_suite_opened, RideOpenSuite, RideSettingsChanged)
7879
self._actions = [
7980
_('Open'),
8081
'---',
@@ -115,6 +116,10 @@ def enable(self):
115116
# if not self.opened:
116117
# self.close_tree()
117118

119+
def disable(self):
120+
self.unregister_actions()
121+
self.unsubscribe_all()
122+
118123
def close_tree(self):
119124
# self.save_setting('opened', False)
120125
self.opened = False
@@ -232,10 +237,17 @@ def update_tree(self):
232237
if not self.file_explorer:
233238
return
234239
self.file_explorer.update_tree()
240+
self.file_explorer.on_size()
235241

236242
def show_popup(self):
237243
self._popup_creator.show(self.file_explorer, PopupMenuItems(self, self._actions, self._actions_nt), self._controller)
238244

245+
def on_suite_opened(self, message):
246+
# Update File Explorer tree when suite is opened to use whole pane (when floating).
247+
# Not working
248+
__ = message
249+
wx.CallAfter(self.update_tree)
250+
239251
def on_open(self, event):
240252
# __ = event
241253
# print(f"DEBUG: FileExplorerPlugin call on_open_file={event}\n"
@@ -254,9 +266,6 @@ def on_open_containing_folder(self, event):
254266
file_manager = self.global_settings[FILE_MANAGER]
255267
except KeyError:
256268
file_manager = None
257-
# self._controller.execute(
258-
# ctrlcommands.OpenContainingFolder(file_manager, self.file_explorer.current_path)
259-
# print(f"DEBUG: FileExplorerPlugin call file manager={file_manager}")
260269
start_filemanager(self.file_explorer.current_path, file_manager)
261270

262271
def on_config_panel(self):
@@ -296,8 +305,7 @@ def __init__(self, parent, plugin, controller=None):
296305
self.current_path = None
297306
self._apply_settings()
298307
self.Bind(wx.EVT_CLOSE, self.on_close)
299-
# self.Bind(wx.EVT_SIZE, self.on_size) # DEBUG With this activated, the "toolbar" is hidden
300-
self.Bind(wx.EVT_MOVE, self.on_size)
308+
self.Bind(wx.EVT_SIZE, self.on_size)
301309
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_right_click)
302310
self.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
303311
PUBLISHER.subscribe(self.on_settings_changed, RideSettingsChanged)
@@ -333,7 +341,7 @@ def update_tree(self):
333341
self.tree_ctrl.TreeCtrl.EnsureVisible(self.tree_ctrl.TreeCtrl.GetSelection())
334342
except Exception:
335343
pass
336-
# self.on_size(None)
344+
# self.on_size(wx.EVT_SIZE)
337345
self.Refresh()
338346
self.Update()
339347
self.tree_ctrl.Update()
@@ -389,8 +397,9 @@ def on_key_press(self, event):
389397
print(f"DEBUG: FileExplorer on_key_press Skipping {event.KeyCode()}")
390398
event.Skip()
391399

392-
def on_size(self, event):
393-
__ = event
400+
def on_size(self, event=None):
401+
if event:
402+
event.Skip()
394403
self.update_tree()
395404
sz = self.GetSize() # + wx.Size(-5, -5)
396405
# print(f"DEBUG: FileExplorer On size refreshing. sz={sz}")
@@ -403,43 +412,29 @@ def on_size(self, event):
403412
self.tree_ctrl.Update()
404413

405414
def on_right_click(self, event):
406-
# __ = event
407-
# event.Skip()
408-
# print(f"DEBUG: FileExplorer mouse RightClick event={event} controller={self._controller}")
415+
__ = event
409416
if not self._right_click:
410417
self._right_click = True
411418
handler = None
412-
# item = self.HitTest(self.ScreenToClient(wx.GetMousePosition())) # wx.TREE_HITTEST_ONITEMLABEL)
413419
tc = self.tree_ctrl.GetTreeCtrl()
414-
# item, _ = tc.HitTest(self.ScreenToClient(wx.GetMousePosition()))
415420
item = tc.GetSelection()
416421
if item:
417-
# print(f"DEBUG: FileExplorer mouse RightClick item={item} type={type(item)}")
418-
# id=self.GetPopupMenuSelectionFromUser()
419-
handler = self.tree_ctrl.GetPath(item) # self.GetItemData(item)
422+
handler = self.tree_ctrl.GetPath(item)
420423
if handler:
421-
# handler.show_popup()
422424
self.current_path = handler
423-
# print(f"DEBUG: FileExplorer PATH={handler}")
424425
if self._plugin:
425426
self._plugin.show_popup()
426427
self._right_click = False
427428

428429
def on_settings_changed(self, message):
429430
"""Redraw the colors if the color settings are modified"""
430431
if message.keys[0] == "General":
431-
# print(f"DEBUG: FileExplorer on_settings_changed GENERAL={message.keys}\n"
432-
# f"settings={self._plugin.general_settings}")
433432
if message.keys[-1] == "apply to panels":
434433
self.update_tree()
435434
return
436435
section, _ = message.keys
437436
if section == PLUGIN_NAME:
438-
# print(f"DEBUG: FileExplorer on_settings_changed SECTION={message.keys}\n"
439-
# f"settings={self._plugin.settings}")
440437
self.update_tree()
441-
# mgr = self.parent.GetManager()
442-
# if mgr.GetPane('file_explorer'):
443438
if self._plugin._pane:
444439
pane_info = self._plugin._pane
445440
docked = self._plugin.settings['docked']
@@ -452,7 +447,6 @@ def on_settings_changed(self, message):
452447
pane_info.Show(True)
453448
else:
454449
pane_info.Hide()
455-
# print(f"DEBUG: FileExplorer on_settings_changed Call Update {opened=} {docked=}")
456450
self._plugin._pane.GetManager().Update()
457451

458452
def general_font_size(self) -> int:
@@ -478,5 +472,4 @@ def _create_pane_toolbar(self):
478472
self.pane_toolbar.add_expanding(default_components)
479473
self.pane_toolbar.AddStretchSpacer()
480474
self.pane_toolbar.add_with_padding(self.config_button)
481-
# self.sizer.add_expanding(self.pane_toolbar, propotion=0)
482475
self.sizer.Add(self.pane_toolbar, proportion=0)

src/robotide/ui/mainframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def on_open_file(self, event):
453453
# path = self.filemgr.current_path # .GetFilePath()
454454
# print(f"DEBUG: mainframe.py RideFrame on_open_file 1 path={path}")
455455
path = self.filemgr.tree_ctrl.GetPath()
456-
print(f"DEBUG: mainframe.py RideFrame on_open_file 2 path={path}")
456+
# print(f"DEBUG: mainframe.py RideFrame on_open_file 2 path={path}")
457457
ext = ''
458458
if len(path) > 0:
459459
ext = splitext(path)

src/robotide/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
#
1616
# Automatically generated by `tasks.py`.
1717

18-
VERSION = 'v2.2.1dev2'
18+
VERSION = 'v2.2.1dev3'

0 commit comments

Comments
 (0)