Skip to content

Commit

Permalink
Disable confirmation after manually setting bpm count (exaile#862)
Browse files Browse the repository at this point in the history
* Fixes exaile#717
  • Loading branch information
luzip665 committed Mar 7, 2023
1 parent b64e0cc commit 4e6c69f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
31 changes: 20 additions & 11 deletions plugins/bpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import xlgui.main
from xlgui.widgets import menu, dialogs

from . import bpmdetect
from . import bpmdetect, bpm_prefs

autodetect_enabled = bpmdetect.autodetect_supported()

Expand Down Expand Up @@ -72,6 +72,9 @@ def on_gui_loaded(self):
for p in menu_providers:
providers.register(p, self.menuitem)

def get_preferences_pane(self):
return bpm_prefs

def disable(self, exaile):
"""
Called when the plugin is disabled
Expand Down Expand Up @@ -124,16 +127,22 @@ def set_bpm(self, track, bpm, parent_window=None):
# Turn it into a rounded int.
bpm = int(round(float(bpm)))

msg = Gtk.MessageDialog(
buttons=Gtk.ButtonsType.YES_NO,
message_type=Gtk.MessageType.QUESTION,
modal=True,
text=_('Set BPM of %d on %s?') % (bpm, track.get_tag_display('title')),
transient_for=parent_window,
)
msg.set_default_response(Gtk.ResponseType.NO)
result = msg.run()
msg.destroy()
if settings.get_option(
'plugin/bpm/show_confirmation_on_manual_setting', True
):
msg = Gtk.MessageDialog(
buttons=Gtk.ButtonsType.YES_NO,
message_type=Gtk.MessageType.QUESTION,
modal=True,
text=_('Set BPM of %d on %s?')
% (bpm, track.get_tag_display('title')),
transient_for=parent_window,
)
msg.set_default_response(Gtk.ResponseType.NO)
result = msg.run()
msg.destroy()
else:
result = Gtk.ResponseType.YES
self._set_bpm(result, bpm, track)

def _set_bpm(self, result, bpm, track):
Expand Down
12 changes: 12 additions & 0 deletions plugins/bpm/bpm_prefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
from xlgui.preferences import widgets
from xl.nls import gettext as _

name = _("BPM Counter")
basedir = os.path.dirname(os.path.realpath(__file__))
ui = os.path.join(basedir, "bpm_prefs.ui")


class ShowConfimation(widgets.CheckPreference):
default = True
name = "plugin/bpm/show_confirmation_on_manual_setting"
26 changes: 26 additions & 0 deletions plugins/bpm/bpm_prefs.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkGrid" id="preferences_pane">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">4</property>
<property name="column_spacing">2</property>
<child>
<object class="GtkCheckButton" id="plugin/bpm/show_confirmation_on_manual_setting">
<property name="label" translatable="yes">Enable confirmation dialog after manually setting bpm</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes"></property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">3</property>
</packing>
</child>
</object>
</interface>

0 comments on commit 4e6c69f

Please sign in to comment.