<commit_before>const Lang = imports.lang;

const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Signals = imports.signals;

const Gettext = imports.gettext.domain('bitcoin-markets');
const _ = Gettext.gettext;

const makeConfigRow = (description, widget) => {
  let box = new Gtk.Box({
    orientation: Gtk.Orientation.HORIZONTAL,
    margin_bottom: 8,
    hexpand: true,
    vexpand: false
  });

  let label = new Gtk.Label({
    label: description,
    xalign: 0,
    expand: true
  });

  box.add(label);
  box.add(widget);

  return box;
};



const ComboBoxView = new Lang.Class({
  Name: "ComboBoxView",

  Columns: { LABEL: 0, VALUE: 1 },

  _init: function (options) {
    let model = new Gtk.ListStore();
    model.set_column_types([GObject.TYPE_STRING]);

    let comboBox = new Gtk.ComboBox({model: model});
    let renderer = new Gtk.CellRendererText();

    comboBox.pack_start(renderer, true);
    comboBox.add_attribute(renderer, 'text', 0);

    this.widget = comboBox;
    this.model = model;
    this.setOptions(options);

    comboBox.connect('changed', (entry) => {
      let i = comboBox.get_active();
      if (i in this._options) {
        this.emit('changed', this._options[i].value);
      }
    });
  },

  setOptions: function (options) {
    this.model.clear();
    this._options = options || [];

    this._options.forEach((o) => {
      let iter;

      this.model.set(
        iter = this.model.append(), [this.Columns.LABEL], [o.label]
      );

      if (o.active) {
        this.widget.set_active_iter(iter);
      }
    });
  }
});
Signals.addSignalMethods(ComboBoxView.prototype);


const makeComboBoxCurrency = (currencies, selected) => {
  let options = currencies.sort().map(
    (c) => ({label: c, value: c, active: (c === selected)})
  );

  return new ComboBoxView(options);
};

const makeComboBoxCoin = (coins, selected) => {
  let options = coins.sort().map(
    (c) => ({label: c, value: c, active: (c === selected)})
  );

  return new ComboBoxView(options);
};<commit_msg>Do not sort currencies and coins alphabetically<commit_after>const Lang = imports.lang;

const Gtk = imports.gi.Gtk;
const GObject = imports.gi.GObject;
const Signals = imports.signals;

const Gettext = imports.gettext.domain('bitcoin-markets');
const _ = Gettext.gettext;

const makeConfigRow = (description, widget) => {
  let box = new Gtk.Box({
    orientation: Gtk.Orientation.HORIZONTAL,
    margin_bottom: 8,
    hexpand: true,
    vexpand: false
  });

  let label = new Gtk.Label({
    label: description,
    xalign: 0,
    expand: true
  });

  box.add(label);
  box.add(widget);

  return box;
};



const ComboBoxView = new Lang.Class({
  Name: "ComboBoxView",

  Columns: { LABEL: 0, VALUE: 1 },

  _init: function (options) {
    let model = new Gtk.ListStore();
    model.set_column_types([GObject.TYPE_STRING]);

    let comboBox = new Gtk.ComboBox({model: model});
    let renderer = new Gtk.CellRendererText();

    comboBox.pack_start(renderer, true);
    comboBox.add_attribute(renderer, 'text', 0);

    this.widget = comboBox;
    this.model = model;
    this.setOptions(options);

    comboBox.connect('changed', (entry) => {
      let i = comboBox.get_active();
      if (i in this._options) {
        this.emit('changed', this._options[i].value);
      }
    });
  },

  setOptions: function (options) {
    this.model.clear();
    this._options = options || [];

    this._options.forEach((o) => {
      let iter;

      this.model.set(
        iter = this.model.append(), [this.Columns.LABEL], [o.label]
      );

      if (o.active) {
        this.widget.set_active_iter(iter);
      }
    });
  }
});
Signals.addSignalMethods(ComboBoxView.prototype);


const makeComboBoxCurrency = (currencies, selected) => {
  let options = currencies.map(
    (c) => ({label: c, value: c, active: (c === selected)})
  );

  return new ComboBoxView(options);
};

const makeComboBoxCoin = (coins, selected) => {
  let options = coins.map(
    (c) => ({label: c, value: c, active: (c === selected)})
  );

  return new ComboBoxView(options);
};
{'fraction_non_alphanumeric': 0.15486077186126038, 'fraction_numerical': 0.002442598925256473, 'mean_word_length': 3.1321897073662965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7294375', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1362, 'n_words': 306}