StatusBarExtended icon indicating copy to clipboard operation
StatusBarExtended copied to clipboard

Changing pane with TAB doesn't refresh status bar

Open kek91 opened this issue 9 years ago • 11 comments

StatusBarExtended refreshes only upon on_path_changed(). Should refresh when changing pane with TAB button

kek91 avatar Mar 01 '17 14:03 kek91

This is most probably an issue with the on_path_changed() not being fired by fman core itself. Should probably report the issue there.

bastijnv avatar Mar 03 '17 11:03 bastijnv

But the tab button shouldn't trigger on_path_changed() because it doesn't actually change path, it just moves the cursor to the other pane, so there's nothing wrong with on_path_changed() per se.

I just need a method to hook into (like I did on toggle_selection()), I looked through the core plugin but I couldn't find any methods for changing cursor pane, only "MoveCursorDown/Up" etc (and I guess it would be overkill to refresh statusbar on every cursor movement in the same pane).

I'll tag @mherrmann and maybe he can give us a hint

kek91 avatar Mar 03 '17 12:03 kek91

I agree, makes sense. Would be nice if a on_pane_changed() was there though it might be overkill if we can't find more use-cases for this.

bastijnv avatar Mar 03 '17 15:03 bastijnv

I can see the need for this. What would be most logical to me would be an on_pane_activated event. What do you guys think?

mherrmann avatar Mar 05 '17 11:03 mherrmann

on_pane_activated suggest you subscribe to both panes (guessing by the API naming). Or did you mean to fire with the activated pane ID in the args and is the API name a bit confusing.

I can think of two situations:

  • You want to know when a specific pane is activated; this would suggest on_pane_actived.
  • You just want to refresh something when a pane is switched. In this case it might be easier to have something like on_active_pane_changed(id).

Of course on_pane_activated(id) could be your intention but I was misinterpreting the API.

bastijnv avatar Mar 05 '17 14:03 bastijnv

Actually, on_activated would be a better name for what I mean. Maybe that already clarifies what you now asked @bastijnv.

I would make on_activated similar to on_path_changed. Say you have:

class Foo(DirectoryPaneListener):
    def on_path_changed(self):
        pass
    def on_activated(self):
        pass

When there are two panes (the default), there would be two instances of Foo. When one pane's path changes, on_path_changed is called on that instance. When the user presses TAB so the other pane becomes active, that other Foo instance's on_activated method is called.

Does that make sense?

mherrmann avatar Mar 06 '17 09:03 mherrmann

on_pane_activated or on_activated or whatever is perfect. Once that is fired we can simply do self.pane.id to get the current pane :)

kek91 avatar Mar 06 '17 13:03 kek91

What do you think of on_activated @bastijnv ?

mherrmann avatar Mar 06 '17 17:03 mherrmann

That would work. Generic so it could also be reused for other elements in the future.

Thanks @m_herrmann.

bastijnv avatar Mar 06 '17 19:03 bastijnv

@mherrmann so it ends up in your notifications (previous autocorrected to your twitter).

bastijnv avatar Mar 06 '17 19:03 bastijnv

Okay, that's the way I'll implement it then. I've created a card so I don't forget.

mherrmann avatar Mar 08 '17 04:03 mherrmann