From 5802dec15b2ca06d9502d2fda258cb9a9deaa1bf Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 11:58:41 -0800 Subject: [PATCH 1/2] DisplaysView: Gtk4 prep --- src/Views/DisplaysView.vala | 81 ++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 7abb6412..8ae946aa 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -20,11 +20,11 @@ * Oleksandr Lynok */ -public class Display.DisplaysView : Gtk.Grid { +public class Display.DisplaysView : Gtk.Box { public DisplaysOverlay displays_overlay; private Gtk.ComboBoxText dpi_combo; - private Gtk.Grid rotation_lock_grid; + private Gtk.Box rotation_lock_box; private const string TOUCHSCREEN_SETTINGS_PATH = "org.gnome.settings-daemon.peripherals.touchscreen"; @@ -34,13 +34,15 @@ public class Display.DisplaysView : Gtk.Grid { var mirror_label = new Gtk.Label (_("Mirror Display:")); var mirror_switch = new Gtk.Switch (); - var mirror_grid = new Gtk.Grid () { - column_spacing = 6, - margin = 6, - valign = Gtk.Align.CENTER + var mirror_box = new Gtk.Box (HORIZONTAL, 6) { + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6, + valign = CENTER }; - mirror_grid.add (mirror_label); - mirror_grid.add (mirror_switch); + mirror_box.add (mirror_label); + mirror_box.add (mirror_switch); var dpi_label = new Gtk.Label (_("Scaling factor:")); @@ -49,12 +51,14 @@ public class Display.DisplaysView : Gtk.Grid { dpi_combo.append_text (_("HiDPI") + " (2×)"); dpi_combo.append_text (_("HiDPI") + " (3×)"); - var dpi_grid = new Gtk.Grid () { - column_spacing = 6, - margin = 6 + var dpi_box = new Gtk.Box (HORIZONTAL, 6) { + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6 }; - dpi_grid.add (dpi_label); - dpi_grid.add (dpi_combo); + dpi_box.add (dpi_label); + dpi_box.add (dpi_combo); var detect_button = new Gtk.Button.with_label (_("Detect Displays")); @@ -62,40 +66,44 @@ public class Display.DisplaysView : Gtk.Grid { apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); apply_button.sensitive = false; - var button_grid = new Gtk.Grid () { - column_homogeneous = true, - column_spacing = 6, - margin = 6, - valign = Gtk.Align.CENTER + var button_box = new Gtk.Box (HORIZONTAL, 6) { + homogeneous = true, + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6, + valign = CENTER }; - button_grid.add (detect_button); - button_grid.add (apply_button); + button_box.add (detect_button); + button_box.add (apply_button); var action_bar = new Gtk.ActionBar (); action_bar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); - action_bar.pack_start (dpi_grid); - action_bar.pack_start (mirror_grid); + action_bar.pack_start (dpi_box); + action_bar.pack_start (mirror_box); var schema_source = GLib.SettingsSchemaSource.get_default (); var rotation_lock_schema = schema_source.lookup (TOUCHSCREEN_SETTINGS_PATH, true); if (rotation_lock_schema != null) { - rotation_lock_grid = new Gtk.Grid () { - column_spacing = 6, - margin = 6, - valign = Gtk.Align.CENTER + rotation_lock_box = new Gtk.Box (HORIZONTAL, 6) { + margin_top = 6, + margin_end = 6, + margin_bottom = 6, + margin_start = 6, + valign = CENTER }; - action_bar.pack_start (rotation_lock_grid); + action_bar.pack_start (rotation_lock_box); detect_accelerometer.begin (); } else { info ("Schema \"org.gnome.settings-daemon.peripherals.touchscreen\" is not installed on your system."); } - action_bar.pack_end (button_grid); + action_bar.pack_end (button_box); - orientation = Gtk.Orientation.VERTICAL; - add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL)); + orientation = VERTICAL; + add (new Gtk.Separator (HORIZONTAL)); add (displays_overlay); add (action_bar); @@ -104,9 +112,9 @@ public class Display.DisplaysView : Gtk.Grid { }); unowned Display.MonitorManager monitor_manager = Display.MonitorManager.get_default (); - mirror_grid.sensitive = monitor_manager.monitors.size > 1; + mirror_box.sensitive = monitor_manager.monitors.size > 1; monitor_manager.notify["monitor-number"].connect (() => { - mirror_grid.sensitive = monitor_manager.monitors.size > 1; + mirror_box.sensitive = monitor_manager.monitors.size > 1; }); detect_button.clicked.connect (() => displays_overlay.rescan_displays ()); @@ -149,12 +157,11 @@ public class Display.DisplaysView : Gtk.Grid { var rotation_lock_label = new Gtk.Label (_("Rotation Lock:")); var rotation_lock_switch = new Gtk.Switch (); - rotation_lock_grid.add (rotation_lock_label); - rotation_lock_grid.add (rotation_lock_switch); + rotation_lock_box.add (rotation_lock_label); + rotation_lock_box.add (rotation_lock_switch); + rotation_lock_box.show_all (); - touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", SettingsBindFlags.DEFAULT); - - rotation_lock_grid.show_all (); + touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", DEFAULT); } } From e6d6abc04fbfc3abd118988f87435324a7a79389 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 11:59:18 -0800 Subject: [PATCH 2/2] Bump copyright header --- src/Views/DisplaysView.vala | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 8ae946aa..0ac72168 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -1,20 +1,6 @@ -/*- - * Copyright (c) 2014-2018 elementary LLC. - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this software; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. +/* + * SPDX-License-Identifier: LGPL-2.0-or-later + * SPDX-FileCopyrightText: 2014-2023 elementary, Inc. (https://elementary.io) * * Authored by: Corentin Noël * Oleksandr Lynok