Skip to content
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

plugin: add a tap bpm plugin #2264

Merged
merged 2 commits into from
Feb 25, 2017
Merged

plugin: add a tap bpm plugin #2264

merged 2 commits into from
Feb 25, 2017

Conversation

ptitjes
Copy link
Collaborator

@ptitjes ptitjes commented Feb 23, 2017

This is a very little plugin that allows the user to tap the BPM for the selected song and save it in its tags.

self.pack_start(box, False, True, 0)

self.tap_btn = Gtk.Button(label=_("Tap"))
self.tap_btn.connect('button-press-event', self.tap)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'clicked' event, otherwise pressing space/enter wont do anything if the button is focused.

Copy link
Collaborator Author

@ptitjes ptitjes Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used press event because when you tap with a mouse or a pad, whereas the clicked comes at the release of the mouse/pad button. The user (well me) expects to tap at press. It is really not nice when tap is triggered by release, because not only you have to tap in rhythm but also kinda press the button for the same duration every time (not simple, I tried :p).

Maybe I should document it so that not one wonders in the future.

I could add an additional trigger for key-presses when the button is focused...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, let's leave it that way then for now..


box = Gtk.HBox()
box.set_spacing(6)
box.pack_start(Gtk.Label(_("BPM:")), False, True, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a translators comment above:

# TRANSLATORS: BPM measn "beats per minute"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure !

self.show_all()

def update(self):
GObject.idle_add(self.do_update)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the idle_add?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work without it, I think because we are in modal dialog.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What doesn't work? It seems to work the same here as far as I can see.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If call do_update directly in update, the label is never updated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, forget it you're right ! :)
I'll change that.

return

# Save metadata
self._panel.save()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug, but try to save before destroying the window. After destroy() widgets shouldn't be used anymore and while it currently doesn't use it in save(), it might in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I'll modify that !

* clean code
* add key-press-event support
* save metadata before destroying widgets
@ptitjes
Copy link
Collaborator Author

ptitjes commented Feb 24, 2017

@lazka Changes made as requested. I kept using "button-press-event" but added code to handle space/return key presses.

@lazka lazka merged commit 6c4fa6d into quodlibet:master Feb 25, 2017
@lazka
Copy link
Member

lazka commented Feb 25, 2017

Thanks

@ptitjes
Copy link
Collaborator Author

ptitjes commented Feb 25, 2017

Thank you !

@ptitjes ptitjes deleted the tapbpm branch February 25, 2017 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants