diff --git a/src/prefs.js b/src/prefs.js
index fb502f0..b77a97c 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -230,22 +230,6 @@ const Preferences = class {
// set the window as notebook, it is being used as parent for dialogs
this.notebook = window
- // Timeout to delay the update of the settings
- this._panel_size_timeout = 0
- this._dot_height_timeout = 0
- this._tray_size_timeout = 0
- this._leftbox_size_timeout = 0
- this._globalBorderRadius_margin_timeout = 0
- this._appicon_margin_timeout = 0
- this._panel_top_bottom_margins_timeout = 0
- this._panel_side_margins_timeout = 0
- this._appicon_padding_timeout = 0
- this._opacity_timeout = 0
- this._tray_padding_timeout = 0
- this._statusicon_padding_timeout = 0
- this._leftbox_padding_timeout = 0
- this._addFormatValueCallbacks()
-
PanelSettings.setMonitorsInfo(settings).then(() => {
this._bindSettings()
@@ -808,126 +792,6 @@ const Preferences = class {
dialog.set_default_size(1, 1)
}
- _addFormatValueCallbacks() {
- // position
- this._builder
- .get_object('panel_size_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- this._builder
- .get_object('panel_length_scale')
- .set_format_value_func((scale, value) => {
- return value + ' %'
- })
-
- // style
- this._builder
- .get_object('global_border_radius_scale')
- .set_format_value_func((scale, value) => {
- return value * 4 + ' px'
- })
-
- this._builder
- .get_object('appicon_margin_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
- this._builder
- .get_object('panel_top_bottom_margins_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
- this._builder
- .get_object('panel_side_margins_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- this._builder
- .get_object('appicon_padding_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- // fine-tune box1
- this._builder
- .get_object('tray_size_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- this._builder
- .get_object('leftbox_size_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- // fine-tune box2
- this._builder
- .get_object('tray_padding_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- this._builder
- .get_object('statusicon_padding_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- this._builder
- .get_object('leftbox_padding_scale')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
-
- // animate hovering app icons dialog
- this._builder
- .get_object('animate_appicon_hover_options_duration_scale')
- .set_format_value_func((scale, value) => {
- return _('%d ms').format(value)
- })
-
- this._builder
- .get_object('animate_appicon_hover_options_rotation_scale')
- .set_format_value_func((scale, value) => {
- return _('%d °').format(value)
- })
-
- this._builder
- .get_object('animate_appicon_hover_options_travel_scale')
- .set_format_value_func((scale, value) => {
- return _('%d %%').format(value)
- })
-
- this._builder
- .get_object('animate_appicon_hover_options_zoom_scale')
- .set_format_value_func((scale, value) => {
- return _('%d %%').format(value)
- })
-
- this._builder
- .get_object('animate_appicon_hover_options_convexity_scale')
- .set_format_value_func((scale, value) => {
- return _('%.1f').format(value)
- })
-
- this._builder
- .get_object('animate_appicon_hover_options_extent_scale')
- .set_format_value_func((scale, value) => {
- return ngettext('%d icon', '%d icons', value).format(value)
- })
-
- // highlight appicon on hover dialog
- this._builder
- .get_object('highlight_appicon_borderradius')
- .set_format_value_func((scale, value) => {
- return value + ' px'
- })
- }
-
_setMonitorsInfo() {
this.monitors = PanelSettings.availableMonitors
@@ -963,27 +827,6 @@ const Preferences = class {
}
_bindSettings() {
- // size options
- let panel_size_scale = this._builder.get_object('panel_size_scale')
- panel_size_scale.set_range(
- DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length - 1],
- DEFAULT_PANEL_SIZES[0],
- )
- DEFAULT_PANEL_SIZES.slice(1, -1).forEach(function (val) {
- panel_size_scale.add_mark(val, Gtk.PositionType.TOP, val.toString())
- })
-
- // Correct for rtl languages
- if (this._rtl) {
- // Flip value position: this is not done automatically
- panel_size_scale.set_value_pos(Gtk.PositionType.LEFT)
- // I suppose due to a bug, having a more than one mark and one above a value of 100
- // makes the rendering of the marks wrong in rtl. This doesn't happen setting the scale as not flippable
- // and then manually inverting it
- panel_size_scale.set_flippable(false)
- panel_size_scale.set_inverted(true)
- }
-
// App icon style option
this._builder
.get_object('appicon_style_combo')
@@ -1385,21 +1228,17 @@ const Preferences = class {
maybeSetPanelLengthScaleValueChange(value)
this._setPanelLenghtWidgetSensitivity(value)
}
- let panelLengthScaleValueChangeId = 0
+
let maybeSetPanelLengthScaleValueChange = (value) => {
const panel_length_scale = this._builder.get_object('panel_length_scale')
- if (panelLengthScaleValueChangeId) {
- panel_length_scale.disconnect(panelLengthScaleValueChangeId)
- panelLengthScaleValueChangeId = 0
+ if (panelLengthScale.valueChangedId) {
+ panel_length_scale.disconnect(panelLengthScale.valueChangedId)
+ panelLengthScale.valueChangedId = 0
}
- if (value != -1) {
- panelLengthScaleValueChangeId = panel_length_scale.connect(
- 'value-changed',
- () => setPanelLength(panel_length_scale.get_value()),
- )
- } else panel_length_scale.set_value(100)
+ if (value != -1) connectValueChanged(panel_length_scale, panelLengthScale)
+ else panel_length_scale.set_value(100)
}
const dynamicLengthButton = this._builder.get_object(
@@ -3091,7 +2930,36 @@ const Preferences = class {
// Fine-tune panel
- let sizeScales = [
+ let panelLengthScale = {
+ objectName: 'panel_length_scale',
+ valueName: '',
+ range: LENGTH_MARKS,
+ unit: '%',
+ getValue: () =>
+ PanelSettings.getPanelLength(this._settings, this._currentMonitorIndex),
+ setValue: (value) => setPanelLength(value),
+ manualConnect: true,
+ }
+ let scaleInfos = [
+ {
+ objectName: 'panel_size_scale',
+ valueName: 'tray-size',
+ range: DEFAULT_PANEL_SIZES,
+ getValue: () =>
+ PanelSettings.getPanelSize(this._settings, this._currentMonitorIndex),
+ setValue: (value) => {
+ const monitorSync = this._settings.get_boolean(
+ 'panel-element-positions-monitors-sync',
+ )
+ const monitorsToSetFor = monitorSync
+ ? Object.keys(this.monitors)
+ : [this._currentMonitorIndex]
+ monitorsToSetFor.forEach((monitorIndex) => {
+ PanelSettings.setPanelSize(this._settings, monitorIndex, value)
+ })
+ },
+ },
+ panelLengthScale,
{
objectName: 'tray_size_scale',
valueName: 'tray-size',
@@ -3143,7 +3011,6 @@ const Preferences = class {
valueName: 'status-icon-padding',
range: DEFAULT_PADDING_SIZES,
},
- { objectName: 'panel_length_scale', valueName: '', range: LENGTH_MARKS },
{
objectName: 'highlight_appicon_borderradius',
valueName: 'highlight-appicon-hover-border-radius',
@@ -3151,41 +3018,67 @@ const Preferences = class {
},
]
- for (const idx in sizeScales) {
- let size_scale = this._builder.get_object(sizeScales[idx].objectName)
- let range = sizeScales[idx].range
- let factor = sizeScales[idx].rangeFactor
- size_scale.set_range(range[range.length - 1], range[0])
- let value
- if (sizeScales[idx].objectName === 'panel_length_scale') {
- let length = PanelSettings.getPanelLength(
- this._settings,
- this._currentMonitorIndex,
- )
+ let connectValueChanged = (scaleObj, scaleInfo) => {
+ let timeoutId = 0
- value = length == -1 ? 100 : length
- } else {
- value = this._settings.get_int(sizeScales[idx].valueName)
- }
- size_scale.set_value(value)
+ scaleObj = scaleObj || this._builder.get_object(scaleInfo.objectName)
+
+ scaleInfo.valueChangedId = scaleObj.connect('value-changed', () => {
+ // Avoid settings the size consinuosly
+ if (timeoutId > 0) GLib.Source.remove(timeoutId)
+
+ timeoutId = GLib.timeout_add(
+ GLib.PRIORITY_DEFAULT,
+ SCALE_UPDATE_TIMEOUT,
+ () => {
+ let value = scaleObj.get_value()
+
+ scaleInfo.setValue
+ ? scaleInfo.setValue(value)
+ : this._settings.set_int(scaleInfo.valueName, value)
+ timeoutId = 0
+
+ return GLib.SOURCE_REMOVE
+ },
+ )
+ })
+ }
+
+ for (const idx in scaleInfos) {
+ let scaleInfo = scaleInfos[idx]
+ let scaleObj = this._builder.get_object(scaleInfo.objectName)
+ let range = scaleInfo.range
+ let factor = scaleInfo.rangeFactor
+ let value = scaleInfo.getValue
+ ? scaleInfo.getValue()
+ : this._settings.get_int(scaleInfo.valueName)
+
+ scaleObj.set_range(range[range.length - 1], range[0])
+ scaleObj.set_value(value)
// Add marks from range arrays, omitting the first and last values.
range.slice(1, -1).forEach(function (val) {
- size_scale.add_mark(
+ scaleObj.add_mark(
val,
Gtk.PositionType.TOP,
(val * (factor || 1)).toString(),
)
})
+ if (!scaleInfo.manualConnect) connectValueChanged(scaleObj, scaleInfo)
+
+ scaleObj.set_format_value_func((scale, value) => {
+ return `${value} ${scaleInfo.unit || 'px'}`
+ })
+
// Corrent for rtl languages
if (this._rtl) {
// Flip value position: this is not done automatically
- size_scale.set_value_pos(Gtk.PositionType.LEFT)
+ scaleObj.set_value_pos(Gtk.PositionType.LEFT)
// I suppose due to a bug, having a more than one mark and one above a value of 100
// makes the rendering of the marks wrong in rtl. This doesn't happen setting the scale as not flippable
// and then manually inverting it
- size_scale.set_flippable(false)
- size_scale.set_inverted(true)
+ scaleObj.set_flippable(false)
+ scaleObj.set_inverted(true)
}
}
@@ -3193,6 +3086,43 @@ const Preferences = class {
PanelSettings.getPanelLength(this._settings, this._currentMonitorIndex),
)
+ // animate hovering app icons dialog
+ this._builder
+ .get_object('animate_appicon_hover_options_duration_scale')
+ .set_format_value_func((scale, value) => {
+ return _('%d ms').format(value)
+ })
+
+ this._builder
+ .get_object('animate_appicon_hover_options_rotation_scale')
+ .set_format_value_func((scale, value) => {
+ return _('%d °').format(value)
+ })
+
+ this._builder
+ .get_object('animate_appicon_hover_options_travel_scale')
+ .set_format_value_func((scale, value) => {
+ return _('%d %%').format(value)
+ })
+
+ this._builder
+ .get_object('animate_appicon_hover_options_zoom_scale')
+ .set_format_value_func((scale, value) => {
+ return _('%d %%').format(value)
+ })
+
+ this._builder
+ .get_object('animate_appicon_hover_options_convexity_scale')
+ .set_format_value_func((scale, value) => {
+ return _('%.1f').format(value)
+ })
+
+ this._builder
+ .get_object('animate_appicon_hover_options_extent_scale')
+ .set_format_value_func((scale, value) => {
+ return ngettext('%d icon', '%d icons', value).format(value)
+ })
+
this._settings.bind(
'animate-app-switch',
this._builder.get_object('animate_app_switch_switch'),
@@ -3746,217 +3676,6 @@ const BuilderScope = GObject.registerClass(
'TOP',
)
}
-
- panel_size_scale_value_changed_cb(scale) {
- // Avoid settings the size continuously
- if (this._preferences._panel_size_timeout > 0)
- GLib.Source.remove(this._preferences._panel_size_timeout)
-
- this._preferences._panel_size_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- const value = scale.get_value()
- const monitorSync = this._preferences._settings.get_boolean(
- 'panel-element-positions-monitors-sync',
- )
- const monitorsToSetFor = monitorSync
- ? Object.keys(this._preferences.monitors)
- : [this._preferences._currentMonitorIndex]
- monitorsToSetFor.forEach((monitorIndex) => {
- PanelSettings.setPanelSize(
- this._preferences._settings,
- monitorIndex,
- value,
- )
- })
-
- this._preferences._panel_size_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- tray_size_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._tray_size_timeout > 0)
- GLib.Source.remove(this._preferences._tray_size_timeout)
-
- this._preferences._tray_size_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int('tray-size', scale.get_value())
- this._preferences._tray_size_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- leftbox_size_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._leftbox_size_timeout > 0)
- GLib.Source.remove(this._preferences._leftbox_size_timeout)
-
- this._preferences._leftbox_size_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int('leftbox-size', scale.get_value())
- this._preferences._leftbox_size_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- global_border_radius_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._globalBorderRadius_margin_timeout > 0)
- GLib.Source.remove(this._preferences._globalBorderRadius_margin_timeout)
-
- this._preferences._globalBorderRadius_margin_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'global-border-radius',
- scale.get_value(),
- )
- this._preferences._globalBorderRadius_margin_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- appicon_margin_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._appicon_margin_timeout > 0)
- GLib.Source.remove(this._preferences._appicon_margin_timeout)
-
- this._preferences._appicon_margin_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'appicon-margin',
- scale.get_value(),
- )
- this._preferences._appicon_margin_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- panel_top_bottom_margins_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._panel_top_bottom_margins_timeout > 0)
- GLib.Source.remove(this._preferences._panel_top_bottom_margins_timeout)
-
- this._preferences._panel_top_bottom_margins_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'panel-top-bottom-margins',
- scale.get_value(),
- )
- this._preferences._panel_top_bottom_margins_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- panel_side_margins_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._panel_side_margins_timeout > 0)
- GLib.Source.remove(this._preferences._panel_side_margins_timeout)
-
- this._preferences._panel_side_margins_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'panel-side-margins',
- scale.get_value(),
- )
- this._preferences._panel_side_margins_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- appicon_padding_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._appicon_padding_timeout > 0)
- GLib.Source.remove(this._preferences._appicon_padding_timeout)
-
- this._preferences._appicon_padding_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'appicon-padding',
- scale.get_value(),
- )
- this._preferences._appicon_padding_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- tray_padding_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._tray_padding_timeout > 0)
- GLib.Source.remove(this._preferences._tray_padding_timeout)
-
- this._preferences._tray_padding_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int('tray-padding', scale.get_value())
- this._preferences._tray_padding_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- statusicon_padding_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._statusicon_padding_timeout > 0)
- GLib.Source.remove(this._preferences._statusicon_padding_timeout)
-
- this._preferences._statusicon_padding_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'status-icon-padding',
- scale.get_value(),
- )
- this._preferences._statusicon_padding_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
-
- leftbox_padding_scale_value_changed_cb(scale) {
- // Avoid settings the size consinuosly
- if (this._preferences._leftbox_padding_timeout > 0)
- GLib.Source.remove(this._preferences._leftbox_padding_timeout)
-
- this._preferences._leftbox_padding_timeout = GLib.timeout_add(
- GLib.PRIORITY_DEFAULT,
- SCALE_UPDATE_TIMEOUT,
- () => {
- this._preferences._settings.set_int(
- 'leftbox-padding',
- scale.get_value(),
- )
- this._preferences._leftbox_padding_timeout = 0
- return GLib.SOURCE_REMOVE
- },
- )
- }
},
)
diff --git a/ui/SettingsFineTune.ui b/ui/SettingsFineTune.ui
index e15fbdd..562a436 100644
--- a/ui/SettingsFineTune.ui
+++ b/ui/SettingsFineTune.ui
@@ -58,7 +58,6 @@
0
right
True
-
@@ -76,7 +75,6 @@
0
right
True
-
@@ -102,7 +100,6 @@
0
right
True
-
@@ -120,7 +117,6 @@
0
right
True
-
@@ -138,7 +134,6 @@
0
right
True
-
diff --git a/ui/SettingsPosition.ui b/ui/SettingsPosition.ui
index c02a88a..a87ea78 100644
--- a/ui/SettingsPosition.ui
+++ b/ui/SettingsPosition.ui
@@ -159,7 +159,6 @@
0
right
300
-
diff --git a/ui/SettingsStyle.ui b/ui/SettingsStyle.ui
index 3ef051f..4d8dde7 100644
--- a/ui/SettingsStyle.ui
+++ b/ui/SettingsStyle.ui
@@ -59,7 +59,6 @@
0
right
300
-
@@ -81,7 +80,6 @@
0
right
300
-
@@ -98,7 +96,6 @@
0
right
300
-
@@ -275,7 +272,6 @@
0
right
300
-
@@ -292,7 +288,6 @@
0
right
300
-