From 1fc29bfd216e24c7839185faa980e0cb3ab3c71b Mon Sep 17 00:00:00 2001 From: Jacek Kosek Date: Thu, 6 Jan 2022 08:45:31 +0100 Subject: [PATCH] hda-analyzer: Initial move from to "gi" python bindings New dynamic Gtk bindings with ver.3: hda_analyzer.py - mostly OK hda_graph.py - started hda_guilib.py - mostly OK From: Jacek Kosek Signed-off-by: Jaroslav Kysela --- alsatool | 123 +++++++++-- comments.py | 17 +- config.py | 1 + hda-analyzer/hda_analyzer.py | 186 +++++++++-------- hda-analyzer/hda_graph.py | 117 +++++------ hda-analyzer/hda_guilib.py | 386 ++++++++++++++++++----------------- utils.py | 2 +- 7 files changed, 474 insertions(+), 358 deletions(-) diff --git a/alsatool b/alsatool index dfb9da8..29904e4 100755 --- a/alsatool +++ b/alsatool @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python2 # -*- Python -*- """HG ALSA Tool @@ -56,7 +56,7 @@ def selectrepos(repos): for repo in repos: if (neg and repo[0] != '-') or \ (not neg and repo[0] == '-'): - raise ValueError, "inverted and non-inverted repo specifications cannot be mixed!" + raise ValueError("inverted and non-inverted repo specifications cannot be mixed!") if neg: negres.remove(repo[1:]) if neg: @@ -112,6 +112,40 @@ def push(argv=None): if git_system(repo, "push --tags origin master:refs/heads/master"): raise ValueError, "push %s" % repo +def checkout_reltest(repo): + reltest = config.GIT_RELTEST + if git_system(repo, "checkout %s" % reltest): + if git_system(repo, "checkout -b %s master" % reltest): + raise ValueError, "checkout %s" % repo + if git_system(repo, "reset --hard master"): + raise ValueError, "reset master" + +def reltest(argv=None): + repos = selectrepos(argv) + reltest = config.GIT_RELTEST + for repo in repos: + if git_system(repo, "checkout %s" % reltest): + raise ValueError, "checkout %s" % repo + if git_system(repo, "push -f %s %s" % (reltest, reltest)): + raise ValueError, "push %s" % repo + if git_system(repo, "checkout master"): + raise ValueError, "checkout master %s" % repo + +def remote(argv=None): + url = argv[0] + repos = selectrepos(argv[1:]) + first = True + reltest = config.GIT_RELTEST + for repo in repos: + if not first: + print + first = False + print("%s" % repo) + print("*"*len(repo)) + git_system(repo, "remote remove " + reltest) + if git_system(repo, "remote add %s %s" % (reltest, "%s/%s.git" % (url, repo))): + raise ValueError, "remote add %s" % repo + def version_sort(tags): tags1 = [] tags2 = {} @@ -212,6 +246,7 @@ def release1(repo, tag): print(''.rjust(11 + len(repo), '*')) version = tag[1:] pull([repo]) + checkout_reltest(repo) if repo == 'alsa-driver': pull(['alsa-kmirror']) files = [] @@ -282,19 +317,24 @@ def release1(repo, tag): break open(config.ROOT + '/' + repo + '/PKG-INFO', "w+").write(''.join(lines)) files.append('PKG-INFO') + elif repo in ['alsa-ucm-conf', 'alsa-topology-conf']: + open(config.ROOT + '/' + repo + '/VERSION', "w+").write('%s\n' % version) + files.append('VERSION') os.chdir(config.ROOT + '/' + repo) - if not repo in ['alsa-ucm-conf', 'alsa-topology-conf']: + if not repo in ['aa']: for file in files: if os.system("git add %s" % file): raise ValueError, "git add %s" % file if os.system('git commit -m "Release %s\n\nSigned-off-by: Jaroslav Kysela \n"' % tag): raise ValueError, "git commit" if not repo in ['alsa-driver']: - if os.system('git tag %s -a -m "Release %s\n\nSigned-off-by: Jaroslav Kysela \n"' % (tag, tag)): + if os.system('git tag -f %s -a -m "Release %s\n\nSigned-off-by: Jaroslav Kysela \n"' % (tag, tag)): raise ValueError, "git tag" else: if os.system('git branch -l %s %s' % tag): raise ValueError, "git new branch" + if os.system('git checkout master'): + raise ValueError, "git checkout master" def release(argv): if argv == None or argv[0][0] != 'v': @@ -549,6 +589,25 @@ def changes(argv): """) + def update_tagmsg(repo, tagmsg): + reltest = config.GIT_RELTEST + if git_system(repo, "checkout %s" % reltest): + raise ValueError, "checkout" + fd = git_popen(repo, "tag %s -l --format='%%(contents)'" % rev2) + lines = fd.readlines() + fd.close() + wanted = 'Release %s\n' % rev2 + if lines[0] != wanted: + print('comment', repr(lines[0])) + print('wanted', wanted[:-1]) + raise ValueError, "release!" + fp = open('/tmp/alsa-tagmsg.txt', 'w+') + fp.write(tagmsg) + fp.close() + print(tagmsg) + if git_system(repo, "tag -f -F /tmp/alsa-tagmsg.txt %s" % rev2): + raise ValueError, "tag" + try: rev1 = argv[0] rev2 = argv[1] @@ -560,6 +619,7 @@ def changes(argv): regex = CommentRegex() changes = [] fullset = config.REPOSITORIES + #fullset = ['alsa-ucm-conf'] fromrev = {} @@ -631,6 +691,7 @@ def changes(argv): str = '=Changelog between %s and %s releases=\n' % (rev_to_dot(rev), rev_to_dot(rev2)) short += str for module in groups[rev]: + tagmsg = 'Release %s\n\n' % rev2 short += '==%s==\n' % module items = get_items(res[module].keys()) for items1 in items: @@ -638,6 +699,7 @@ def changes(argv): if not res[module].has_key(b): continue short += '===%s===\n' % esc(b) + tagmsg += '%s\n' % b for a in res[module][b]: log = a['comment'].splitlines()[0] if log[:9] == 'Summary: ': @@ -645,6 +707,9 @@ def changes(argv): elif log[:8] == 'Summary:': log = log[8:] short += ': %s\n' % esc(log) + tagmsg += ' - %s\n' % log + tagmsg += '\nSigned-off-by: Jaroslav Kysela \n' + update_tagmsg(module, tagmsg) for rev in groups: long += '=Detailed changelog between %s and %s releases=\n' % (rev_to_dot(rev), rev_to_dot(rev2)) long += str @@ -666,8 +731,16 @@ def changes(argv): long_soc += '===%s===\n' % esc(b) for a in res[module][b]: log = a['comment'].splitlines() - first = "-" - for l in log: + t = '- %s\n' % esc(log[0].strip()) + if hdaflag: + long_hda += t + elif socflag: + long_soc += t + else: + long += t + code = '' + long += '<code>\n' + for l in log[1:]: if l[:13] == "Patch-level: ": continue if l[:13] == "Patch-Level: ": @@ -676,17 +749,39 @@ def changes(argv): continue if l[:10].lower() == "acked-by: ": continue + if l[:13].lower() == "reported-by: ": + continue + if l[:13].lower() == "reviewed-by: ": + continue if l[:6].lower() == "from: ": continue + if l[:7].lower() == "fixes: ": + continue if l[:4].lower() == "cc: ": continue - if hdaflag: - long_hda += ': %s %s\n' % (first, esc(l)) - elif socflag: - long_soc += ': %s %s\n' % (first, esc(l)) - else: - long += ': %s %s\n' % (first, esc(l)) - first = " " + c = esc(l) + c.replace(' ', ' ') + c.replace('\t', '        ') + t = ' %s\n' % c.rstrip() + code += t + if code[:2] == " \n": + code = code[2:] + while code and code[-1] == '\n': + code = code[:-1] + while code and code[-1] == ' ': + code = code[:-1] + while code and code[-1] == '\n': + code = code[:-1] + #print(repr(code)) + if code: + code = '<code>\n' + code + '</code>\n' + if hdaflag: + long_hda += code + elif socflag: + long_soc += code + else: + long += code + print("Changes are in /tmp/alsa-changes.wiki") fp = open('/tmp/alsa-changes.wiki', 'w+') @@ -1478,6 +1573,8 @@ CMDS=[ ['diff', diff, '[repo]', 'Do diff on selected or all (default) repositories'], ['pull', pull, '[repo]', 'Do pull on selected or all (default) repositories'], ['push', push, '[repo]', 'Do push on selected or all (default) repositories'], + ['reltest', reltest, '[repo]', 'Push reltest branch'], + ['remote', remote, '[repo] remote_url', 'Add remote for the reltest'], ['showchanged', showchanged, 'tag [repo]', 'Show which repositories were changed since tag'], ['release', release, 'tag [repo]', 'Do an ALSA release (auto = automatic change control)'], ['changes', changes, 'oldtag newtag', 'Show changes between oldtag and newtag'], diff --git a/comments.py b/comments.py index 3f4f8f3..6af75aa 100644 --- a/comments.py +++ b/comments.py @@ -34,6 +34,7 @@ COMMENT_MAP = { ['/gitcompile', 'gitcompile'], ['/ChangeLog', 'IGNORE'], ['/.travis.yml', 'Core'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-driver": [ @@ -681,6 +682,7 @@ COMMENT_MAP = { ['/include/bswap.h', 'Compatibility routines'], ['/include/conf.h', 'Config API'], ['/include/control.h', 'Control API'], + ['/include/control_plugin.h', 'Control Plugin API'], ['/include/control_external.h', 'External Control Plugin SDK'], ['/include/hwdep.h', 'HWDEP API'], ['/include/(input|output).h', 'I/O API'], @@ -748,6 +750,7 @@ COMMENT_MAP = { ['/hgcompile', 'Core'], ['/gitcompile', 'Core'], ['/.travis.yml', 'Core'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-firmware": [ @@ -768,14 +771,16 @@ COMMENT_MAP = { ['/aica/.*', 'AICA (Dreamcast) Firmware'], ['/ca0132/.*', 'Sound Blaster HDA CA0132 Firmware'], ['/cs46xx/.*', 'Cirrus Logic CS46xx Firmware'], + ['/m4/.*', 'Core'], ['/configure.*', 'Core'], - ['/Makefile.am', 'Core'], + ['/Makefile.*', 'Core'], ['/README.*', 'Core'], ['/COPY.*', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], ['/gitcompile', 'Core'], ['/.travis.yml', 'Core'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-plugins": [ @@ -807,6 +812,7 @@ COMMENT_MAP = { ['/hgcompile', 'Core'], ['/gitcompile', 'Core'], ['/install-hooks.am', 'Core'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-python": [ @@ -826,6 +832,7 @@ COMMENT_MAP = { ['/test/.*', 'Test python scripts'], ['/tools/.*', 'Tools python scripts'], ['/doc/.*', 'Documentation'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-oss": [ @@ -845,6 +852,7 @@ COMMENT_MAP = { ['/hgcompile', 'Core'], ['/gitcompile', 'Core'], ['/COPYING', 'Documentation'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "tinycompress": [ @@ -856,6 +864,8 @@ COMMENT_MAP = { ['/cplay.c', 'Utilities'], ['/crec.c', 'Utilities'], ['/utils.c', 'Utilities'], + ['/src/utils-lgpl/fcplay.c', 'Utilities'], + ['/tinycompress.pc.in', 'pkg-config'], ['/configure.*', 'Core'], ['/cvscompile', 'Core'], ['/hgcompile', 'Core'], @@ -870,6 +880,7 @@ COMMENT_MAP = { ['/NEWS', 'Core'], ['/ChangeLog', 'Core'], ['/m4/.place_holder', 'IGNORE'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-ucm-conf": [ @@ -877,12 +888,16 @@ COMMENT_MAP = { ['/ucm2/.*', 'Configuration'], ['/README*', 'Description'], ['/LICEN*', 'Description'], + ['/VERS*', 'Description'], + ['/.github', 'Core'], ['/', 'ERROR'], ], "alsa-topology-conf": [ ['/topology', 'Configuration files'], ['/README.*', 'Description'], ['/LICEN.*', 'Description'], + ['/VERS*', 'Description'], + ['/.github', 'Core'], ['/', 'ERROR'], ] } diff --git a/config.py b/config.py index 4a78ba5..71639a8 100644 --- a/config.py +++ b/config.py @@ -11,6 +11,7 @@ GERRORS = 0 GERRORSA = [] TMPDIR = '/dev/shm/alsatool' SMTP_SERVER = 'localhost' +GIT_RELTEST = 'reltest' GIT_KERNEL_MERGE = 'v4.8' GIT_DRIVER_MERGE = 'mirror/v1.0.25' GIT_MERGE_REPOS = [ diff --git a/hda-analyzer/hda_analyzer.py b/hda-analyzer/hda_analyzer.py index eafece8..cd9351c 100755 --- a/hda-analyzer/hda_analyzer.py +++ b/hda-analyzer/hda_analyzer.py @@ -29,9 +29,11 @@ Usage: hda_analyzer [[codec_proc] ...] import os import sys -import gobject -import gtk -import pango +import gi +gi.require_version("Gtk", "3.0") +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import Pango from hda_codec import HDACodec, HDA_card_list, HDA_Exporter_pyscript, \ EAPDBTL_BITS, PIN_WIDGET_CONTROL_BITS, \ @@ -139,83 +141,77 @@ def save_to_file(filename, txt, mode=None): ITALIC_COLUMN ) = range(5) -class HDAAnalyzer(gtk.Window): +class HDAAnalyzer(Gtk.Window): info_buffer = None node_window = None codec = None node = None def __init__(self): - gtk.Window.__init__(self) + GObject.GObject.__init__(self) self.connect('destroy', self.__destroy) self.set_default_size(800, 400) self.set_title(self.__class__.__name__) self.set_border_width(10) - self.tooltips = gtk.Tooltips() - - hbox = gtk.HBox(False, 3) + hbox = Gtk.HBox(False, 3) self.add(hbox) - vbox = gtk.VBox(False, 0) - scrolled_window = gtk.ScrolledWindow() - scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled_window.set_shadow_type(gtk.SHADOW_IN) + vbox = Gtk.VBox(False, 0) + scrolled_window = Gtk.ScrolledWindow() + scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + scrolled_window.set_shadow_type(Gtk.ShadowType.IN) treeview = self.__create_treeview() treeview.set_size_request(250, 600) scrolled_window.add(treeview) - vbox.pack_start(scrolled_window) - hbox1 = gtk.HBox(False, 0) - button = gtk.Button("About") + vbox.pack_start(scrolled_window, True, True, 0) + hbox1 = Gtk.HBox(False, 0) + button = Gtk.Button("About") button.connect("clicked", self.__about_clicked) - self.tooltips.set_tip(button, "README! Show the purpose of this program.") - hbox1.pack_start(button) - button = gtk.Button("Revert") + button.set_tooltip_text("README! Show the purpose of this program.") + hbox1.pack_start(button, True, True, 0) + button = Gtk.Button("Revert") button.connect("clicked", self.__revert_clicked) - self.tooltips.set_tip(button, "Revert settings for selected codec.") - hbox1.pack_start(button) - button = gtk.Button("Diff") + button.set_tooltip_text("Revert settings for selected codec.") + hbox1.pack_start(button, True, True, 0) + button = Gtk.Button("Diff") button.connect("clicked", self.__diff_clicked) - self.tooltips.set_tip(button, "Show settings diff for selected codec.") - hbox1.pack_start(button) - button = gtk.Button("Exp") + button.set_tooltip_text("Show settings diff for selected codec.") + hbox1.pack_start(button, True, True, 0) + button = Gtk.Button("Exp") button.connect("clicked", self.__export_clicked) - self.tooltips.set_tip(button, "Export settings differences for selected codec.\nGenerates a python script.") - hbox1.pack_start(button) - button = gtk.Button("Graph") + button.set_tooltip_text("Export settings differences for selected codec.\nGenerates a python script.") + hbox1.pack_start(button, True, True, 0) + button = Gtk.Button("Graph") button.connect("clicked", self.__graph_clicked) - self.tooltips.set_tip(button, "Show graph for selected codec.") - hbox1.pack_start(button) - vbox.pack_start(hbox1, False, False) - hbox.pack_start(vbox, False, False) - - self.notebook = gtk.Notebook() - hbox.pack_start(self.notebook, expand=True) - - self.node_window = gtk.Table() + button.set_tooltip_text("Show graph for selected codec.") + hbox1.pack_start(button, True, True, 0) + vbox.pack_start(hbox1, False, False,0) + hbox.pack_start(vbox, False, False,0) + self.notebook = Gtk.Notebook() + hbox.pack_start(self.notebook, True, True, 0) + self.node_window = Gtk.Table() self._new_notebook_page(self.node_window, '_Node editor') - scrolled_window, self.info_buffer = self.__create_text(self.__dump_visibility) self._new_notebook_page(scrolled_window, '_Text dump') - self.show_all() TRACKER.add(self) - + def __destroy(self, widget): TRACKER.close(self) def simple_dialog(self, type, msg): - dialog = gtk.MessageDialog(self, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - type, gtk.BUTTONS_OK, msg) + dialog = Gtk.MessageDialog(self, + Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + type, Gtk.ButtonsType.OK, msg) dialog.run() dialog.destroy() def __about_clicked(self, button): - dialog = gtk.Dialog('About', self, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - (gtk.STOCK_OK, gtk.RESPONSE_OK)) - text_view = gtk.TextView() + dialog = Gtk.Dialog('About', self, + Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + (Gtk.STOCK_OK, Gtk.ResponseType.OK)) + text_view = Gtk.TextView() text_view.set_border_width(4) str = """\ HDA Analyzer @@ -232,13 +228,13 @@ mailing list - http://www.alsa-project.org . Bugs, ideas, comments about this program should be sent to alsa-devel mailing list, too. """ - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer() iter = buffer.get_iter_at_offset(0) buffer.insert(iter, str[:-1]) text_view.set_buffer(buffer) text_view.set_editable(False) text_view.set_cursor_visible(False) - dialog.vbox.pack_start(text_view, False, False) + dialog.vbox.pack_start(text_view, False, False,0) dialog.show_all() dialog.run() dialog.destroy() @@ -246,92 +242,92 @@ mailing list, too. def __revert_clicked(self, button): if not self.codec: msg = "Please, select a codec in left codec/node tree." - type = gtk.MESSAGE_WARNING + type = Gtk.MessageType.WARNING else: self.codec.revert() self.__refresh() msg = "Setting for codec %s/%s (%s) was reverted!" % (self.codec.card, self.codec.device, self.codec.name) - type = gtk.MESSAGE_INFO + type = Gtk.MessageType.INFO self.simple_dialog(type, msg) def __diff_clicked(self, button): if not self.codec: - self.simple_dialog(gtk.MESSAGE_WARNING, "Please, select a codec in left codec/node tree.") + self.simple_dialog(Gtk.MessageType.WARNING, "Please, select a codec in left codec/node tree.") return - dialog = gtk.Dialog('Diff', self, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - (gtk.STOCK_OK, gtk.RESPONSE_OK)) - text_view = gtk.TextView() + dialog = Gtk.Dialog('Diff', self, + Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + (Gtk.STOCK_OK, Gtk.ResponseType.OK)) + text_view = Gtk.TextView() text_view.set_border_width(4) fontName = get_fixed_font() text_view.modify_font(fontName) str = do_diff1(self.codec, DIFF_TREE[self.card][self.codec.device]) if str == '': str = 'No changes' - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer() iter = buffer.get_iter_at_offset(0) buffer.insert(iter, str[:-1]) text_view.set_buffer(buffer) text_view.set_editable(False) text_view.set_cursor_visible(False) - dialog.vbox.pack_start(text_view, False, False) + dialog.vbox.pack_start(text_view, False, False,0) dialog.show_all() dialog.run() dialog.destroy() def __export_clicked(self, button): if not self.codec: - self.simple_dialog(gtk.MESSAGE_WARNING, "Please, select a codec in left codec/node tree.") + self.simple_dialog(Gtk.MessageType.WARNING, "Please, select a codec in left codec/node tree.") return exporter = HDA_Exporter_pyscript() self.codec.export(exporter) - dialog = gtk.Dialog(exporter.title(), self, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - (gtk.STOCK_OK, gtk.RESPONSE_OK, - gtk.STOCK_SAVE_AS, gtk.RESPONSE_YES)) - text_view = gtk.TextView() + dialog = Gtk.Dialog(exporter.title(), self, + Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + (Gtk.STOCK_OK, Gtk.ResponseType.OK, + Gtk.STOCK_SAVE_AS, Gtk.ResponseType.YES)) + text_view = Gtk.TextView() text_view.set_border_width(4) fontName = get_fixed_font() text_view.modify_font(fontName) str = exporter.text(self.codec) - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer() iter = buffer.get_iter_at_offset(0) buffer.insert(iter, str[:-1]) text_view.set_buffer(buffer) text_view.set_editable(False) text_view.set_cursor_visible(False) - dialog.vbox.pack_start(text_view, False, False) + dialog.vbox.pack_start(text_view, False, False,0) dialog.show_all() r = dialog.run() dialog.destroy() - if r == gtk.RESPONSE_YES: - sdialog = gtk.FileChooserDialog('Save %s as...' % exporter.stitle(), - self, gtk.FILE_CHOOSER_ACTION_SAVE, - (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, - gtk.STOCK_SAVE, gtk.RESPONSE_OK)) - sdialog.set_default_response(gtk.RESPONSE_OK) - - filter = gtk.FileFilter() + if r == Gtk.ResponseType.YES: + sdialog = Gtk.FileChooserDialog('Save %s as...' % exporter.stitle(), + self, Gtk.FileChooserAction.SAVE, + (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) + sdialog.set_default_response(Gtk.ResponseType.OK) + + filter = Gtk.FileFilter() filter.set_name("Python Scripts") filter.add_mime_type("text/x-python") filter.add_mime_type("text/x-python-script") filter.add_pattern("*.py") sdialog.add_filter(filter) - filter = gtk.FileFilter() + filter = Gtk.FileFilter() filter.set_name("All files") filter.add_pattern("*") sdialog.add_filter(filter) sr = sdialog.run() - if sr == gtk.RESPONSE_OK: + if sr == Gtk.ResponseType.OK: save_to_file(sdialog.get_filename(), str, 0755) sdialog.destroy() def __graph_clicked(self, button): if not self.codec: - self.simple_dialog(gtk.MESSAGE_WARNING, "Please, select a codec in left codec/node tree.") + self.simple_dialog(Gtk.MessageType.WARNING, "Please, select a codec in left codec/node tree.") return create_graph(self.codec) @@ -400,22 +396,22 @@ mailing list, too. self.node_window.show_all() def _new_notebook_page(self, widget, label): - l = gtk.Label('') + l = Gtk.Label(label='') l.set_text_with_mnemonic(label) self.notebook.append_page(widget, l) def __create_treeview(self): - model = gtk.TreeStore( - gobject.TYPE_STRING, - gobject.TYPE_INT, - gobject.TYPE_INT, - gobject.TYPE_INT, - gobject.TYPE_BOOLEAN + model = Gtk.TreeStore( + GObject.TYPE_STRING, + GObject.TYPE_INT, + GObject.TYPE_INT, + GObject.TYPE_INT, + GObject.TYPE_BOOLEAN ) - treeview = gtk.TreeView(model) + treeview = Gtk.TreeView(model) selection = treeview.get_selection() - selection.set_mode(gtk.SELECTION_BROWSE) + selection.set_mode(Gtk.SelectionMode.BROWSE) treeview.set_size_request(200, -1) for card in CODEC_TREE: @@ -446,10 +442,10 @@ mailing list, too. ITALIC_COLUMN, False) nid += 1 - cell = gtk.CellRendererText() - cell.set_property('style', pango.STYLE_ITALIC) + cell = Gtk.CellRendererText() + cell.set_property('style', Pango.Style.ITALIC) - column = gtk.TreeViewColumn('Nodes', cell, text=TITLE_COLUMN, + column = Gtk.TreeViewColumn('Nodes', cell, text=TITLE_COLUMN, style_set=ITALIC_COLUMN) treeview.append_column(column) @@ -457,20 +453,20 @@ mailing list, too. selection.connect('changed', self.selection_changed_cb) treeview.expand_all() - + print("JKK end treeview") return treeview def __create_text(self, callback): - scrolled_window = gtk.ScrolledWindow() - scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled_window.set_shadow_type(gtk.SHADOW_IN) + scrolled_window = Gtk.ScrolledWindow() + scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + scrolled_window.set_shadow_type(Gtk.ShadowType.IN) - text_view = gtk.TextView() + text_view = Gtk.TextView() fontName = get_fixed_font() text_view.modify_font(fontName) scrolled_window.add(text_view) - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer() text_view.set_buffer(buffer) text_view.set_editable(False) text_view.set_cursor_visible(False) @@ -539,7 +535,7 @@ def main(argv): create_graph(CODEC_TREE[card][codec]) else: HDAAnalyzer() - gtk.main() + Gtk.main() return 1 if __name__ == '__main__': diff --git a/hda-analyzer/hda_graph.py b/hda-analyzer/hda_graph.py index 1937c6c..4023145 100755 --- a/hda-analyzer/hda_graph.py +++ b/hda-analyzer/hda_graph.py @@ -12,10 +12,11 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -import gobject -import gtk -from gtk import gdk -import pango +import gi +gi.require_version("Gtk", "3.0") +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import Gdk import cairo from hda_guilib import * @@ -440,15 +441,18 @@ class Route: self.highlight = True return True -class CodecGraphLayout(gtk.Layout): +class CodecGraphLayout(Gtk.Layout): def __init__(self, adj1, adj2, codec, mytitle, statusbar): - gtk.Layout.__init__(self, adj1, adj2) + super(CodecGraphLayout,self).__init__() self.set_events(0) - self.add_events(gtk.gdk.EXPOSURE_MASK | gtk.gdk.POINTER_MOTION_MASK | - gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | - gtk.gdk.LEAVE_NOTIFY_MASK | gtk.gdk.SCROLL_MASK) - self.expose_handler = self.connect("expose-event", self.expose) + self.set_hadjustment(adj1) + self.set_vadjustment(adj2) + + self.add_events(Gdk.EventMask.EXPOSURE_MASK | Gdk.EventMask.POINTER_MOTION_MASK | + Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | + Gdk.EventMask.LEAVE_NOTIFY_MASK | Gdk.EventMask.SCROLL_MASK) + self.expose_handler = self.connect("draw", self.expose) self.click_handler = self.connect("button-press-event", self.button_click) self.release_handler = self.connect("button-release-event", self.button_release) self.motion_handler = self.connect("motion-notify-event", self.mouse_move) @@ -558,14 +562,13 @@ class CodecGraphLayout(gtk.Layout): return res def expose(self, widget, event): - if not self.flags() & gtk.REALIZED: + if not self.get_realized(): return # background - cr = self.bin_window.cairo_create() + cr = self.get_bin_window().cairo_create() cr.set_source_rgb(1.0, 1.0, 1.0) - cr.rectangle(event.area.x, event.area.y, - event.area.width, event.area.height) + cr.rectangle(*event.clip_extents()) cr.clip() cr.paint() @@ -646,13 +649,13 @@ class CodecGraphLayout(gtk.Layout): return route def show_popup(self, event): - screen_width = gtk.gdk.screen_width() - screen_height = gtk.gdk.screen_height() + screen_width = Gdk.Screen.width() + screen_height = Gdk.Screen.height() if self.popup_win: self.popup_win.destroy() - self.popup_win = gtk.Window(gtk.WINDOW_POPUP) - label = gtk.Label() + self.popup_win = Gtk.Window(Gtk.WindowType.POPUP) + label = Gtk.Label() label.modify_font(get_fixed_font()) label.set_text(self.popup) self.popup_win.add(label) @@ -755,7 +758,7 @@ class CodecGraphLayout(gtk.Layout): if self.popup_win: self.popup_win.destroy() if not node.win: - win = gtk.Window() + win = Gtk.Window() win.set_default_size(500, 600) gui = NodeGui(node=node.node) win.set_title(self.mytitle + ' ' + gui.mytitle) @@ -770,15 +773,15 @@ class CodecGraphLayout(gtk.Layout): def button_click(self, widget, event): if event.button != 3: if event.button == 8: - self.scroll_me(self, DummyScrollEvent(gtk.gdk.SCROLL_LEFT)) + self.scroll_me(self, DummyScrollEvent(Gdk.ScrollDirection.LEFT)) elif event.button == 9: - self.scroll_me(self, DummyScrollEvent(gtk.gdk.SCROLL_RIGHT)) + self.scroll_me(self, DummyScrollEvent(Gdk.ScrollDirection.RIGHT)) return False node, what = self.find_node(event) m = None if node: - m = gtk.Menu() - i = gtk.MenuItem("Open") + m = Gtk.Menu() + i = Gtk.MenuItem("Open") i.connect("activate", self.open_node, node) i.show() m.append(i) @@ -795,16 +798,16 @@ class CodecGraphLayout(gtk.Layout): if routes: i = None if len(routes) == 1: - i = gtk.MenuItem(text + ' ' + routes[0].longdesc()) + i = Gtk.MenuItem(text + ' ' + routes[0].longdesc()) i.connect("activate", self.mark_route, routes[0], "mark", True) else: - menu = gtk.Menu() + menu = Gtk.Menu() for route in routes: - i = gtk.MenuItem(route.longdesc()) + i = Gtk.MenuItem(route.longdesc()) i.connect("activate", self.mark_route, route, "mark", True) i.show() menu.append(i) - i = gtk.MenuItem(text) + i = Gtk.MenuItem(text) i.set_submenu(menu) if i: i.show() @@ -822,45 +825,45 @@ class CodecGraphLayout(gtk.Layout): if routes: i = None if len(routes) == 1: - i = gtk.MenuItem(text + ' ' + routes[0].longdesc()) + i = Gtk.MenuItem(text + ' ' + routes[0].longdesc()) i.connect("activate", self.mark_route, routes[0], "mark", False) else: - menu = gtk.Menu() + menu = Gtk.Menu() for route in routes: - i = gtk.MenuItem(route.longdesc()) + i = Gtk.MenuItem(route.longdesc()) i.connect("activate", self.mark_route, route, "mark", False) i.show() menu.append(i) - i = gtk.MenuItem(text) + i = Gtk.MenuItem(text) i.set_submenu(menu) if i: i.show() m.append(i) if not self.startnode: - i = gtk.MenuItem("Mark as start point") + i = Gtk.MenuItem("Mark as start point") i.connect("activate", self.mark_it, node, "start", True) else: - i = gtk.MenuItem("Clear start point") + i = Gtk.MenuItem("Clear start point") i.connect("activate", self.mark_it, None, "start", False) i.show() m.append(i) if not self.endnode: - i = gtk.MenuItem("Mark as finish point") + i = Gtk.MenuItem("Mark as finish point") i.connect("activate", self.mark_it, node, "end", True) else: - i = gtk.MenuItem("Clear finish point") + i = Gtk.MenuItem("Clear finish point") i.connect("activate", self.mark_it, None, "end", False) i.show() m.append(i) else: route = self.find_route(event) if route: - m = gtk.Menu() + m = Gtk.Menu() if not route.marked: - i = gtk.MenuItem("Mark selected route %s" % route.shortdesc()) + i = Gtk.MenuItem("Mark selected route %s" % route.shortdesc()) i.connect("activate", self.mark_route, route, "mark", True) else: - i = gtk.MenuItem("Clear selected route %s" % route.shortdesc()) + i = Gtk.MenuItem("Clear selected route %s" % route.shortdesc()) i.connect("activate", self.mark_route, route, "mark", False) i.show() m.append(i) @@ -872,50 +875,50 @@ class CodecGraphLayout(gtk.Layout): pass def scroll_me(self, widget, event): - if event.direction == gtk.gdk.SCROLL_UP: + if event.direction == Gdk.ScrollDirection.UP: adj = self.get_vadjustment() adj.set_value(adj.get_value()-40) - elif event.direction == gtk.gdk.SCROLL_DOWN: + elif event.direction == Gdk.ScrollDirection.DOWN: adj = self.get_vadjustment() adj.set_value(adj.get_value()+40) - elif event.direction == gtk.gdk.SCROLL_LEFT: + elif event.direction == Gdk.ScrollDirection.LEFT: adj = self.get_hadjustment() adj.set_value(adj.get_value()-40) - elif event.direction == gtk.gdk.SCROLL_RIGHT: + elif event.direction == Gdk.ScrollDirection.RIGHT: adj = self.get_hadjustment() adj.set_value(adj.get_value()+40) -gobject.type_register(CodecGraphLayout) +GObject.type_register(CodecGraphLayout) -class CodecGraph(gtk.Window): +class CodecGraph(Gtk.Window): def __init__(self, codec): - gtk.Window.__init__(self) + super(CodecGraph,self).__init__() self.codec = codec self.connect('destroy', self.__destroy) self.set_default_size(800, 600) self.set_title(self.__class__.__name__ + ' ' + self.codec.name) self.set_border_width(0) - table = gtk.Table(2, 3, False) + table = Gtk.Table(2, 3, False) self.add(table) - statusbar = gtk.Statusbar() + statusbar = Gtk.Statusbar() self.layout = CodecGraphLayout(None, None, codec, self.get_title(), statusbar) - table.attach(self.layout, 0, 1, 0, 1, gtk.FILL|gtk.EXPAND, - gtk.FILL|gtk.EXPAND, 0, 0) - vScrollbar = gtk.VScrollbar(None) - table.attach(vScrollbar, 1, 2, 0, 1, gtk.FILL|gtk.SHRINK, - gtk.FILL|gtk.SHRINK, 0, 0) - hScrollbar = gtk.HScrollbar(None) - table.attach(hScrollbar, 0, 1, 1, 2, gtk.FILL|gtk.SHRINK, - gtk.FILL|gtk.SHRINK, 0, 0) + table.attach(self.layout, 0, 1, 0, 1, Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND, + Gtk.AttachOptions.FILL|Gtk.AttachOptions.EXPAND, 0, 0) + vScrollbar = Gtk.VScrollbar(None) + table.attach(vScrollbar, 1, 2, 0, 1, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, + Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0) + hScrollbar = Gtk.HScrollbar(None) + table.attach(hScrollbar, 0, 1, 1, 2, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, + Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0) vAdjust = self.layout.get_vadjustment() vScrollbar.set_adjustment(vAdjust) hAdjust = self.layout.get_hadjustment() hScrollbar.set_adjustment(hAdjust) - table.attach(statusbar, 0, 2, 2, 3, gtk.FILL|gtk.SHRINK, - gtk.FILL|gtk.SHRINK, 0, 0) + table.attach(statusbar, 0, 2, 2, 3, Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, + Gtk.AttachOptions.FILL|Gtk.AttachOptions.SHRINK, 0, 0) self.show_all() GRAPH_WINDOWS[codec] = self TRACKER.add(self) diff --git a/hda-analyzer/hda_guilib.py b/hda-analyzer/hda_guilib.py index ffc11c9..efb6d87 100644 --- a/hda-analyzer/hda_guilib.py +++ b/hda-analyzer/hda_guilib.py @@ -12,9 +12,12 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -import gobject -import gtk -import pango +import gi +gi.require_version("Gtk", "3.0") +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import Gdk +from gi.repository import Pango from hda_codec import HDACodec, HDA_card_list, \ EAPDBTL_BITS, PIN_WIDGET_CONTROL_BITS, \ @@ -27,21 +30,21 @@ CODEC_TREE = {} DIFF_TREE = {} def get_fixed_font(): - return pango.FontDescription("Misc Fixed,Courier Bold 9") + return Pango.FontDescription("Misc Fixed,Courier Bold 9") -class HDASignal(gobject.GObject): +class HDASignal(GObject.GObject): def __init__(self): - self.__gobject_init__() + super(HDASignal,self).__init__() -gobject.signal_new("hda-codec-changed", HDASignal, - gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, - (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)) -gobject.signal_new("hda-node-changed", HDASignal, - gobject.SIGNAL_RUN_FIRST, - gobject.TYPE_NONE, - (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)) +GObject.signal_new("hda-codec-changed", HDASignal, + GObject.SignalFlags.RUN_FIRST, + None, + (GObject.TYPE_PYOBJECT,GObject.TYPE_PYOBJECT)) +GObject.signal_new("hda-node-changed", HDASignal, + GObject.SignalFlags.RUN_FIRST, + None, + (GObject.TYPE_PYOBJECT,GObject.TYPE_PYOBJECT)) HDA_SIGNAL = HDASignal() @@ -67,17 +70,16 @@ def do_diff(): print "Diff was stored to: %s" % DIFF_FILE return (diff and hw > 0) and True or False -class NodeGui(gtk.ScrolledWindow): +class NodeGui(Gtk.ScrolledWindow): def __init__(self, card=None, codec=None, node=None, doframe=False): - gtk.ScrolledWindow.__init__(self) - self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - self.set_shadow_type(gtk.SHADOW_IN) + super(NodeGui,self).__init__() + self.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + self.set_shadow_type(Gtk.ShadowType.IN) self.read_all = self.__read_all_none self.node = None self.codec = None self.popups = [] - self.tooltips = gtk.Tooltips() if card and not codec and not node: self.__build_card(card, doframe) elif codec and not card and not node: @@ -108,14 +110,14 @@ class NodeGui(gtk.ScrolledWindow): self.read_all() def show_popup(self, text): - screen_width = gtk.gdk.screen_width() - screen_height = gtk.gdk.screen_height() + screen_width = Gdk.Screen.width() + screen_height = Gdk.Screen.height() - popup_win = gtk.Window(gtk.WINDOW_POPUP) - popup_win.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0xffff, 0xd700, 0)) - frame = gtk.Frame() + popup_win = Gtk.Window(Gtk.WindowType.POPUP) + popup_win.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(0xffff, 0xd700, 0)) + frame = Gtk.Frame() popup_win.add(frame) - label = gtk.Label() + label = Gtk.Label() label.modify_font(get_fixed_font()) if text[-1] == '\n': text = text[:-1] @@ -126,7 +128,7 @@ class NodeGui(gtk.ScrolledWindow): popup_width, popup_height = popup_win.get_size() rootwin = self.get_screen().get_root_window() - x, y, mods = rootwin.get_pointer() + _, x, y, _ = rootwin.get_pointer() pos_x = x - popup_width/2 if pos_x < 0: @@ -159,16 +161,16 @@ class NodeGui(gtk.ScrolledWindow): self.popups.append([None, widget, gettext, data]) def __create_text(self, callback): - scrolled_window = gtk.ScrolledWindow() - scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled_window.set_shadow_type(gtk.SHADOW_IN) + scrolled_window = Gtk.ScrolledWindow() + scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + scrolled_window.set_shadow_type(Gtk.ShadowType.IN) - text_view = gtk.TextView() + text_view = Gtk.TextView() fontName = get_fixed_font() text_view.modify_font(fontName) scrolled_window.add(text_view) - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer(None) text_view.set_buffer(buffer) text_view.set_editable(False) text_view.set_cursor_visible(False) @@ -179,12 +181,12 @@ class NodeGui(gtk.ScrolledWindow): return scrolled_window, buffer def __new_text_view(self, text=None): - text_view = gtk.TextView() + text_view = Gtk.TextView() text_view.set_border_width(4) fontName = get_fixed_font() text_view.modify_font(fontName) if not text is None: - buffer = gtk.TextBuffer(None) + buffer = Gtk.TextBuffer() iter = buffer.get_iter_at_offset(0) if text[-1] == '\n': text = text[:-1] @@ -195,7 +197,7 @@ class NodeGui(gtk.ScrolledWindow): return text_view def __build_node_caps(self, node): - frame = gtk.Frame('Node Caps') + frame = Gtk.Frame.new('Node Caps') frame.set_border_width(4) if len(node.wcaps_list) == 0: return frame @@ -218,16 +220,16 @@ class NodeGui(gtk.ScrolledWindow): idx += 1 def __build_connection_list(self, node): - frame = gtk.Frame('Connection List') + frame = Gtk.Frame.new('Connection List') frame.set_border_width(4) - sw = gtk.ScrolledWindow() - #sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) - sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + sw = Gtk.ScrolledWindow() + #sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN) + sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) frame.add(sw) if node.conn_list and node.connections: - model = gtk.ListStore( - gobject.TYPE_BOOLEAN, - gobject.TYPE_STRING + model = Gtk.ListStore( + GObject.TYPE_BOOLEAN, + GObject.TYPE_STRING ) idx = 0 for i in node.connections: @@ -237,18 +239,18 @@ class NodeGui(gtk.ScrolledWindow): 1, node1.name()) idx += 1 self.connection_model = model - treeview = gtk.TreeView(model) + treeview = Gtk.TreeView(model) treeview.set_rules_hint(True) - treeview.get_selection().set_mode(gtk.SELECTION_SINGLE) + treeview.get_selection().set_mode(Gtk.SelectionMode.SINGLE) treeview.set_size_request(300, 30 + len(node.connections) * 25) - renderer = gtk.CellRendererToggle() + renderer = Gtk.CellRendererToggle() renderer.set_radio(True) if not node.active_connection is None: renderer.connect("toggled", self.__node_connection_toggled, (model, node)) - column = gtk.TreeViewColumn("Active", renderer, active=0) + column = Gtk.TreeViewColumn("Active", renderer, active=0) treeview.append_column(column) - renderer = gtk.CellRendererText() - column = gtk.TreeViewColumn("Source Node", renderer, text=1, editable=1) + renderer = Gtk.CellRendererText() + column = Gtk.TreeViewColumn("Source Node", renderer, text=1, editable=1) treeview.append_column(column) sw.add(treeview) return frame @@ -281,9 +283,9 @@ class NodeGui(gtk.ScrolledWindow): def build_caps(title, caps, vals): if caps and caps.cloned: title += ' (Global)' - frame = gtk.Frame(title) + frame = Gtk.Frame.new(title) frame.set_border_width(4) - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) if caps: if caps.ofs != None: str = 'Offset: %d\n' % caps.ofs @@ -300,29 +302,29 @@ class NodeGui(gtk.ScrolledWindow): ctls = node.get_mixercontrols() for val in vals.vals: if vals.stereo and idx & 1 == 0: - frame1 = gtk.Frame() - vbox.pack_start(frame1, False, False) - vbox1 = gtk.VBox(False, 0) + frame1 = Gtk.Frame() + vbox.pack_start(frame1, False, False, 0) + vbox1 = Gtk.VBox(False, 0) frame1.add(vbox1) - hbox = gtk.HBox(False, 0) - label = gtk.Label('Val[%d]' % idx) - hbox.pack_start(label, False, False) + hbox = Gtk.HBox(False, 0) + label = Gtk.Label(label='Val[%d]' % idx) + hbox.pack_start(label, False, False, 0) if caps.mute: - checkbutton = gtk.CheckButton('Mute') + checkbutton = Gtk.CheckButton('Mute') checkbutton.connect("toggled", self.__amp_mute_toggled, (caps, vals, idx)) #checkbutton.set_active(True) self.amp_checkbuttons[caps.dir].append(checkbutton) - hbox.pack_start(checkbutton, False, False) + hbox.pack_start(checkbutton, False, False, 0) else: self.amp_checkbuttons[caps.dir].append(None) if caps.stepsize > 0: - adj = gtk.Adjustment((val & 0x7f) % (caps.nsteps+1), 0.0, caps.nsteps+1, 1.0, 1.0, 1.0) - scale = gtk.HScale(adj) + adj = Gtk.Adjustment((val & 0x7f) % (caps.nsteps+1), 0.0, caps.nsteps+1, 1.0, 1.0, 1.0) + scale = Gtk.HScale.new(adj) scale.set_digits(0) - scale.set_value_pos(gtk.POS_RIGHT) + scale.set_value_pos(Gtk.PositionType.RIGHT) adj.connect("value_changed", self.__amp_value_changed, (caps, vals, idx)) self.amp_adjs[caps.dir].append(adj) - hbox.pack_start(scale, True, True) + hbox.pack_start(scale, True, True, 0) else: self.amp_adjs[caps.dir].append(None) sep = False @@ -330,30 +332,30 @@ class NodeGui(gtk.ScrolledWindow): if ctl.hdactl.amp_index_match(idx): if ctl.stype == 'boolean': if not sep: - hbox.pack_start(gtk.VSeparator(), False, False) - hbox.pack_start(gtk.Label('CTLIFC'), False, False) + hbox.pack_start(Gtk.VSeparator(), False, False, 0) + hbox.pack_start(Gtk.Label('CTLIFC'), False, False, 0) sep = True - checkbutton = gtk.CheckButton('Mute') + checkbutton = Gtk.CheckButton('Mute') checkbutton.connect("toggled", self.__ctl_mute_toggled, (ctl, idx)) self.make_popup(checkbutton, self.__popup_show_ctl, (ctl, idx)) - hbox.pack_start(checkbutton, False, False) + hbox.pack_start(checkbutton, False, False, 0) for ctl in ctls: if ctl.hdactl.amp_index_match(idx): if ctl.stype.startswith('integer'): if not sep: - hbox.pack_start(gtk.VSeparator(), False, False) + hbox.pack_start(Gtk.VSeparator(), False, False, 0) sep = True - adj = gtk.Adjustment(0, ctl.min, ctl.max, ctl.step, ctl.step, ctl.step) - scale = gtk.HScale(adj) + adj = Gtk.Adjustment(0, ctl.min, ctl.max, ctl.step, ctl.step, ctl.step) + scale = Gtk.HScale.new(adj) scale.set_digits(0) - scale.set_value_pos(gtk.POS_RIGHT) + scale.set_value_pos(Gtk.PositionType.RIGHT) adj.connect("value_changed", self.__ctl_value_changed, (ctl, idx)) self.make_popup(scale, self.__popup_show_ctl, (ctl, idx)) - hbox.pack_start(scale, True, True) + hbox.pack_start(scale, True, True, 0) if vbox1: - vbox1.pack_start(hbox, False, False) + vbox1.pack_start(hbox, False, False, 0) else: - vbox.pack_start(hbox, False, False) + vbox.pack_start(hbox, False, False, 0) idx += 1 frame.add(vbox) return frame @@ -361,15 +363,15 @@ class NodeGui(gtk.ScrolledWindow): self.amp_checkbuttons = {} self.amp_adjs = {} self.mixer_elems = {} - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) c = build_caps('Input Amplifier', node.in_amp and node.amp_caps_in or None, node.in_amp and node.amp_vals_in or None) - hbox.pack_start(c) + hbox.pack_start(c, True, True, 0) c = build_caps('Output Amplifier', node.out_amp and node.amp_caps_out or None, node.out_amp and node.amp_vals_out or None) - hbox.pack_start(c) + hbox.pack_start(c, True, True, 0) return hbox @@ -404,12 +406,12 @@ class NodeGui(gtk.ScrolledWindow): idx1 += 1 def __build_pin(self, node): - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) if node.pincap or node.pincap_vref or node.pincap_eapdbtl: - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) if node.pincap or node.pincap_vref: - frame = gtk.Frame('PIN Caps') + frame = Gtk.Frame.new('PIN Caps') frame.set_border_width(4) str = '' for i in node.pincap: @@ -417,24 +419,24 @@ class NodeGui(gtk.ScrolledWindow): for i in node.pincap_vref: str += 'VREF_%s\n' % i frame.add(self.__new_text_view(text=str)) - vbox.pack_start(frame) + vbox.pack_start(frame, True, True, 0) if 'EAPD' in node.pincap: - frame = gtk.Frame('EAPD') + frame = Gtk.Frame.new('EAPD') frame.set_border_width(4) - vbox1 = gtk.VBox(False, 0) + vbox1 = Gtk.VBox(False, 0) self.pincap_eapdbtls_checkbuttons = [] for name in EAPDBTL_BITS: - checkbutton = gtk.CheckButton(name) + checkbutton = Gtk.CheckButton(name) checkbutton.connect("toggled", self.__pincap_eapdbtl_toggled, (node, name)) self.pincap_eapdbtls_checkbuttons.append(checkbutton) - vbox1.pack_start(checkbutton, False, False) + vbox1.pack_start(checkbutton, False, False, 0) frame.add(vbox1) - vbox.pack_start(frame, False, False) - hbox.pack_start(vbox) + vbox.pack_start(frame, False, False, 0) + hbox.pack_start(vbox, True, True, 0) - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) - frame = gtk.Frame('Config Default') + frame = Gtk.Frame.new('Config Default') frame.set_border_width(4) str = 'Jack connection: %s\n' % node.jack_conn_name str += 'Jack type: %s\n' % node.jack_type_name @@ -445,37 +447,37 @@ class NodeGui(gtk.ScrolledWindow): if 'NO_PRESENCE' in node.defcfg_misc: str += 'No presence\n' frame.add(self.__new_text_view(text=str)) - vbox.pack_start(frame) + vbox.pack_start(frame, True, True, 0) - frame = gtk.Frame('Widget Control') + frame = Gtk.Frame.new('Widget Control') frame.set_border_width(4) - vbox1 = gtk.VBox(False, 0) + vbox1 = Gtk.VBox(False, 0) self.pin_checkbuttons = [] for name in PIN_WIDGET_CONTROL_BITS: - checkbutton = gtk.CheckButton(name) + checkbutton = Gtk.CheckButton(name) checkbutton.connect("toggled", self.__pinctls_toggled, (node, name)) self.pin_checkbuttons.append(checkbutton) - vbox1.pack_start(checkbutton, False, False) + vbox1.pack_start(checkbutton, False, False, 0) if node.pincap_vref: - combobox = gtk.combo_box_new_text() + combobox = Gtk.ComboBoxText() for name in PIN_WIDGET_CONTROL_VREF: if name: combobox.append_text(name) combobox.connect("changed", self.__pinctls_vref_change, node) self.pincap_vref_combobox = combobox - hbox1 = gtk.HBox(False, 0) - label = gtk.Label('VREF') - hbox1.pack_start(label, False, False) - hbox1.pack_start(combobox) - vbox1.pack_start(hbox1, False, False) + hbox1 = Gtk.HBox(False, 0) + label = Gtk.Label(label='VREF') + hbox1.pack_start(label, False, False, 0) + hbox1.pack_start(combobox, True, True, 0) + vbox1.pack_start(hbox1, False, False, 0) frame.add(vbox1) - vbox.pack_start(frame, False, False) + vbox.pack_start(frame, False, False, 0) - hbox.pack_start(vbox) + hbox.pack_start(vbox, True, True, 0) return hbox def __build_mix(self, node): - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) return hbox def __sdi_select_changed(self, adj, node): @@ -506,9 +508,9 @@ class NodeGui(gtk.ScrolledWindow): entry.set_text("0x%02x" % node.dig1_category) def __build_aud(self, node): - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) - frame = gtk.Frame('Converter') + frame = Gtk.Frame.new('Converter') frame.set_border_width(4) str = 'Audio Stream:\t%s\n' % node.aud_stream str += 'Audio Channel:\t%s\n' % node.aud_channel @@ -525,84 +527,84 @@ class NodeGui(gtk.ScrolledWindow): str += 'Global Bits:\t%s\n' % node.codec.pcm_bits str += 'Global Streams:\t%s\n' % node.codec.pcm_streams frame.add(self.__new_text_view(text=str)) - vbox.pack_start(frame) + vbox.pack_start(frame, True, True, 0) if not node.sdi_select is None: - hbox1 = gtk.HBox(False, 0) - frame = gtk.Frame('SDI Select') - adj = gtk.Adjustment(node.sdi_select, 0.0, 16.0, 1.0, 1.0, 1.0) + hbox1 = Gtk.HBox(False, 0) + frame = Gtk.Frame.new() + adj = Gtk.Adjustment(node.sdi_select, 0.0, 16.0, 1.0, 1.0, 1.0) self.sdi_select_adj = adj - scale = gtk.HScale(adj) + scale = Gtk.HScale.new(adj) scale.set_digits(0) - scale.set_value_pos(gtk.POS_LEFT) + scale.set_value_pos(Gtk.PositionType.LEFT) scale.set_size_request(200, 16) adj.connect("value_changed", self.__sdi_select_changed, node) frame.add(scale) - hbox1.pack_start(frame, False, False) - vbox.pack_start(hbox1, False, False) + hbox1.pack_start(frame, False, False, 0) + vbox.pack_start(hbox1, False, False, 0) if node.digital: - hbox1 = gtk.HBox(False, 0) - frame = gtk.Frame('Digital Converter') - vbox1 = gtk.VBox(False, 0) + hbox1 = Gtk.HBox(False, 0) + frame = Gtk.Frame.new('Digital Converter') + vbox1 = Gtk.VBox(False, 0) self.digital_checkbuttons = [] for name in DIG1_BITS: - checkbutton = gtk.CheckButton(name) + checkbutton = Gtk.CheckButton(name) checkbutton.connect("toggled", self.__dig1_toggled, (node, name)) self.digital_checkbuttons.append(checkbutton) - vbox1.pack_start(checkbutton, False, False) + vbox1.pack_start(checkbutton, False, False, 0) frame.add(vbox1) - hbox1.pack_start(frame) - frame = gtk.Frame('Digital Converter Category') - entry = gtk.Entry() + hbox1.pack_start(frame, True, True, 0) + frame = Gtk.Frame.new('Digital Converter Category') + entry = Gtk.Entry() self.dig_category_entry = entry entry.set_width_chars(4) entry.connect("activate", self.__dig1_category_activate, node) frame.add(entry) - hbox1.pack_start(frame) - vbox.pack_start(hbox1, False, False) + hbox1.pack_start(frame, True, True, 0) + vbox.pack_start(hbox1, False, False, 0) return vbox def __build_device(self, device): - vbox = gtk.VBox(False, 0) - frame = gtk.Frame('Device') + vbox = Gtk.VBox(False, 0) + frame = Gtk.Frame.new('Device') frame.set_border_width(4) - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) s = 'name=' + str(device.name) + ', type=' + \ str(device.type) + ', device=' + str(device.device) - label = gtk.Label(s) - hbox.pack_start(label, False, False) + label = Gtk.Label(label=s) + hbox.pack_start(label, False, False, 0) frame.add(hbox) - vbox.pack_start(frame) + vbox.pack_start(frame, True, True, 0) return vbox def __build_controls(self, ctrls): - vbox = gtk.VBox(False, 0) - frame = gtk.Frame('Controls') + vbox = Gtk.VBox(False, 0) + frame = Gtk.Frame.new('Controls') frame.set_border_width(4) - vbox1 = gtk.VBox(False, 0) + vbox1 = Gtk.VBox(False, 0) for ctrl in ctrls: - hbox1 = gtk.HBox(False, 0) - vbox1.pack_start(hbox1, False, False) + hbox1 = Gtk.HBox(False, 0) + vbox1.pack_start(hbox1, False, False, 0) s = (ctrl.iface and ('iface=' + ctrl.iface + ',') or '') + \ 'name=' + str(ctrl.name) + ', index=' + str(ctrl.index) + \ ', device=' + str(ctrl.device) - label = gtk.Label(s) - hbox1.pack_start(label, False, False) + label = Gtk.Label(label=s) + hbox1.pack_start(label, False, False, 0) if ctrl.amp_chs: - hbox1 = gtk.HBox(False, 0) - vbox1.pack_start(hbox1, False, False) + hbox1 = Gtk.HBox(False, 0) + vbox1.pack_start(hbox1, False, False, 0) s = ' chs=' + str(ctrl.amp_chs) + ', dir=' + str(ctrl.amp_dir) + \ ', idx=' + str(ctrl.amp_idx) + ', ofs=' + str(ctrl.amp_ofs) - label = gtk.Label(s) - hbox1.pack_start(label, False, False) + label = Gtk.Label(label=s) + hbox1.pack_start(label, False, False, 0) frame.add(vbox1) - vbox.pack_start(frame) + vbox.pack_start(frame, True, True, 0) return vbox def __build_proc(self, node): - frame = gtk.Frame('Processing Caps') + frame = Gtk.Frame.new('Processing Caps') frame.set_border_width(4) str = 'benign=%i\nnumcoef=%i\n' % (node.proc_benign, node.proc_numcoef) frame.add(self.__new_text_view(text=str)) @@ -665,34 +667,34 @@ class NodeGui(gtk.ScrolledWindow): self.node = node self.mytitle = node.name() if doframe: - mframe = gtk.Frame(self.mytitle) + mframe = Gtk.Frame.new(self.mytitle) mframe.set_border_width(4) else: - mframe = gtk.Table() + mframe = Gtk.Table() - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) dev = node.get_device() if not dev is None: - vbox.pack_start(self.__build_device(dev), False, False) + vbox.pack_start(self.__build_device(dev), False, False,0) ctrls = node.get_controls() if ctrls: node.get_mixercontrols() # workaround - vbox.pack_start(self.__build_controls(ctrls), False, False) - hbox = gtk.HBox(False, 0) - hbox.pack_start(self.__build_node_caps(node)) - hbox.pack_start(self.__build_connection_list(node)) - vbox.pack_start(hbox, False, False) + vbox.pack_start(self.__build_controls(ctrls), False, False,0) + hbox = Gtk.HBox(False, 0) + hbox.pack_start(self.__build_node_caps(node), True, True, 0) + hbox.pack_start(self.__build_connection_list(node), True, True, 0) + vbox.pack_start(hbox, False, False, 0) if node.in_amp or node.out_amp: - vbox.pack_start(self.__build_amps(node), False, False) + vbox.pack_start(self.__build_amps(node), False, False,0) if node.wtype_id == 'PIN': - vbox.pack_start(self.__build_pin(node), False, False) + vbox.pack_start(self.__build_pin(node), False, False,0) elif node.wtype_id in ['AUD_IN', 'AUD_OUT']: - vbox.pack_start(self.__build_aud(node), False, False) + vbox.pack_start(self.__build_aud(node), False, False,0) else: if not node.wtype_id in ['AUD_MIX', 'BEEP', 'AUD_SEL']: print 'Node type %s has no GUI support' % node.wtype_id if node.proc_wid: - vbox.pack_start(self.__build_proc(node), False, False) + vbox.pack_start(self.__build_proc(node), False, False,0) mframe.add(vbox) self.add_with_viewport(mframe) @@ -700,9 +702,9 @@ class NodeGui(gtk.ScrolledWindow): self.read_all = self.__read_all_node def __build_codec_info(self, codec): - vbox = gtk.VBox(False, 0) + vbox = Gtk.VBox(False, 0) - frame = gtk.Frame('Codec Identification') + frame = Gtk.Frame.new('Codec Identification') frame.set_border_width(4) str = 'Audio Fcn Group: %s\n' % (codec.afg and "0x%02x" % codec.afg or "N/A") if codec.afg: @@ -714,9 +716,9 @@ class NodeGui(gtk.ScrolledWindow): str += 'Subsystem ID:\t 0x%08x\n' % codec.subsystem_id str += 'Revision ID:\t 0x%08x\n' % codec.revision_id frame.add(self.__new_text_view(text=str)) - vbox.pack_start(frame, False, False) + vbox.pack_start(frame, False, False,0) - frame = gtk.Frame('PCM Global Capabilities') + frame = Gtk.Frame.new('PCM Global Capabilities') frame.set_border_width(4) str = 'Rates:\t\t %s\n' % codec.pcm_rates[:6] if len(codec.pcm_rates) > 6: @@ -724,14 +726,14 @@ class NodeGui(gtk.ScrolledWindow): str += 'Bits:\t\t %s\n' % codec.pcm_bits str += 'Streams:\t %s\n' % codec.pcm_streams frame.add(self.__new_text_view(text=str)) - vbox.pack_start(frame, False, False) + vbox.pack_start(frame, False, False, 0) return vbox def __build_codec_amps(self, codec): def build_caps(title, caps): - frame = gtk.Frame(title) + frame = Gtk.Frame.new(title) frame.set_border_width(4) if caps and caps.ofs != None: str = 'Offset:\t\t %d\n' % caps.ofs @@ -741,11 +743,11 @@ class NodeGui(gtk.ScrolledWindow): frame.add(self.__new_text_view(text=str)) return frame - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) c = build_caps('Global Input Amplifier Caps', codec.amp_caps_in) - hbox.pack_start(c) + hbox.pack_start(c, True, True, 0) c = build_caps('Global Output Amplifier Caps', codec.amp_caps_out) - hbox.pack_start(c) + hbox.pack_start(c, True, True, 0) return hbox @@ -755,30 +757,30 @@ class NodeGui(gtk.ScrolledWindow): button.set_active(codec.gpio.test(id, idx)) def __build_codec_gpio(self, codec): - frame = gtk.Frame('GPIO') + frame = Gtk.Frame.new('GPIO') frame.set_border_width(4) - hbox = gtk.HBox(False, 0) + hbox = Gtk.HBox(False, 0) str = 'IO Count: %d\n' % codec.gpio_max str += 'O Count: %d\n' % codec.gpio_o str += 'I Count: %d\n' % codec.gpio_i str += 'Unsolicited: %s\n' % (codec.gpio_unsol and "True" or "False") str += 'Wake: %s\n' % (codec.gpio_wake and "True" or "False") - hbox.pack_start(self.__new_text_view(text=str), False, False) + hbox.pack_start(self.__new_text_view(text=str), False, False,0) frame.add(hbox) self.gpio_checkbuttons = [] for id in GPIO_IDS: id1 = id == 'direction' and 'out-dir' or id - frame1 = gtk.Frame(id1) + frame1 = Gtk.Frame.new(id1) frame1.set_border_width(4) - vbox1 = gtk.VBox(False, 0) + vbox1 = Gtk.VBox(False, 0) self.gpio_checkbuttons.append([]) for i in range(codec.gpio_max): - checkbutton = checkbutton = gtk.CheckButton('[%d]' % i) + checkbutton = checkbutton = Gtk.CheckButton('[%d]' % i) checkbutton.connect("toggled", self.__gpio_toggled, (codec, id, i)) self.gpio_checkbuttons[-1].append(checkbutton) - vbox1.pack_start(checkbutton, False, False) + vbox1.pack_start(checkbutton, False, False, 0) frame1.add(vbox1) - hbox.pack_start(frame1, False, False) + hbox.pack_start(frame1, False, False, 0) return frame def __read_all_codec(self): @@ -792,15 +794,15 @@ class NodeGui(gtk.ScrolledWindow): self.codec = codec self.mytitle = codec.name if doframe: - mframe = gtk.Frame(self.mytitle) + mframe = Gtk.Frame.new(self.mytitle) mframe.set_border_width(4) else: - mframe = gtk.Table() + mframe = Gtk.Table() - vbox = gtk.VBox(False, 0) - vbox.pack_start(self.__build_codec_info(codec), False, False) - vbox.pack_start(self.__build_codec_amps(codec), False, False) - vbox.pack_start(self.__build_codec_gpio(codec), False, False) + vbox = Gtk.VBox(False, 0) + vbox.pack_start(self.__build_codec_info(codec), False, False,0) + vbox.pack_start(self.__build_codec_amps(codec), False, False,0) + vbox.pack_start(self.__build_codec_gpio(codec), False, False,0) mframe.add(vbox) self.add_with_viewport(mframe) self.read_all = self.__read_all_codec @@ -816,32 +818,34 @@ class NodeGui(gtk.ScrolledWindow): def __build_card(self, card, doframe=False): self.mytitle = card.name if doframe: - mframe = gtk.Frame(self.mytitle) + mframe = Gtk.Frame.new(self.mytitle) mframe.set_border_width(4) else: - mframe = gtk.Table() + mframe = Gtk.Table() - vbox = gtk.VBox(False, 0) - vbox.pack_start(self.__build_card_info(card), False, False) + vbox = Gtk.VBox(False, 0) + vbox.pack_start(self.__build_card_info(card), False, False,0) mframe.add(vbox) self.add_with_viewport(mframe) -class SimpleProgressDialog(gtk.Dialog): +class SimpleProgressDialog(Gtk.Dialog): def __init__(self, title): - gtk.Dialog.__init__(self, title, None, gtk.DIALOG_MODAL, None) + super(SimpleProgressDialog,self).__init__() + self.set_title(title) + self.set_modal(True) self.set_deletable(False) box = self.get_child() - box.pack_start(gtk.Label(), False, False, 0) - self.progressbar = gtk.ProgressBar() + box.pack_start(Gtk.Label(), False, False, 0) + self.progressbar = Gtk.ProgressBar() box.pack_start(self.progressbar, False, False, 0) def set_fraction(self, fraction): self.progressbar.set_fraction(fraction) - while gtk.events_pending(): - gtk.main_iteration_do(False) + while Gtk.events_pending(): + Gtk.main_iteration_do(False) class TrackWindows: @@ -857,19 +861,19 @@ class TrackWindows: self.windows.remove(win) if not self.windows: self.do_diff(win) - gtk.main_quit() + Gtk.main_quit() def do_diff(self, widget): if do_diff(): - dialog = gtk.MessageDialog(widget, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, + dialog = Gtk.MessageDialog(widget, + Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, + Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "HDA-Analyzer: Would you like to revert\n" "settings for all HDA codecs?") response = dialog.run() dialog.destroy() - if response == gtk.RESPONSE_YES: + if response == Gtk.ResponseType.YES: for card in CODEC_TREE: for codec in CODEC_TREE[card]: CODEC_TREE[card][codec].revert() diff --git a/utils.py b/utils.py index dc86904..2e66a84 100644 --- a/utils.py +++ b/utils.py @@ -114,7 +114,7 @@ def git_read_commits(repo, old, head, kernel_tree=False, reverse=False): a = line.split(': ') commit[a[0].strip()] = a[-1].strip() elif line.startswith(' '): - commit['comment'] += line[4:].strip() + '\n' + commit['comment'] += line[4:].rstrip() + '\n' else: line = line.strip() if line: -- 2.47.1