263 lines
10 KiB
Diff
263 lines
10 KiB
Diff
--- a/usr/share/pulseaudio-equalizer/pulseaudio-equalizer.py
|
|
+++ b/usr/share/pulseaudio-equalizer/pulseaudio-equalizer.py
|
|
@@ -8,11 +8,13 @@
|
|
# Version: (see '/usr/pulseaudio-equalizer' script)
|
|
#
|
|
|
|
-import pygtk
|
|
-pygtk.require('2.0')
|
|
-import gtk, gobject
|
|
+import gi
|
|
+gi.require_version("Gtk", "3.0")
|
|
+from gi.repository import GLib as glib, Gtk as gtk
|
|
import os
|
|
|
|
+GTK_VERSION = (gtk.MAJOR_VERSION, gtk.MINOR_VERSION, gtk.MICRO_VERSION)
|
|
+
|
|
configdir = glib.get_user_config_dir() + "/pulse"
|
|
eqconfig = configdir + "/equalizerrc"
|
|
eqconfig2 = configdir + "/equalizerrc.test"
|
|
@@ -300,12 +302,16 @@ class Equalizer:
|
|
def on_removepreset(self,widget):
|
|
global preset
|
|
global presets
|
|
- dialog = gtk.FileChooserDialog("Choose preset to remove...",
|
|
- None,
|
|
- gtk.FILE_CHOOSER_ACTION_OPEN,
|
|
- (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
|
- gtk.STOCK_OK, gtk.RESPONSE_OK))
|
|
- dialog.set_default_response(gtk.RESPONSE_OK)
|
|
+ dialog = gtk.FileChooserDialog(title="Choose preset to remove...",
|
|
+ transient_for=widget.get_toplevel(),
|
|
+ action=gtk.FileChooserAction.OPEN)
|
|
+
|
|
+ button = dialog.add_button("_Cancel", gtk.ResponseType.CANCEL)
|
|
+ button.set_image(gtk.Image.new_from_icon_name("gtk-cancel", gtk.IconSize.BUTTON))
|
|
+ button = dialog.add_button("_Open", gtk.ResponseType.OK)
|
|
+ button.set_image(gtk.Image.new_from_icon_name("document-open", gtk.IconSize.BUTTON))
|
|
+ button.grab_default()
|
|
+ dialog.set_default_response(gtk.ResponseType.OK)
|
|
|
|
filter = gtk.FileFilter()
|
|
filter.set_name("Preset files")
|
|
@@ -315,7 +321,7 @@ class Equalizer:
|
|
dialog.show()
|
|
|
|
response = dialog.run()
|
|
- if response == gtk.RESPONSE_OK:
|
|
+ if response == gtk.ResponseType.OK:
|
|
filename = dialog.get_filename()
|
|
path_and_name = os.path.split(filename)
|
|
name = path_and_name[1]
|
|
@@ -358,14 +364,14 @@ class Equalizer:
|
|
def __init__(self):
|
|
GetSettings()
|
|
|
|
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
|
+ self.window = gtk.Window()
|
|
self.window.set_resizable(True)
|
|
|
|
self.window.connect("destroy", self.destroy_equalizer)
|
|
self.window.set_title(windowtitle + " [" + realstatus + "]")
|
|
self.window.set_border_width(0)
|
|
|
|
- icon_theme = gtk.icon_theme_get_default()
|
|
+ icon_theme = gtk.IconTheme.get_default()
|
|
if icon_theme.has_icon("multimedia-volume-control"):
|
|
icon = icon_theme.load_icon("multimedia-volume-control", 16, 0)
|
|
self.window.set_icon(icon)
|
|
@@ -380,19 +386,22 @@ class Equalizer:
|
|
|
|
menu = gtk.Menu()
|
|
|
|
- menu_item = gtk.MenuItem('Reset to defaults')
|
|
+ menu_item = gtk.MenuItem(label="Reset to defaults")
|
|
menu_item.connect("activate", self.on_resetsettings)
|
|
menu.append(menu_item)
|
|
menu_item.show()
|
|
- menu_item = gtk.MenuItem("Remove user preset...")
|
|
+ menu_item = gtk.MenuItem(label="Remove user preset...")
|
|
menu_item.connect("activate", self.on_removepreset)
|
|
menu.append(menu_item)
|
|
menu_item.show()
|
|
- root_menu = gtk.MenuItem("Advanced")
|
|
+ root_menu = gtk.MenuItem(label="Advanced")
|
|
root_menu.show()
|
|
root_menu.set_submenu(menu)
|
|
|
|
- vbox1 = gtk.VBox(False, 0)
|
|
+ if GTK_VERSION >= (3, 0, 0):
|
|
+ vbox1 = gtk.Box(orientation=gtk.Orientation.VERTICAL)
|
|
+ else:
|
|
+ vbox1 = gtk.VBox()
|
|
self.window.add(vbox1)
|
|
vbox1.show()
|
|
menu_bar = gtk.MenuBar()
|
|
@@ -400,22 +409,31 @@ class Equalizer:
|
|
menu_bar.show()
|
|
menu_bar.append (root_menu)
|
|
|
|
- hbox1 = gtk.HBox(False, 1)
|
|
+ if GTK_VERSION >= (3, 0, 0):
|
|
+ hbox1 = gtk.Box(orientation=gtk.Orientation.HORIZONTAL, spacing=1)
|
|
+ else:
|
|
+ hbox1 = gtk.HBox(spacing=1)
|
|
#hbox1.set_border_width(10)
|
|
vbox1.add(hbox1)
|
|
hbox1.show()
|
|
|
|
- table = gtk.Table(3, 17, False)
|
|
- table.set_border_width(5)
|
|
- hbox1.add(table)
|
|
+ if GTK_VERSION >= (3, 10, 0):
|
|
+ grid = gtk.Grid()
|
|
+ else:
|
|
+ grid = gtk.Table(n_rows=3, n_columns=17)
|
|
+ grid.set_border_width(5)
|
|
+ hbox1.add(grid)
|
|
|
|
# Preamp widget
|
|
global preampscale
|
|
global preampscalevalue
|
|
- preampscale = gtk.VScale()
|
|
+ if GTK_VERSION >= (3, 2, 0):
|
|
+ preampscale = gtk.Scale(orientation=gtk.Orientation.VERTICAL)
|
|
+ else:
|
|
+ preampscale = gtk.VScale()
|
|
preampscale.set_draw_value(0)
|
|
preampscale.set_inverted(1)
|
|
- preampscale.set_value_pos(gtk.POS_BOTTOM)
|
|
+ preampscale.set_value_pos(gtk.PositionType.BOTTOM)
|
|
preampscale.set_range(0.0, 2.0)
|
|
preampscale.set_increments(1, 0.1)
|
|
preampscale.set_digits(1)
|
|
@@ -426,16 +444,25 @@ class Equalizer:
|
|
label.set_markup("<small>Preamp</small>")
|
|
preampscalevalue = gtk.Label()
|
|
preampscalevalue.set_markup(str(preampscale.get_value()) + "x")
|
|
- table.attach(label, 1, 2, 0, 1)
|
|
- table.attach(preampscale, 1, 2, 1, 2)
|
|
- table.attach(preampscalevalue, 1, 2, 2, 3)
|
|
+ if GTK_VERSION >= (3, 10, 0):
|
|
+ grid.attach(label, 1, 0, 1, 1)
|
|
+ grid.attach(preampscale, 1, 1, 1, 1)
|
|
+ grid.attach(preampscalevalue, 1, 2, 1, 1)
|
|
+ else:
|
|
+ grid.attach(label, 1, 2, 0, 1)
|
|
+ grid.attach(preampscale, 1, 2, 1, 2)
|
|
+ grid.attach(preampscalevalue, 1, 2, 2, 3)
|
|
#label.show()
|
|
#preampscale.show()
|
|
#preampscalevalue.show()
|
|
|
|
# Separator between preamp and bands
|
|
- separator = gtk.VSeparator()
|
|
- table.attach(separator, 2, 3, 1, 2)
|
|
+ if GTK_VERSION >= (3, 10, 0):
|
|
+ separator = gtk.Separator(orientation=gtk.Orientation.VERTICAL)
|
|
+ grid.attach(separator, 2, 1, 1, 1)
|
|
+ else:
|
|
+ separator = gtk.VSeparator()
|
|
+ grid.attach(separator, 2, 3, 1, 2)
|
|
#separator.show()
|
|
|
|
# Equalizer bands
|
|
@@ -448,7 +475,7 @@ class Equalizer:
|
|
self.scales[x] = scale
|
|
scale.set_draw_value(0)
|
|
scale.set_inverted(1)
|
|
- scale.set_value_pos(gtk.POS_BOTTOM)
|
|
+ scale.set_value_pos(gtk.PositionType.BOTTOM)
|
|
scale.set_range(float(ranges[0]), float(ranges[1]))
|
|
scale.set_increments(1, 0.1)
|
|
scale.set_digits(1)
|
|
@@ -462,16 +489,24 @@ class Equalizer:
|
|
scalevalue = gtk.Label()
|
|
self.scalevalues[x] = scalevalue
|
|
scalevalue.set_markup("<small>" + str(scale.get_value()) + "\ndB</small>")
|
|
- table.attach(label, x + 2, x + 3, 0, 1)
|
|
- table.attach(scale, x + 2, x + 3, 1, 2)
|
|
- table.attach(scalevalue, x + 2, x + 3, 2, 3)
|
|
+ if GTK_VERSION >= (3, 10, 0):
|
|
+ grid.attach(label, x + 2, 0, 1, 1)
|
|
+ grid.attach(scale, x + 2, 1, 1, 1)
|
|
+ grid.attach(scalevalue, x + 2, 2, 1, 1)
|
|
+ else:
|
|
+ grid.attach(label, x + 2, x + 3, 0, 1)
|
|
+ grid.attach(scale, x + 2, x + 3, 1, 2)
|
|
+ grid.attach(scalevalue, x + 2, x + 3, 2, 3)
|
|
label.show()
|
|
scale.show()
|
|
scalevalue.show()
|
|
|
|
- table.show()
|
|
+ grid.show()
|
|
|
|
- vbox2 = gtk.VBox(True, 1)
|
|
+ if GTK_VERSION >= (3, 0, 0):
|
|
+ vbox2 = gtk.Box(orientation=gtk.Orientation.VERTICAL, homogeneous=True, spacing=1)
|
|
+ else:
|
|
+ vbox2 = gtk.VBox(homogeneous=True, spacing=1)
|
|
vbox2.set_border_width(10)
|
|
hbox1.add(vbox2)
|
|
vbox2.show()
|
|
@@ -482,7 +517,7 @@ class Equalizer:
|
|
presetslabel.show()
|
|
|
|
global presetsbox
|
|
- presetsbox = gtk.combo_box_entry_new_text()
|
|
+ presetsbox = gtk.ComboBoxText.new_with_entry()
|
|
vbox2.pack_start(presetsbox, False, False, 0)
|
|
presetsbox.get_child().set_text(preset)
|
|
for i in range(len(rawpresets)):
|
|
@@ -490,38 +525,41 @@ class Equalizer:
|
|
presetsbox.connect("changed", self.on_presetsbox, x)
|
|
presetsbox.show()
|
|
|
|
- savepreset = gtk.Button("Save Preset")
|
|
+ savepreset = gtk.Button(label="Save Preset")
|
|
vbox2.pack_start(savepreset, False, False, 0)
|
|
savepreset.connect("clicked", self.on_savepreset)
|
|
savepreset.show()
|
|
|
|
global eqenabled
|
|
- eqenabled = gtk.CheckButton("EQ Enabled")
|
|
+ eqenabled = gtk.CheckButton(label="EQ Enabled")
|
|
eqenabled.set_active(status)
|
|
- eqenabled.unset_flags(gtk.CAN_FOCUS)
|
|
+ eqenabled.set_can_focus(False)
|
|
eqenabled.connect("clicked", self.on_eqenabled)
|
|
vbox2.pack_start(eqenabled, False, False, 0)
|
|
eqenabled.show()
|
|
|
|
global keepsettings
|
|
- keepsettings = gtk.CheckButton('Keep Settings')
|
|
+ keepsettings = gtk.CheckButton(label="Keep Settings")
|
|
keepsettings.set_active(persistence)
|
|
- keepsettings.unset_flags(gtk.CAN_FOCUS)
|
|
+ keepsettings.set_can_focus(False)
|
|
keepsettings.connect("clicked", self.on_keepsettings)
|
|
vbox2.pack_start(keepsettings, False, False, 0)
|
|
keepsettings.show()
|
|
|
|
- applysettings = gtk.Button("Apply Settings")
|
|
+ applysettings = gtk.Button(label="Apply Settings")
|
|
vbox2.pack_start(applysettings, False, False, 0)
|
|
applysettings.connect("clicked", self.on_applysettings)
|
|
applysettings.show()
|
|
|
|
- quitbutton = gtk.Button("Quit")
|
|
+ quitbutton = gtk.Button(label="Quit")
|
|
vbox2.pack_start(quitbutton, False, False, 0)
|
|
quitbutton.connect("clicked", lambda w: gtk.main_quit())
|
|
quitbutton.show()
|
|
|
|
- separator = gtk.HSeparator()
|
|
+ if GTK_VERSION >= (3, 2, 0):
|
|
+ separator = gtk.Separator(orientation=gtk.Orientation.HORIZONTAL)
|
|
+ else:
|
|
+ separator = gtk.HSeparator()
|
|
vbox2.pack_start(separator, False, False, 0)
|
|
separator.set_size_request(100, 10)
|
|
#separator.show()
|