From f993a9e16c69d99bffcad5feb0768c5ca8eb8614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 22 Jan 2021 22:19:04 +0100 Subject: [PATCH] Make elapsed popover separator creation more universal --- src/buttons.js | 26 ++++++++++++++++++++++++++ src/controls.js | 24 +----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/buttons.js b/src/buttons.js index 67d02f5b..8a7014f6 100644 --- a/src/buttons.js +++ b/src/buttons.js @@ -231,4 +231,30 @@ class ClapperElapsedPopoverButton extends LabelPopoverButton this.scrolledWindow.max_content_height = (isFullscreen) ? 190 : 150; } + + addSeparator(text) + { + const box = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + hexpand: true, + }); + const label = new Gtk.Label({ + label: text, + halign: Gtk.Align.CENTER, + }); + const leftSeparator = new Gtk.Separator({ + orientation: Gtk.Orientation.HORIZONTAL, + hexpand: true, + valign: Gtk.Align.CENTER, + }); + const rightSeparator = new Gtk.Separator({ + orientation: Gtk.Orientation.HORIZONTAL, + hexpand: true, + valign: Gtk.Align.CENTER, + }); + box.append(leftSeparator); + box.append(label); + box.append(rightSeparator); + this.popoverBox.append(box); + } }); diff --git a/src/controls.js b/src/controls.js index af180a89..308d5b12 100644 --- a/src/controls.js +++ b/src/controls.js @@ -319,29 +319,7 @@ class ClapperControls extends Gtk.Box elapsedRevealer.set_reveal_child(true); this.revealersArr.push(elapsedRevealer); - const speedSeparatorBox = new Gtk.Box({ - orientation: Gtk.Orientation.HORIZONTAL, - hexpand: true, - }); - const speedLabel = new Gtk.Label({ - label: 'Speed', - halign: Gtk.Align.CENTER, - }); - const leftSeparator = new Gtk.Separator({ - orientation: Gtk.Orientation.HORIZONTAL, - hexpand: true, - valign: Gtk.Align.CENTER, - }); - const rightSeparator = new Gtk.Separator({ - orientation: Gtk.Orientation.HORIZONTAL, - hexpand: true, - valign: Gtk.Align.CENTER, - }); - speedSeparatorBox.append(leftSeparator); - speedSeparatorBox.append(speedLabel); - speedSeparatorBox.append(rightSeparator); - this.elapsedButton.popoverBox.append(speedSeparatorBox); - + this.elapsedButton.addSeparator('Speed'); const speedScale = new Gtk.Scale({ orientation: Gtk.Orientation.HORIZONTAL, value_pos: Gtk.PositionType.BOTTOM,