a few changes
This commit is contained in:
@ -19,7 +19,7 @@
|
||||
const Main = imports.ui.main;
|
||||
const PopupMenu = imports.ui.popupMenu;
|
||||
const VolumeMenu = imports.ui.status.volume;
|
||||
const {Atk, St, GObject, GLib} = imports.gi;
|
||||
const { Atk, St, GObject, GLib } = imports.gi;
|
||||
|
||||
const Gvc = imports.gi.Gvc;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
@ -29,14 +29,16 @@ const _d = Lib._log;
|
||||
const Prefs = Me.imports.prefs;
|
||||
const SignalManager = Lib.SignalManager;
|
||||
|
||||
let maxId = -1;
|
||||
|
||||
var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
var SoundDeviceChooserBase = class SoundDeviceChooserBase {
|
||||
|
||||
constructor(deviceType) {
|
||||
_d("SDC: init");
|
||||
this.menuItem = new PopupMenu.PopupSubMenuMenuItem ('Extension initialising...', true);
|
||||
this.menuItem = new PopupMenu.PopupSubMenuMenuItem('Extension initialising...', true);
|
||||
this.deviceType = deviceType;
|
||||
this._devices = {};
|
||||
this._cards = [];
|
||||
this._availableDevicesIds = {};
|
||||
this._control = VolumeMenu.getMixerControl();
|
||||
this._settings = Lib.getSettings(Prefs.SETTINGS_SCHEMA);
|
||||
@ -44,9 +46,9 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
this._setLog();
|
||||
this._signalManager = new SignalManager();
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.ENABLE_LOG, this._setLog.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.ENABLE_LOG, this._setLog.bind(this));
|
||||
|
||||
if(this._control.get_state() == Gvc.MixerControlState.READY) {
|
||||
if (this._control.get_state() == Gvc.MixerControlState.READY) {
|
||||
this._onControlStateChanged();
|
||||
}
|
||||
else {
|
||||
@ -54,28 +56,31 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
}
|
||||
|
||||
_setLog(){ Lib.setLog(this._settings.get_boolean(Prefs.ENABLE_LOG));}
|
||||
_setLog() { Lib.setLog(this._settings.get_boolean(Prefs.ENABLE_LOG)); }
|
||||
|
||||
_onControlStateChanged() {
|
||||
if(this._control.get_state() == Gvc.MixerControlState.READY) {
|
||||
if(!this._initialised) {
|
||||
if (this._control.get_state() == Gvc.MixerControlState.READY) {
|
||||
if (!this._initialised) {
|
||||
this._initialised = true;
|
||||
|
||||
this._signalManager.addSignal(this._control, this.deviceType + "-added", this._deviceAdded.bind(this));
|
||||
this._signalManager.addSignal(this._control, this.deviceType + "-removed", this._deviceRemoved.bind(this));
|
||||
this._signalManager.addSignal(this._control, "active-" + this.deviceType + "-update", this._deviceActivated.bind(this));
|
||||
this._signalManager.addSignal(this._control, "card-removed", this._updateCards.bind(this));
|
||||
this._signalManager.addSignal(this._control, "card-added", this._updateCards.bind(this));
|
||||
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.HIDE_ON_SINGLE_DEVICE,this._setChooserVisibility.bind(this) );
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.SHOW_PROFILES , this._setProfileVisibility.bind(this));
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.ICON_THEME , this._setIcons.bind(this));
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.HIDE_MENU_ICONS , this._setIcons.bind(this));
|
||||
this._signalManager.addSignal(this._settings,"changed::" + Prefs.PORT_SETTINGS , this._resetDevices.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.HIDE_ON_SINGLE_DEVICE, this._setChooserVisibility.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.SHOW_PROFILES, this._setProfileVisibility.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.ICON_THEME, this._setIcons.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.HIDE_MENU_ICONS, this._setIcons.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + Prefs.PORT_SETTINGS, this._resetDevices.bind(this));
|
||||
|
||||
this._show_device_signal = Prefs["SHOW_" + this.deviceType.toUpperCase() + "_DEVICES"];
|
||||
this._show_device_signal = Prefs["SHOW_" + this.deviceType.toUpperCase() + "_DEVICES"];
|
||||
|
||||
this._signalManager.addSignal(this._settings,"changed::" + this._show_device_signal, this._setVisibility.bind(this));
|
||||
this._signalManager.addSignal(this._settings, "changed::" + this._show_device_signal, this._setVisibility.bind(this));
|
||||
|
||||
this._portsSettings = JSON.parse(this._settings.get_string(Prefs.PORT_SETTINGS));
|
||||
//this._portsSettings = JSON.parse(this._settings.get_string(Prefs.PORT_SETTINGS));
|
||||
this._portsSettings = Prefs.getPortsFromSettings(this._settings);
|
||||
|
||||
/**
|
||||
* There is no direct way to get all the UI devices from
|
||||
@ -86,33 +91,35 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
*/
|
||||
|
||||
let id = 0;
|
||||
let maxId = -1;
|
||||
let dummyDevice = new Gvc.MixerUIDevice();
|
||||
maxId = dummyDevice.get_id();
|
||||
if (maxId < 0) {
|
||||
let dummyDevice = new Gvc.MixerUIDevice();
|
||||
maxId = dummyDevice.get_id();
|
||||
}
|
||||
_d("Max Id:" + maxId);
|
||||
|
||||
let defaultDevice = this.getDefaultDevice();
|
||||
while(++id < maxId) {
|
||||
while (++id < maxId) {
|
||||
let uidevice = this._deviceAdded(this._control, id);
|
||||
if(uidevice) {
|
||||
if (uidevice) {
|
||||
let stream = this._control.get_stream_from_device(uidevice);
|
||||
if(stream) {
|
||||
if (stream) {
|
||||
let stream_port = stream.get_port();
|
||||
let uidevice_port = uidevice.get_port();
|
||||
|
||||
if(((!stream_port && !uidevice_port) ||
|
||||
(stream_port && stream_port.port === uidevice_port)) &&
|
||||
stream == defaultDevice) {
|
||||
if (((!stream_port && !uidevice_port) ||
|
||||
(stream_port && stream_port.port === uidevice_port)) &&
|
||||
stream == defaultDevice) {
|
||||
this._deviceActivated(this._control, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//We dont have any way to understand that the profile has changed in the settings
|
||||
//Just an useless workaround and potentially crashes shell
|
||||
this.activeProfileTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2000,
|
||||
this._setActiveProfile.bind(this));
|
||||
|
||||
this.activeProfileTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000,
|
||||
this._setActiveProfile.bind(this));
|
||||
|
||||
if(this._controlStateChangeSignal) {
|
||||
if (this._controlStateChangeSignal) {
|
||||
this._controlStateChangeSignal.disconnect();
|
||||
delete this._controlStateChangeSignal;
|
||||
}
|
||||
@ -121,20 +128,30 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
}
|
||||
|
||||
_updateCards(control, cardId) {
|
||||
this._cards = [];
|
||||
let cards = this._control.get_cards();
|
||||
for (let card of cards) {
|
||||
this._cards.push(card.index);
|
||||
}
|
||||
}
|
||||
|
||||
_deviceAdded(control, id, dontcheck) {
|
||||
let obj = this._devices[id];
|
||||
let uidevice = null;
|
||||
|
||||
if(!obj) {
|
||||
if (!obj) {
|
||||
uidevice = this.lookupDeviceById(id);
|
||||
if(!uidevice) {
|
||||
if (!uidevice || !uidevice.port_name || uidevice.description.match(/Dummy\s+(Output|Input)/gi)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
obj = new Object();
|
||||
obj.id = id;
|
||||
obj.uidevice = uidevice;
|
||||
obj.text = uidevice.description;
|
||||
if(uidevice.origin != "")
|
||||
obj.text += " (" + uidevice.origin + ")";
|
||||
if (uidevice.origin != "")
|
||||
obj.text += " - " + uidevice.origin;
|
||||
|
||||
/*
|
||||
* obj.item = this.menu.addAction( obj.text, function() {
|
||||
@ -146,19 +163,20 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
*/
|
||||
|
||||
let icon = uidevice.get_icon_name();
|
||||
if(icon == null || icon.trim() == "")
|
||||
if (icon == null || icon.trim() == "")
|
||||
icon = this.getDefaultIcon();
|
||||
let icon_name = this._getIcon(icon);
|
||||
|
||||
obj.item = this.menuItem.menu.addAction( obj.text, function() {
|
||||
obj.item = this.menuItem.menu.addAction(obj.text, function() {
|
||||
_d("Device Change request");
|
||||
this.changeDevice(uidevice);
|
||||
}.bind(this), icon_name);
|
||||
|
||||
if(!obj.profiles) {
|
||||
if (!obj.profiles) {
|
||||
obj.profiles = Lib.getProfiles(control, uidevice);
|
||||
}
|
||||
|
||||
if(!obj.profilesitems) {
|
||||
if (!obj.profilesitems) {
|
||||
obj.profilesitems = [];
|
||||
}
|
||||
this._devices[id] = obj;
|
||||
@ -175,27 +193,38 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
}
|
||||
|
||||
if(obj.active) {
|
||||
if (obj.active) {
|
||||
return uidevice;
|
||||
}
|
||||
|
||||
_d("Added: " + id + ":" + uidevice.description + ":" + uidevice.port_name);
|
||||
if(!this._availableDevicesIds[id]){
|
||||
_d("Added: " + id + ":" + uidevice.description + ":" + uidevice.port_name + ":" + obj.uidevice.origin);
|
||||
if (!this._availableDevicesIds[id]) {
|
||||
this._availableDevicesIds[id] = 0;
|
||||
}
|
||||
this._availableDevicesIds[id] ++;
|
||||
this._availableDevicesIds[id]++;
|
||||
|
||||
obj.active = true;
|
||||
obj.activeProfile = uidevice.get_active_profile();
|
||||
let showProfiles = this._settings.get_boolean(Prefs.SHOW_PROFILES);
|
||||
let stream = this._control.get_stream_from_device(uidevice);
|
||||
if (stream) {
|
||||
obj.activeProfile = uidevice.get_active_profile();
|
||||
}
|
||||
else {
|
||||
obj.activeProfile = "";
|
||||
}
|
||||
//let showProfiles = this._settings.get_boolean(Prefs.SHOW_PROFILES);
|
||||
if (obj.profiles) {
|
||||
for (let profile of obj.profiles) {
|
||||
let profileItem = obj.profilesitems[profile.name];
|
||||
if(!profileItem) {
|
||||
if (!profileItem) {
|
||||
let profileName = profile.name;
|
||||
profileItem = this.menuItem.menu.addAction( "Profile: " + profile.human_name, function() {
|
||||
profileItem = this.menuItem.menu.addAction("Profile: " + profile.human_name, function() {
|
||||
_d("i am setting profile, " + profile.human_name + ":" + uidevice.description + ":" + uidevice.port_name);
|
||||
if(this._activeDevice && this._activeDevice.uidevice !== uidevice) {
|
||||
let stream = this._control.get_stream_from_device(uidevice);
|
||||
//No Active stream probably inactive port
|
||||
if (!stream) {
|
||||
return;
|
||||
}
|
||||
if (this._activeDevice && this._activeDevice.uidevice !== uidevice) {
|
||||
_d("Changing active device to " + uidevice.description + ":" + uidevice.port_name);
|
||||
this.changeDevice(uidevice);
|
||||
}
|
||||
@ -205,10 +234,10 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
obj.profilesitems[profileName] = profileItem;
|
||||
profileItem.setProfileActive = function(active) {
|
||||
if(active) {
|
||||
if (active) {
|
||||
// this._ornamentLabel.text = "\u2727";
|
||||
this._ornamentLabel.text = "\u266A";
|
||||
if(this.add_style_pseudo_class) {
|
||||
if (this.add_style_pseudo_class) {
|
||||
this.add_style_pseudo_class('checked');
|
||||
this.remove_style_pseudo_class('insensitive');
|
||||
}
|
||||
@ -219,7 +248,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
else {
|
||||
this._ornamentLabel.text = "";
|
||||
if(this.add_style_pseudo_class) {
|
||||
if (this.add_style_pseudo_class) {
|
||||
this.remove_style_pseudo_class('checked');
|
||||
this.add_style_pseudo_class('insensitive');
|
||||
}
|
||||
@ -235,7 +264,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
profileItem.setProfileActive(obj.activeProfile == profile.name);
|
||||
}
|
||||
}
|
||||
if (!dontcheck && !this._canShowDevice(uidevice, uidevice.port_available)) {
|
||||
if (!dontcheck && !this._canShowDevice(uidevice, uidevice.port_available)) {
|
||||
this._deviceRemoved(control, id, true);
|
||||
}
|
||||
this._setChooserVisibility();
|
||||
@ -245,25 +274,26 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
_deviceRemoved(control, id, dontcheck) {
|
||||
let obj = this._devices[id];
|
||||
if(obj && obj.active) {
|
||||
_d("Removed: " + id);
|
||||
if(!dontcheck && this._canShowDevice(obj.uidevice, false)) {
|
||||
//delete this._devices[id];
|
||||
if (obj && obj.active) {
|
||||
_d("Removed: " + id + ":" + obj.uidevice.description + ":" + obj.uidevice.port_name + ":" + obj.uidevice.origin);
|
||||
if (!dontcheck && this._canShowDevice(obj.uidevice, false)) {
|
||||
_d('Device removed, but not hiding as its set to be shown always');
|
||||
return;
|
||||
}
|
||||
delete this._availableDevicesIds[id] ;
|
||||
delete this._availableDevicesIds[id];
|
||||
obj.item.actor.visible = false;
|
||||
obj.active = false;
|
||||
if (obj.profiles) {
|
||||
for (let profile of obj.profiles) {
|
||||
let profileItem = obj.profilesitems[profile.name];
|
||||
if(profileItem) {
|
||||
if (profileItem) {
|
||||
profileItem.actor.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.deviceRemovedTimout) {
|
||||
if (this.deviceRemovedTimout) {
|
||||
GLib.source_remove(this.deviceRemovedTimout);
|
||||
this.deviceRemovedTimout = null;
|
||||
}
|
||||
@ -273,11 +303,12 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
* when the uidevice is removed, Speakers are automatically
|
||||
* activated. So, lets wait for sometime before activating.
|
||||
*/
|
||||
this.deviceRemovedTimout = GLib.timeout_add(GLib.PRIORITY_DEFAULT,1500, function() {
|
||||
this.deviceRemovedTimout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1500, function() {
|
||||
_d("Device Removed timeout");
|
||||
if (obj === this._activeDevice) {
|
||||
for ( let id in this._devices) {
|
||||
for (let id in this._devices) {
|
||||
let device = this._devices[id];
|
||||
if(device.active == true) {
|
||||
if (device.active == true) {
|
||||
this.changeDevice(device.uidevice);
|
||||
break;
|
||||
}
|
||||
@ -293,11 +324,11 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
_deviceActivated(control, id) {
|
||||
let obj = this._devices[id];
|
||||
if(obj && obj !== this._activeDevice) {
|
||||
_d("Activated: " + id);
|
||||
if(this._activeDevice) {
|
||||
if (obj && obj !== this._activeDevice) {
|
||||
_d("Activated: " + id + ":" + obj.uidevice.description + ":" + obj.uidevice.port_name + ":" + obj.uidevice.origin);
|
||||
if (this._activeDevice) {
|
||||
this._activeDevice.item.setOrnament(PopupMenu.Ornament.NONE);
|
||||
if(this._activeDevice.item.remove_style_pseudo_class) {
|
||||
if (this._activeDevice.item.remove_style_pseudo_class) {
|
||||
this._activeDevice.item.remove_style_pseudo_class('checked');
|
||||
}
|
||||
else {
|
||||
@ -306,7 +337,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
this._activeDevice = obj;
|
||||
obj.item.setOrnament(PopupMenu.Ornament.CHECK);
|
||||
if(obj.item.add_style_pseudo_class) {
|
||||
if (obj.item.add_style_pseudo_class) {
|
||||
obj.item.add_style_pseudo_class('checked');
|
||||
}
|
||||
else {
|
||||
@ -318,7 +349,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
if (!this._settings.get_boolean(Prefs.HIDE_MENU_ICONS)) {
|
||||
let icon = obj.uidevice.get_icon_name();
|
||||
if(icon == null || icon.trim() == "")
|
||||
if (icon == null || icon.trim() == "")
|
||||
icon = this.getDefaultIcon();
|
||||
this.menuItem.icon.icon_name = this._getIcon(icon);
|
||||
} else {
|
||||
@ -328,21 +359,27 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
|
||||
_setActiveProfile() {
|
||||
for (let id in this._devices) {
|
||||
//_d("Setting Active Profile");
|
||||
/*for (let id in this._devices) {
|
||||
let device = this._devices[id];
|
||||
if(device.active) {
|
||||
if (device.active) {
|
||||
this._setDeviceActiveProfile(device);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
this._setDeviceActiveProfile(this._activeDevice);
|
||||
return true;
|
||||
}
|
||||
|
||||
_setDeviceActiveProfile(device) {
|
||||
if (!device.uidevice.port_name) {
|
||||
if (!device.uidevice.port_name || !this._availableDevicesIds[device.id]) {
|
||||
return;
|
||||
}
|
||||
let stream = this._control.get_stream_from_device(device.uidevice);
|
||||
if (stream) {
|
||||
return;
|
||||
}
|
||||
let activeProfile = device.uidevice.get_active_profile();
|
||||
if(activeProfile && device.activeProfile != activeProfile) {
|
||||
if (activeProfile && device.activeProfile != activeProfile) {
|
||||
device.activeProfile = activeProfile;
|
||||
for (let profile of device.profiles) {
|
||||
device.profilesitems[profile.name].setProfileActive(profile.name == device.activeProfile);
|
||||
@ -373,7 +410,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
let visibility = this._settings.get_boolean(Prefs.SHOW_PROFILES);
|
||||
for (let id in this._availableDevicesIds) {
|
||||
let device = this._devices[id];
|
||||
if ( device.profiles ) {
|
||||
if (device.profiles) {
|
||||
for (let profile of device.profiles) {
|
||||
device.profilesitems[profile.name].actor.visible =
|
||||
(visibility && device.item.actor.visible && Object.keys(device.profilesitems).length > 1);
|
||||
@ -385,12 +422,12 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
_getIcon(name) {
|
||||
let iconsType = this._settings.get_string(Prefs.ICON_THEME);
|
||||
switch (iconsType) {
|
||||
case Prefs.ICON_THEME_COLORED:
|
||||
return name;
|
||||
case Prefs.ICON_THEME_MONOCHROME:
|
||||
return name + "-symbolic";
|
||||
default:
|
||||
return "none";
|
||||
case Prefs.ICON_THEME_COLORED:
|
||||
return name;
|
||||
case Prefs.ICON_THEME_MONOCHROME:
|
||||
return name + "-symbolic";
|
||||
default:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,7 +436,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
for (let id in this._devices) {
|
||||
let device = this._devices[id];
|
||||
let icon = device.uidevice.get_icon_name();
|
||||
if(icon == null || icon.trim() == "")
|
||||
if (icon == null || icon.trim() == "")
|
||||
icon = this.getDefaultIcon();
|
||||
// device.item._icon.icon_name = this._getIcon(icon);
|
||||
device.item.setIcon(this._getIcon(icon));
|
||||
@ -409,7 +446,7 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
// Gnome menu, not in the list.
|
||||
if (!this._settings.get_boolean(Prefs.HIDE_MENU_ICONS)) {
|
||||
let icon = this._activeDevice.uidevice.get_icon_name();
|
||||
if(icon == null || icon.trim() == "")
|
||||
if (icon == null || icon.trim() == "")
|
||||
icon = this.getDefaultIcon();
|
||||
|
||||
this.menuItem.icon.icon_name = this._getIcon(icon);
|
||||
@ -420,21 +457,39 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
|
||||
_canShowDevice(uidevice, defaultValue) {
|
||||
if(!uidevice || !this._portsSettings || uidevice.port_name == null || uidevice.description == null) {
|
||||
if (!uidevice || !this._portsSettings || uidevice.port_name == null || uidevice.description == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
let stream = this._control.get_stream_from_device(uidevice);
|
||||
let cardName = null;
|
||||
if (stream) {
|
||||
let cardId = stream.get_card_index();
|
||||
if (cardId != null) {
|
||||
_d("Card Index" + cardId);
|
||||
let _card = Lib.getCard(cardId);
|
||||
if (_card) {
|
||||
cardName = _card.name;
|
||||
}
|
||||
else {
|
||||
//card id found, but not available in list
|
||||
return false;
|
||||
}
|
||||
_d("Card Name" + cardName);
|
||||
}
|
||||
}
|
||||
|
||||
for (let port of this._portsSettings) {
|
||||
if(port && port.name == uidevice.port_name && port.human_name == uidevice.description) {
|
||||
switch(port.display_option) {
|
||||
case 1:
|
||||
return true;
|
||||
//_d("P" + port.name + "==" + uidevice.port_name + "==" + port.human_name + "==" + uidevice.description + "==" + cardName + "==" + port.card_name)
|
||||
if (port && port.name == uidevice.port_name && port.human_name == uidevice.description && (!cardName || cardName == port.card_name)) {
|
||||
switch (port.display_option) {
|
||||
case 1:
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
return false;
|
||||
case 2:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return defaultValue;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -442,25 +497,26 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
}
|
||||
|
||||
_resetDevices() {
|
||||
this._portsSettings = JSON.parse(this._settings.get_string(Prefs.PORT_SETTINGS));
|
||||
//this._portsSettings = JSON.parse(this._settings.get_string(Prefs.PORT_SETTINGS));
|
||||
this._portsSettings = Prefs.getPortsFromSettings(this._settings);
|
||||
for (let id in this._devices) {
|
||||
let device = this._devices[id];
|
||||
let uidevice = device.uidevice;
|
||||
if(uidevice.port_name == null || uidevice.description == null) {
|
||||
if (uidevice.port_name == null || uidevice.description == null) {
|
||||
continue;
|
||||
}
|
||||
switch(this._canShowDevice(uidevice, uidevice.port_available)) {
|
||||
case true:
|
||||
this._deviceAdded(this._control, uidevice.get_id(), true);
|
||||
break;
|
||||
case false:
|
||||
this._deviceRemoved(this._control, uidevice.get_id(), true);
|
||||
break;
|
||||
switch (this._canShowDevice(uidevice, uidevice.port_available)) {
|
||||
case true:
|
||||
this._deviceAdded(this._control, uidevice.get_id(), true);
|
||||
break;
|
||||
case false:
|
||||
this._deviceRemoved(this._control, uidevice.get_id(), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_setVisibility () {
|
||||
_setVisibility() {
|
||||
if (!this._settings.get_boolean(this._show_device_signal))
|
||||
this.menuItem.actor.visible = false;
|
||||
else
|
||||
@ -471,11 +527,11 @@ var SoundDeviceChooserBase = class SoundDeviceChooserBase{
|
||||
|
||||
destroy() {
|
||||
this._signalManager.disconnectAll();
|
||||
if(this.deviceRemovedTimout) {
|
||||
if (this.deviceRemovedTimout) {
|
||||
GLib.source_remove(this.deviceRemovedTimout);
|
||||
this.deviceRemovedTimout = null;
|
||||
}
|
||||
if(this.activeProfileTimeout) {
|
||||
if (this.activeProfileTimeout) {
|
||||
GLib.source_remove(this.activeProfileTimeout);
|
||||
this.activeProfileTimeout = null;
|
||||
}
|
||||
|
@ -27,11 +27,11 @@ const Prefs = Me.imports.prefs;
|
||||
var DEBUG = false;
|
||||
|
||||
var logWrap;
|
||||
if(log != undefined){
|
||||
logWrap = log;
|
||||
if (log != undefined) {
|
||||
logWrap = log;
|
||||
}
|
||||
else {
|
||||
logWrap = global.log
|
||||
logWrap = global.log
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,42 +57,48 @@ function getSettings(schema) {
|
||||
let schemaDir = Me.dir.get_child('schemas');
|
||||
let schemaSource;
|
||||
if (schemaDir.query_exists(null))
|
||||
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(),GioSSS.get_default(),false);
|
||||
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(), GioSSS.get_default(), false);
|
||||
else
|
||||
schemaSource = GioSSS.get_default();
|
||||
|
||||
let schemaObj = schemaSource.lookup(schema, true);
|
||||
if (!schemaObj)
|
||||
throw new Error('Schema ' + schema + ' could not be found for extension '
|
||||
+ Me.metadata.uuid + '. Please check your installation.');
|
||||
+ Me.metadata.uuid + '. Please check your installation.');
|
||||
|
||||
let _settings = new Gio.Settings({ settings_schema: schemaObj });
|
||||
return _settings;
|
||||
}
|
||||
|
||||
let cards;
|
||||
function getProfiles(control, uidevice)
|
||||
{
|
||||
|
||||
function getCard(card_index) {
|
||||
if (!cards || Object.keys(cards).length == 0) {
|
||||
refreshCards();
|
||||
}
|
||||
return cards[card_index];
|
||||
}
|
||||
|
||||
|
||||
function getProfiles(control, uidevice) {
|
||||
let stream = control.lookup_stream_id(uidevice.get_stream_id());
|
||||
if(stream) {
|
||||
if(!cards || Object.keys(cards).length == 0 || !cards[stream.card_index]) {
|
||||
if (stream) {
|
||||
if (!cards || Object.keys(cards).length == 0 || !cards[stream.card_index]) {
|
||||
refreshCards();
|
||||
}
|
||||
|
||||
if(cards && cards[stream.card_index]) {
|
||||
_log("Getting profile form stream id " + uidevice.port_name );
|
||||
if (cards && cards[stream.card_index]) {
|
||||
_log("Getting profile form stream id " + uidevice.port_name);
|
||||
return getProfilesForPort(uidevice.port_name, cards[stream.card_index]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* Device is not active device, lets try match with port name */
|
||||
refreshCards();
|
||||
for (let id in cards) {
|
||||
let profiles;
|
||||
_log("Getting profile from cards " + uidevice.port_name + " for card id " + id);
|
||||
if((profiles = getProfilesForPort(uidevice.port_name, cards[id])))
|
||||
{
|
||||
_log("Getting profile from cards " + uidevice.port_name + " for card id " + id);
|
||||
if ((profiles = getProfilesForPort(uidevice.port_name, cards[id]))) {
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
@ -103,20 +109,20 @@ function getProfiles(control, uidevice)
|
||||
|
||||
let ports;
|
||||
function getPorts(refresh) {
|
||||
if(!ports || ports.length == 0 || refresh) {
|
||||
if (!ports || ports.length == 0 || refresh) {
|
||||
refreshCards();
|
||||
}
|
||||
return ports;
|
||||
}
|
||||
|
||||
function isCmdFound(cmd){
|
||||
function isCmdFound(cmd) {
|
||||
try {
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync(cmd);
|
||||
return true;
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync(cmd);
|
||||
return true;
|
||||
}
|
||||
catch(e) {
|
||||
_log('ERROR: '+ cmd +' execution failed. ' + e);
|
||||
return false;
|
||||
catch (e) {
|
||||
_log('ERROR: ' + cmd + ' execution failed. ' + e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,58 +132,60 @@ function refreshCards() {
|
||||
// if(_settings == null) {getSettings(Prefs.SETTINGS_SCHEMA);}
|
||||
let _settings = getSettings(Prefs.SETTINGS_SCHEMA);
|
||||
let error = false;
|
||||
if(_settings.get_boolean(Prefs.NEW_PROFILE_ID)) {
|
||||
let newProfLogic = _settings.get_boolean(Prefs.NEW_PROFILE_ID);
|
||||
if (newProfLogic) {
|
||||
_log("New logic");
|
||||
let pyLocation = Me.dir.get_child('utils/pa_helper.py').get_path();
|
||||
let pyLocation = Me.dir.get_child('utils/pa_helper.py').get_path();
|
||||
let pythonExec = 'python';
|
||||
let pyVer = 3;
|
||||
while(!isCmdFound(pythonExec) && pyVer >=2){
|
||||
while (!isCmdFound(pythonExec) && pyVer >= 2) {
|
||||
_log(pythonExec + " is not found. Try next");
|
||||
pythonExec = 'python' + pyVer--;
|
||||
}
|
||||
|
||||
if(pyVer <= 1) {
|
||||
|
||||
if (pyVer <= 1) {
|
||||
_log('ERROR: Python not found. fallback to default mode' + e);
|
||||
_settings.set_boolean(Prefs.NEW_PROFILE_ID, false);
|
||||
Gio.Settings.sync();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync(pythonExec+ ' ' + pyLocation);
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync(pythonExec + ' ' + pyLocation);
|
||||
// _log("result" + result +" out"+out + " exit_code" +
|
||||
// exit_code + "err" +err);
|
||||
if(result && !exit_code) {
|
||||
if (result && !exit_code) {
|
||||
if (out instanceof Uint8Array) {
|
||||
out = ByteArray.toString(out);
|
||||
}
|
||||
let obj = JSON.parse(out);
|
||||
cards = obj['cards'];
|
||||
ports = obj['ports'];
|
||||
ports = obj['ports'];
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
catch (e) {
|
||||
error = true;
|
||||
_log('ERROR: Python execution failed. fallback to default mode' + e);
|
||||
_settings.set_boolean(Prefs.NEW_PROFILE_ID, false);
|
||||
Gio.Settings.sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!_settings.get_boolean(Prefs.NEW_PROFILE_ID) || error){
|
||||
try {
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync('pactl list cards');
|
||||
if(result && !exit_code) {
|
||||
parseOutput(out);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
_log('ERROR: pactl execution failed. No ports/profiles will be displayed');
|
||||
}
|
||||
//error = true;
|
||||
if (!newProfLogic || error) {
|
||||
try {
|
||||
let [result, out, err, exit_code] = GLib.spawn_command_line_sync('pactl list cards');
|
||||
if (result && !exit_code) {
|
||||
parseOutput(out);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
_log('ERROR: pactl execution failed. No ports/profiles will be displayed');
|
||||
}
|
||||
}
|
||||
// _log(JSON.stringify(cards));
|
||||
// _log(JSON.stringify(ports));
|
||||
|
||||
//_log(Array.isArray(cards));
|
||||
//_log(JSON.stringify(cards));
|
||||
//_log(Array.isArray(ports));
|
||||
//_log(JSON.stringify(ports));
|
||||
}
|
||||
|
||||
function parseOutput(out) {
|
||||
@ -193,40 +201,55 @@ function parseOutput(out) {
|
||||
let port;
|
||||
let matches;
|
||||
// _log("Unmatched line:" + out);
|
||||
while(lines.length > 0) {
|
||||
while (lines.length > 0) {
|
||||
let line = lines.shift();
|
||||
|
||||
if( (matches = /^Card\s#(\d+)$/.exec(line) )) {
|
||||
if ((matches = /^Card\s#(\d+)$/.exec(line))) {
|
||||
cardIndex = matches[1];
|
||||
if(!cards[cardIndex]) {
|
||||
cards[cardIndex] = {'index':cardIndex,'profiles':[], 'ports':[]};
|
||||
if (!cards[cardIndex]) {
|
||||
cards[cardIndex] = { 'index': cardIndex, 'profiles': [], 'ports': [] };
|
||||
}
|
||||
}
|
||||
else if (line.match(/^\t*Profiles:$/) ) {
|
||||
else if ((matches = /^\t*Name:\s+(.*?)$/.exec(line)) && cards[cardIndex]) {
|
||||
cards[cardIndex].name = matches[1];
|
||||
parseSection = "CARDS"
|
||||
}
|
||||
else if (line.match(/^\tProperties:$/) && parseSection == "CARDS") {
|
||||
parseSection = "PROPS";
|
||||
}
|
||||
else if (line.match(/^\t*Profiles:$/)) {
|
||||
parseSection = "PROFILES";
|
||||
}
|
||||
else if (line.match(/^\t*Ports:$/)) {
|
||||
parseSection = "PORTS";
|
||||
}
|
||||
else if(cards[cardIndex]) {
|
||||
switch(parseSection) {
|
||||
case "PROFILES":
|
||||
if((matches = /.*?((?:output|input)[^+]*?):\s(.*?)\s\(sinks:/.exec(line))) {
|
||||
cards[cardIndex].profiles.push({'name': matches[1], 'human_name': matches[2]});
|
||||
}
|
||||
break;
|
||||
case "PORTS":
|
||||
if((matches = /\t*(.*?):\s(.*?)\s\(priority:/.exec(line))) {
|
||||
port = {'name' : matches[1], 'human_name' : matches[2]};
|
||||
cards[cardIndex].ports.push(port);
|
||||
ports.push({'name' : matches[1], 'human_name' : matches[2]});
|
||||
}
|
||||
else if( port && (matches = /\t*Part of profile\(s\):\s(.*)/.exec(line))) {
|
||||
let profileStr = matches[1];
|
||||
port.profiles = profileStr.split(', ');
|
||||
port = null;
|
||||
}
|
||||
break;
|
||||
else if (cards[cardIndex]) {
|
||||
switch (parseSection) {
|
||||
case "PROPS":
|
||||
if ((matches = /alsa\.card_name\s+=\s+"(.*?)"/.exec(line))) {
|
||||
cards[cardIndex].alsa_name = matches[1];
|
||||
}
|
||||
else if((matches = /device\.description\s+=\s+"(.*?)"/.exec(line))) {
|
||||
cards[cardIndex].card_description = matches[1];
|
||||
}
|
||||
break;
|
||||
case "PROFILES":
|
||||
if ((matches = /.*?((?:output|input)[^+]*?):\s(.*?)\s\(sinks:/.exec(line))) {
|
||||
cards[cardIndex].profiles.push({ 'name': matches[1], 'human_name': matches[2] });
|
||||
}
|
||||
break;
|
||||
case "PORTS":
|
||||
if ((matches = /\t*(.*?):\s(.*?)\s\(.*?priority:/.exec(line))) {
|
||||
port = { 'name': matches[1], 'human_name': matches[2], 'card_name': cards[cardIndex].name, 'card_description' : cards[cardIndex].card_description };
|
||||
cards[cardIndex].ports.push(port);
|
||||
ports.push(port);
|
||||
}
|
||||
else if (port && (matches = /\t*Part of profile\(s\):\s(.*)/.exec(line))) {
|
||||
let profileStr = matches[1];
|
||||
port.profiles = profileStr.split(', ');
|
||||
port = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,7 +268,7 @@ var Signal = class Signal {
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if(this._signalId) {
|
||||
if (this._signalId) {
|
||||
this._signalSource.disconnect(this._signalId);
|
||||
this._signalId = null;
|
||||
}
|
||||
@ -260,12 +283,12 @@ var SignalManager = class SignalManager {
|
||||
|
||||
addSignal(signalSource, signalName, callback) {
|
||||
let obj = null;
|
||||
if(signalSource && signalName && callback) {
|
||||
if (signalSource && signalName && callback) {
|
||||
obj = new Signal(signalSource, signalName, callback);
|
||||
obj.connect();
|
||||
this._signals.push(obj);
|
||||
let sourceSignals = this._signalsBySource[signalSource]
|
||||
if(!sourceSignals) {
|
||||
if (!sourceSignals) {
|
||||
sourceSignals = [];
|
||||
this._signalsBySource[signalSource] = sourceSignals;
|
||||
}
|
||||
@ -276,13 +299,13 @@ var SignalManager = class SignalManager {
|
||||
}
|
||||
|
||||
disconnectAll() {
|
||||
for (let signal of this._signals){
|
||||
for (let signal of this._signals) {
|
||||
signal.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
disconnectBySource(signalSource) {
|
||||
if(this._signalsBySource[signalSource]) {
|
||||
if (this._signalsBySource[signalSource]) {
|
||||
for (let signal of this._signalsBySource[signalSource]) {
|
||||
signal.disconnect();
|
||||
}
|
||||
@ -292,15 +315,15 @@ var SignalManager = class SignalManager {
|
||||
|
||||
|
||||
function getProfilesForPort(portName, card) {
|
||||
if(card.ports) {
|
||||
if (card.ports) {
|
||||
for (let port of card.ports) {
|
||||
if(portName === port.name) {
|
||||
if (portName === port.name) {
|
||||
let profiles = [];
|
||||
if (port.profiles) {
|
||||
for (let profile of port.profiles) {
|
||||
if(profile.indexOf('+input:') == -1) {
|
||||
if (profile.indexOf('+input:') == -1) {
|
||||
for (let cardProfile of card.profiles) {
|
||||
if(profile === cardProfile.name) {
|
||||
if (profile === cardProfile.name) {
|
||||
profiles.push(cardProfile);
|
||||
}
|
||||
}
|
||||
@ -319,7 +342,7 @@ function setLog(value) {
|
||||
}
|
||||
|
||||
function _log(msg) {
|
||||
if ( DEBUG == true ) {
|
||||
if (DEBUG == true) {
|
||||
// global.log("SDC Debug: " + msg);
|
||||
logWrap("SDC Debug: " + msg);
|
||||
}
|
||||
@ -327,11 +350,11 @@ function _log(msg) {
|
||||
|
||||
function dump(obj) {
|
||||
var propValue;
|
||||
for(var propName in obj) {
|
||||
try{
|
||||
for (var propName in obj) {
|
||||
try {
|
||||
propValue = obj[propName];
|
||||
_log(propName + propValue);
|
||||
_log(propName + "=" + propValue);
|
||||
}
|
||||
catch(e){_log(propName + "!!!Error!!!");}
|
||||
}
|
||||
catch (e) { _log(propName + "!!!Error!!!"); }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-09-24 23:47+0200\n"
|
||||
"PO-Revision-Date: 2020-09-02 18:22+0200\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.4.1\n"
|
||||
"Last-Translator: Heimen Stoffels <vistausss@outlook.com>\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: nl\n"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:15
|
||||
msgid "Monochrome"
|
||||
msgstr "Monochroom"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:19
|
||||
msgid "Colored"
|
||||
msgstr "Gekleurd"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:23
|
||||
msgid "None"
|
||||
msgstr "Geen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:100
|
||||
msgid "Hide selector if there's only one device"
|
||||
msgstr "Keuzemenu verbergen als er slechts één apparaat is"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:142
|
||||
msgid "Display audio profiles for selection"
|
||||
msgstr "Audioprofielen tonen in keuzemenu"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:175
|
||||
msgid "General Settings"
|
||||
msgstr "Algemene instellingen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:220
|
||||
msgid "Show output devices"
|
||||
msgstr "Uitvoerapparaten tonen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:253
|
||||
msgid "Output Devices"
|
||||
msgstr "Uitvoerapparaten"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:300
|
||||
msgid "Show input devices"
|
||||
msgstr "Invoerapparaten tonen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:343
|
||||
msgid "Show volume control for default device"
|
||||
msgstr "Volumebediening van standaardapparaat tonen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:376
|
||||
msgid "Input Devices"
|
||||
msgstr "Invoerapparaten"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:422
|
||||
msgid "Icon Theme"
|
||||
msgstr "Pictogramthema"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:472
|
||||
msgid "Display icons only in selection list"
|
||||
msgstr "Alleen pictogrammen tonen in keuzelijst"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:504
|
||||
msgid "Icons"
|
||||
msgstr "Pictogrammen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:549
|
||||
msgid "Enable Log messages"
|
||||
msgstr "Logboek bijhouden"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:588
|
||||
msgid "Enable new profile identification "
|
||||
msgstr "Nieuwe profielidentificatie inschakelen "
|
||||
|
||||
#: prefs-dialog.gtkbuilder:620
|
||||
msgid "Miscellaneous"
|
||||
msgstr "Overig"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:688
|
||||
msgid "Name"
|
||||
msgstr "Naam"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:702
|
||||
msgid "Show"
|
||||
msgstr "Tonen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:716
|
||||
msgid "Hide"
|
||||
msgstr "Verbergen"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:730
|
||||
msgid "Default"
|
||||
msgstr "Standaard"
|
||||
|
||||
#: prefs-dialog.gtkbuilder:756
|
||||
msgid "Port Settings"
|
||||
msgstr "Poortinstellingen"
|
@ -11,5 +11,5 @@
|
||||
],
|
||||
"url": "https://github.com/kgshank/gse-sound-output-device-chooser",
|
||||
"uuid": "sound-output-device-chooser@kgshank.net",
|
||||
"version": 32
|
||||
"version": 33
|
||||
}
|
@ -48,7 +48,55 @@ var ICON_THEME_COLORED = "colored";
|
||||
var ICON_THEME_MONOCHROME = "monochrome";
|
||||
var ICON_THEME_NONE = "none";
|
||||
|
||||
function init(){}
|
||||
const PORT_SETTINGS_VERSION = 2;
|
||||
|
||||
function init() { }
|
||||
|
||||
function getPortsFromSettings(_settings) {
|
||||
let obj = JSON.parse(_settings.get_string(PORT_SETTINGS));
|
||||
let currentSettingsVersion = PORT_SETTINGS_VERSION;
|
||||
if (Array.isArray(obj)) {
|
||||
currentSettingsVersion = 1;
|
||||
}
|
||||
if (currentSettingsVersion < PORT_SETTINGS_VERSION) {
|
||||
obj = migratePortSettings(currentSettingsVersion, obj, _settings);
|
||||
}
|
||||
return obj.ports;
|
||||
}
|
||||
|
||||
function setPortsSettings(ports,_settings) {
|
||||
let settingsObj = { 'version': PORT_SETTINGS_VERSION };
|
||||
settingsObj.ports = ports;
|
||||
_d(JSON.stringify(settingsObj));
|
||||
_settings.set_string(PORT_SETTINGS, JSON.stringify(settingsObj));
|
||||
return settingsObj;
|
||||
}
|
||||
|
||||
function getPortDisplayName(port) {
|
||||
return port.card_description + " - " + port.human_name;
|
||||
}
|
||||
|
||||
function migratePortSettings(currVersion, currSettings, _settings) {
|
||||
let ports = [];
|
||||
switch (currVersion) {
|
||||
case 1:
|
||||
let _lPorts = Lib.getPorts(true).slice();
|
||||
for (let port of currSettings) {
|
||||
for (var i = 0; i < _lPorts.length; i++) {
|
||||
let _lPort = _lPorts[i];
|
||||
if (port.human_name == _lPort.human_name && port.name == _lPort.name) {
|
||||
port.card_name = _lPort.card_name;
|
||||
port.display_name = getPortDisplayName(_lPort);
|
||||
_lPorts.splice(i, 1);
|
||||
ports.push(port);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return setPortsSettings(ports,_settings);
|
||||
}
|
||||
|
||||
|
||||
const SDCSettingsWidget = new GObject.Class({
|
||||
@ -64,12 +112,12 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
// creates the settings
|
||||
this._settings = Lib.getSettings(SETTINGS_SCHEMA);
|
||||
|
||||
Lib.setLog(this._settings.get_boolean(ENABLE_LOG));
|
||||
Lib.setLog(this._settings.get_boolean(ENABLE_LOG));
|
||||
|
||||
// creates the ui builder and add the main resource file
|
||||
let uiFilePath = Me.path + "/ui/prefs-dialog.gtkbuilder";
|
||||
let builder = new Gtk.Builder();
|
||||
builder.set_translation_domain('sound-output-device-chooser');
|
||||
builder.set_translation_domain('sound-output-device-chooser');
|
||||
|
||||
if (builder.add_from_file(uiFilePath) == 0) {
|
||||
_d("JS LOG: could not load the ui file: %s".format(uiFilePath));
|
||||
@ -81,7 +129,7 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
|
||||
this.pack_start(label, true, true, 0);
|
||||
} else {
|
||||
_d('JS LOG:_UI file receive and load: '+uiFilePath);
|
||||
_d('JS LOG:_UI file receive and load: ' + uiFilePath);
|
||||
|
||||
let mainContainer = builder.get_object("main-container");
|
||||
|
||||
@ -111,7 +159,7 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
this._settings.bind(NEW_PROFILE_ID, newProfileIdSwitch, "active", Gio.SettingsBindFlags.DEFAULT);
|
||||
this._settings.bind(ICON_THEME, iconThemeCombo, "active-id", Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
|
||||
//Show always is not working always, hidden in the UI directly
|
||||
let showAlwaysToggleRender = builder.get_object("ShowAlwaysToggleRender");
|
||||
let hideAlwaysToggleRender = builder.get_object("HideAlwaysToggleRender");
|
||||
let showActiveToggleRender = builder.get_object("ShowActiveToggleRender");
|
||||
@ -127,11 +175,10 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
}
|
||||
},
|
||||
|
||||
_populatePorts: function (){
|
||||
_populatePorts: function() {
|
||||
let ports = Lib.getPorts(true);
|
||||
for (let port of ports)
|
||||
{
|
||||
this._portsStore.set(this._portsStore.append(),[0,1,2,3,4,5],[port.human_name, false, false, true, port.name,3]);
|
||||
for (let port of ports) {
|
||||
this._portsStore.set(this._portsStore.append(), [0, 1, 2, 3, 4, 5, 6, 7], [port.human_name, false, false, true, port.name, 3, port.card_name, getPortDisplayName(port)]);
|
||||
}
|
||||
},
|
||||
|
||||
@ -149,18 +196,22 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
|
||||
_toggleCallback: function(widget, path, activeCol, inactiveCols) {
|
||||
let active = !widget.active;
|
||||
if(!active)
|
||||
{
|
||||
if (!active) {
|
||||
return;
|
||||
}
|
||||
let [success, iter] = this._portsStore.get_iter_from_string(path);
|
||||
if (!success) {
|
||||
return;
|
||||
}
|
||||
/*Dont support non-pci cards for show always*/
|
||||
let card_name = this._portsStore.get_value(iter, 6);
|
||||
if(!/\.pci-/.exec(card_name) && activeCol == 1){
|
||||
this._toggleCallback(widget, path, 3, [1, 2]);
|
||||
return;
|
||||
}
|
||||
this._portsStore.set_value(iter, activeCol, active);
|
||||
this._portsStore.set_value(iter, 5, activeCol);
|
||||
for (let col of inactiveCols)
|
||||
{
|
||||
for (let col of inactiveCols) {
|
||||
this._portsStore.set_value(iter, col, !active);
|
||||
}
|
||||
this._commitSettings();
|
||||
@ -171,21 +222,23 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
let [success, iter] = this._portsStore.get_iter_first();
|
||||
|
||||
while (iter && success) {
|
||||
if(!this._portsStore.get_value(iter,3)) {
|
||||
if (!this._portsStore.get_value(iter, 3)) {
|
||||
ports.push({
|
||||
human_name: this._portsStore.get_value(iter, 0),
|
||||
name: this._portsStore.get_value(iter, 4),
|
||||
display_option: this._portsStore.get_value(iter, 5)
|
||||
display_option: this._portsStore.get_value(iter, 5),
|
||||
card_name: this._portsStore.get_value(iter, 6),
|
||||
display_name: this._portsStore.get_value(iter, 7)
|
||||
});
|
||||
}
|
||||
success = this._portsStore.iter_next(iter);
|
||||
}
|
||||
|
||||
this._settings.set_string(PORT_SETTINGS, JSON.stringify(ports));
|
||||
setPortsSettings(ports, this._settings);
|
||||
},
|
||||
|
||||
_restorePortsFromSettings: function() {
|
||||
let ports = JSON.parse(this._settings.get_string(PORT_SETTINGS));
|
||||
let ports = getPortsFromSettings(this._settings);
|
||||
|
||||
let found;
|
||||
for (let port of ports) {
|
||||
@ -199,8 +252,9 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
while (iter && success) {
|
||||
let human_name = this._portsStore.get_value(iter, 0);
|
||||
let name = this._portsStore.get_value(iter, 4);
|
||||
let card_name = this._portsStore.get_value(iter, 6);
|
||||
|
||||
if(port.name == name && port.human_name == human_name) {
|
||||
if (port.name == name && port.human_name == human_name && port.card_name == card_name) {
|
||||
this._portsStore.set_value(iter, 3, false);
|
||||
this._portsStore.set_value(iter, port.display_option, true);
|
||||
this._portsStore.set_value(iter, 5, port.display_option);
|
||||
@ -210,10 +264,10 @@ const SDCSettingsWidget = new GObject.Class({
|
||||
success = this._portsStore.iter_next(iter);
|
||||
}
|
||||
|
||||
if(!found){
|
||||
if (!found) {
|
||||
iter = this._portsStore.append();
|
||||
this._portsStore.set(iter, [0,1,2,3,4,5],
|
||||
[port.human_name, false, false, false, port.name,port.display_option]);
|
||||
this._portsStore.set(iter, [0, 1, 2, 3, 4, 5, 6, 7],
|
||||
[port.human_name, false, false, false, port.name, port.display_option, port.card_name, port.display_name]);
|
||||
this._portsStore.set_value(iter, port.display_option, true);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!-- Generated with glade 3.38.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.16"/>
|
||||
<object class="GtkListStore" id="icon-theme-store">
|
||||
@ -38,65 +38,69 @@
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name SelectedColumn -->
|
||||
<column type="gint"/>
|
||||
<!-- column-name CardName -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name DisplayName -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkBox" id="main-container">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">6</property>
|
||||
<property name="margin_right">6</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">6</property>
|
||||
<property name="margin-right">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">12</property>
|
||||
<property name="margin_right">6</property>
|
||||
<property name="margin_top">12</property>
|
||||
<property name="margin_bottom">12</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">12</property>
|
||||
<property name="margin-right">6</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">out</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">out</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Hide selector if there's only one device</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -108,9 +112,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="single-device">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -124,21 +128,21 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Display audio profiles for selection</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -150,9 +154,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="show-profile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -166,22 +170,22 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">20</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="margin-right">20</property>
|
||||
<property name="label" translatable="yes">Extend Volume Menu to fit device names</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -193,9 +197,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="expand-volume-menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -214,7 +218,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">General Settings</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
@ -231,35 +235,35 @@
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">out</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">out</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Show output devices</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -271,9 +275,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="show-output-devices">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -292,7 +296,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Output Devices</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
@ -309,37 +313,37 @@
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">out</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">out</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Show input devices</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -351,9 +355,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="show-input-devices">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -367,22 +371,22 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Show volume control for default device</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -394,9 +398,9 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="show-input-slider">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -415,7 +419,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Input Devices</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
@ -432,36 +436,36 @@
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="name">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Icon Theme</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -472,12 +476,12 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="icon-theme">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-right">5</property>
|
||||
<property name="model">icon-theme-store</property>
|
||||
<property name="id_column">0</property>
|
||||
<property name="id-column">0</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="Text"/>
|
||||
<attributes>
|
||||
@ -497,21 +501,21 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Display icons only in selection list</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -523,8 +527,8 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="hide-menu-icons">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="margin-right">5</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -543,7 +547,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Icons</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
@ -560,36 +564,36 @@
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="selection-mode">none</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="name">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Enable Log messages</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -601,7 +605,7 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="enable-log">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
@ -615,21 +619,21 @@
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-top">6</property>
|
||||
<property name="margin-bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin-left">5</property>
|
||||
<property name="label" translatable="yes">Enable new profile identification </property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -641,7 +645,7 @@
|
||||
<child>
|
||||
<object class="GtkSwitch" id="new-profile-identification">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="active">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
@ -661,7 +665,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Miscellaneous</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
@ -685,41 +689,42 @@
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">6</property>
|
||||
<property name="margin_right">12</property>
|
||||
<property name="margin_top">12</property>
|
||||
<property name="margin_bottom">12</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">6</property>
|
||||
<property name="margin-right">12</property>
|
||||
<property name="margin-top">12</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">out</property>
|
||||
<property name="label-xalign">0</property>
|
||||
<property name="shadow-type">out</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">4</property>
|
||||
<property name="margin_right">4</property>
|
||||
<property name="margin_bottom">4</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-left">4</property>
|
||||
<property name="margin-right">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="opacity">0.99999999865889544</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="opacity">0.9999999986588954</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="resize_mode">queue</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<property name="resize-mode">queue</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="min-content-width">500</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="port-treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">ports-store</property>
|
||||
<child internal-child="selection">
|
||||
@ -729,20 +734,21 @@
|
||||
<object class="GtkTreeViewColumn" id="PortNameColumn">
|
||||
<property name="resizable">True</property>
|
||||
<property name="sizing">autosize</property>
|
||||
<property name="min_width">100</property>
|
||||
<property name="min-width">100</property>
|
||||
<property name="title" translatable="yes">Name</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="sort_order">descending</property>
|
||||
<property name="sort-order">descending</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="PortNameRenderer"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
<attribute name="text">7</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="ShowAlwaysColumn">
|
||||
<property name="visible">False</property>
|
||||
<property name="sizing">autosize</property>
|
||||
<property name="title" translatable="yes">Show</property>
|
||||
<child>
|
||||
@ -797,7 +803,7 @@
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Port Settings</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
|
Binary file not shown.
@ -2,6 +2,7 @@
|
||||
# '/usr/include/pulse/introspect.h' '/usr/include/pulse/mainloop.h' '/usr/include/pulse/context.h'
|
||||
# Refer additional licensing requirements for the files included
|
||||
# sample commands used
|
||||
# python3 /usr/bin/clang2py --clang-args="-I/usr/include/clang/6.0/include -I/usr/include/pulse" -l /usr/lib/libpulse.so '/usr/include/pulse/introspect.h' '/usr/include/pulse/mainloop.h' '/usr/include/pulse/proplist.h'
|
||||
# python3 /usr/local/bin/clang2py --clang-args="-I/usr/include/clang/6.0/include -I/usr/include/pulse" -l /usr/lib/x86_64-linux-gnu/libpulse.so '/usr/include/pulse/introspect.h' '/usr/include/pulse/mainloop.h'
|
||||
# python3 /usr/local/bin/clang2py --clang-args="-I/usr/include/clang/6.0/include -I/usr/include/pulse" -l /usr/lib/x86_64-linux-gnu/libpulse.so '/usr/include/pulse/context.h'
|
||||
################################################################################
|
||||
@ -490,6 +491,16 @@ pa_operation_unref.argtypes = [POINTER_T(struct_pa_operation)]
|
||||
# ('tv_usec', ctypes.c_int64),
|
||||
# ]
|
||||
|
||||
pa_proplist_to_string = _libraries['libpulse.so'].pa_proplist_to_string
|
||||
pa_proplist_to_string.restype = POINTER_T(ctypes.c_char)
|
||||
pa_proplist_to_string.argtypes = [POINTER_T(struct_pa_proplist)]
|
||||
|
||||
pa_proplist_gets = _libraries['libpulse.so'].pa_proplist_gets
|
||||
pa_proplist_gets.restype = POINTER_T(ctypes.c_char)
|
||||
pa_proplist_gets.argtypes = [POINTER_T(struct_pa_proplist), POINTER_T(ctypes.c_char)]
|
||||
|
||||
|
||||
|
||||
__all__ = \
|
||||
['PA_CONTEXT_AUTHORIZING', 'PA_CONTEXT_CONNECTING',
|
||||
'PA_CONTEXT_FAILED', 'PA_CONTEXT_NOAUTOSPAWN',
|
||||
@ -534,4 +545,4 @@ __all__ = \
|
||||
'struct_pa_mainloop_api', 'struct_pa_operation',
|
||||
'struct_pa_proplist', 'struct_pa_sample_spec',
|
||||
'struct_pa_spawn_api', 'struct_pa_time_event', 'struct_pollfd',
|
||||
'struct_timeval', 'uint32_t']
|
||||
'struct_timeval', 'uint32_t','pa_proplist_to_string','pa_proplist_gets']
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
import libpulse_introspect as pa
|
||||
import sys
|
||||
from ctypes import c_int,byref
|
||||
from ctypes import c_int,byref, c_char_p, cast
|
||||
import time
|
||||
from json import dumps
|
||||
|
||||
@ -58,8 +58,8 @@ class PAHelper():
|
||||
|
||||
pa.pa_mainloop_iterate(self.mainloop, 0, byref(retVal))
|
||||
|
||||
# print(dumps(self._ports, indent = 5))
|
||||
print(dumps({'cards': self._cards, 'ports':self._ports}, indent = 5))
|
||||
|
||||
print(dumps({'cards': self._cards, 'ports':self._ports}, indent = 5))
|
||||
|
||||
try:
|
||||
if operation:
|
||||
@ -82,6 +82,13 @@ class PAHelper():
|
||||
card_obj['index'] = str(card.index)
|
||||
self._cards[card.index] = card_obj
|
||||
card_obj['profiles'] = []
|
||||
|
||||
card_name = cast(pa.pa_proplist_gets(card.proplist,c_char_p(b'alsa.card_name')),c_char_p)
|
||||
card_obj['alsa_name'] = card_name.value.decode('utf8') if card_name else ''
|
||||
description = cast(pa.pa_proplist_gets(card.proplist,c_char_p(b'device.description')),c_char_p)
|
||||
card_obj['card_description'] = description.value.decode('utf8') if description else ''
|
||||
|
||||
card_obj['name'] = card.name.decode('utf8') if card.name else ''
|
||||
for k in range(0, card.n_profiles):
|
||||
if(card.profiles2[k]):
|
||||
profile = card.profiles2[k].contents
|
||||
@ -102,6 +109,7 @@ class PAHelper():
|
||||
obj['available'] = port.available
|
||||
obj['n_profiles'] = port.n_profiles
|
||||
obj['profiles'] = []
|
||||
obj['card_name'] = card_obj['name']
|
||||
for j in range(0, port.n_profiles):
|
||||
if(port.profiles2[j]):
|
||||
profile = port.profiles2[j].contents
|
||||
|
Reference in New Issue
Block a user