<commit_before>from ..core.toolwindow import ToolWindow, error_message
from gi.repository import GLib

class Transmission(ToolWindow):
    def on_map(self, window):
        try:
            self._instrument.samplestore.disconnect(self._onlistchangedconnection)
            del self._onlistchangedconnection
        except AttributeError:
            pass
        self._onlistchangedconnection=self._instrument.samplestore.connect('list-changed', self.on_samplelistchanged)
        self.on_samplelistchanged(self._instrument.samplestore)

    def on_unmap(self, window):
        try:
            self._instrument.samplestore.disconnect(self._onlistchangedconnection)
            del self._onlistchangedconnection
        except AttributeError:
            pass

    def on_samplelistchanged(self, samplestore):
        idx=self._builder.get_object('emptyname_combo').get_active()
        try:
            prevselected=self._builder.get_object('samplenamestore')[idx][0]
        except IndexError:
            prevselected=None
        self._builder.get_object('samplenamestore').clear()
        for i,sn in enumerate(sorted(samplestore)):
            self._builder.get_object('samplenamestore').append([sn.title])
            if sn.title==prevselected:
                self._builder.get_object('emptyname_combo').set_active(i)
        if self._builder.get_object('emptyname_combo').get_active()<0:
            self._builder.get_object('emptyname_combo').set_active(0)

    def on_add(self, button):
        self._builder.get_object('transmstore').append(('','','','','','',False,0,-1))

    def on_remove(self, button):
        model, it=self._builder.get_object('transmselection').get_selected()
        if it is not None:
            model.remove(it)

    def on_start(self, button):
        if button.get_label()=='Start':
            self._make_insensitive('Transmission measurement running',['entry_expander', 'transmview', 'add_button', 'remove_button', 'close_button'])
            self._builder.get_object('start_button').set_label('Stop')
            samplenames=', '.join("'%s'"%row[0] for row in self._builder.get_object('transmstore'))
            self._interpreterconnections=[self._instrument.interpreter.connect('cmd-return', self.on_cmd_return),<commit_msg>Transmission GUI: samples are no longer measured in reversed order.<commit_after>from gi.repository import GLib

from ..core.toolwindow import ToolWindow, error_message


class Transmission(ToolWindow):
    def on_map(self, window):
        try:
            self._instrument.samplestore.disconnect(self._onlistchangedconnection)
            del self._onlistchangedconnection
        except AttributeError:
            pass
        self._onlistchangedconnection=self._instrument.samplestore.connect('list-changed', self.on_samplelistchanged)
        self.on_samplelistchanged(self._instrument.samplestore)

    def on_unmap(self, window):
        try:
            self._instrument.samplestore.disconnect(self._onlistchangedconnection)
            del self._onlistchangedconnection
        except AttributeError:
            pass

    def on_samplelistchanged(self, samplestore):
        idx=self._builder.get_object('emptyname_combo').get_active()
        try:
            prevselected=self._builder.get_object('samplenamestore')[idx][0]
        except IndexError:
            prevselected=None
        self._builder.get_object('samplenamestore').clear()
        for i,sn in enumerate(sorted(samplestore)):
            self._builder.get_object('samplenamestore').append([sn.title])
            if sn.title==prevselected:
                self._builder.get_object('emptyname_combo').set_active(i)
        if self._builder.get_object('emptyname_combo').get_active()<0:
            self._builder.get_object('emptyname_combo').set_active(0)

    def on_add(self, button):
        self._builder.get_object('transmstore').append(('','','','','','',False,0,-1))

    def on_remove(self, button):
        model, it=self._builder.get_object('transmselection').get_selected()
        if it is not None:
            model.remove(it)

    def on_start(self, button):
        if button.get_label()=='Start':
            self._make_insensitive('Transmission measurement running',['entry_expander', 'transmview', 'add_button', 'remove_button', 'close_button'])
            self._builder.get_object('start_button').set_label('Stop')
            samplenames = ', '.join("'%s'" % row[0] for row in reversed(self._builder.get_object('transmstore')))
            self._interpreterconnections=[self._instrument.interpreter.connect('cmd-return', self.on_cmd_return),
{'fraction_non_alphanumeric': 0.12093628088426528, 'fraction_numerical': 0.002600780234070221, 'mean_word_length': 3.3414863593603013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '802378', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1335, 'n_words': 191}