[gnome-shell] screenshot: Connect shot/cast toggle with bind_property



commit 6d3dd232ad1118ad477fd95a121cabbb0d66ffd4
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Sat Feb 12 10:21:37 2022 +0300

    screenshot: Connect shot/cast toggle with bind_property
    
    This way we don't need to uncheck the other button manually, and it also
    allows switching the mode by setting the other button's checked to
    false, and not just by setting the target mode's button to true. An
    example clean-up can be seen in the "V" key handler.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2107>

 js/ui/screenshot.js | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index cc81490c98..3740975b1d 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -1212,6 +1212,9 @@ var ScreenshotUI = GObject.registerClass({
             this._onCastButtonToggled.bind(this));
         this._shotCastContainer.add_child(this._castButton);
 
+        this._shotButton.bind_property('checked', this._castButton, 'checked',
+            GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.INVERT_BOOLEAN);
+
         this._shotCastTooltip = new Tooltip(this._shotCastContainer, {
             text: _('Screenshot / Screencast'),
             style_class: 'screenshot-ui-tooltip',
@@ -1638,7 +1641,6 @@ var ScreenshotUI = GObject.registerClass({
     _onShotButtonToggled() {
         if (this._shotButton.checked) {
             this._shotButton.toggle_mode = false;
-            this._castButton.checked = false;
 
             this._stageScreenshotContainer.show();
             this._stageScreenshotContainer.remove_all_transitions();
@@ -1655,7 +1657,6 @@ var ScreenshotUI = GObject.registerClass({
     _onCastButtonToggled() {
         if (this._castButton.checked) {
             this._castButton.toggle_mode = false;
-            this._shotButton.checked = false;
 
             this._captureButton.add_style_pseudo_class('cast');
 
@@ -1966,11 +1967,7 @@ var ScreenshotUI = GObject.registerClass({
         }
 
         if (symbol === Clutter.KEY_v || symbol === Clutter.KEY_V) {
-            if (this._shotButton.checked)
-                this._castButton.checked = true;
-            else
-                this._shotButton.checked = true;
-
+            this._castButton.checked = !this._castButton.checked;
             return Clutter.EVENT_STOP;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]