mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-15 00:34:05 +09:00
export functions and vars in panelPosition.js and paneSettings.js
This commit is contained in:
@@ -15,31 +15,31 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var SHOW_APPS_BTN = 'showAppsButton';
|
||||
var ACTIVITIES_BTN = 'activitiesButton';
|
||||
var TASKBAR = 'taskbar';
|
||||
var DATE_MENU = 'dateMenu';
|
||||
var SYSTEM_MENU = 'systemMenu';
|
||||
var LEFT_BOX = 'leftBox';
|
||||
var CENTER_BOX = 'centerBox';
|
||||
var RIGHT_BOX = 'rightBox';
|
||||
var DESKTOP_BTN = 'desktopButton';
|
||||
export var SHOW_APPS_BTN = 'showAppsButton';
|
||||
export var ACTIVITIES_BTN = 'activitiesButton';
|
||||
export var TASKBAR = 'taskbar';
|
||||
export var DATE_MENU = 'dateMenu';
|
||||
export var SYSTEM_MENU = 'systemMenu';
|
||||
export var LEFT_BOX = 'leftBox';
|
||||
export var CENTER_BOX = 'centerBox';
|
||||
export var RIGHT_BOX = 'rightBox';
|
||||
export var DESKTOP_BTN = 'desktopButton';
|
||||
|
||||
var STACKED_TL = 'stackedTL';
|
||||
var STACKED_BR = 'stackedBR';
|
||||
var CENTERED = 'centered';
|
||||
var CENTERED_MONITOR = 'centerMonitor';
|
||||
export var STACKED_TL = 'stackedTL';
|
||||
export var STACKED_BR = 'stackedBR';
|
||||
export var CENTERED = 'centered';
|
||||
export var CENTERED_MONITOR = 'centerMonitor';
|
||||
|
||||
var TOP = 'TOP';
|
||||
var BOTTOM = 'BOTTOM';
|
||||
var LEFT = 'LEFT';
|
||||
var RIGHT = 'RIGHT';
|
||||
export var TOP = 'TOP';
|
||||
export var BOTTOM = 'BOTTOM';
|
||||
export var LEFT = 'LEFT';
|
||||
export var RIGHT = 'RIGHT';
|
||||
|
||||
var START = 'START';
|
||||
var MIDDLE = 'MIDDLE';
|
||||
var END = 'END';
|
||||
export var START = 'START';
|
||||
export var MIDDLE = 'MIDDLE';
|
||||
export var END = 'END';
|
||||
|
||||
var defaults = [
|
||||
export var defaults = [
|
||||
{ element: SHOW_APPS_BTN, visible: true, position: STACKED_TL },
|
||||
{ element: ACTIVITIES_BTN, visible: false, position: STACKED_TL },
|
||||
{ element: LEFT_BOX, visible: true, position: STACKED_TL },
|
||||
@@ -51,11 +51,11 @@ var defaults = [
|
||||
{ element: DESKTOP_BTN, visible: true, position: STACKED_BR },
|
||||
];
|
||||
|
||||
var optionDialogFunctions = {};
|
||||
export var optionDialogFunctions = {};
|
||||
|
||||
optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions';
|
||||
optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions';
|
||||
|
||||
function checkIfCentered(position) {
|
||||
export function checkIfCentered(position) {
|
||||
return position == CENTERED || position == CENTERED_MONITOR;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
import * as Pos from './panelPositions.js';
|
||||
|
||||
/** Return object representing a settings value that is stored as JSON. */
|
||||
function getSettingsJson(settings, setting) {
|
||||
export function getSettingsJson(settings, setting) {
|
||||
try {
|
||||
return JSON.parse(settings.get_string(setting));
|
||||
} catch(e) {
|
||||
@@ -26,7 +26,7 @@ function getSettingsJson(settings, setting) {
|
||||
}
|
||||
}
|
||||
/** Write value object as JSON to setting in settings. */
|
||||
function setSettingsJson(settings, setting, value) {
|
||||
export function setSettingsJson(settings, setting, value) {
|
||||
try {
|
||||
const json = JSON.stringify(value);
|
||||
settings.set_string(setting, json);
|
||||
@@ -36,7 +36,7 @@ function setSettingsJson(settings, setting, value) {
|
||||
}
|
||||
|
||||
/** Returns size of panel on a specific monitor, in pixels. */
|
||||
function getPanelSize(settings, monitorIndex) {
|
||||
export function getPanelSize(settings, monitorIndex) {
|
||||
const sizes = getSettingsJson(settings, 'panel-sizes');
|
||||
// Pull in deprecated setting if panel-sizes does not have setting for monitor.
|
||||
const fallbackSize = settings.get_int('panel-size');
|
||||
@@ -44,7 +44,7 @@ function getPanelSize(settings, monitorIndex) {
|
||||
return sizes[monitorIndex] || fallbackSize || theDefault;
|
||||
}
|
||||
|
||||
function setPanelSize(settings, monitorIndex, value) {
|
||||
export function setPanelSize(settings, monitorIndex, value) {
|
||||
if (!(Number.isInteger(value) && value <= 128 && value >= 16)) {
|
||||
log('Not setting invalid panel size: ' + value);
|
||||
return;
|
||||
@@ -58,13 +58,13 @@ function setPanelSize(settings, monitorIndex, value) {
|
||||
* Returns length of panel on a specific monitor, as a whole number percent,
|
||||
* from settings. e.g. 100
|
||||
*/
|
||||
function getPanelLength(settings, monitorIndex) {
|
||||
export function getPanelLength(settings, monitorIndex) {
|
||||
const lengths = getSettingsJson(settings, 'panel-lengths');
|
||||
const theDefault = 100;
|
||||
return lengths[monitorIndex] || theDefault;
|
||||
}
|
||||
|
||||
function setPanelLength(settings, monitorIndex, value) {
|
||||
export function setPanelLength(settings, monitorIndex, value) {
|
||||
if (!(Number.isInteger(value) && value <= 100 && value >= 0)) {
|
||||
log('Not setting invalid panel length: ' + value);
|
||||
return;
|
||||
@@ -75,14 +75,14 @@ function setPanelLength(settings, monitorIndex, value) {
|
||||
}
|
||||
|
||||
/** Returns position of panel on a specific monitor. */
|
||||
function getPanelPosition(settings, monitorIndex) {
|
||||
export function getPanelPosition(settings, monitorIndex) {
|
||||
const positions = getSettingsJson(settings, 'panel-positions');
|
||||
const fallbackPosition = settings.get_string('panel-position');
|
||||
const theDefault = Pos.BOTTOM;
|
||||
return positions[monitorIndex] || fallbackPosition || theDefault;
|
||||
}
|
||||
|
||||
function setPanelPosition(settings, monitorIndex, value) {
|
||||
export function setPanelPosition(settings, monitorIndex, value) {
|
||||
if (!(value === Pos.TOP || value === Pos.BOTTOM || value === Pos.LEFT
|
||||
|| value === Pos.RIGHT)) {
|
||||
log('Not setting invalid panel position: ' + value);
|
||||
@@ -94,13 +94,13 @@ function setPanelPosition(settings, monitorIndex, value) {
|
||||
}
|
||||
|
||||
/** Returns anchor location of panel on a specific monitor. */
|
||||
function getPanelAnchor(settings, monitorIndex) {
|
||||
export function getPanelAnchor(settings, monitorIndex) {
|
||||
const anchors = getSettingsJson(settings, 'panel-anchors');
|
||||
const theDefault = Pos.MIDDLE;
|
||||
return anchors[monitorIndex] || theDefault;
|
||||
}
|
||||
|
||||
function setPanelAnchor(settings, monitorIndex, value) {
|
||||
export function setPanelAnchor(settings, monitorIndex, value) {
|
||||
if (!(value === Pos.START || value === Pos.MIDDLE || value === Pos.END)) {
|
||||
log('Not setting invalid panel anchor: ' + value);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user