add ranges to drawing settings schema
* It is no longer required to clamp the setting value in area.js. * Add a "range" property, completed with another 'step' property, to PixelSpinButton in order to directly initiate the lower and upper values of the adjustment from the relevant setting range. * Not related: fix an inversion between Pango and Cairo in element.js.
This commit is contained in:
parent
03b73862cc
commit
56008f3041
10
area.js
10
area.js
|
|
@ -241,7 +241,7 @@ var DrawingArea = new Lang.Class({
|
||||||
while (this.squareAreaSize * 2 < Math.min(this.monitor.width, this.monitor.height))
|
while (this.squareAreaSize * 2 < Math.min(this.monitor.width, this.monitor.height))
|
||||||
this.squareAreaSize *= 2;
|
this.squareAreaSize *= 2;
|
||||||
} else {
|
} else {
|
||||||
this.squareAreaSize = Math.max(64, Me.drawingSettings.get_uint('square-area-size'));
|
this.squareAreaSize = Me.drawingSettings.get_uint('square-area-size');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.areaBackgroundColor = getClutterColorFromString(Me.drawingSettings.get_string('background-color'), 'BLACK');
|
this.areaBackgroundColor = getClutterColorFromString(Me.drawingSettings.get_string('background-color'), 'BLACK');
|
||||||
|
|
@ -251,16 +251,16 @@ var DrawingArea = new Lang.Class({
|
||||||
this.gridLineSpacing = Math.round(this.monitor.width / (5 * GRID_TILES_HORIZONTAL_NUMBER));
|
this.gridLineSpacing = Math.round(this.monitor.width / (5 * GRID_TILES_HORIZONTAL_NUMBER));
|
||||||
this.gridLineWidth = this.gridLineSpacing / 20;
|
this.gridLineWidth = this.gridLineSpacing / 20;
|
||||||
} else {
|
} else {
|
||||||
this.gridLineSpacing = Math.max(1, Me.drawingSettings.get_uint('grid-line-spacing'));
|
this.gridLineSpacing = Me.drawingSettings.get_uint('grid-line-spacing');
|
||||||
this.gridLineWidth = Math.round(Math.max(0.1, Me.drawingSettings.get_double('grid-line-width')) * 100) / 100;
|
this.gridLineWidth = Math.round(Me.drawingSettings.get_double('grid-line-width') * 100) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dashOffset = Math.round(Me.drawingSettings.get_double('dash-offset') * 100) / 100;
|
this.dashOffset = Math.round(Me.drawingSettings.get_double('dash-offset') * 100) / 100;
|
||||||
if (Me.drawingSettings.get_boolean('dash-array-auto')) {
|
if (Me.drawingSettings.get_boolean('dash-array-auto')) {
|
||||||
this.dashArray = [0, 0];
|
this.dashArray = [0, 0];
|
||||||
} else {
|
} else {
|
||||||
let on = Math.round(Math.max(0, Me.drawingSettings.get_double('dash-array-on')) * 100) / 100;
|
let on = Math.round(Me.drawingSettings.get_double('dash-array-on') * 100) / 100;
|
||||||
let off = Math.round(Math.max(0, Me.drawingSettings.get_double('dash-array-off')) * 100) / 100;
|
let off = Math.round(Me.drawingSettings.get_double('dash-array-off') * 100) / 100;
|
||||||
this.dashArray = [on, off];
|
this.dashArray = [on, off];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
10
elements.js
10
elements.js
|
|
@ -35,18 +35,18 @@ var getPangoFontFamilies = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFillRuleSvgName = function(fillRule) {
|
const getFillRuleSvgName = function(fillRule) {
|
||||||
return fillRule == Pango.FillRule.EVEN_ODD ? 'evenodd' : 'nonzero';
|
return fillRule == Cairo.FillRule.EVEN_ODD ? 'evenodd' : 'nonzero';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLineCapSvgName = function(lineCap) {
|
const getLineCapSvgName = function(lineCap) {
|
||||||
return lineCap == Pango.LineCap.BUTT ? 'butt' :
|
return lineCap == Cairo.LineCap.BUTT ? 'butt' :
|
||||||
lineCap == Pango.LineCap.SQUASH ? 'square' :
|
lineCap == Cairo.LineCap.SQUASH ? 'square' :
|
||||||
'round';
|
'round';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLineJoinSvgName = function(lineJoin) {
|
const getLineJoinSvgName = function(lineJoin) {
|
||||||
return lineJoin == Pango.LineJoin.MITER ? 'miter' :
|
return lineJoin == Cairo.LineJoin.MITER ? 'miter' :
|
||||||
lineJoin == Pango.LineJoin.BEVEL ? 'bevel' :
|
lineJoin == Cairo.LineJoin.BEVEL ? 'bevel' :
|
||||||
'round';
|
'round';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
46
prefs.js
46
prefs.js
|
|
@ -181,8 +181,8 @@ const DrawingPage = new GObject.Class({
|
||||||
let squareAreaAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
let squareAreaAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
||||||
name: this.schema.get_key('square-area-auto').get_summary(),
|
name: this.schema.get_key('square-area-auto').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('square-area-auto').get_description() });
|
tooltip_text: this.schema.get_key('square-area-auto').get_description() });
|
||||||
let squareAreaSizeButton = new PixelSpinButton({ width_chars: 5, digits: 0,
|
let squareAreaSizeButton = new PixelSpinButton({ width_chars: 5, digits: 0, step: 1,
|
||||||
adjustment: Gtk.Adjustment.new(0, 64, 32768, 1, 10, 0),
|
range: this.schema.get_key('square-area-size').get_range(),
|
||||||
name: this.schema.get_key('square-area-size').get_summary(),
|
name: this.schema.get_key('square-area-size').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('square-area-size').get_description() });
|
tooltip_text: this.schema.get_key('square-area-size').get_description() });
|
||||||
this.settings.bind('square-area-auto', squareAreaAutoButton, 'active', 0);
|
this.settings.bind('square-area-auto', squareAreaAutoButton, 'active', 0);
|
||||||
|
|
@ -204,12 +204,12 @@ const DrawingPage = new GObject.Class({
|
||||||
let gridLineAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
let gridLineAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
||||||
name: this.schema.get_key('grid-line-auto').get_summary(),
|
name: this.schema.get_key('grid-line-auto').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('grid-line-auto').get_description() });
|
tooltip_text: this.schema.get_key('grid-line-auto').get_description() });
|
||||||
let gridLineWidthButton = new PixelSpinButton({ width_chars: 5, digits: 1,
|
let gridLineWidthButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
|
||||||
adjustment: Gtk.Adjustment.new(0, 0.1, 10, 0.1, 1, 0),
|
range: this.schema.get_key('grid-line-width').get_range(),
|
||||||
name: this.schema.get_key('grid-line-width').get_summary(),
|
name: this.schema.get_key('grid-line-width').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('grid-line-width').get_description() });
|
tooltip_text: this.schema.get_key('grid-line-width').get_description() });
|
||||||
let gridLineSpacingButton = new PixelSpinButton({ width_chars: 5, digits: 1,
|
let gridLineSpacingButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 1,
|
||||||
adjustment: Gtk.Adjustment.new(0, 1, 16384, 1, 10, 0),
|
range: this.schema.get_key('grid-line-spacing').get_range(),
|
||||||
name: this.schema.get_key('grid-line-spacing').get_summary(),
|
name: this.schema.get_key('grid-line-spacing').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('grid-line-spacing').get_description() });
|
tooltip_text: this.schema.get_key('grid-line-spacing').get_description() });
|
||||||
this.settings.bind('grid-line-auto', gridLineAutoButton, 'active', 0);
|
this.settings.bind('grid-line-auto', gridLineAutoButton, 'active', 0);
|
||||||
|
|
@ -241,12 +241,12 @@ const DrawingPage = new GObject.Class({
|
||||||
let dashArrayAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
let dashArrayAutoButton = new Gtk.CheckButton({ label: _("Auto"),
|
||||||
name: this.schema.get_key('dash-array-auto').get_summary(),
|
name: this.schema.get_key('dash-array-auto').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('dash-array-auto').get_description() });
|
tooltip_text: this.schema.get_key('dash-array-auto').get_description() });
|
||||||
let dashArrayOnButton = new PixelSpinButton({ width_chars: 5, digits: 1,
|
let dashArrayOnButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
|
||||||
adjustment: Gtk.Adjustment.new(0, 0, 16384, 0.1, 1, 0),
|
range: this.schema.get_key('dash-array-on').get_range(),
|
||||||
name: this.schema.get_key('dash-array-on').get_summary(),
|
name: this.schema.get_key('dash-array-on').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('dash-array-on').get_description() });
|
tooltip_text: this.schema.get_key('dash-array-on').get_description() });
|
||||||
let dashArrayOffButton = new PixelSpinButton({ width_chars: 5, digits: 1,
|
let dashArrayOffButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
|
||||||
adjustment: Gtk.Adjustment.new(0, 0, 16384, 0.1, 1, 0),
|
range: this.schema.get_key('dash-array-off').get_range(),
|
||||||
name: this.schema.get_key('dash-array-off').get_summary(),
|
name: this.schema.get_key('dash-array-off').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('dash-array-off').get_description() });
|
tooltip_text: this.schema.get_key('dash-array-off').get_description() });
|
||||||
this.settings.bind('dash-array-auto', dashArrayAutoButton, 'active', 0);
|
this.settings.bind('dash-array-auto', dashArrayAutoButton, 'active', 0);
|
||||||
|
|
@ -260,8 +260,8 @@ const DrawingPage = new GObject.Class({
|
||||||
toolsListBox.add(dashArrayRow);
|
toolsListBox.add(dashArrayRow);
|
||||||
|
|
||||||
let dashOffsetRow = new PrefRow({ label: this.schema.get_key('dash-offset').get_summary() });
|
let dashOffsetRow = new PrefRow({ label: this.schema.get_key('dash-offset').get_summary() });
|
||||||
let dashOffsetButton = new PixelSpinButton({ width_chars: 5, digits: 1,
|
let dashOffsetButton = new PixelSpinButton({ width_chars: 5, digits: 1, step: 0.1,
|
||||||
adjustment: Gtk.Adjustment.new(0, -16384, 16384, 0.1, 1, 0),
|
range: this.schema.get_key('dash-offset').get_range(),
|
||||||
name: this.schema.get_key('dash-offset').get_summary(),
|
name: this.schema.get_key('dash-offset').get_summary(),
|
||||||
tooltip_text: this.schema.get_key('dash-offset').get_description() });
|
tooltip_text: this.schema.get_key('dash-offset').get_description() });
|
||||||
this.settings.bind('dash-offset', dashOffsetButton, 'value', 0);
|
this.settings.bind('dash-offset', dashOffsetButton, 'value', 0);
|
||||||
|
|
@ -523,6 +523,28 @@ const PixelSpinButton = new GObject.Class({
|
||||||
Name: 'DrawOnYourScreenPixelSpinButton',
|
Name: 'DrawOnYourScreenPixelSpinButton',
|
||||||
GTypeName: 'DrawOnYourScreenPixelSpinButton',
|
GTypeName: 'DrawOnYourScreenPixelSpinButton',
|
||||||
Extends: Gtk.SpinButton,
|
Extends: Gtk.SpinButton,
|
||||||
|
Properties: {
|
||||||
|
'range': GObject.param_spec_variant('range', 'range', 'GSettings range',
|
||||||
|
GLib.VariantType.new('(sv)'), null, GObject.ParamFlags.WRITABLE),
|
||||||
|
|
||||||
|
'step': GObject.ParamSpec.double('step', 'step', 'step increment',
|
||||||
|
GObject.ParamFlags.WRITABLE,
|
||||||
|
0, 1000, 1)
|
||||||
|
},
|
||||||
|
|
||||||
|
set range(range) {
|
||||||
|
let [type, variant] = range.deep_unpack();
|
||||||
|
if (type == 'range') {
|
||||||
|
let [min, max] = variant.deep_unpack();
|
||||||
|
this.adjustment.set_lower(min);
|
||||||
|
this.adjustment.set_upper(max);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
set step(step) {
|
||||||
|
this.adjustment.set_step_increment(step);
|
||||||
|
this.adjustment.set_page_increment(step * 10);
|
||||||
|
},
|
||||||
|
|
||||||
// Add 'px' unit.
|
// Add 'px' unit.
|
||||||
vfunc_output: function() {
|
vfunc_output: function() {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -48,16 +48,19 @@
|
||||||
<description>Compute the lengths from the line width</description>
|
<description>Compute the lengths from the line width</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="d" name="dash-array-on">
|
<key type="d" name="dash-array-on">
|
||||||
|
<range min="0.1" max="16384"/>
|
||||||
<default>5</default>
|
<default>5</default>
|
||||||
<summary>Dash array on</summary>
|
<summary>Dash array on</summary>
|
||||||
<description>The dash length in pixels</description>
|
<description>The dash length in pixels</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="d" name="dash-array-off">
|
<key type="d" name="dash-array-off">
|
||||||
|
<range min="0.1" max="16384"/>
|
||||||
<default>15</default>
|
<default>15</default>
|
||||||
<summary>Dash array off</summary>
|
<summary>Dash array off</summary>
|
||||||
<description>The gap between the dashes in pixels</description>
|
<description>The gap between the dashes in pixels</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="d" name="dash-offset">
|
<key type="d" name="dash-offset">
|
||||||
|
<range min="-16384" max="16384"/>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<summary>Dash offset</summary>
|
<summary>Dash offset</summary>
|
||||||
<description>The dash offset in pixels</description>
|
<description>The dash offset in pixels</description>
|
||||||
|
|
@ -73,11 +76,13 @@
|
||||||
<description>Compute the lengths from the screen size</description>
|
<description>Compute the lengths from the screen size</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="u" name="grid-line-spacing">
|
<key type="u" name="grid-line-spacing">
|
||||||
|
<range min="1" max="16384"/>
|
||||||
<default>10</default>
|
<default>10</default>
|
||||||
<summary>Grid overlay line spacing</summary>
|
<summary>Grid overlay line spacing</summary>
|
||||||
<description>The gap between lines in pixels</description>
|
<description>The gap between lines in pixels</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="d" name="grid-line-width">
|
<key type="d" name="grid-line-width">
|
||||||
|
<range min="0.1" max="10"/>
|
||||||
<default>0.5</default>
|
<default>0.5</default>
|
||||||
<summary>Grid overlay line width</summary>
|
<summary>Grid overlay line width</summary>
|
||||||
<description>The line width in pixels</description>
|
<description>The line width in pixels</description>
|
||||||
|
|
@ -102,6 +107,7 @@
|
||||||
<description>Compute the size of the square area from the screen size</description>
|
<description>Compute the size of the square area from the screen size</description>
|
||||||
</key>
|
</key>
|
||||||
<key type="u" name="square-area-size">
|
<key type="u" name="square-area-size">
|
||||||
|
<range min="64" max="32768"/>
|
||||||
<default>512</default>
|
<default>512</default>
|
||||||
<summary>Square area size</summary>
|
<summary>Square area size</summary>
|
||||||
<description>The size of the square area in pixels</description>
|
<description>The size of the square area in pixels</description>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue