All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-19  0:54   ` James Cameron
  2018-09-20  7:13   ` Takashi Iwai
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 2/7] hwmixvolume: replace PyGTK with gobject-introspection Emmanuel Gil Peyrot
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

This is the recommended coding style for all Python programs, as
specified in PEP-0008[1].

[1] https://www.python.org/dev/peps/pep-0008/

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index ef80bc8..038bcb3 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -26,285 +26,285 @@ EVENT_INFO = alsahcontrol.event_mask['INFO']
 EVENT_REMOVE = alsahcontrol.event_mask_remove
 
 class Stream:
-	def __init__(self, element, parent):
-		self.element = element
-		self.element.set_callback(self)
-		self.parent = parent
-		self.label = None
-		self.scales = []
-		self.adjustments = []
-		self.callback(self.element, EVENT_INFO)
-
-	def destroy(self):
-		self.deactivate()
-
-	def callback(self, e, mask):
-		if mask == EVENT_REMOVE:
-			self.deactivate()
-		elif (mask & EVENT_INFO) != 0:
-			info = alsahcontrol.Info(self.element)
-			if info.is_inactive:
-				self.deactivate()
-			else:
-				self.activate()
-		elif (mask & EVENT_VALUE) != 0:
-			self.update_scales_from_ctl()
-
-	def activate(self):
-		if self.label:
-			return
-		info = alsahcontrol.Info(self.element)
-		value = alsahcontrol.Value(self.element)
-		value.read()
-		values = value.get_tuple(TYPE_INTEGER, info.count)
-		self.label = gtk.Label(self.get_label(info))
-		self.label.set_single_line_mode(True)
-		self.parent.scales_vbox.pack_start(self.label, expand=False)
-		for i in range(info.count):
-			adj = gtk.Adjustment(value=values[i],
-					lower=info.min, upper=info.max,
-					step_incr=1,
-					page_incr=(info.max-info.min+1)/8)
-			adj.connect('value-changed', self.update_ctl_from_scale, i)
-			scale = gtk.HScale(adj)
-			scale.set_draw_value(False)
-			self.parent.scales_vbox.pack_start(scale, expand=False)
-			self.scales.append(scale)
-			self.adjustments.append(adj)
-		self.parent.scales_vbox.show_all()
-		self.parent.update_msg_label()
-
-	def deactivate(self):
-		if not self.label:
-			return
-		self.label.destroy()
-		for s in self.scales:
-			s.destroy()
-		self.label = None
-		self.scales = []
-		self.adjustments = []
-		self.parent.update_msg_label()
-
-	def update_scales_from_ctl(self):
-		if not self.label:
-			return
-		count = len(self.adjustments)
-		value = alsahcontrol.Value(self.element)
-		value.read()
-		values = value.get_tuple(TYPE_INTEGER, count)
-		for i in range(count):
-			self.adjustments[i].set_value(values[i])
-
-	def update_ctl_from_scale(self, adj, index):
-		scale_value = adj.get_value()
-		value_to_set = int(round(adj.get_value()))
-		count = len(self.adjustments)
-		value = alsahcontrol.Value(self.element)
-		if self.parent.lock_check.get_active():
-			values = [value_to_set  for i in range(count)]
-		else:
-			value.read()
-			values = value.get_array(TYPE_INTEGER, count)
-			values[index] = value_to_set
-		value.set_array(TYPE_INTEGER, values)
-		value.write()
-		if value_to_set != scale_value:
-			adj.set_value(value_to_set)
-
-	def get_label(self, info):
-		pid = self.get_pid(info)
-		if pid:
-			cmdline = self.get_pid_cmdline(pid)
-			if cmdline:
-				return cmdline
-			else:
-				return "PID %d" % pid
-		else:
-			name = info.name
-			if name[-7:] == " Volume":
-				name = name[:-7]
-			if name[-9:] == " Playback":
-				name = name[:-9]
-			return name
-
-	def get_pid(self, info):
-		card = self.parent.current_card
-		device = info.device
-		subdevice = info.subdevice
-		if subdevice == 0:
-			subdevice = info.index
-		filename = "/proc/asound/card%d/pcm%dp/sub%d/status" % (card, device, subdevice)
-		try:
-			f = open(filename, "r")
-		except IOError:
-			return None
-		try:
-			for line in f.readlines():
-				if line[:9] == "owner_pid":
-					return int(line.split(':')[1].strip())
-		finally:
-			f.close()
-		return None
-
-	def get_pid_cmdline(self, pid):
-		try:
-			f = open("/proc/%d/cmdline" % pid, "r")
-		except IOError:
-			return None
-		try:
-			cmdline = f.read()
-		finally:
-			f.close()
-		return cmdline.replace('\x00', ' ').strip()
+    def __init__(self, element, parent):
+        self.element = element
+        self.element.set_callback(self)
+        self.parent = parent
+        self.label = None
+        self.scales = []
+        self.adjustments = []
+        self.callback(self.element, EVENT_INFO)
+
+    def destroy(self):
+        self.deactivate()
+
+    def callback(self, e, mask):
+        if mask == EVENT_REMOVE:
+            self.deactivate()
+        elif (mask & EVENT_INFO) != 0:
+            info = alsahcontrol.Info(self.element)
+            if info.is_inactive:
+                self.deactivate()
+            else:
+                self.activate()
+        elif (mask & EVENT_VALUE) != 0:
+            self.update_scales_from_ctl()
+
+    def activate(self):
+        if self.label:
+            return
+        info = alsahcontrol.Info(self.element)
+        value = alsahcontrol.Value(self.element)
+        value.read()
+        values = value.get_tuple(TYPE_INTEGER, info.count)
+        self.label = gtk.Label(self.get_label(info))
+        self.label.set_single_line_mode(True)
+        self.parent.scales_vbox.pack_start(self.label, expand=False)
+        for i in range(info.count):
+            adj = gtk.Adjustment(value=values[i],
+                    lower=info.min, upper=info.max,
+                    step_incr=1,
+                    page_incr=(info.max-info.min+1)/8)
+            adj.connect('value-changed', self.update_ctl_from_scale, i)
+            scale = gtk.HScale(adj)
+            scale.set_draw_value(False)
+            self.parent.scales_vbox.pack_start(scale, expand=False)
+            self.scales.append(scale)
+            self.adjustments.append(adj)
+        self.parent.scales_vbox.show_all()
+        self.parent.update_msg_label()
+
+    def deactivate(self):
+        if not self.label:
+            return
+        self.label.destroy()
+        for s in self.scales:
+            s.destroy()
+        self.label = None
+        self.scales = []
+        self.adjustments = []
+        self.parent.update_msg_label()
+
+    def update_scales_from_ctl(self):
+        if not self.label:
+            return
+        count = len(self.adjustments)
+        value = alsahcontrol.Value(self.element)
+        value.read()
+        values = value.get_tuple(TYPE_INTEGER, count)
+        for i in range(count):
+            self.adjustments[i].set_value(values[i])
+
+    def update_ctl_from_scale(self, adj, index):
+        scale_value = adj.get_value()
+        value_to_set = int(round(adj.get_value()))
+        count = len(self.adjustments)
+        value = alsahcontrol.Value(self.element)
+        if self.parent.lock_check.get_active():
+            values = [value_to_set  for i in range(count)]
+        else:
+            value.read()
+            values = value.get_array(TYPE_INTEGER, count)
+            values[index] = value_to_set
+        value.set_array(TYPE_INTEGER, values)
+        value.write()
+        if value_to_set != scale_value:
+            adj.set_value(value_to_set)
+
+    def get_label(self, info):
+        pid = self.get_pid(info)
+        if pid:
+            cmdline = self.get_pid_cmdline(pid)
+            if cmdline:
+                return cmdline
+            else:
+                return "PID %d" % pid
+        else:
+            name = info.name
+            if name[-7:] == " Volume":
+                name = name[:-7]
+            if name[-9:] == " Playback":
+                name = name[:-9]
+            return name
+
+    def get_pid(self, info):
+        card = self.parent.current_card
+        device = info.device
+        subdevice = info.subdevice
+        if subdevice == 0:
+            subdevice = info.index
+        filename = "/proc/asound/card%d/pcm%dp/sub%d/status" % (card, device, subdevice)
+        try:
+            f = open(filename, "r")
+        except IOError:
+            return None
+        try:
+            for line in f.readlines():
+                if line[:9] == "owner_pid":
+                    return int(line.split(':')[1].strip())
+        finally:
+            f.close()
+        return None
+
+    def get_pid_cmdline(self, pid):
+        try:
+            f = open("/proc/%d/cmdline" % pid, "r")
+        except IOError:
+            return None
+        try:
+            cmdline = f.read()
+        finally:
+            f.close()
+        return cmdline.replace('\x00', ' ').strip()
 
 class MixerWindow(gtk.Window):
-	card_numbers = alsacard.card_list()
-	current_card = -1
-	hcontrol = None
-	scales_vbox = None
-	msg_label = None
-	streams = []
-	hctl_sources = []
-
-	def __init__(self):
-		gtk.Window.__init__(self)
-		self.connect('destroy', lambda w: gtk.main_quit())
-		self.set_title("Hardware Mixer Volumes")
-
-		vbox = gtk.VBox()
-		self.add(vbox)
-
-		hbox = gtk.HBox()
-		vbox.pack_start(hbox, expand=False)
-
-		label = gtk.Label("_Sound Card: ")
-		label.set_use_underline(True)
-		hbox.pack_start(label, expand=False)
-
-		combo = gtk.combo_box_new_text()
-		for i in self.card_numbers:
-			str = "%d: %s" % (i, alsacard.card_get_name(i))
-			combo.append_text(str)
-		if len(self.card_numbers) > 0:
-			combo.set_active(0)
-		combo.connect('changed', lambda c: self.change_card(self.card_numbers[combo.get_active()]))
-		hbox.pack_start(combo)
-		label.set_mnemonic_widget(combo)
-
-		self.lock_check = gtk.CheckButton(label="_Lock Channels")
-		self.lock_check.set_active(True)
-		vbox.pack_start(self.lock_check, expand=False)
-
-		scrollwin = gtk.ScrolledWindow()
-		scrollwin.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC)
-		scrollwin.set_shadow_type(gtk.SHADOW_NONE)
-		vbox.pack_start(scrollwin)
-
-		self.scales_vbox = gtk.VBox()
-		scrollwin.add_with_viewport(self.scales_vbox)
-
-		label = gtk.Label()
-		label.set_single_line_mode(True)
-		line_height = label.size_request()[1]
-		label.destroy()
-		scale = gtk.HScale()
-		scale.set_draw_value(False)
-		line_height += scale.size_request()[1]
-		scale.destroy()
-		# always have space for at least four sliders
-		scrollwin.set_size_request(width=-1, height=line_height*4+4)
-
-		# TODO: select the default card or the first card with stream controls
-		if len(self.card_numbers) > 0:
-			self.change_card(self.card_numbers[0])
-		self.update_msg_label()
-
-		self.show_all()
-
-	def change_card(self, cardnum):
-		for s in self.hctl_sources:
-			gobject.source_remove(s)
-		self.hctl_sources = []
-
-		self.hcontrol = self.open_hcontrol_for_card(cardnum)
-
-		for s in self.streams:
-			s.destroy()
-		self.streams = []
-
-		self.current_card = cardnum
-
-		if not self.hcontrol:
-			self.update_msg_label()
-			return
-
-		for id in self.hcontrol.list():
-			if not self.is_stream_elem(id):
-				continue
-			elem = alsahcontrol.Element(self.hcontrol, id[0])
-			info = alsahcontrol.Info(elem)
-			if not self.is_stream_info(info):
-				continue
-			stream = Stream(elem, self)
-			self.streams.append(stream)
-
-		for fd,condition in self.hcontrol.poll_fds:
-			self.hctl_sources.append(gobject.io_add_watch(fd, condition, self.hctl_io_callback))
-
-		self.update_msg_label()
-
-		self.scales_vbox.show_all()
-
-	def update_msg_label(self):
-		needs_msg = len(self.scales_vbox.get_children()) < 2
-		has_msg = self.msg_label
-		if has_msg and not needs_msg:
-			self.msg_label.destroy()
-			self.msg_label = None
-		elif needs_msg:
-			if len(self.streams) > 0:
-				msg = "There are no open streams."
-			else:
-				msg = "This card does not have stream controls."
-			if not has_msg:
-				self.msg_label = gtk.Label(msg)
-				self.scales_vbox.pack_start(self.msg_label)
-				self.scales_vbox.show_all()
-			elif self.msg_label.get_text() != msg:
-				self.msg_label.set_text(msg)
-
-	def open_hcontrol_for_card(self, cardnum):
-		devname = "hw:CARD=" + str(cardnum)
-		try:
-			hc = alsahcontrol.HControl(name=devname,
-					mode=alsahcontrol.open_mode['NONBLOCK'])
-		except:
-			# TODO: alsa error msg
-			dlg = gtk.MessageDialog(self,
-					gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-					gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
-					"Cannot open sound card control device.")
-			dlg.run()
-			dlg.destroy()
-			return None
-		return hc
-
-	def is_stream_elem(self, id):
-		return ((id[1] == INTF_PCM and
-			 id[4] in ("PCM Playback Volume", "EMU10K1 PCM Volume")) or
-			(id[1] == INTF_MIXER and
-			 id[4] == "VIA DXS Playback Volume"))
-
-	def is_stream_info(self, info):
-		return info.is_readable and info.is_writable and info.type == TYPE_INTEGER
-
-	def hctl_io_callback(self, source, condition):
-		self.hcontrol.handle_events()
-		return True
+    card_numbers = alsacard.card_list()
+    current_card = -1
+    hcontrol = None
+    scales_vbox = None
+    msg_label = None
+    streams = []
+    hctl_sources = []
+
+    def __init__(self):
+        gtk.Window.__init__(self)
+        self.connect('destroy', lambda w: gtk.main_quit())
+        self.set_title("Hardware Mixer Volumes")
+
+        vbox = gtk.VBox()
+        self.add(vbox)
+
+        hbox = gtk.HBox()
+        vbox.pack_start(hbox, expand=False)
+
+        label = gtk.Label("_Sound Card: ")
+        label.set_use_underline(True)
+        hbox.pack_start(label, expand=False)
+
+        combo = gtk.combo_box_new_text()
+        for i in self.card_numbers:
+            str = "%d: %s" % (i, alsacard.card_get_name(i))
+            combo.append_text(str)
+        if len(self.card_numbers) > 0:
+            combo.set_active(0)
+        combo.connect('changed', lambda c: self.change_card(self.card_numbers[combo.get_active()]))
+        hbox.pack_start(combo)
+        label.set_mnemonic_widget(combo)
+
+        self.lock_check = gtk.CheckButton(label="_Lock Channels")
+        self.lock_check.set_active(True)
+        vbox.pack_start(self.lock_check, expand=False)
+
+        scrollwin = gtk.ScrolledWindow()
+        scrollwin.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC)
+        scrollwin.set_shadow_type(gtk.SHADOW_NONE)
+        vbox.pack_start(scrollwin)
+
+        self.scales_vbox = gtk.VBox()
+        scrollwin.add_with_viewport(self.scales_vbox)
+
+        label = gtk.Label()
+        label.set_single_line_mode(True)
+        line_height = label.size_request()[1]
+        label.destroy()
+        scale = gtk.HScale()
+        scale.set_draw_value(False)
+        line_height += scale.size_request()[1]
+        scale.destroy()
+        # always have space for at least four sliders
+        scrollwin.set_size_request(width=-1, height=line_height*4+4)
+
+        # TODO: select the default card or the first card with stream controls
+        if len(self.card_numbers) > 0:
+            self.change_card(self.card_numbers[0])
+        self.update_msg_label()
+
+        self.show_all()
+
+    def change_card(self, cardnum):
+        for s in self.hctl_sources:
+            gobject.source_remove(s)
+        self.hctl_sources = []
+
+        self.hcontrol = self.open_hcontrol_for_card(cardnum)
+
+        for s in self.streams:
+            s.destroy()
+        self.streams = []
+
+        self.current_card = cardnum
+
+        if not self.hcontrol:
+            self.update_msg_label()
+            return
+
+        for id in self.hcontrol.list():
+            if not self.is_stream_elem(id):
+                continue
+            elem = alsahcontrol.Element(self.hcontrol, id[0])
+            info = alsahcontrol.Info(elem)
+            if not self.is_stream_info(info):
+                continue
+            stream = Stream(elem, self)
+            self.streams.append(stream)
+
+        for fd,condition in self.hcontrol.poll_fds:
+            self.hctl_sources.append(gobject.io_add_watch(fd, condition, self.hctl_io_callback))
+
+        self.update_msg_label()
+
+        self.scales_vbox.show_all()
+
+    def update_msg_label(self):
+        needs_msg = len(self.scales_vbox.get_children()) < 2
+        has_msg = self.msg_label
+        if has_msg and not needs_msg:
+            self.msg_label.destroy()
+            self.msg_label = None
+        elif needs_msg:
+            if len(self.streams) > 0:
+                msg = "There are no open streams."
+            else:
+                msg = "This card does not have stream controls."
+            if not has_msg:
+                self.msg_label = gtk.Label(msg)
+                self.scales_vbox.pack_start(self.msg_label)
+                self.scales_vbox.show_all()
+            elif self.msg_label.get_text() != msg:
+                self.msg_label.set_text(msg)
+
+    def open_hcontrol_for_card(self, cardnum):
+        devname = "hw:CARD=" + str(cardnum)
+        try:
+            hc = alsahcontrol.HControl(name=devname,
+                    mode=alsahcontrol.open_mode['NONBLOCK'])
+        except:
+            # TODO: alsa error msg
+            dlg = gtk.MessageDialog(self,
+                    gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                    gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
+                    "Cannot open sound card control device.")
+            dlg.run()
+            dlg.destroy()
+            return None
+        return hc
+
+    def is_stream_elem(self, id):
+        return ((id[1] == INTF_PCM and
+             id[4] in ("PCM Playback Volume", "EMU10K1 PCM Volume")) or
+            (id[1] == INTF_MIXER and
+             id[4] == "VIA DXS Playback Volume"))
+
+    def is_stream_info(self, info):
+        return info.is_readable and info.is_writable and info.type == TYPE_INTEGER
+
+    def hctl_io_callback(self, source, condition):
+        self.hcontrol.handle_events()
+        return True
 
 def main():
-	MixerWindow()
-	gtk.main()
+    MixerWindow()
+    gtk.main()
 
 main()
 
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 2/7] hwmixvolume: replace PyGTK with gobject-introspection
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0 Emmanuel Gil Peyrot
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

This doesn’t work yet, we require Gtk 3.0 rather than 2.0 and the API
changed quite a lot, so this is but a preparatory patch.

This is done so that we can get rid of GTK+ 2 which has been EOL for
many years already, and to add Python 3 support because Python 2 will
very soon be EOL as well.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index 038bcb3..64d232c 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -15,7 +15,10 @@
 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-import gobject, gtk
+import gi
+gi.require_version('GLib', '2.0')
+gi.require_version('Gtk', '3.0')
+from gi.repository import GLib, Gtk
 from pyalsa import alsacard, alsahcontrol
 
 INTF_PCM = alsahcontrol.interface_id['PCM']
@@ -57,16 +60,16 @@ class Stream:
         value = alsahcontrol.Value(self.element)
         value.read()
         values = value.get_tuple(TYPE_INTEGER, info.count)
-        self.label = gtk.Label(self.get_label(info))
+        self.label = Gtk.Label(self.get_label(info))
         self.label.set_single_line_mode(True)
         self.parent.scales_vbox.pack_start(self.label, expand=False)
         for i in range(info.count):
-            adj = gtk.Adjustment(value=values[i],
+            adj = Gtk.Adjustment(value=values[i],
                     lower=info.min, upper=info.max,
                     step_incr=1,
                     page_incr=(info.max-info.min+1)/8)
             adj.connect('value-changed', self.update_ctl_from_scale, i)
-            scale = gtk.HScale(adj)
+            scale = Gtk.HScale(adj)
             scale.set_draw_value(False)
             self.parent.scales_vbox.pack_start(scale, expand=False)
             self.scales.append(scale)
@@ -157,7 +160,7 @@ class Stream:
             f.close()
         return cmdline.replace('\x00', ' ').strip()
 
-class MixerWindow(gtk.Window):
+class MixerWindow(Gtk.Window):
     card_numbers = alsacard.card_list()
     current_card = -1
     hcontrol = None
@@ -167,21 +170,21 @@ class MixerWindow(gtk.Window):
     hctl_sources = []
 
     def __init__(self):
-        gtk.Window.__init__(self)
-        self.connect('destroy', lambda w: gtk.main_quit())
+        Gtk.Window.__init__(self)
+        self.connect('destroy', lambda w: Gtk.main_quit())
         self.set_title("Hardware Mixer Volumes")
 
-        vbox = gtk.VBox()
+        vbox = Gtk.VBox()
         self.add(vbox)
 
-        hbox = gtk.HBox()
+        hbox = Gtk.HBox()
         vbox.pack_start(hbox, expand=False)
 
-        label = gtk.Label("_Sound Card: ")
+        label = Gtk.Label("_Sound Card: ")
         label.set_use_underline(True)
         hbox.pack_start(label, expand=False)
 
-        combo = gtk.combo_box_new_text()
+        combo = Gtk.combo_box_new_text()
         for i in self.card_numbers:
             str = "%d: %s" % (i, alsacard.card_get_name(i))
             combo.append_text(str)
@@ -191,23 +194,23 @@ class MixerWindow(gtk.Window):
         hbox.pack_start(combo)
         label.set_mnemonic_widget(combo)
 
-        self.lock_check = gtk.CheckButton(label="_Lock Channels")
+        self.lock_check = Gtk.CheckButton(label="_Lock Channels")
         self.lock_check.set_active(True)
         vbox.pack_start(self.lock_check, expand=False)
 
-        scrollwin = gtk.ScrolledWindow()
-        scrollwin.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC)
-        scrollwin.set_shadow_type(gtk.SHADOW_NONE)
+        scrollwin = Gtk.ScrolledWindow()
+        scrollwin.set_policy(hscrollbar_policy=Gtk.POLICY_NEVER, vscrollbar_policy=Gtk.POLICY_AUTOMATIC)
+        scrollwin.set_shadow_type(Gtk.SHADOW_NONE)
         vbox.pack_start(scrollwin)
 
-        self.scales_vbox = gtk.VBox()
+        self.scales_vbox = Gtk.VBox()
         scrollwin.add_with_viewport(self.scales_vbox)
 
-        label = gtk.Label()
+        label = Gtk.Label()
         label.set_single_line_mode(True)
         line_height = label.size_request()[1]
         label.destroy()
-        scale = gtk.HScale()
+        scale = Gtk.HScale()
         scale.set_draw_value(False)
         line_height += scale.size_request()[1]
         scale.destroy()
@@ -223,7 +226,7 @@ class MixerWindow(gtk.Window):
 
     def change_card(self, cardnum):
         for s in self.hctl_sources:
-            gobject.source_remove(s)
+            GLib.source_remove(s)
         self.hctl_sources = []
 
         self.hcontrol = self.open_hcontrol_for_card(cardnum)
@@ -249,7 +252,7 @@ class MixerWindow(gtk.Window):
             self.streams.append(stream)
 
         for fd,condition in self.hcontrol.poll_fds:
-            self.hctl_sources.append(gobject.io_add_watch(fd, condition, self.hctl_io_callback))
+            self.hctl_sources.append(GLib.io_add_watch(fd, condition, self.hctl_io_callback))
 
         self.update_msg_label()
 
@@ -267,7 +270,7 @@ class MixerWindow(gtk.Window):
             else:
                 msg = "This card does not have stream controls."
             if not has_msg:
-                self.msg_label = gtk.Label(msg)
+                self.msg_label = Gtk.Label(msg)
                 self.scales_vbox.pack_start(self.msg_label)
                 self.scales_vbox.show_all()
             elif self.msg_label.get_text() != msg:
@@ -280,9 +283,9 @@ class MixerWindow(gtk.Window):
                     mode=alsahcontrol.open_mode['NONBLOCK'])
         except:
             # TODO: alsa error msg
-            dlg = gtk.MessageDialog(self,
-                    gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                    gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
+            dlg = Gtk.MessageDialog(self,
+                    Gtk.DIALOG_MODAL | Gtk.DIALOG_DESTROY_WITH_PARENT,
+                    Gtk.MESSAGE_ERROR, Gtk.BUTTONS_OK,
                     "Cannot open sound card control device.")
             dlg.run()
             dlg.destroy()
@@ -304,7 +307,7 @@ class MixerWindow(gtk.Window):
 
 def main():
     MixerWindow()
-    gtk.main()
+    Gtk.main()
 
 main()
 
-- 
2.19.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent Emmanuel Gil Peyrot
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 2/7] hwmixvolume: replace PyGTK with gobject-introspection Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-19 13:22   ` Takashi Sakamoto
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 4/7] hwmixvolume: use a with context to open files Emmanuel Gil Peyrot
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

This replaces VBox and HBox with Grid (using Gtk.Orientation), HScale
with Scale, creates labels with mnemonics, set hexpand and vexpand
properly, use the correct enum container classes, use the correct getter
for size request, and finally update to the correct GLib watch function.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index 64d232c..8e0b6b8 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -60,18 +60,18 @@ class Stream:
         value = alsahcontrol.Value(self.element)
         value.read()
         values = value.get_tuple(TYPE_INTEGER, info.count)
-        self.label = Gtk.Label(self.get_label(info))
+        self.label = Gtk.Label.new(self.get_label(info))
         self.label.set_single_line_mode(True)
-        self.parent.scales_vbox.pack_start(self.label, expand=False)
+        self.parent.scales_vbox.add(self.label)
         for i in range(info.count):
             adj = Gtk.Adjustment(value=values[i],
                     lower=info.min, upper=info.max,
                     step_incr=1,
                     page_incr=(info.max-info.min+1)/8)
             adj.connect('value-changed', self.update_ctl_from_scale, i)
-            scale = Gtk.HScale(adj)
+            scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
             scale.set_draw_value(False)
-            self.parent.scales_vbox.pack_start(scale, expand=False)
+            self.parent.scales_vbox.add(scale)
             self.scales.append(scale)
             self.adjustments.append(adj)
         self.parent.scales_vbox.show_all()
@@ -174,45 +174,48 @@ class MixerWindow(Gtk.Window):
         self.connect('destroy', lambda w: Gtk.main_quit())
         self.set_title("Hardware Mixer Volumes")
 
-        vbox = Gtk.VBox()
+        vbox = Gtk.Grid()
+        vbox.set_orientation(Gtk.Orientation.VERTICAL)
         self.add(vbox)
 
-        hbox = Gtk.HBox()
-        vbox.pack_start(hbox, expand=False)
+        hbox = Gtk.Grid()
+        vbox.add(hbox)
 
-        label = Gtk.Label("_Sound Card: ")
-        label.set_use_underline(True)
-        hbox.pack_start(label, expand=False)
+        label = Gtk.Label.new_with_mnemonic("_Sound Card: ")
+        hbox.add(label)
 
-        combo = Gtk.combo_box_new_text()
+        combo = Gtk.ComboBoxText()
+        combo.set_hexpand(True)
         for i in self.card_numbers:
             str = "%d: %s" % (i, alsacard.card_get_name(i))
             combo.append_text(str)
         if len(self.card_numbers) > 0:
             combo.set_active(0)
         combo.connect('changed', lambda c: self.change_card(self.card_numbers[combo.get_active()]))
-        hbox.pack_start(combo)
+        hbox.add(combo)
         label.set_mnemonic_widget(combo)
 
-        self.lock_check = Gtk.CheckButton(label="_Lock Channels")
+        self.lock_check = Gtk.CheckButton.new_with_mnemonic(label="_Lock Channels")
         self.lock_check.set_active(True)
-        vbox.pack_start(self.lock_check, expand=False)
+        vbox.add(self.lock_check)
 
         scrollwin = Gtk.ScrolledWindow()
-        scrollwin.set_policy(hscrollbar_policy=Gtk.POLICY_NEVER, vscrollbar_policy=Gtk.POLICY_AUTOMATIC)
-        scrollwin.set_shadow_type(Gtk.SHADOW_NONE)
-        vbox.pack_start(scrollwin)
+        scrollwin.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
+        scrollwin.set_shadow_type(Gtk.ShadowType.NONE)
+        scrollwin.set_vexpand(True)
+        vbox.add(scrollwin)
 
-        self.scales_vbox = Gtk.VBox()
-        scrollwin.add_with_viewport(self.scales_vbox)
+        self.scales_vbox = Gtk.Grid()
+        self.scales_vbox.set_orientation(Gtk.Orientation.VERTICAL)
+        scrollwin.add(self.scales_vbox)
 
         label = Gtk.Label()
         label.set_single_line_mode(True)
-        line_height = label.size_request()[1]
+        line_height = max(label.get_size_request().height, 0)
         label.destroy()
-        scale = Gtk.HScale()
+        scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL)
         scale.set_draw_value(False)
-        line_height += scale.size_request()[1]
+        line_height += max(scale.get_size_request().height, 0)
         scale.destroy()
         # always have space for at least four sliders
         scrollwin.set_size_request(width=-1, height=line_height*4+4)
@@ -252,7 +255,7 @@ class MixerWindow(Gtk.Window):
             self.streams.append(stream)
 
         for fd,condition in self.hcontrol.poll_fds:
-            self.hctl_sources.append(GLib.io_add_watch(fd, condition, self.hctl_io_callback))
+            self.hctl_sources.append(GLib.io_add_watch(fd, 0, GLib.IOCondition(condition), self.hctl_io_callback))
 
         self.update_msg_label()
 
@@ -270,8 +273,9 @@ class MixerWindow(Gtk.Window):
             else:
                 msg = "This card does not have stream controls."
             if not has_msg:
-                self.msg_label = Gtk.Label(msg)
-                self.scales_vbox.pack_start(self.msg_label)
+                self.msg_label = Gtk.Label.new(msg)
+                self.msg_label.set_vexpand(True)
+                self.scales_vbox.add(self.msg_label)
                 self.scales_vbox.show_all()
             elif self.msg_label.get_text() != msg:
                 self.msg_label.set_text(msg)
@@ -284,8 +288,8 @@ class MixerWindow(Gtk.Window):
         except:
             # TODO: alsa error msg
             dlg = Gtk.MessageDialog(self,
-                    Gtk.DIALOG_MODAL | Gtk.DIALOG_DESTROY_WITH_PARENT,
-                    Gtk.MESSAGE_ERROR, Gtk.BUTTONS_OK,
+                    Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                    Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                     "Cannot open sound card control device.")
             dlg.run()
             dlg.destroy()
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 4/7] hwmixvolume: use a with context to open files
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
                   ` (2 preceding siblings ...)
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0 Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 5/7] hwmixvolume: switch the shebang to python Emmanuel Gil Peyrot
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

This feature has been added in Python 2.5 and automatically closes an
open file once the context exits.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index 8e0b6b8..7f8ba8e 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -138,26 +138,20 @@ class Stream:
             subdevice = info.index
         filename = "/proc/asound/card%d/pcm%dp/sub%d/status" % (card, device, subdevice)
         try:
-            f = open(filename, "r")
+            with open(filename, "r") as f:
+                for line in f:
+                    if line[:9] == "owner_pid":
+                        return int(line.split(':')[1].strip())
         except IOError:
             return None
-        try:
-            for line in f.readlines():
-                if line[:9] == "owner_pid":
-                    return int(line.split(':')[1].strip())
-        finally:
-            f.close()
         return None
 
     def get_pid_cmdline(self, pid):
         try:
-            f = open("/proc/%d/cmdline" % pid, "r")
+            with open("/proc/%d/cmdline" % pid, "r") as f:
+                cmdline = f.read()
         except IOError:
             return None
-        try:
-            cmdline = f.read()
-        finally:
-            f.close()
         return cmdline.replace('\x00', ' ').strip()
 
 class MixerWindow(Gtk.Window):
-- 
2.19.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 5/7] hwmixvolume: switch the shebang to python
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
                   ` (3 preceding siblings ...)
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 4/7] hwmixvolume: use a with context to open files Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 6/7] hwmixvolume: add my copyright Emmanuel Gil Peyrot
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

This signifies that this code is now compatible with both Python 2 and
Python 3, as per PEP-0394[1].

[1] https://www.python.org/dev/peps/pep-0394/

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index 7f8ba8e..4804a9b 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/env python
 
 # hwmixvolume - ALSA hardware mixer volume control applet
 # Copyright (c) 2009-2010 Clemens Ladisch
-- 
2.19.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 6/7] hwmixvolume: add my copyright
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
                   ` (4 preceding siblings ...)
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 5/7] hwmixvolume: switch the shebang to python Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 7/7] hwmixvolume: mention the new dependencies in the README Emmanuel Gil Peyrot
  2018-09-19 14:15 ` [PATCH - hwmixvolume v2 0/7] Migrate to GTK+ 3.0 and allow python3 Takashi Sakamoto
  7 siblings, 0 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
index 4804a9b..871c2c5 100755
--- a/hwmixvolume/hwmixvolume
+++ b/hwmixvolume/hwmixvolume
@@ -2,6 +2,7 @@
 
 # hwmixvolume - ALSA hardware mixer volume control applet
 # Copyright (c) 2009-2010 Clemens Ladisch
+# Copyright (c) 2018 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
 #
 # Permission to use, copy, modify, and/or distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH - hwmixvolume v2 7/7] hwmixvolume: mention the new dependencies in the README
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
                   ` (5 preceding siblings ...)
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 6/7] hwmixvolume: add my copyright Emmanuel Gil Peyrot
@ 2018-09-18 13:42 ` Emmanuel Gil Peyrot
  2018-09-19 14:15 ` [PATCH - hwmixvolume v2 0/7] Migrate to GTK+ 3.0 and allow python3 Takashi Sakamoto
  7 siblings, 0 replies; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-18 13:42 UTC (permalink / raw)
  To: patch; +Cc: linkmauve, alsa-devel

From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

diff --git a/hwmixvolume/README b/hwmixvolume/README
index 9884ec2..56c7554 100644
--- a/hwmixvolume/README
+++ b/hwmixvolume/README
@@ -8,7 +8,8 @@ that use hardware mixing, i.e., those based on the following chips:
 * Yamaha DS-1 (YMF-724/740/744/754) (driver: snd-ymfpci)
 
 
-This tool requires Python, pygtk, and alsa-pyton 1.0.22 or later.
+This tool requires Python, PyGObject, GTK+ 3.0 or later, and alsa-python 1.0.22
+or later.
 
 It is recommended to use at least Linux kernel 2.6.32 or alsa-driver 1.0.22;
 otherwise, the name of the program that is using a stream cannot be shown.
-- 
2.19.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent Emmanuel Gil Peyrot
@ 2018-09-19  0:54   ` James Cameron
  2018-09-20  7:13     ` Takashi Iwai
  2018-09-20  7:13   ` Takashi Iwai
  1 sibling, 1 reply; 16+ messages in thread
From: James Cameron @ 2018-09-19  0:54 UTC (permalink / raw)
  To: Emmanuel Gil Peyrot; +Cc: linkmauve, alsa-devel, patch

For the series;

Reviewed-by: James Cameron <quozl@laptop.org>

-- 
James Cameron
http://quozl.netrek.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0 Emmanuel Gil Peyrot
@ 2018-09-19 13:22   ` Takashi Sakamoto
  2018-09-19 13:36     ` Emmanuel Gil Peyrot
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Sakamoto @ 2018-09-19 13:22 UTC (permalink / raw)
  To: Emmanuel Gil Peyrot, patch; +Cc: linkmauve, alsa-devel

Hi,

On Sep 18 2018 22:42, Emmanuel Gil Peyrot wrote:
> From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> 
> This replaces VBox and HBox with Grid (using Gtk.Orientation), HScale
> with Scale, creates labels with mnemonics, set hexpand and vexpand
> properly, use the correct enum container classes, use the correct getter
> for size request, and finally update to the correct GLib watch function.
> 
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> 
> diff --git a/hwmixvolume/hwmixvolume b/hwmixvolume/hwmixvolume
> index 64d232c..8e0b6b8 100755
> --- a/hwmixvolume/hwmixvolume
> +++ b/hwmixvolume/hwmixvolume
> @@ -60,18 +60,18 @@ class Stream:
>           value = alsahcontrol.Value(self.element)
>           value.read()
>           values = value.get_tuple(TYPE_INTEGER, info.count)
> -        self.label = Gtk.Label(self.get_label(info))
> +        self.label = Gtk.Label.new(self.get_label(info))
>           self.label.set_single_line_mode(True)
> -        self.parent.scales_vbox.pack_start(self.label, expand=False)
> +        self.parent.scales_vbox.add(self.label)
>           for i in range(info.count):
>               adj = Gtk.Adjustment(value=values[i],
>                       lower=info.min, upper=info.max,
>                       step_incr=1,
>                       page_incr=(info.max-info.min+1)/8)
>               adj.connect('value-changed', self.update_ctl_from_scale, i)
> -            scale = Gtk.HScale(adj)
> +            scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
>               scale.set_draw_value(False)
> -            self.parent.scales_vbox.pack_start(scale, expand=False)
> +            self.parent.scales_vbox.add(scale)
>               self.scales.append(scale)
>               self.adjustments.append(adj)
>           self.parent.scales_vbox.show_all()
> @@ -174,45 +174,48 @@ class MixerWindow(Gtk.Window):
>           self.connect('destroy', lambda w: Gtk.main_quit())
>           self.set_title("Hardware Mixer Volumes")
>   
> -        vbox = Gtk.VBox()
> +        vbox = Gtk.Grid()
> +        vbox.set_orientation(Gtk.Orientation.VERTICAL)

As long as I know, g-i of Gtk+3 has both of 'Gtk.VBox' and 'Gtk.HBox'.
I don't object to this patchset if they satisfy your demand, however
from my curiosity would I ask you the reason to use 'Gtk.Grid' instead
of them? This patch includes no lines to add rows/colums and to me no
requirement to use grid in this point.

>           self.add(vbox)
>   
> -        hbox = Gtk.HBox()
> -        vbox.pack_start(hbox, expand=False)
> +        hbox = Gtk.Grid()
> +        vbox.add(hbox)
>   
> -        label = Gtk.Label("_Sound Card: ")
> -        label.set_use_underline(True)
> -        hbox.pack_start(label, expand=False)
> +        label = Gtk.Label.new_with_mnemonic("_Sound Card: ")
> +        hbox.add(label)
>   
> -        combo = Gtk.combo_box_new_text()
> +        combo = Gtk.ComboBoxText()
> +        combo.set_hexpand(True)
>           for i in self.card_numbers:
>               str = "%d: %s" % (i, alsacard.card_get_name(i))
>               combo.append_text(str)
>           if len(self.card_numbers) > 0:
>               combo.set_active(0)
>           combo.connect('changed', lambda c: self.change_card(self.card_numbers[combo.get_active()]))
> -        hbox.pack_start(combo)
> +        hbox.add(combo)
>           label.set_mnemonic_widget(combo)
>   
> -        self.lock_check = Gtk.CheckButton(label="_Lock Channels")
> +        self.lock_check = Gtk.CheckButton.new_with_mnemonic(label="_Lock Channels")
>           self.lock_check.set_active(True)
> -        vbox.pack_start(self.lock_check, expand=False)
> +        vbox.add(self.lock_check)
>   
>           scrollwin = Gtk.ScrolledWindow()
> -        scrollwin.set_policy(hscrollbar_policy=Gtk.POLICY_NEVER, vscrollbar_policy=Gtk.POLICY_AUTOMATIC)
> -        scrollwin.set_shadow_type(Gtk.SHADOW_NONE)
> -        vbox.pack_start(scrollwin)
> +        scrollwin.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)
> +        scrollwin.set_shadow_type(Gtk.ShadowType.NONE)
> +        scrollwin.set_vexpand(True)
> +        vbox.add(scrollwin)
>   
> -        self.scales_vbox = Gtk.VBox()
> -        scrollwin.add_with_viewport(self.scales_vbox)
> +        self.scales_vbox = Gtk.Grid()
> +        self.scales_vbox.set_orientation(Gtk.Orientation.VERTICAL)
> +        scrollwin.add(self.scales_vbox)
>   
>           label = Gtk.Label()
>           label.set_single_line_mode(True)
> -        line_height = label.size_request()[1]
> +        line_height = max(label.get_size_request().height, 0)
>           label.destroy()
> -        scale = Gtk.HScale()
> +        scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL)
>           scale.set_draw_value(False)
> -        line_height += scale.size_request()[1]
> +        line_height += max(scale.get_size_request().height, 0)
>           scale.destroy()
>           # always have space for at least four sliders
>           scrollwin.set_size_request(width=-1, height=line_height*4+4)
> @@ -252,7 +255,7 @@ class MixerWindow(Gtk.Window):
>               self.streams.append(stream)
>   
>           for fd,condition in self.hcontrol.poll_fds:
> -            self.hctl_sources.append(GLib.io_add_watch(fd, condition, self.hctl_io_callback))
> +            self.hctl_sources.append(GLib.io_add_watch(fd, 0, GLib.IOCondition(condition), self.hctl_io_callback))
>   
>           self.update_msg_label()
>   
> @@ -270,8 +273,9 @@ class MixerWindow(Gtk.Window):
>               else:
>                   msg = "This card does not have stream controls."
>               if not has_msg:
> -                self.msg_label = Gtk.Label(msg)
> -                self.scales_vbox.pack_start(self.msg_label)
> +                self.msg_label = Gtk.Label.new(msg)
> +                self.msg_label.set_vexpand(True)
> +                self.scales_vbox.add(self.msg_label)
>                   self.scales_vbox.show_all()
>               elif self.msg_label.get_text() != msg:
>                   self.msg_label.set_text(msg)
> @@ -284,8 +288,8 @@ class MixerWindow(Gtk.Window):
>           except:
>               # TODO: alsa error msg
>               dlg = Gtk.MessageDialog(self,
> -                    Gtk.DIALOG_MODAL | Gtk.DIALOG_DESTROY_WITH_PARENT,
> -                    Gtk.MESSAGE_ERROR, Gtk.BUTTONS_OK,
> +                    Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
> +                    Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
>                       "Cannot open sound card control device.")
>               dlg.run()
>               dlg.destroy()

Thanks

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0
  2018-09-19 13:22   ` Takashi Sakamoto
@ 2018-09-19 13:36     ` Emmanuel Gil Peyrot
  2018-09-19 14:14       ` Takashi Sakamoto
  0 siblings, 1 reply; 16+ messages in thread
From: Emmanuel Gil Peyrot @ 2018-09-19 13:36 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: linkmauve, alsa-devel, patch

On Wed, Sep 19, 2018 at 10:22:48PM +0900, Takashi Sakamoto wrote:
> Hi,

Hi,

> 
> On Sep 18 2018 22:42, Emmanuel Gil Peyrot wrote:
> > From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
[…]
> > @@ -174,45 +174,48 @@ class MixerWindow(Gtk.Window):
> >           self.connect('destroy', lambda w: Gtk.main_quit())
> >           self.set_title("Hardware Mixer Volumes")
> > -        vbox = Gtk.VBox()
> > +        vbox = Gtk.Grid()
> > +        vbox.set_orientation(Gtk.Orientation.VERTICAL)
> 
> As long as I know, g-i of Gtk+3 has both of 'Gtk.VBox' and 'Gtk.HBox'.
> I don't object to this patchset if they satisfy your demand, however
> from my curiosity would I ask you the reason to use 'Gtk.Grid' instead
> of them? This patch includes no lines to add rows/colums and to me no
> requirement to use grid in this point.

The Gtk.VBox documentation[1] says:

“Deprecated since version 3.2: You can use Gtk.Box.new() with
Gtk.Orientation.VERTICAL instead, which is a quick and easy change. But
the recommendation is to switch to Gtk.Grid, since Gtk.Box is going to
go away eventually. See Migrating from other containers to GtkGrid.”

Since no backwards incompatible change can be made in GTK+ 3.x, it is
still present as of 3.24, but it has been removed in 4.0 and it’d be
nice to support this one already when it’ll be released. :)

> Thanks
> 
> Takashi Sakamoto

Thanks,

[1] https://lazka.github.io/pgi-docs/Gtk-3.0/classes/VBox.html

-- 
Emmanuel Gil Peyrot
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0
  2018-09-19 13:36     ` Emmanuel Gil Peyrot
@ 2018-09-19 14:14       ` Takashi Sakamoto
  0 siblings, 0 replies; 16+ messages in thread
From: Takashi Sakamoto @ 2018-09-19 14:14 UTC (permalink / raw)
  To: Emmanuel Gil Peyrot; +Cc: linkmauve, alsa-devel, patch

On Sep 19 2018 22:36, Emmanuel Gil Peyrot wrote:
> On Wed, Sep 19, 2018 at 10:22:48PM +0900, Takashi Sakamoto wrote:
>> On Sep 18 2018 22:42, Emmanuel Gil Peyrot wrote:
>>> From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> […]
>>> @@ -174,45 +174,48 @@ class MixerWindow(Gtk.Window):
>>>            self.connect('destroy', lambda w: Gtk.main_quit())
>>>            self.set_title("Hardware Mixer Volumes")
>>> -        vbox = Gtk.VBox()
>>> +        vbox = Gtk.Grid()
>>> +        vbox.set_orientation(Gtk.Orientation.VERTICAL)
>>
>> As long as I know, g-i of Gtk+3 has both of 'Gtk.VBox' and 'Gtk.HBox'.
>> I don't object to this patchset if they satisfy your demand, however
>> from my curiosity would I ask you the reason to use 'Gtk.Grid' instead
>> of them? This patch includes no lines to add rows/colums and to me no
>> requirement to use grid in this point.
> 
> The Gtk.VBox documentation[1] says:
> 
> “Deprecated since version 3.2: You can use Gtk.Box.new() with
> Gtk.Orientation.VERTICAL instead, which is a quick and easy change. But
> the recommendation is to switch to Gtk.Grid, since Gtk.Box is going to
> go away eventually. See Migrating from other containers to GtkGrid.”
> 
> Since no backwards incompatible change can be made in GTK+ 3.x, it is
> still present as of 3.24, but it has been removed in 4.0 and it’d be
> nice to support this one already when it’ll be released. :)

Thanks for your explanation. Indeed, gtk+ community obsoleted
gtk_vbox[1] and gtk_hbox[2] in their v3.89.1 release.

(g-i is a specification for metadata format for API of library.
PyGobject is a Python binding to handle the metadata and library. The
status of public API is decided by the library itself.)

Furthermore, gtk+ community published an instruction to use gtk_grid
instead of gtk_box[3].

Totally, your changes are good enough.

[1] Delete gtkvbox.{c,h} (fe24fcbc) · Commits · GNOME / gtk · GitLab
https://gitlab.gnome.org/GNOME/gtk/commit/fe24fcbc3e71bcf7e222a4106bf6e3f7ec114e28
[2] Remove GtkHBox (fb3d9022) · Commits · GNOME / gtk · GitLab
https://gitlab.gnome.org/GNOME/gtk/commit/fb3d9022ad98049c887cec5aeffd6b73deb043ba
[3] Migrating from other containers to GtkGrid: GTK+ 3 Reference Manual
https://developer.gnome.org/gtk3/stable/gtk-migrating-GtkGrid.html


Thanks

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 0/7] Migrate to GTK+ 3.0 and allow python3
       [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
                   ` (6 preceding siblings ...)
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 7/7] hwmixvolume: mention the new dependencies in the README Emmanuel Gil Peyrot
@ 2018-09-19 14:15 ` Takashi Sakamoto
  7 siblings, 0 replies; 16+ messages in thread
From: Takashi Sakamoto @ 2018-09-19 14:15 UTC (permalink / raw)
  To: Emmanuel Gil Peyrot, patch; +Cc: linkmauve, alsa-devel

Hi,

On Sep 18 2018 22:42, Emmanuel Gil Peyrot wrote:
> From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> 
> hwmixvolume was one of the last few programs on my system to depend on
> PyGTK.  This series ports it to GTK+ 3.x using gobject-introspection,
> which allows it to run on Python 3.x too.
> 
> My audio card does not have stream controls so I’ve been unable to test
> whether the functionality is working properly, but from my reading of
> the documentation it should be fine.
> 
> Changes since v1:
> - Reordered tab→space patch before everything else, to make it possible
>    to merge it as is without any other change.
> - Merged fixup commits into the main switch patch, as they had no reason
>    to stand by themselves.
> - Replaced iteration on file.readlines() with file.__iter__() directly
>    (thanks Sakamoto-san).
> - Fix a typo in the README (thanks Sakamoto-san).
> - Explicit more the reason for each patch (thanks Iwai-san), except for
>    trivial ones.
> 
> Emmanuel Gil Peyrot (7):
>    hwmixvolume: use four spaces instead of one tab for indent
>    hwmixvolume: replace PyGTK with gobject-introspection
>    hwmixvolume: switch to GTK+ 3.0 and GLib 2.0
>    hwmixvolume: use a with context to open files
>    hwmixvolume: switch the shebang to python
>    hwmixvolume: add my copyright
>    hwmixvolume: mention the new dependencies in the README
> 
>   hwmixvolume/README      |   3 +-
>   hwmixvolume/hwmixvolume | 560 ++++++++++++++++++++--------------------
>   2 files changed, 283 insertions(+), 280 deletions(-)

I reviewed all of the above patches.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>


Thanks

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
  2018-09-19  0:54   ` James Cameron
@ 2018-09-20  7:13     ` Takashi Iwai
  2018-09-20  8:45       ` James Cameron
  0 siblings, 1 reply; 16+ messages in thread
From: Takashi Iwai @ 2018-09-20  7:13 UTC (permalink / raw)
  To: James Cameron; +Cc: Emmanuel Gil Peyrot, linkmauve, alsa-devel

On Wed, 19 Sep 2018 02:54:33 +0200,
James Cameron wrote:
> 
> For the series;
> 
> Reviewed-by: James Cameron <quozl@laptop.org>

Oh sorry, I overlooked this reply and put only Sakamoto-san's
reviewed-by tag, then pushed out without noticing this.


Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
  2018-09-18 13:42 ` [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent Emmanuel Gil Peyrot
  2018-09-19  0:54   ` James Cameron
@ 2018-09-20  7:13   ` Takashi Iwai
  1 sibling, 0 replies; 16+ messages in thread
From: Takashi Iwai @ 2018-09-20  7:13 UTC (permalink / raw)
  To: Emmanuel Gil Peyrot; +Cc: linkmauve, alsa-devel, patch

On Tue, 18 Sep 2018 15:42:31 +0200,
Emmanuel Gil Peyrot wrote:
> 
> From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> 
> This is the recommended coding style for all Python programs, as
> specified in PEP-0008[1].
> 
> [1] https://www.python.org/dev/peps/pep-0008/
> 
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>

Applied all 7 patches now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
  2018-09-20  7:13     ` Takashi Iwai
@ 2018-09-20  8:45       ` James Cameron
  2018-09-20  9:20         ` Takashi Iwai
  0 siblings, 1 reply; 16+ messages in thread
From: James Cameron @ 2018-09-20  8:45 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Emmanuel Gil Peyrot, linkmauve, alsa-devel

On Thu, Sep 20, 2018 at 09:13:19AM +0200, Takashi Iwai wrote:
> On Wed, 19 Sep 2018 02:54:33 +0200,
> James Cameron wrote:
> > 
> > For the series;
> > 
> > Reviewed-by: James Cameron <quozl@laptop.org>
> 
> Oh sorry, I overlooked this reply and put only Sakamoto-san's
> reviewed-by tag, then pushed out without noticing this.

That's fine.  I'm not exactly a regular reviewer, but I have a focus
on PyGObject with GTK+ 3 at the moment in other work, so I felt
obliged to help.  ;-)

-- 
James Cameron
http://quozl.netrek.org/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent
  2018-09-20  8:45       ` James Cameron
@ 2018-09-20  9:20         ` Takashi Iwai
  0 siblings, 0 replies; 16+ messages in thread
From: Takashi Iwai @ 2018-09-20  9:20 UTC (permalink / raw)
  To: James Cameron; +Cc: Emmanuel Gil Peyrot, linkmauve, alsa-devel

On Thu, 20 Sep 2018 10:45:33 +0200,
James Cameron wrote:
> 
> On Thu, Sep 20, 2018 at 09:13:19AM +0200, Takashi Iwai wrote:
> > On Wed, 19 Sep 2018 02:54:33 +0200,
> > James Cameron wrote:
> > > 
> > > For the series;
> > > 
> > > Reviewed-by: James Cameron <quozl@laptop.org>
> > 
> > Oh sorry, I overlooked this reply and put only Sakamoto-san's
> > reviewed-by tag, then pushed out without noticing this.
> 
> That's fine.  I'm not exactly a regular reviewer, but I have a focus
> on PyGObject with GTK+ 3 at the moment in other work, so I felt
> obliged to help.  ;-)

Thank you for reviews in anyway!


Takashi

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-09-20  9:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180918134237.8489-1-linkmauve@jabberfr.org>
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 1/7] hwmixvolume: use four spaces instead of one tab for indent Emmanuel Gil Peyrot
2018-09-19  0:54   ` James Cameron
2018-09-20  7:13     ` Takashi Iwai
2018-09-20  8:45       ` James Cameron
2018-09-20  9:20         ` Takashi Iwai
2018-09-20  7:13   ` Takashi Iwai
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 2/7] hwmixvolume: replace PyGTK with gobject-introspection Emmanuel Gil Peyrot
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 3/7] hwmixvolume: switch to GTK+ 3.0 and GLib 2.0 Emmanuel Gil Peyrot
2018-09-19 13:22   ` Takashi Sakamoto
2018-09-19 13:36     ` Emmanuel Gil Peyrot
2018-09-19 14:14       ` Takashi Sakamoto
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 4/7] hwmixvolume: use a with context to open files Emmanuel Gil Peyrot
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 5/7] hwmixvolume: switch the shebang to python Emmanuel Gil Peyrot
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 6/7] hwmixvolume: add my copyright Emmanuel Gil Peyrot
2018-09-18 13:42 ` [PATCH - hwmixvolume v2 7/7] hwmixvolume: mention the new dependencies in the README Emmanuel Gil Peyrot
2018-09-19 14:15 ` [PATCH - hwmixvolume v2 0/7] Migrate to GTK+ 3.0 and allow python3 Takashi Sakamoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.