From 49e4d5db8f1c32b28fce5ff4b22e5e1bd23feb68 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 15:42:12 -0800 Subject: [PATCH 01/31] Update deps --- .github/workflows/main.yml | 2 +- src/meson.build | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 49cca9ac..e2ca43f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,7 +25,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y meson libgranite-dev libswitchboard-2.0-dev valac + apt install -y meson libadwaita-1-dev libgranite-7-dev libswitchboard-3-dev valac - name: Build env: DESTDIR: out diff --git a/src/meson.build b/src/meson.build index 0398be8a..09d324c2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -16,7 +16,7 @@ plug_files = files( 'Widgets/DisplaysOverlay.vala', ) -switchboard_dep = dependency('switchboard-2.0') +switchboard_dep = dependency('switchboard-3') switchboard_plugsdir = switchboard_dep.get_pkgconfig_variable('plugsdir', define_variable: ['libdir', libdir]) shared_module( @@ -28,9 +28,9 @@ shared_module( dependency('glib-2.0'), dependency('gio-2.0'), dependency('gobject-2.0'), - dependency('granite'), - dependency('gtk+-3.0'), - dependency('libhandy-1', version: '>=0.83.0'), + dependency('granite-7'), + dependency('gtk4'), + dependency('libadwaita-1'), meson.get_compiler('vala').find_library('posix'), switchboard_dep ], From e08639acc045216e412aa3a8332a9b9b65367d3d Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 15:47:08 -0800 Subject: [PATCH 02/31] remove DisplayWindow --- po/POTFILES | 1 - src/Widgets/DisplayWidget.vala | 67 +++++++++++++++++----------------- src/Widgets/DisplayWindow.vala | 57 ----------------------------- src/meson.build | 1 - 4 files changed, 33 insertions(+), 93 deletions(-) delete mode 100644 src/Widgets/DisplayWindow.vala diff --git a/po/POTFILES b/po/POTFILES index 134c436b..dedb9db0 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -10,6 +10,5 @@ src/Objects/Monitor.vala src/Views/NightLightView.vala src/Views/DisplaysView.vala src/Views/FiltersView.vala -src/Widgets/DisplayWindow.vala src/Widgets/DisplayWidget.vala src/Widgets/DisplaysOverlay.vala diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 3dca298b..0ea7bb5a 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -26,7 +26,7 @@ public struct Display.Resolution { bool is_current; } -public class Display.DisplayWidget : Gtk.EventBox { +public class Display.DisplayWidget : Gtk.Fixed { public signal void set_as_primary (); public signal void move_display (double diff_x, double diff_y); public signal void end_grab (int delta_x, int delta_y); @@ -45,7 +45,6 @@ public class Display.DisplayWidget : Gtk.EventBox { private double start_y = 0; private bool holding = false; - public DisplayWindow display_window { get; private set; } public Gtk.Button primary_image { get; private set; } public Gtk.MenuButton toggle_settings { get; private set; } @@ -514,38 +513,38 @@ public class Display.DisplayWidget : Gtk.EventBox { }); } - public override bool button_press_event (Gdk.EventButton event) { - if (only_display) { - return false; - } - - start_x = event.x_root; - start_y = event.y_root; - holding = true; - return false; - } - - public override bool button_release_event (Gdk.EventButton event) { - holding = false; - if ((delta_x == 0 && delta_y == 0) || only_display) { - return false; - } - - var old_delta_x = delta_x; - var old_delta_y = delta_y; - delta_x = 0; - delta_y = 0; - end_grab (old_delta_x, old_delta_y); - return false; - } - - public override bool motion_notify_event (Gdk.EventMotion event) { - if (holding && !only_display) { - move_display (event.x_root - start_x, event.y_root - start_y); - } - - return false; - } + // public override bool button_press_event (Gdk.EventButton event) { + // if (only_display) { + // return false; + // } + + // start_x = event.x_root; + // start_y = event.y_root; + // holding = true; + // return false; + // } + + // public override bool button_release_event (Gdk.EventButton event) { + // holding = false; + // if ((delta_x == 0 && delta_y == 0) || only_display) { + // return false; + // } + + // var old_delta_x = delta_x; + // var old_delta_y = delta_y; + // delta_x = 0; + // delta_y = 0; + // end_grab (old_delta_x, old_delta_y); + // return false; + // } + + // public override bool motion_notify_event (Gdk.EventMotion event) { + // if (holding && !only_display) { + // move_display (event.x_root - start_x, event.y_root - start_y); + // } + + // return false; + // } public void set_primary (bool is_primary) { if (is_primary) { diff --git a/src/Widgets/DisplayWindow.vala b/src/Widgets/DisplayWindow.vala deleted file mode 100644 index b0710a90..00000000 --- a/src/Widgets/DisplayWindow.vala +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright 2014-2021 elementary, Inc. - * - * 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. - * - * Authored by: Corentin Noël - */ - -public class Display.DisplayWindow : Hdy.Window { - public Display.VirtualMonitor virtual_monitor { get; construct; } - - private const int SPACING = 12; - - public DisplayWindow (Display.VirtualMonitor virtual_monitor) { - Object (virtual_monitor: virtual_monitor); - } - - construct { - var label = new Gtk.Label (virtual_monitor.get_display_name ()) { - margin = 12 - }; - - add (label); - - input_shape_combine_region (null); - accept_focus = false; - decorated = false; - resizable = false; - deletable = false; - can_focus = false; - skip_taskbar_hint = true; - skip_pager_hint = true; - type_hint = Gdk.WindowTypeHint.TOOLTIP; - set_keep_above (true); - - stick (); - - var scale_factor = get_style_context ().get_scale (); - move ( - (int) (virtual_monitor.current_x / scale_factor) + SPACING, - (int) (virtual_monitor.current_y / scale_factor) + SPACING - ); - } -} diff --git a/src/meson.build b/src/meson.build index 09d324c2..53825475 100644 --- a/src/meson.build +++ b/src/meson.build @@ -11,7 +11,6 @@ plug_files = files( 'Views/NightLightView.vala', 'Views/DisplaysView.vala', 'Views' / 'FiltersView.vala', - 'Widgets/DisplayWindow.vala', 'Widgets/DisplayWidget.vala', 'Widgets/DisplaysOverlay.vala', ) From 4a74f3ada8b35c85e6788d18d48987116669c2e8 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 15:58:09 -0800 Subject: [PATCH 03/31] Filters view stuff --- src/Views/FiltersView.vala | 92 ++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index 93949040..dcde174b 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -15,16 +15,16 @@ public class Display.FiltersView : Gtk.Box { wrap = true, xalign = 0 }; - colorblindness_subtitle.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + colorblindness_subtitle.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); // FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4 var colorblindness_headerbox = new Gtk.Box (VERTICAL, 0) { margin_bottom = 3 }; - colorblindness_headerbox.add (colorblindness_header); - colorblindness_headerbox.add (colorblindness_subtitle); + colorblindness_headerbox.append (colorblindness_header); + colorblindness_headerbox.append (colorblindness_subtitle); - var none_radio = new Gtk.RadioButton.with_label (null, _("None")); + var none_radio = new Gtk.CheckButton.with_label (_("None")); var protanopia_label = new Gtk.Label ( TEXT_MARKUP.printf (_("Red/Green"), _("Protanopia")) @@ -36,13 +36,14 @@ public class Display.FiltersView : Gtk.Box { }; var protanopia_box = new Gtk.Box (HORIZONTAL, 0); - protanopia_box.add (protanopia_label); - protanopia_box.add (new ColorSwatch ("green")); - protanopia_box.add (new ColorSwatch ("orange")); - protanopia_box.add (new ColorSwatch ("red")); - - var protanopia_radio = new Gtk.RadioButton.from_widget (none_radio) { - child = protanopia_box + protanopia_box.append (protanopia_label); + protanopia_box.append (new ColorSwatch ("green")); + protanopia_box.append (new ColorSwatch ("orange")); + protanopia_box.append (new ColorSwatch ("red")); + + var protanopia_radio = new Gtk.CheckButton () { + child = protanopia_box, + group = none_radio }; var protanopia_hc_label = new Gtk.Label ( @@ -55,10 +56,11 @@ public class Display.FiltersView : Gtk.Box { }; var protanopia_hc_box = new Gtk.Box (HORIZONTAL, 0); - protanopia_hc_box.add (protanopia_hc_label); + protanopia_hc_box.append (protanopia_hc_label); - var protanopia_hc_radio = new Gtk.RadioButton.from_widget (none_radio) { - child = protanopia_hc_box + var protanopia_hc_radio = new Gtk.CheckButton () { + child = protanopia_hc_box, + group = none_radio }; var deuteranopia_label = new Gtk.Label ( @@ -71,13 +73,14 @@ public class Display.FiltersView : Gtk.Box { }; var deuteranopia_box = new Gtk.Box (HORIZONTAL, 0); - deuteranopia_box.add (deuteranopia_label); - deuteranopia_box.add (new ColorSwatch ("teal")); - deuteranopia_box.add (new ColorSwatch ("purple")); - deuteranopia_box.add (new ColorSwatch ("pink")); - - var deuteranopia_radio = new Gtk.RadioButton.from_widget (none_radio) { - child = deuteranopia_box + deuteranopia_box.append (deuteranopia_label); + deuteranopia_box.append (new ColorSwatch ("teal")); + deuteranopia_box.append (new ColorSwatch ("purple")); + deuteranopia_box.append (new ColorSwatch ("pink")); + + var deuteranopia_radio = new Gtk.CheckButton () { + child = deuteranopia_box, + group = none_radio }; var deuteranopia_hc_label = new Gtk.Label ( @@ -90,10 +93,11 @@ public class Display.FiltersView : Gtk.Box { }; var deuteranopia_hc_box = new Gtk.Box (HORIZONTAL, 0); - deuteranopia_hc_box.add (deuteranopia_hc_label); + deuteranopia_hc_box.append (deuteranopia_hc_label); - var deuteranopia_hc_radio = new Gtk.RadioButton.from_widget (none_radio) { - child = deuteranopia_hc_box + var deuteranopia_hc_radio = new Gtk.CheckButton () { + child = deuteranopia_hc_box, + group = none_radio }; var tritanopia_label = new Gtk.Label ( @@ -106,12 +110,13 @@ public class Display.FiltersView : Gtk.Box { }; var tritanopia_box = new Gtk.Box (HORIZONTAL, 0); - tritanopia_box.add (tritanopia_label); - tritanopia_box.add (new ColorSwatch ("yellow")); - tritanopia_box.add (new ColorSwatch ("blue")); + tritanopia_box.append (tritanopia_label); + tritanopia_box.append (new ColorSwatch ("yellow")); + tritanopia_box.append (new ColorSwatch ("blue")); - var tritanopia_radio = new Gtk.RadioButton.from_widget (none_radio) { - child = tritanopia_box + var tritanopia_radio = new Gtk.CheckButton () { + child = tritanopia_box, + group = none_radio }; var colorblindness_adjustment = new Gtk.Adjustment (0, 0.15, 1, 0.01, 0, 0); @@ -125,14 +130,14 @@ public class Display.FiltersView : Gtk.Box { colorblindness_scale.add_mark (1, BOTTOM, _("More Assistance")); var colorblindness_box = new Gtk.Box (VERTICAL, 6); - colorblindness_box.add (colorblindness_headerbox); - colorblindness_box.add (none_radio); - colorblindness_box.add (protanopia_radio); - colorblindness_box.add (protanopia_hc_radio); - colorblindness_box.add (deuteranopia_radio); - colorblindness_box.add (deuteranopia_hc_radio); - colorblindness_box.add (tritanopia_radio); - colorblindness_box.add (colorblindness_scale); + colorblindness_box.append (colorblindness_headerbox); + colorblindness_box.append (none_radio); + colorblindness_box.append (protanopia_radio); + colorblindness_box.append (protanopia_hc_radio); + colorblindness_box.append (deuteranopia_radio); + colorblindness_box.append (deuteranopia_hc_radio); + colorblindness_box.append (tritanopia_radio); + colorblindness_box.append (colorblindness_scale); var grayscale_header = new Granite.HeaderLabel (_("Grayscale")); @@ -148,7 +153,7 @@ public class Display.FiltersView : Gtk.Box { wrap = true, xalign = 0 }; - grayscale_subtitle.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + grayscale_subtitle.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); var grayscale_adjustment = new Gtk.Adjustment (0, 0.15, 1, 0.01, 0, 0); @@ -169,13 +174,14 @@ public class Display.FiltersView : Gtk.Box { grayscale_grid.attach (grayscale_scale, 0, 2, 2); var box = new Gtk.Box (VERTICAL, 24); - box.add (colorblindness_box); - box.add (grayscale_grid); + box.append (colorblindness_box); + box.append (grayscale_grid); - var clamp = new Hdy.Clamp (); - clamp.add (box); + var clamp = new Adw.Clamp () { + child = box + }; - add (clamp); + append (clamp); margin_start = 12; margin_end = 12; margin_bottom = 12; From 32fdc4e2916e3d6b6d157f614aff4282f1a67f1c Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 16:01:34 -0800 Subject: [PATCH 04/31] NightLightView --- src/Views/NightLightView.vala | 52 ++++++++++++++--------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/src/Views/NightLightView.vala b/src/Views/NightLightView.vala index a13f9ef6..cdc4648e 100644 --- a/src/Views/NightLightView.vala +++ b/src/Views/NightLightView.vala @@ -5,7 +5,9 @@ public class Display.NightLightView : Gtk.Box { construct { - var nightlight_header = new Granite.HeaderLabel (_("Night Light")); + var nightlight_header = new Granite.HeaderLabel (_("Night Light")) { + secondary_text = _("Making the colors of your display warmer may help prevent eye strain and sleeplessness") + }; var nightlight_switch = new Gtk.Switch () { halign = END, @@ -13,15 +15,6 @@ public class Display.NightLightView : Gtk.Box { valign = CENTER }; - // FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4 - var nightlight_subtitle = new Gtk.Label ( - _("Making the colors of your display warmer may help prevent eye strain and sleeplessness") - ) { - wrap = true, - xalign = 0 - }; - nightlight_subtitle.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - var temp_adjustment = new Gtk.Adjustment (0, 1500, 6000, 10, 0, 0); var temp_scale = new Gtk.Scale (HORIZONTAL, temp_adjustment) { @@ -33,46 +26,44 @@ public class Display.NightLightView : Gtk.Box { temp_scale.add_mark (1500, Gtk.PositionType.BOTTOM, _("More Warm")); temp_scale.add_mark (4500, Gtk.PositionType.BOTTOM, null); temp_scale.add_mark (6000, Gtk.PositionType.BOTTOM, _("Less Warm")); - temp_scale.get_style_context ().add_class ("warmth"); + temp_scale.add_css_class ("warmth"); var nightlight_grid = new Gtk.Grid () { column_spacing = 12 }; nightlight_grid.attach (nightlight_header, 0, 0); - nightlight_grid.attach (nightlight_subtitle, 0, 1); - nightlight_grid.attach (nightlight_switch, 1, 0, 1, 2); - nightlight_grid.attach (temp_scale, 0, 2, 2); + nightlight_grid.attach (nightlight_switch, 1, 0); + nightlight_grid.attach (temp_scale, 0, 1, 2); var schedule_header = new Granite.HeaderLabel (_("Schedule")); - var schedule_sunset_radio = new Gtk.RadioButton.with_label_from_widget ( - null, - _("Sunset to Sunrise") - ); + var schedule_sunset_radio = new Gtk.CheckButton.with_label (_("Sunset to Sunrise")); var from_label = new Gtk.Label (_("From:")); - var from_time = new Granite.Widgets.TimePicker () { + var from_time = new Granite.TimePicker () { hexpand = true, margin_end = 6 }; var to_label = new Gtk.Label (_("To:")); - var to_time = new Granite.Widgets.TimePicker () { + var to_time = new Granite.TimePicker () { hexpand = true }; var schedule_manual_box = new Gtk.Box (HORIZONTAL, 6); - schedule_manual_box.add (from_label); - schedule_manual_box.add (from_time); - schedule_manual_box.add (to_label); - schedule_manual_box.add (to_time); + schedule_manual_box.append (from_label); + schedule_manual_box.append (from_time); + schedule_manual_box.append (to_label); + schedule_manual_box.append (to_time); - var schedule_manual_radio = new Gtk.RadioButton.from_widget (schedule_sunset_radio); + var schedule_manual_radio = new Gtk.CheckButton () { + group = schedule_sunset_radio + }; var schedule_grid = new Gtk.Grid () { - column_spacing = 7, // Off by one with Gtk.RadioButton + column_spacing = 7, // Off by one with Gtk.CheckButton row_spacing = 6 }; schedule_grid.attach (schedule_header, 0, 3, 2); @@ -81,18 +72,17 @@ public class Display.NightLightView : Gtk.Box { schedule_grid.attach (schedule_manual_box, 1, 6); var box = new Gtk.Box (VERTICAL, 24); - box.add (nightlight_grid); - box.add (schedule_grid); + box.append (nightlight_grid); + box.append (schedule_grid); - var clamp = new Hdy.Clamp () { + var clamp = new Adw.Clamp () { child = box }; - add (clamp); + append (clamp); margin_start = 12; margin_end = 12; margin_bottom = 12; - show_all (); var settings = new Settings ("org.gnome.settings-daemon.plugins.color"); settings.bind ("night-light-enabled", nightlight_switch, "active", DEFAULT); From ebc270e5e86e30370c03714bc09d3f28ec57dca4 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 16:03:48 -0800 Subject: [PATCH 05/31] DisplayPlug --- src/DisplayPlug.vala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/DisplayPlug.vala b/src/DisplayPlug.vala index fde2eb9b..6a3ebb3a 100644 --- a/src/DisplayPlug.vala +++ b/src/DisplayPlug.vala @@ -64,7 +64,6 @@ public class Display.Plug : Switchboard.Plug { var stack_switcher = new Gtk.StackSwitcher () { halign = Gtk.Align.CENTER, - homogeneous = true, margin_top = 12, margin_end = 12, margin_bottom = 12, @@ -72,10 +71,16 @@ public class Display.Plug : Switchboard.Plug { stack = stack }; + var switcher_sizegroup = new Gtk.SizeGroup (HORIZONTAL); + unowned var switcher_child =stack_switcher.get_first_child (); + while (switcher_child != null) { + switcher_sizegroup.add_widget (switcher_child); + switcher_child = switcher_child.get_next_sibling (); + } + box = new Gtk.Box (VERTICAL, 0); - box.add (stack_switcher); - box.add (stack); - box.show_all (); + box.append (stack_switcher); + box.append (stack); stack.notify["visible-child"].connect (() => { if (stack.visible_child == displays_view) { From 088efb74327881b5d80c088e55bfbbf416254f43 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Mon, 8 Jan 2024 16:09:57 -0800 Subject: [PATCH 06/31] DisplaysView --- src/Views/DisplaysView.vala | 86 ++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 7abb6412..48d3766b 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.append (mirror_label); + mirror_box.append (mirror_switch); var dpi_label = new Gtk.Label (_("Scaling factor:")); @@ -49,64 +51,70 @@ 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.append (dpi_label); + dpi_box.append (dpi_combo); var detect_button = new Gtk.Button.with_label (_("Detect Displays")); var apply_button = new Gtk.Button.with_label (_("Apply")); - apply_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + apply_button.add_css_class (Granite.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.append (detect_button); + button_box.append (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.add_css_class (Granite.STYLE_CLASS_FLAT); + 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)); - add (displays_overlay); - add (action_bar); + orientation = VERTICAL; + append (new Gtk.Separator (HORIZONTAL)); + append (displays_overlay); + append (action_bar); displays_overlay.configuration_changed.connect ((changed) => { apply_button.sensitive = changed; }); 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,10 @@ 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.append (rotation_lock_label); + rotation_lock_box.append (rotation_lock_switch); touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", SettingsBindFlags.DEFAULT); - - rotation_lock_grid.show_all (); } } From cd6b60725c67099f985c8b0ed39b5788b8b4f76d Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Wed, 10 Jan 2024 09:52:22 -0800 Subject: [PATCH 07/31] DisplayWidget: more fixes --- src/Widgets/DisplayWidget.vala | 89 +++++++++++++++------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 58889814..ef5d86ad 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -26,7 +26,7 @@ public struct Display.Resolution { bool is_current; } -public class Display.DisplayWidget : Gtk.Fixed { +public class Display.DisplayWidget : Gtk.Box { public signal void set_as_primary (); public signal void move_display (double diff_x, double diff_y); public signal void end_grab (int delta_x, int delta_y); @@ -62,9 +62,6 @@ public class Display.DisplayWidget : Gtk.Fixed { private int real_width = 0; private int real_height = 0; - private Gtk.EventControllerMotion motion_event_controller; - private Gtk.GestureMultiPress click_gesture; - private enum ResolutionColumns { NAME, WIDTH, @@ -89,14 +86,6 @@ public class Display.DisplayWidget : Gtk.Fixed { } construct { - events |= Gdk.EventMask.BUTTON_PRESS_MASK; - events |= Gdk.EventMask.BUTTON_RELEASE_MASK; - events |= Gdk.EventMask.POINTER_MOTION_MASK; - - display_window = new DisplayWindow (virtual_monitor) { - attached_to = this - }; - virtual_monitor.get_current_mode_size (out real_width, out real_height); primary_image = new Gtk.Button.from_icon_name ("non-starred-symbolic") { @@ -107,7 +96,7 @@ public class Display.DisplayWidget : Gtk.Fixed { margin_bottom = 6, margin_start = 6 }; - primary_image.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + primary_image.add_css_class (Granite.STYLE_CLASS_FLAT); primary_image.clicked.connect (() => set_as_primary ()); var virtual_monitor_name = virtual_monitor.get_display_name (); @@ -255,16 +244,15 @@ public class Display.DisplayWidget : Gtk.Fixed { margin_top = 6, margin_bottom = 12 }; - popover_box.add (use_switch); - popover_box.add (resolution_label); - popover_box.add (resolution_combobox); - popover_box.add (rotation_label); - popover_box.add (rotation_combobox); - popover_box.add (refresh_label); - popover_box.add (refresh_combobox); - popover_box.show_all (); - - var popover = new Gtk.Popover (toggle_settings) { + popover_box.append (use_switch); + popover_box.append (resolution_label); + popover_box.append (resolution_combobox); + popover_box.append (rotation_label); + popover_box.append (rotation_combobox); + popover_box.append (refresh_label); + popover_box.append (refresh_combobox); + + var popover = new Gtk.Popover () { child = popover_box, position = BOTTOM }; @@ -272,7 +260,7 @@ public class Display.DisplayWidget : Gtk.Fixed { toggle_settings = new Gtk.MenuButton () { halign = END, valign = START, - image = new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.MENU), + icon_name = "open-menu-symbolic", margin_top = 6, margin_end = 6, margin_bottom = 6, @@ -280,7 +268,7 @@ public class Display.DisplayWidget : Gtk.Fixed { popover = popover, tooltip_text = _("Configure display") }; - toggle_settings.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + toggle_settings.add_css_class (Granite.STYLE_CLASS_FLAT); var grid = new Gtk.Grid (); grid.attach (primary_image, 0, 0); @@ -288,9 +276,7 @@ public class Display.DisplayWidget : Gtk.Fixed { grid.attach (label, 0, 0, 3, 2); set_primary (virtual_monitor.primary); - add (grid); - - destroy.connect (() => display_window.destroy ()); + append (grid); use_switch.bind_property ("active", resolution_combobox, "sensitive"); use_switch.bind_property ("active", rotation_combobox, "sensitive"); @@ -304,7 +290,7 @@ public class Display.DisplayWidget : Gtk.Fixed { if (use_switch.active) { get_style_context ().remove_class ("disabled"); } else { - get_style_context ().add_class ("disabled"); + add_css_class ("disabled"); } configuration_changed (); @@ -312,7 +298,7 @@ public class Display.DisplayWidget : Gtk.Fixed { }); if (!virtual_monitor.is_active) { - get_style_context ().add_class ("disabled"); + add_css_class ("disabled"); } resolution_combobox.changed.connect (() => { @@ -352,42 +338,42 @@ public class Display.DisplayWidget : Gtk.Fixed { switch (transform) { case DisplayTransform.NORMAL: virtual_monitor.get_current_mode_size (out real_width, out real_height); - label.angle = 0; + // label.angle = 0; label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_90: virtual_monitor.get_current_mode_size (out real_height, out real_width); - label.angle = 270; + // label.angle = 270; label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_180: virtual_monitor.get_current_mode_size (out real_width, out real_height); - label.angle = 180; + // label.angle = 180; label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_270: virtual_monitor.get_current_mode_size (out real_height, out real_width); - label.angle = 90; + // label.angle = 90; label.label = virtual_monitor_name; break; case DisplayTransform.FLIPPED: virtual_monitor.get_current_mode_size (out real_width, out real_height); - label.angle = 0; + // label.angle = 0; label.label = virtual_monitor_name.reverse (); //mirroring simulation, because we can't really mirror the text break; case DisplayTransform.FLIPPED_ROTATION_90: virtual_monitor.get_current_mode_size (out real_height, out real_width); - label.angle = 270; + // label.angle = 270; label.label = virtual_monitor_name.reverse (); break; case DisplayTransform.FLIPPED_ROTATION_180: virtual_monitor.get_current_mode_size (out real_width, out real_height); - label.angle = 180; + // label.angle = 180; label.label = virtual_monitor_name.reverse (); break; case DisplayTransform.FLIPPED_ROTATION_270: virtual_monitor.get_current_mode_size (out real_height, out real_width); - label.angle = 90; + // label.angle = 90; label.label = virtual_monitor_name.reverse (); break; } @@ -418,12 +404,15 @@ public class Display.DisplayWidget : Gtk.Fixed { configuration_changed (); check_position (); - click_gesture = new Gtk.GestureMultiPress (this); + var click_gesture = new Gtk.GestureClick (); click_gesture.pressed.connect (gesture_press_event); click_gesture.released.connect (gesture_release_event); - motion_event_controller = new Gtk.EventControllerMotion (this); + var motion_event_controller = new Gtk.EventControllerMotion (); motion_event_controller.motion.connect (motion_event); + + add_controller (motion_event_controller); + add_controller (click_gesture); } private void populate_refresh_rates () { @@ -562,25 +551,25 @@ public class Display.DisplayWidget : Gtk.Fixed { public void set_primary (bool is_primary) { if (is_primary) { - ((Gtk.Image) primary_image.image).icon_name = "starred-symbolic"; + primary_image.icon_name = "starred-symbolic"; primary_image.tooltip_text = _("Is the primary display"); } else { - ((Gtk.Image) primary_image.image).icon_name = "non-starred-symbolic"; + primary_image.icon_name = "non-starred-symbolic"; primary_image.tooltip_text = _("Set as primary display"); } use_switch.sensitive = !is_primary; } - public override void get_preferred_width (out int minimum_width, out int natural_width) { - minimum_width = (int)(real_width * window_ratio); - natural_width = minimum_width; - } + // public override void get_preferred_width (out int minimum_width, out int natural_width) { + // minimum_width = (int)(real_width * window_ratio); + // natural_width = minimum_width; + // } - public override void get_preferred_height (out int minimum_height, out int natural_height) { - minimum_height = (int)(real_height * window_ratio); - natural_height = minimum_height; - } + // public override void get_preferred_height (out int minimum_height, out int natural_height) { + // minimum_height = (int)(real_height * window_ratio); + // natural_height = minimum_height; + // } public void get_geometry (out int x, out int y, out int width, out int height) { x = virtual_monitor.x; From 915536c8f6f0de75615d3df7f2e3432ba2e7a161 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Wed, 10 Jan 2024 10:06:22 -0800 Subject: [PATCH 08/31] rotate labels with css --- data/Display.css | 12 ++++++++++++ src/Widgets/DisplayWidget.vala | 24 ++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/data/Display.css b/data/Display.css index 121cd320..4d661689 100644 --- a/data/Display.css +++ b/data/Display.css @@ -45,3 +45,15 @@ widget.colored { .colored.disabled button:checked { background: alpha(@SLATE_700, 0.5); } + +label.rotate-90 { + transform: rotate(90deg); +} + +label.rotate-180 { + transform: rotate(1800deg); +} + +label.rotate-270 { + transform: rotate(270deg); +} diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index ef5d86ad..0aa2543f 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -48,6 +48,8 @@ public class Display.DisplayWidget : Gtk.Box { public Gtk.Button primary_image { get; private set; } public Gtk.MenuButton toggle_settings { get; private set; } + private static Gtk.CssProvider display_provider; + private Granite.SwitchModelButton use_switch; private Gtk.ComboBox resolution_combobox; @@ -85,6 +87,11 @@ public class Display.DisplayWidget : Gtk.Box { Object (virtual_monitor: virtual_monitor); } + static construct { + display_provider = new Gtk.CssProvider (); + display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); + } + construct { virtual_monitor.get_current_mode_size (out real_width, out real_height); @@ -106,6 +113,7 @@ public class Display.DisplayWidget : Gtk.Box { hexpand = true, vexpand = true }; + label.get_style_context ().add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); use_switch = new Granite.SwitchModelButton ("Use This Display"); @@ -335,45 +343,45 @@ public class Display.DisplayWidget : Gtk.Box { var transform = (DisplayTransform)((int)val); virtual_monitor.transform = transform; + label.css_classes = {""}; + switch (transform) { case DisplayTransform.NORMAL: virtual_monitor.get_current_mode_size (out real_width, out real_height); - // label.angle = 0; label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_90: virtual_monitor.get_current_mode_size (out real_height, out real_width); - // label.angle = 270; + label.add_css_class ("rotate-270"); label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_180: virtual_monitor.get_current_mode_size (out real_width, out real_height); - // label.angle = 180; + label.add_css_class ("rotate-180"); label.label = virtual_monitor_name; break; case DisplayTransform.ROTATION_270: virtual_monitor.get_current_mode_size (out real_height, out real_width); - // label.angle = 90; + label.add_css_class ("rotate-90"); label.label = virtual_monitor_name; break; case DisplayTransform.FLIPPED: virtual_monitor.get_current_mode_size (out real_width, out real_height); - // label.angle = 0; label.label = virtual_monitor_name.reverse (); //mirroring simulation, because we can't really mirror the text break; case DisplayTransform.FLIPPED_ROTATION_90: virtual_monitor.get_current_mode_size (out real_height, out real_width); - // label.angle = 270; + label.add_css_class ("rotate-270"); label.label = virtual_monitor_name.reverse (); break; case DisplayTransform.FLIPPED_ROTATION_180: virtual_monitor.get_current_mode_size (out real_width, out real_height); - // label.angle = 180; + label.add_css_class ("rotate-180"); label.label = virtual_monitor_name.reverse (); break; case DisplayTransform.FLIPPED_ROTATION_270: virtual_monitor.get_current_mode_size (out real_height, out real_width); - // label.angle = 90; + label.add_css_class ("rotate-90"); label.label = virtual_monitor_name.reverse (); break; } From 1563de9400e37a000a1f6caaffea272822846896 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Thu, 11 Jan 2024 10:55:00 -0800 Subject: [PATCH 09/31] I hate all of this --- src/Widgets/DisplaysOverlay.vala | 180 ++++++++++++++++++------------- 1 file changed, 106 insertions(+), 74 deletions(-) diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index c87bb2f4..e4ba6a98 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -63,10 +63,13 @@ public class Display.DisplaysOverlay : Gtk.Overlay { """; public DisplaysOverlay () { - var grid = new Gtk.Grid (); - grid.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); - grid.expand = true; - add (grid); + var grid = new Gtk.Grid () { + hexpand = true, + vexpand = true + }; + grid.add_css_class (Granite.STYLE_CLASS_VIEW); + + child = grid; monitor_manager = Display.MonitorManager.get_default (); monitor_manager.notify["virtual-monitor-number"].connect (() => rescan_displays ()); @@ -78,40 +81,41 @@ public class Display.DisplaysOverlay : Gtk.Overlay { display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); } - public override bool get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) { - allocation = Gdk.Rectangle (); - if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) { - calculate_ratio (); - } - - if (widget is DisplayWidget) { - var display_widget = (DisplayWidget) widget; - - int x, y, width, height; - display_widget.get_geometry (out x, out y, out width, out height); - x += display_widget.delta_x; - y += display_widget.delta_y; - var x_start = (int) Math.round (x * current_ratio); - var y_start = (int) Math.round (y * current_ratio); - var x_end = (int) Math.round ((x + width) * current_ratio); - var y_end = (int) Math.round ((y + height) * current_ratio); - allocation.x = default_x_margin + x_start; - allocation.y = default_y_margin + y_start; - allocation.width = x_end - x_start; - allocation.height = y_end - y_start; - return true; - } - - return false; - } + // public override bool get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) { + // allocation = Gdk.Rectangle (); + // if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) { + // calculate_ratio (); + // } + + // if (widget is DisplayWidget) { + // var display_widget = (DisplayWidget) widget; + + // int x, y, width, height; + // display_widget.get_geometry (out x, out y, out width, out height); + // x += display_widget.delta_x; + // y += display_widget.delta_y; + // var x_start = (int) Math.round (x * current_ratio); + // var y_start = (int) Math.round (y * current_ratio); + // var x_end = (int) Math.round ((x + width) * current_ratio); + // var y_end = (int) Math.round ((y + height) * current_ratio); + // allocation.x = default_x_margin + x_start; + // allocation.y = default_y_margin + y_start; + // allocation.width = x_end - x_start; + // allocation.height = y_end - y_start; + // return true; + // } + + // return false; + // } public void rescan_displays () { scanning = true; - get_children ().foreach ((child) => { - if (child is DisplayWidget) { - child.destroy (); - } - }); + + // get_children ().foreach ((child) => { + // if (child is DisplayWidget) { + // child.destroy (); + // } + // }); active_displays = 0; foreach (var virtual_monitor in monitor_manager.virtual_monitors) { @@ -129,31 +133,37 @@ public class Display.DisplaysOverlay : Gtk.Overlay { return; } - get_children ().foreach ((child) => { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { if (((DisplayWidget) child).virtual_monitor.is_active) { - ((DisplayWidget) child).display_window.show_all (); + // ((DisplayWidget) child).display_window.show_all (); } } - }); + child = child.get_next_sibling (); + } } public void hide_windows () { - get_children ().foreach ((child) => { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { - ((DisplayWidget) child).display_window.hide (); + // ((DisplayWidget) child).display_window.hide (); } - }); + child = child.get_next_sibling (); + } } private void change_active_displays_sensitivity () { - get_children ().foreach ((child) => { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { if (((DisplayWidget) child).virtual_monitor.is_active) { ((DisplayWidget) child).only_display = (active_displays == 1); } } - }); + child = child.get_next_sibling (); + } } private void check_configuration_changed () { @@ -167,7 +177,8 @@ public class Display.DisplaysOverlay : Gtk.Overlay { int max_width = int.MIN; int max_height = int.MIN; - get_children ().foreach ((child) => { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { var display_widget = (DisplayWidget) child; int x, y, width, height; @@ -178,7 +189,8 @@ public class Display.DisplaysOverlay : Gtk.Overlay { max_width = int.max (max_width, x + width); max_height = int.max (max_height, y + height); } - }); + child = child.get_next_sibling (); + } current_allocated_width = get_allocated_width (); current_allocated_height = get_allocated_height (); @@ -197,20 +209,20 @@ public class Display.DisplaysOverlay : Gtk.Overlay { add_overlay (display_widget); var provider = new Gtk.CssProvider (); try { - var color_number = (get_children ().length () - 2) % 7; + // var color_number = (get_children ().length () - 2) % 7; - var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); - provider.load_from_data (colored_css, colored_css.length); + // var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); + // provider.load_from_data (colored_css.data); var context = display_widget.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_class ("colored"); - context = display_widget.display_window.get_style_context (); - context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); + // context = display_widget.display_window.get_style_context (); + // context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + // context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + // context.add_class ("colored"); context = display_widget.primary_image.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -225,7 +237,6 @@ public class Display.DisplaysOverlay : Gtk.Overlay { critical (e.message); } - display_widget.show_all (); display_widget.set_as_primary.connect (() => set_as_primary (display_widget.virtual_monitor)); display_widget.check_position.connect (() => { @@ -245,7 +256,7 @@ public class Display.DisplaysOverlay : Gtk.Overlay { }); if (!monitor_manager.is_mirrored && virtual_monitor.is_active) { - display_widget.display_window.show_all (); + // display_widget.display_window.show_all (); } display_widget.end_grab.connect ((delta_x, delta_y) => { @@ -256,7 +267,7 @@ public class Display.DisplaysOverlay : Gtk.Overlay { int x, y, width, height; display_widget.get_geometry (out x, out y, out width, out height); display_widget.set_geometry (delta_x + x, delta_y + y, width, height); - display_widget.queue_resize_no_redraw (); + // display_widget.queue_resize_no_redraw (); check_configuration_changed (); check_intersects (display_widget); snap_edges (display_widget); @@ -274,7 +285,8 @@ public class Display.DisplaysOverlay : Gtk.Overlay { } private void set_as_primary (Display.VirtualMonitor new_primary) { - get_children ().foreach ((child) => { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { var display_widget = child as DisplayWidget; var virtual_monitor = display_widget.virtual_monitor; @@ -282,7 +294,9 @@ public class Display.DisplaysOverlay : Gtk.Overlay { display_widget.set_primary (is_primary); virtual_monitor.primary = is_primary; } - }); + child = child.get_next_sibling (); + } + foreach (var virtual_monitor in monitor_manager.virtual_monitors) { virtual_monitor.primary = virtual_monitor == new_primary; } @@ -291,16 +305,16 @@ public class Display.DisplaysOverlay : Gtk.Overlay { } private void move_display (DisplayWidget display_widget, double diff_x, double diff_y) { - reorder_overlay (display_widget, -1); + // reorder_overlay (display_widget, -1); display_widget.delta_x = (int) (diff_x / current_ratio); display_widget.delta_y = (int) (diff_y / current_ratio); - Gdk.ModifierType state; - Gtk.get_current_event_state (out state); - if (!(Gdk.ModifierType.CONTROL_MASK in state)) { - align_edges (display_widget); - } + // Gdk.ModifierType state; + // Gtk.get_current_event_state (out state); + // if (!(Gdk.ModifierType.CONTROL_MASK in state)) { + // align_edges (display_widget); + // } - display_widget.queue_resize_no_redraw (); + // display_widget.queue_resize_no_redraw (); } private void align_edges (DisplayWidget display_widget) { @@ -318,8 +332,10 @@ public class Display.DisplaysOverlay : Gtk.Overlay { widget_points [4] = y + height / 2 - 1; // y_center widget_points [5] = y + height - 1; // y_end - foreach (var child in get_children ()) { + unowned var child = get_first_child (); + while (child != null) { if (!(child is DisplayWidget) || (DisplayWidget) child == display_widget) { + child = child.get_next_sibling (); continue; } @@ -350,6 +366,8 @@ public class Display.DisplaysOverlay : Gtk.Overlay { } } } + + child = child.get_next_sibling (); } if (aligned_delta [0] != int.MAX) { @@ -362,10 +380,12 @@ public class Display.DisplaysOverlay : Gtk.Overlay { private void close_gaps () { var display_widgets = new List (); - foreach (var child in get_children ()) { + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { display_widgets.append ((DisplayWidget) child); } + child = child.get_next_sibling (); } foreach (var display_widget in display_widgets) { @@ -405,7 +425,9 @@ public class Display.DisplaysOverlay : Gtk.Overlay { private void verify_global_positions () { int min_x = int.MAX; int min_y = int.MAX; - get_children ().foreach ((child) => { + + unowned var child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { var display_widget = (DisplayWidget) child; int x, y, width, height; @@ -413,20 +435,23 @@ public class Display.DisplaysOverlay : Gtk.Overlay { min_x = int.min (min_x, x); min_y = int.min (min_y, y); } - }); + child = child.get_next_sibling (); + } if (min_x == 0 && min_y == 0) { return; } - get_children ().foreach ((child) => { + child = get_first_child (); + while (child != null) { if (child is DisplayWidget) { var display_widget = (DisplayWidget) child; int x, y, width, height; display_widget.get_geometry (out x, out y, out width, out height); display_widget.set_geometry (x - min_x, y - min_y, width, height); } - }); + child = child.get_next_sibling (); + } } // If widget is intersects with any other widgets -> move other widgets to fix intersection @@ -440,8 +465,10 @@ public class Display.DisplaysOverlay : Gtk.Overlay { source_display_widget.get_geometry (out source_x, out source_y, out source_width, out source_height); Gdk.Rectangle src_rect = { source_x, source_y, source_width, source_height }; - foreach (var child in get_children ()) { + unowned var child = get_first_child (); + while (child != null) { if (!(child is DisplayWidget) || (DisplayWidget) child == source_display_widget) { + child = child.get_next_sibling (); continue; } @@ -467,9 +494,11 @@ public class Display.DisplaysOverlay : Gtk.Overlay { } other_display_widget.set_geometry (other_x + distance_x, other_y + distance_y, other_width, other_height); - other_display_widget.queue_resize_no_redraw (); + // other_display_widget.queue_resize_no_redraw (); check_intersects (other_display_widget, level + 1, distance_x, distance_y); } + + child = child.get_next_sibling (); } } @@ -478,10 +507,13 @@ public class Display.DisplaysOverlay : Gtk.Overlay { // Snap last_moved debug ("Snapping displays"); var anchors = new List (); - get_children ().foreach ((child) => { + + unowned var child = get_first_child (); + while (child != null) { if (!(child is DisplayWidget) || last_moved.equals ((DisplayWidget)child)) return; anchors.append ((DisplayWidget) child); - }); + child = child.get_next_sibling (); + } snap_widget (last_moved, anchors); From 7d53a81763d42b5f25fb51379b92c372f04d9326 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 11:47:33 -0800 Subject: [PATCH 10/31] Don't subclass overlay --- src/Widgets/DisplaysOverlay.vala | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index b6ea8987..50982a43 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -20,12 +20,13 @@ * Felix Andreas */ -public class Display.DisplaysOverlay : Gtk.Overlay { +public class Display.DisplaysOverlay : Gtk.Box { private const int SNAP_LIMIT = int.MAX - 1; private const int MINIMUM_WIDGET_OFFSET = 50; public signal void configuration_changed (bool changed); + private Gtk.Overlay overlay; private bool scanning = false; private double current_ratio = 1.0f; private int current_allocated_width = 0; @@ -65,12 +66,10 @@ public class Display.DisplaysOverlay : Gtk.Overlay { """; construct { - var grid = new Gtk.Grid () { - hexpand = true, - vexpand = true - }; - grid.add_css_class (Granite.STYLE_CLASS_VIEW); - child = grid; + add_css_class (Granite.STYLE_CLASS_VIEW); + + overlay = new Gtk.Overlay (); + append (overlay); display_widgets = new List (); @@ -190,7 +189,7 @@ public class Display.DisplaysOverlay : Gtk.Overlay { var display_widget = new DisplayWidget (virtual_monitor); current_allocated_width = 0; current_allocated_height = 0; - add_overlay (display_widget); + overlay.add_overlay (display_widget); display_widgets.append (display_widget); var provider = new Gtk.CssProvider (); @@ -345,8 +344,6 @@ public class Display.DisplaysOverlay : Gtk.Overlay { } } } - - child = child.get_next_sibling (); } if (aligned_delta [0] != int.MAX) { @@ -454,8 +451,6 @@ public class Display.DisplaysOverlay : Gtk.Overlay { // other_display_widget.queue_resize_no_redraw (); check_intersects (other_display_widget, level + 1, distance_x, distance_y); } - - child = child.get_next_sibling (); } } From 87abb2d1e1fbb7dd242bb2fc6bfddadcd1094123 Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 11:53:39 -0800 Subject: [PATCH 11/31] Fix radio issues --- data/Display.css | 2 +- src/Views/FiltersView.vala | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/Display.css b/data/Display.css index 4d661689..049005ce 100644 --- a/data/Display.css +++ b/data/Display.css @@ -11,7 +11,7 @@ /* Don't use alpha for the on-screen identifier */ window.colored { - background-color: alpha (@BG_COLOR, 0.8); + background-color: alpha(@BG_COLOR, 0.8); } widget.colored { diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index dcde174b..c720e8e2 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -42,9 +42,9 @@ public class Display.FiltersView : Gtk.Box { protanopia_box.append (new ColorSwatch ("red")); var protanopia_radio = new Gtk.CheckButton () { - child = protanopia_box, group = none_radio }; + protanopia_box.set_parent (protanopia_radio); var protanopia_hc_label = new Gtk.Label ( TEXT_MARKUP.printf (_("Red/Green — High Contrast"), _("Protanopia")) @@ -59,9 +59,9 @@ public class Display.FiltersView : Gtk.Box { protanopia_hc_box.append (protanopia_hc_label); var protanopia_hc_radio = new Gtk.CheckButton () { - child = protanopia_hc_box, group = none_radio }; + protanopia_hc_box.set_parent (protanopia_hc_radio); var deuteranopia_label = new Gtk.Label ( TEXT_MARKUP.printf (_("Green/Red"), _("Deuteranopia")) @@ -79,9 +79,9 @@ public class Display.FiltersView : Gtk.Box { deuteranopia_box.append (new ColorSwatch ("pink")); var deuteranopia_radio = new Gtk.CheckButton () { - child = deuteranopia_box, group = none_radio }; + deuteranopia_box.set_parent (deuteranopia_radio); var deuteranopia_hc_label = new Gtk.Label ( TEXT_MARKUP.printf (_("Green/Red — High Contrast"), _("Deuteranopia")) @@ -96,9 +96,9 @@ public class Display.FiltersView : Gtk.Box { deuteranopia_hc_box.append (deuteranopia_hc_label); var deuteranopia_hc_radio = new Gtk.CheckButton () { - child = deuteranopia_hc_box, group = none_radio }; + deuteranopia_hc_box.set_parent (deuteranopia_hc_radio); var tritanopia_label = new Gtk.Label ( TEXT_MARKUP.printf (_("Blue/Yellow"), _("Tritanopia")) @@ -115,9 +115,9 @@ public class Display.FiltersView : Gtk.Box { tritanopia_box.append (new ColorSwatch ("blue")); var tritanopia_radio = new Gtk.CheckButton () { - child = tritanopia_box, group = none_radio }; + tritanopia_box.set_parent (tritanopia_radio); var colorblindness_adjustment = new Gtk.Adjustment (0, 0.15, 1, 0.01, 0, 0); From 69fb7fea1a16d94aa483ee1f1d761ffdfe0a5f9d Mon Sep 17 00:00:00 2001 From: Danielle Fore Date: Tue, 23 Jan 2024 12:03:40 -0800 Subject: [PATCH 12/31] Use secondary text in filters view --- src/Views/FiltersView.vala | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index c720e8e2..5e59ac13 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -7,22 +7,9 @@ public class Display.FiltersView : Gtk.Box { private const string TEXT_MARKUP = "%s\n%s"; construct { - var colorblindness_header = new Granite.HeaderLabel (_("Color Deficiency Assistance")); - - var colorblindness_subtitle = new Gtk.Label ( - _("Each of the circles below should appear as a different color. A filter can be applied to the entire display to help differentiate between colors.") - ) { - wrap = true, - xalign = 0 - }; - colorblindness_subtitle.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - - // FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4 - var colorblindness_headerbox = new Gtk.Box (VERTICAL, 0) { - margin_bottom = 3 + var colorblindness_header = new Granite.HeaderLabel (_("Color Deficiency Assistance")) { + secondary_text = _("Each of the circles below should appear as a different color. A filter can be applied to the entire display to help differentiate between colors.") }; - colorblindness_headerbox.append (colorblindness_header); - colorblindness_headerbox.append (colorblindness_subtitle); var none_radio = new Gtk.CheckButton.with_label (_("None")); @@ -130,7 +117,7 @@ public class Display.FiltersView : Gtk.Box { colorblindness_scale.add_mark (1, BOTTOM, _("More Assistance")); var colorblindness_box = new Gtk.Box (VERTICAL, 6); - colorblindness_box.append (colorblindness_headerbox); + colorblindness_box.append (colorblindness_header); colorblindness_box.append (none_radio); colorblindness_box.append (protanopia_radio); colorblindness_box.append (protanopia_hc_radio); @@ -139,22 +126,15 @@ public class Display.FiltersView : Gtk.Box { colorblindness_box.append (tritanopia_radio); colorblindness_box.append (colorblindness_scale); - var grayscale_header = new Granite.HeaderLabel (_("Grayscale")); + var grayscale_header = new Granite.HeaderLabel (_("Grayscale")) { + secondary_text = _("Reducing color can help avoid distractions and alleviate screen addiction") + }; var grayscale_switch = new Gtk.Switch () { halign = END, valign = CENTER }; - // FIXME: Replace with Granite.HeaderLabel secondary_text in Gtk4 - var grayscale_subtitle = new Gtk.Label ( - _("Reducing color can help avoid distractions and alleviate screen addiction") - ) { - wrap = true, - xalign = 0 - }; - grayscale_subtitle.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); - var grayscale_adjustment = new Gtk.Adjustment (0, 0.15, 1, 0.01, 0, 0); var grayscale_scale = new Gtk.Scale (HORIZONTAL, grayscale_adjustment) { @@ -169,9 +149,8 @@ public class Display.FiltersView : Gtk.Box { column_spacing = 12 }; grayscale_grid.attach (grayscale_header, 0, 0); - grayscale_grid.attach (grayscale_subtitle, 0, 1); - grayscale_grid.attach (grayscale_switch, 1, 0, 1, 2); - grayscale_grid.attach (grayscale_scale, 0, 2, 2); + grayscale_grid.attach (grayscale_switch, 1, 0); + grayscale_grid.attach (grayscale_scale, 0, 1, 2); var box = new Gtk.Box (VERTICAL, 24); box.append (colorblindness_box); From 5511a8b888cf6d43a2bd03bbdf88077cff4de718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 09:39:16 -0800 Subject: [PATCH 13/31] Maybe fix overlay --- src/Views/DisplaysView.vala | 10 +++-- src/Widgets/DisplayWidget.vala | 23 ++++++----- src/Widgets/DisplaysOverlay.vala | 65 ++++++++++++++++---------------- 3 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 86eeb37b..81bd83b1 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -15,7 +15,9 @@ public class Display.DisplaysView : Gtk.Box { private const string TOUCHSCREEN_SETTINGS_PATH = "org.gnome.settings-daemon.peripherals.touchscreen"; construct { - displays_overlay = new DisplaysOverlay (); + displays_overlay = new DisplaysOverlay () { + vexpand = true + }; var mirror_label = new Gtk.Label (_("Mirror Display:")); var mirror_switch = new Gtk.Switch (); @@ -93,9 +95,9 @@ public class Display.DisplaysView : Gtk.Box { orientation = VERTICAL; - add (new Gtk.Separator (HORIZONTAL)); - add (displays_overlay); - add (action_bar); + append (new Gtk.Separator (HORIZONTAL)); + append (displays_overlay); + append (action_bar); displays_overlay.configuration_changed.connect ((changed) => { apply_button.sensitive = changed; diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 0aa2543f..c0acf1f4 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -26,7 +26,7 @@ public struct Display.Resolution { bool is_current; } -public class Display.DisplayWidget : Gtk.Box { +public class Display.DisplayWidget : Gtk.Widget { public signal void set_as_primary (); public signal void move_display (double diff_x, double diff_y); public signal void end_grab (int delta_x, int delta_y); @@ -88,6 +88,8 @@ public class Display.DisplayWidget : Gtk.Box { } static construct { + set_layout_manager_type (typeof (Gtk.BinLayout)); + display_provider = new Gtk.CssProvider (); display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); } @@ -282,9 +284,9 @@ public class Display.DisplayWidget : Gtk.Box { grid.attach (primary_image, 0, 0); grid.attach (toggle_settings, 2, 0); grid.attach (label, 0, 0, 3, 2); + grid.set_parent (this); set_primary (virtual_monitor.primary); - append (grid); use_switch.bind_property ("active", resolution_combobox, "sensitive"); use_switch.bind_property ("active", rotation_combobox, "sensitive"); @@ -482,6 +484,10 @@ public class Display.DisplayWidget : Gtk.Box { refresh_combobox.sensitive = added > 1; } + ~DisplayWidget () { + get_first_child ().unparent (); + } + private void on_monitor_modes_changed () { set_active_resolution_from_current_mode (); } @@ -569,15 +575,12 @@ public class Display.DisplayWidget : Gtk.Box { use_switch.sensitive = !is_primary; } - // public override void get_preferred_width (out int minimum_width, out int natural_width) { - // minimum_width = (int)(real_width * window_ratio); - // natural_width = minimum_width; - // } + public void get_preferred_size (out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size) { + minimum_size.height = (int)(real_height * window_ratio); + minimum_size.width = (int)(real_width * window_ratio); - // public override void get_preferred_height (out int minimum_height, out int natural_height) { - // minimum_height = (int)(real_height * window_ratio); - // natural_height = minimum_height; - // } + natural_size = minimum_size; + } public void get_geometry (out int x, out int y, out int width, out int height) { x = virtual_monitor.x; diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index 50982a43..cef3a014 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -76,6 +76,8 @@ public class Display.DisplaysOverlay : Gtk.Box { monitor_manager = Display.MonitorManager.get_default (); monitor_manager.notify["virtual-monitor-number"].connect (() => rescan_displays ()); rescan_displays (); + + overlay.get_child_position.connect (on_get_child_position); } static construct { @@ -83,32 +85,32 @@ public class Display.DisplaysOverlay : Gtk.Box { display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); } - // public override bool get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) { - // allocation = Gdk.Rectangle (); - // if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) { - // calculate_ratio (); - // } - - // if (widget is DisplayWidget) { - // var display_widget = (DisplayWidget) widget; - - // int x, y, width, height; - // display_widget.get_geometry (out x, out y, out width, out height); - // x += display_widget.delta_x; - // y += display_widget.delta_y; - // var x_start = (int) Math.round (x * current_ratio); - // var y_start = (int) Math.round (y * current_ratio); - // var x_end = (int) Math.round ((x + width) * current_ratio); - // var y_end = (int) Math.round ((y + height) * current_ratio); - // allocation.x = default_x_margin + x_start; - // allocation.y = default_y_margin + y_start; - // allocation.width = x_end - x_start; - // allocation.height = y_end - y_start; - // return true; - // } - - // return false; - // } + private bool on_get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) { + allocation = Gdk.Rectangle (); + if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) { + calculate_ratio (); + } + + if (widget is DisplayWidget) { + var display_widget = (DisplayWidget) widget; + + int x, y, width, height; + display_widget.get_geometry (out x, out y, out width, out height); + x += display_widget.delta_x; + y += display_widget.delta_y; + var x_start = (int) Math.round (x * current_ratio); + var y_start = (int) Math.round (y * current_ratio); + var x_end = (int) Math.round ((x + width) * current_ratio); + var y_end = (int) Math.round ((y + height) * current_ratio); + allocation.x = default_x_margin + x_start; + allocation.y = default_y_margin + y_start; + allocation.width = x_end - x_start; + allocation.height = y_end - y_start; + return true; + } + + return false; + } public void rescan_displays () { scanning = true; @@ -194,10 +196,10 @@ public class Display.DisplaysOverlay : Gtk.Box { var provider = new Gtk.CssProvider (); try { - // var color_number = (get_children ().length () - 2) % 7; + var color_number = (display_widgets.length () - 2) % 7; - // var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); - // provider.load_from_data (colored_css.data); + var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); + provider.load_from_data (colored_css.data); var context = display_widget.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -285,16 +287,15 @@ public class Display.DisplaysOverlay : Gtk.Box { } private void move_display (DisplayWidget display_widget, double diff_x, double diff_y) { - // reorder_overlay (display_widget, -1); display_widget.delta_x = (int) (diff_x / current_ratio); display_widget.delta_y = (int) (diff_y / current_ratio); // Gdk.ModifierType state; // Gtk.get_current_event_state (out state); // if (!(Gdk.ModifierType.CONTROL_MASK in state)) { - // align_edges (display_widget); + align_edges (display_widget); // } - // display_widget.queue_resize_no_redraw (); + display_widget.queue_resize (); } private void align_edges (DisplayWidget display_widget) { From 6fae79e6cd1322effdd80000c0e386523acc3866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 09:55:41 -0800 Subject: [PATCH 14/31] Use drag gesture --- src/Widgets/DisplayWidget.vala | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index c0acf1f4..67cb9ea2 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -414,15 +414,12 @@ public class Display.DisplayWidget : Gtk.Widget { configuration_changed (); check_position (); - var click_gesture = new Gtk.GestureClick (); - click_gesture.pressed.connect (gesture_press_event); - click_gesture.released.connect (gesture_release_event); + var drag_gesture = new Gtk.GestureDrag (); + drag_gesture.drag_begin.connect (on_drag_begin); + drag_gesture.drag_update.connect (on_drag_update); + drag_gesture.drag_end.connect (on_drag_end); - var motion_event_controller = new Gtk.EventControllerMotion (); - motion_event_controller.motion.connect (motion_event); - - add_controller (motion_event_controller); - add_controller (click_gesture); + add_controller (drag_gesture); } private void populate_refresh_rates () { @@ -534,18 +531,22 @@ public class Display.DisplayWidget : Gtk.Widget { }); } - private void gesture_press_event (int n_press, double x, double y) { + private void on_drag_begin (double x, double y) { if (only_display) { return; } start_x = x; start_y = y; - holding = true; } - private void gesture_release_event (int n_press, double x, double y) { - holding = false; + private void on_drag_update (double offset_x, double offset_y) { + if (!only_display) { + move_display (offset_x, offset_y); + } + } + + private void on_drag_end (double x, double y) { if ((delta_x == 0 && delta_y == 0) || only_display) { return; } @@ -557,12 +558,6 @@ public class Display.DisplayWidget : Gtk.Widget { end_grab (old_delta_x, old_delta_y); } - private void motion_event (double event_x, double event_y) { - if (holding && !only_display) { - move_display (event_x - start_x, event_y - start_y); - } - } - public void set_primary (bool is_primary) { if (is_primary) { primary_image.icon_name = "starred-symbolic"; From 0cc1acb5c76f0783d29c330666341865836ed524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 10:07:32 -0800 Subject: [PATCH 15/31] slightly simplify --- src/Widgets/DisplayWidget.vala | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 67cb9ea2..2e716917 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -43,7 +43,6 @@ public class Display.DisplayWidget : Gtk.Widget { private double start_x = 0; private double start_y = 0; - private bool holding = false; public Gtk.Button primary_image { get; private set; } public Gtk.MenuButton toggle_settings { get; private set; } @@ -540,9 +539,9 @@ public class Display.DisplayWidget : Gtk.Widget { start_y = y; } - private void on_drag_update (double offset_x, double offset_y) { + private void on_drag_update (double x, double y) { if (!only_display) { - move_display (offset_x, offset_y); + move_display (x, y); } } @@ -550,12 +549,10 @@ public class Display.DisplayWidget : Gtk.Widget { if ((delta_x == 0 && delta_y == 0) || only_display) { return; } - - var old_delta_x = delta_x; - var old_delta_y = delta_y; delta_x = 0; delta_y = 0; - end_grab (old_delta_x, old_delta_y); + + end_grab ((int) x, (int) y); } public void set_primary (bool is_primary) { From 9ab83bb11d8e571a4f3feed2ac760828132cbbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 10:10:48 -0800 Subject: [PATCH 16/31] one less commented code --- src/Widgets/DisplaysOverlay.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index cef3a014..e2e932ee 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -449,7 +449,7 @@ public class Display.DisplaysOverlay : Gtk.Box { } other_display_widget.set_geometry (other_x + distance_x, other_y + distance_y, other_width, other_height); - // other_display_widget.queue_resize_no_redraw (); + other_display_widget.queue_resize (); check_intersects (other_display_widget, level + 1, distance_x, distance_y); } } From 3b92f8a16a368d592173a38de27c869835691f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:26:51 -0800 Subject: [PATCH 17/31] Update DisplaysView.vala --- src/Views/DisplaysView.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 81bd83b1..85a0e43a 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -29,7 +29,6 @@ public class Display.DisplaysView : Gtk.Box { margin_start = 6, valign = CENTER }; - mirror_box.append (mirror_label); mirror_box.append (mirror_switch); From 0bd7d2be6af7426efe5b2d534aaa5ad78cbbb2eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:27:16 -0800 Subject: [PATCH 18/31] Update DisplaysView.vala --- src/Views/DisplaysView.vala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 85a0e43a..76bedf9d 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -45,7 +45,6 @@ public class Display.DisplaysView : Gtk.Box { margin_bottom = 6, margin_start = 6 }; - dpi_box.append (dpi_label); dpi_box.append (dpi_combo); @@ -63,7 +62,6 @@ public class Display.DisplaysView : Gtk.Box { margin_start = 6, valign = CENTER }; - button_box.append (detect_button); button_box.append (apply_button); From 8e9c1d223559dc614c8fea9abbdb1ed7196f6242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:27:51 -0800 Subject: [PATCH 19/31] Update DisplaysView.vala --- src/Views/DisplaysView.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 76bedf9d..1fceea27 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -91,7 +91,6 @@ public class Display.DisplaysView : Gtk.Box { action_bar.pack_end (button_box); orientation = VERTICAL; - append (new Gtk.Separator (HORIZONTAL)); append (displays_overlay); append (action_bar); @@ -149,7 +148,7 @@ public class Display.DisplaysView : Gtk.Box { rotation_lock_box.append (rotation_lock_label); rotation_lock_box.append (rotation_lock_switch); - touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", SettingsBindFlags.DEFAULT); + touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", DEFAULT); } } From beeff3bfa6e6da9791017ab8f07925c158c71655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:28:17 -0800 Subject: [PATCH 20/31] Update DisplaysView.vala --- src/Views/DisplaysView.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Views/DisplaysView.vala b/src/Views/DisplaysView.vala index 1fceea27..d9fa8997 100644 --- a/src/Views/DisplaysView.vala +++ b/src/Views/DisplaysView.vala @@ -149,7 +149,6 @@ public class Display.DisplaysView : Gtk.Box { rotation_lock_box.append (rotation_lock_switch); touchscreen_settings.bind ("orientation-lock", rotation_lock_switch, "state", DEFAULT); - } } From 188891cac8669ed2e95b21fd511b444c0a6794f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:36:26 -0800 Subject: [PATCH 21/31] Fix weird layout thing --- src/Views/NightLightView.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Views/NightLightView.vala b/src/Views/NightLightView.vala index cdc4648e..3a445878 100644 --- a/src/Views/NightLightView.vala +++ b/src/Views/NightLightView.vala @@ -61,15 +61,15 @@ public class Display.NightLightView : Gtk.Box { var schedule_manual_radio = new Gtk.CheckButton () { group = schedule_sunset_radio }; + schedule_manual_box.set_parent (schedule_manual_radio); var schedule_grid = new Gtk.Grid () { - column_spacing = 7, // Off by one with Gtk.CheckButton + column_spacing = 6, row_spacing = 6 }; - schedule_grid.attach (schedule_header, 0, 3, 2); - schedule_grid.attach (schedule_sunset_radio, 0, 5, 2); + schedule_grid.attach (schedule_header, 0, 3); + schedule_grid.attach (schedule_sunset_radio, 0, 5); schedule_grid.attach (schedule_manual_radio, 0, 6); - schedule_grid.attach (schedule_manual_box, 1, 6); var box = new Gtk.Box (VERTICAL, 24); box.append (nightlight_grid); From 043cda6d00612f970b19e29ee890ac1904e98692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 13:59:57 -0800 Subject: [PATCH 22/31] Fix warnings --- src/Views/FiltersView.vala | 5 +-- src/Widgets/DisplayWidget.vala | 10 +++-- src/Widgets/DisplaysOverlay.vala | 75 +++++++++++++++----------------- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index 5e59ac13..7d4e776c 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -302,9 +302,8 @@ public class Display.FiltersView : Gtk.Box { } construct { - var context = get_style_context (); - context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class (color); + get_style_context ().add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + add_css_class (color); valign = CENTER; } diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 2e716917..d567efc4 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -297,7 +297,7 @@ public class Display.DisplayWidget : Gtk.Widget { if (refresh_combobox.active == -1) refresh_combobox.set_active (0); if (use_switch.active) { - get_style_context ().remove_class ("disabled"); + remove_css_class ("disabled"); } else { add_css_class ("disabled"); } @@ -567,9 +567,11 @@ public class Display.DisplayWidget : Gtk.Widget { use_switch.sensitive = !is_primary; } - public void get_preferred_size (out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size) { - minimum_size.height = (int)(real_height * window_ratio); - minimum_size.width = (int)(real_width * window_ratio); + public new void get_preferred_size (out Gtk.Requisition minimum_size, out Gtk.Requisition natural_size) { + minimum_size = Gtk.Requisition () { + height = (int)(real_height * window_ratio), + width = (int)(real_width * window_ratio) + }; natural_size = minimum_size; } diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index e2e932ee..c71628fe 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -29,8 +29,8 @@ public class Display.DisplaysOverlay : Gtk.Box { private Gtk.Overlay overlay; private bool scanning = false; private double current_ratio = 1.0f; - private int current_allocated_width = 0; - private int current_allocated_height = 0; + private int current_width = 0; + private int current_height = 0; private int default_x_margin = 0; private int default_y_margin = 0; @@ -87,7 +87,7 @@ public class Display.DisplaysOverlay : Gtk.Box { private bool on_get_child_position (Gtk.Widget widget, out Gdk.Rectangle allocation) { allocation = Gdk.Rectangle (); - if (current_allocated_width != get_allocated_width () || current_allocated_height != get_allocated_height ()) { + if (current_width != get_width () || current_height != get_height ()) { calculate_ratio (); } @@ -177,52 +177,49 @@ public class Display.DisplaysOverlay : Gtk.Box { max_height = int.max (max_height, y + height); } - current_allocated_width = get_allocated_width (); - current_allocated_height = get_allocated_height (); + current_width = get_width (); + current_height = get_height (); current_ratio = double.min ( - (double) (get_allocated_width () - 24) / (double) added_width, - (double) (get_allocated_height () - 24) / (double) added_height + (double) (get_width () - 24) / (double) added_width, + (double) (get_height () - 24) / (double) added_height ); - default_x_margin = (int) ((get_allocated_width () - max_width * current_ratio) / 2); - default_y_margin = (int) ((get_allocated_height () - max_height * current_ratio) / 2); + default_x_margin = (int) ((get_width () - max_width * current_ratio) / 2); + default_y_margin = (int) ((get_height () - max_height * current_ratio) / 2); } private void add_output (Display.VirtualMonitor virtual_monitor) { var display_widget = new DisplayWidget (virtual_monitor); - current_allocated_width = 0; - current_allocated_height = 0; + current_width = 0; + current_height = 0; overlay.add_overlay (display_widget); display_widgets.append (display_widget); + var color_number = (display_widgets.length () - 2) % 7; + + var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); + var provider = new Gtk.CssProvider (); - try { - var color_number = (display_widgets.length () - 2) % 7; - - var colored_css = COLORED_STYLE_CSS.printf (colors[color_number], text_colors[color_number]); - provider.load_from_data (colored_css.data); - - var context = display_widget.get_style_context (); - context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); - - // context = display_widget.display_window.get_style_context (); - // context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - // context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - // context.add_class ("colored"); - - context = display_widget.primary_image.get_style_context (); - context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); - - context = display_widget.toggle_settings.get_style_context (); - context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); - } catch (GLib.Error e) { - critical (e.message); - } + provider.load_from_data (colored_css.data); + + var context = display_widget.get_style_context (); + context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_class ("colored"); + + // context = display_widget.display_window.get_style_context (); + // context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + // context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + // context.add_class ("colored"); + + context = display_widget.primary_image.get_style_context (); + context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_class ("colored"); + + context = display_widget.toggle_settings.get_style_context (); + context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + context.add_class ("colored"); display_widget.set_as_primary.connect (() => set_as_primary (display_widget.virtual_monitor)); From dca986f01944ae3d1fdfb847687ff0f15a6b807b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 12 Feb 2024 14:00:51 -0800 Subject: [PATCH 23/31] uncomment code --- src/Widgets/DisplaysOverlay.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index c71628fe..bd3d2fef 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -251,7 +251,7 @@ public class Display.DisplaysOverlay : Gtk.Box { int x, y, width, height; display_widget.get_geometry (out x, out y, out width, out height); display_widget.set_geometry (delta_x + x, delta_y + y, width, height); - // display_widget.queue_resize_no_redraw (); + display_widget.queue_resize (); check_configuration_changed (); check_intersects (display_widget); snap_edges (display_widget); From 709c322f88fccc480e8cc89212af565c3299904f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 20 Feb 2024 20:34:49 -0800 Subject: [PATCH 24/31] lint --- src/Widgets/DisplayWidget.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index f39333a1..5b10efdc 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -419,7 +419,7 @@ public class Display.DisplayWidget : Gtk.Widget { configuration_changed (); check_position (); - var drag_gesture = new Gtk.GestureDrag (); + var drag_gesture = new Gtk.GestureDrag (); drag_gesture.drag_begin.connect (on_drag_begin); drag_gesture.drag_update.connect (on_drag_update); drag_gesture.drag_end.connect (on_drag_end); From 33a4ef681f38fece0aa6d387eeb74091ff2fa692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 22 Feb 2024 13:17:46 -0800 Subject: [PATCH 25/31] Css stuff --- data/Display.css | 21 +++++++++------------ src/Widgets/DisplayWidget.vala | 15 +++++++-------- src/Widgets/DisplaysOverlay.vala | 3 --- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/data/Display.css b/data/Display.css index ccbcf583..c5d4ea82 100644 --- a/data/Display.css +++ b/data/Display.css @@ -1,43 +1,40 @@ /* For better dark style support */ @define-color BG_COLOR_ALPHA alpha(@BG_COLOR, 0.75); -.colored { +display-widget { background-color: @BG_COLOR_ALPHA; + border: 1px solid mix(@BG_COLOR_ALPHA, @TEXT_COLOR, 0.3); color: @TEXT_COLOR; text-shadow: 0 1px 1px alpha(white, 0.1); -gtk-icon-shadow: 0 1px 1px alpha(white, 0.1); -gtk-icon-palette: warning white; } -widget.colored { - border: 1px solid mix(@BG_COLOR_ALPHA, @TEXT_COLOR, 0.3); -} - -.colored button { +display-widget button { background: transparent; /* Fix stacking alpha on top of each other */ border-radius: 50%; padding: 6px; } -.colored button:focus { +display-widget button:focus { background: alpha(@TEXT_COLOR, 0.25); } -.colored button:checked { +display-widget button:checked { background: alpha(@TEXT_COLOR, 0.5); border-color: transparent; } -.colored.disabled { +display-widget.disabled { background-color: @SLATE_100; color: @SLATE_700; } -.colored.disabled button:focus { +display-widget.disabled button:focus { background: alpha(@SLATE_700, 0.25); } -.colored.disabled button:checked { +display-widget.disabled button:checked { background: alpha(@SLATE_700, 0.5); } @@ -46,7 +43,7 @@ label.rotate-90 { } label.rotate-180 { - transform: rotate(1800deg); + transform: rotate(180deg); } label.rotate-270 { diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 6cecd957..c07324ee 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -26,7 +26,7 @@ public struct Display.Resolution { bool is_current; } -public class Display.DisplayWidget : Gtk.Widget { +public class Display.DisplayWidget : Gtk.Box { public signal void set_as_primary (); public signal void check_position (); public signal void configuration_changed (); @@ -87,12 +87,14 @@ public class Display.DisplayWidget : Gtk.Widget { } static construct { - set_layout_manager_type (typeof (Gtk.BinLayout)); - display_provider = new Gtk.CssProvider (); display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); } + class construct { + set_css_name ("display-widget"); + } + construct { virtual_monitor.get_current_mode_size (out real_width, out real_height); @@ -283,7 +285,8 @@ public class Display.DisplayWidget : Gtk.Widget { grid.attach (primary_image, 0, 0); grid.attach (toggle_settings, 2, 0); grid.attach (label, 0, 0, 3, 2); - grid.set_parent (this); + + append (grid); set_primary (virtual_monitor.primary); @@ -473,10 +476,6 @@ public class Display.DisplayWidget : Gtk.Widget { refresh_combobox.sensitive = added > 1; } - ~DisplayWidget () { - get_first_child ().unparent (); - } - private void on_monitor_modes_changed () { set_active_resolution_from_current_mode (); } diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index a3dc4e78..a7dff8a1 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -333,17 +333,14 @@ public class Display.DisplaysOverlay : Gtk.Box { var context = display_widget.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); context = display_widget.primary_image.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); context = display_widget.toggle_settings.get_style_context (); context.add_provider (provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_provider (display_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - context.add_class ("colored"); display_widget.set_as_primary.connect (() => set_as_primary (display_widget.virtual_monitor)); From 16c5f2a1b915fac35e329ee7859b7faf15e74e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 23 Feb 2024 16:57:34 -0800 Subject: [PATCH 26/31] Finish namespace stuff --- .github/workflows/gettext.yml | 2 +- .github/workflows/release.yml | 2 +- README.md | 12 ++++++------ ...d.display.gresource.xml => display.gresource.xml} | 2 +- data/display.metainfo.xml.in | 6 +++--- data/meson.build | 7 ++++++- meson.build | 10 ++-------- ...y-plug.pot => io.elementary.settings.display.pot} | 0 src/DisplayPlug.vala | 2 +- src/Views/FiltersView.vala | 2 +- src/Widgets/DisplayWidget.vala | 2 +- src/Widgets/DisplaysOverlay.vala | 2 +- src/meson.build | 2 +- 13 files changed, 25 insertions(+), 26 deletions(-) rename data/{io.elementary.switchboard.display.gresource.xml => display.gresource.xml} (75%) rename po/{display-plug.pot => io.elementary.settings.display.pot} (100%) diff --git a/.github/workflows/gettext.yml b/.github/workflows/gettext.yml index 3f5087d5..839f84b2 100644 --- a/.github/workflows/gettext.yml +++ b/.github/workflows/gettext.yml @@ -2,7 +2,7 @@ name: Gettext Updates on: push: - branches: [master] + branches: [main] jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6d9a340a..e2418cdd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: pull_request: - branches: [master] + branches: [main] types: [closed] jobs: release: diff --git a/README.md b/README.md index eda3adba..ab3da153 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Switchboard Display Plug +# Display Settings [![Packaging status](https://repology.org/badge/tiny-repos/switchboard-plug-display.svg)](https://repology.org/metapackage/switchboard-plug-display) [![Translation status](https://l10n.elementary.io/widgets/switchboard/-/switchboard-plug-display/svg-badge.svg)](https://l10n.elementary.io/engage/switchboard/?utm_source=widget) -Extension for [Switchboard](https://github.com/elementary/switchboard) to manage multiple monitor setups. +Extension for [Ssstem Settings](https://github.com/elementary/switchboard) to manage multiple monitor setups. ![screenshot](data/screenshot.png?raw=true) @@ -10,9 +10,9 @@ Extension for [Switchboard](https://github.com/elementary/switchboard) to manage You'll need the following dependencies: -* libgranite-dev -* libgtk-3-dev -* libswitchboard-2.0-dev +* libgranite-7-dev +* libgtk-4-dev +* libswitchboard-3-dev * meson * valac @@ -24,4 +24,4 @@ Run `meson` to configure the build environment and then `ninja` to build To install, use `ninja install` - sudo ninja install + ninja install diff --git a/data/io.elementary.switchboard.display.gresource.xml b/data/display.gresource.xml similarity index 75% rename from data/io.elementary.switchboard.display.gresource.xml rename to data/display.gresource.xml index 64f749db..4ec22cef 100644 --- a/data/io.elementary.switchboard.display.gresource.xml +++ b/data/display.gresource.xml @@ -1,6 +1,6 @@ - + Display.css Filters.css diff --git a/data/display.metainfo.xml.in b/data/display.metainfo.xml.in index 8101fcb8..4e513932 100644 --- a/data/display.metainfo.xml.in +++ b/data/display.metainfo.xml.in @@ -1,8 +1,8 @@ - io.elementary.switchboard.display - io.elementary.switchboard - display-plug + io.elementary.settings.display + io.elementary.settings + io.elementary.settings.display CC0-1.0 GPL-3.0+ diff --git a/data/meson.build b/data/meson.build index 9e22b7fa..bb32ce31 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,8 +1,13 @@ i18n.merge_file( input: 'display.metainfo.xml.in', - output: 'io.elementary.switchboard.display.metainfo.xml', + output: gettext_name + '.metainfo.xml', po_dir: meson.project_source_root() / 'po' / 'extra', type: 'xml', install: true, install_dir: get_option('datadir') / 'metainfo', ) + +gresource = gnome.compile_resources( + 'gresource', + 'display.gresource.xml' +) diff --git a/meson.build b/meson.build index 20410e4f..ced548fa 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ project( version: '7.0.0' ) -gettext_name = meson.project_name() + '-plug' +gettext_name = 'io.elementary.settings.' + meson.project_name() gnome = import('gnome') i18n = import('i18n') @@ -17,15 +17,9 @@ add_project_arguments( language:'c' ) -asresources = gnome.compile_resources( - 'as-resources', 'data/' + 'io.elementary.switchboard.display.gresource.xml', - source_dir: 'data', - c_name: 'as' -) - config_data = configuration_data() config_data.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir'))) -config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name() + '-plug') +config_data.set_quoted('GETTEXT_PACKAGE', gettext_name) config_file = configure_file( input: 'src/Config.vala.in', output: '@BASENAME@', diff --git a/po/display-plug.pot b/po/io.elementary.settings.display.pot similarity index 100% rename from po/display-plug.pot rename to po/io.elementary.settings.display.pot diff --git a/src/DisplayPlug.vala b/src/DisplayPlug.vala index 6a3ebb3a..08392aaa 100644 --- a/src/DisplayPlug.vala +++ b/src/DisplayPlug.vala @@ -35,7 +35,7 @@ public class Display.Plug : Switchboard.Plug { settings.set ("display/night-light", "night-light"); settings.set ("display/filters", "filters"); Object (category: Category.HARDWARE, - code_name: "io.elementary.switchboard.display", + code_name: "io.elementary.settings.display", display_name: _("Displays"), description: _("Configure resolution and position of monitors and projectors"), icon: "preferences-desktop-display", diff --git a/src/Views/FiltersView.vala b/src/Views/FiltersView.vala index 7d4e776c..d264d2ff 100644 --- a/src/Views/FiltersView.vala +++ b/src/Views/FiltersView.vala @@ -298,7 +298,7 @@ public class Display.FiltersView : Gtk.Box { static construct { provider = new Gtk.CssProvider (); - provider.load_from_resource ("io/elementary/switchboard/display/Filters.css"); + provider.load_from_resource ("io/elementary/settings/display/Filters.css"); } construct { diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index c07324ee..6cfde268 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -88,7 +88,7 @@ public class Display.DisplayWidget : Gtk.Box { static construct { display_provider = new Gtk.CssProvider (); - display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); + display_provider.load_from_resource ("io/elementary/settings/display/Display.css"); } class construct { diff --git a/src/Widgets/DisplaysOverlay.vala b/src/Widgets/DisplaysOverlay.vala index a7dff8a1..dc7a1244 100644 --- a/src/Widgets/DisplaysOverlay.vala +++ b/src/Widgets/DisplaysOverlay.vala @@ -102,7 +102,7 @@ public class Display.DisplaysOverlay : Gtk.Box { static construct { display_provider = new Gtk.CssProvider (); - display_provider.load_from_resource ("io/elementary/switchboard/display/Display.css"); + display_provider.load_from_resource ("io/elementary/settings/display/Display.css"); GLib.Bus.get_proxy.begin ( GLib.BusType.SESSION, diff --git a/src/meson.build b/src/meson.build index 71c0786b..60897e1a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -23,7 +23,7 @@ shared_module( meson.project_name(), plug_files, config_file, - asresources, + gresource, dependencies: [ dependency('glib-2.0'), dependency('gio-2.0'), From ea73c2fc90a1d2e11e3355c5939c42d1c4f4f567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 23 Feb 2024 16:58:59 -0800 Subject: [PATCH 27/31] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ab3da153..0adff170 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Packaging status](https://repology.org/badge/tiny-repos/switchboard-plug-display.svg)](https://repology.org/metapackage/switchboard-plug-display) [![Translation status](https://l10n.elementary.io/widgets/switchboard/-/switchboard-plug-display/svg-badge.svg)](https://l10n.elementary.io/engage/switchboard/?utm_source=widget) -Extension for [Ssstem Settings](https://github.com/elementary/switchboard) to manage multiple monitor setups. +Extension for [System Settings](https://github.com/elementary/switchboard) to manage multiple monitor setups. ![screenshot](data/screenshot.png?raw=true) From 64d3124ad1dbc416ba38cba7ede131644544b7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 23 Feb 2024 16:59:32 -0800 Subject: [PATCH 28/31] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0adff170..4a7deae8 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Extension for [System Settings](https://github.com/elementary/switchboard) to ma You'll need the following dependencies: +* libadwaita-1-dev * libgranite-7-dev * libgtk-4-dev * libswitchboard-3-dev From c50ae14c81f90419ee448dd5f1ae7693c583f037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 26 Feb 2024 09:18:07 -0800 Subject: [PATCH 29/31] Fix review comments --- data/Display.css | 1 + src/Widgets/DisplayWidget.vala | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/data/Display.css b/data/Display.css index c5d4ea82..cc2222af 100644 --- a/data/Display.css +++ b/data/Display.css @@ -5,6 +5,7 @@ display-widget { background-color: @BG_COLOR_ALPHA; border: 1px solid mix(@BG_COLOR_ALPHA, @TEXT_COLOR, 0.3); color: @TEXT_COLOR; + padding: 6px; text-shadow: 0 1px 1px alpha(white, 0.1); -gtk-icon-shadow: 0 1px 1px alpha(white, 0.1); -gtk-icon-palette: warning white; diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 6cfde268..16536119 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -100,11 +100,7 @@ public class Display.DisplayWidget : Gtk.Box { primary_image = new Gtk.Button.from_icon_name ("non-starred-symbolic") { halign = START, - valign = START, - margin_top = 6, - margin_end = 6, - margin_bottom = 6, - margin_start = 6 + valign = START }; primary_image.add_css_class (Granite.STYLE_CLASS_FLAT); primary_image.clicked.connect (() => set_as_primary ()); @@ -269,17 +265,13 @@ public class Display.DisplayWidget : Gtk.Box { }; toggle_settings = new Gtk.MenuButton () { + has_frame = false, halign = END, valign = START, icon_name = "open-menu-symbolic", - margin_top = 6, - margin_end = 6, - margin_bottom = 6, - margin_start = 6, popover = popover, tooltip_text = _("Configure display") }; - toggle_settings.add_css_class (Granite.STYLE_CLASS_FLAT); var grid = new Gtk.Grid (); grid.attach (primary_image, 0, 0); @@ -314,6 +306,9 @@ public class Display.DisplayWidget : Gtk.Box { } resolution_combobox.changed.connect (() => { + // Prevent breaking autohide by closing popover + popover.popdown (); + int active_width, active_height; Gtk.TreeIter iter; if (resolution_combobox.get_active_iter (out iter)) { @@ -339,6 +334,9 @@ public class Display.DisplayWidget : Gtk.Box { }); rotation_combobox.changed.connect (() => { + // Prevent breaking autohide by closing popover + popover.popdown (); + Value val; Gtk.TreeIter iter; rotation_combobox.get_active_iter (out iter); @@ -395,6 +393,9 @@ public class Display.DisplayWidget : Gtk.Box { }); refresh_combobox.changed.connect (() => { + // Prevent breaking autohide by closing popover + popover.popdown (); + Value val; Gtk.TreeIter iter; if (refresh_combobox.get_active_iter (out iter)) { From 88ee53d11320032e7753c6afbbede38f67a9135a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 28 Feb 2024 10:13:06 -0800 Subject: [PATCH 30/31] Has frame property --- src/Widgets/DisplayWidget.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 657e429f..eb8537e7 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -90,10 +90,10 @@ public class Display.DisplayWidget : Gtk.Box { virtual_monitor.get_current_mode_size (out real_width, out real_height); primary_image = new Gtk.Button.from_icon_name ("non-starred-symbolic") { + has_frame = false, halign = START, valign = START }; - primary_image.add_css_class (Granite.STYLE_CLASS_FLAT); primary_image.clicked.connect (() => set_as_primary ()); var virtual_monitor_name = virtual_monitor.get_display_name (); From dd6756b35ba5ef682c7ad7e5916e094a32e1c83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Wed, 28 Feb 2024 10:16:01 -0800 Subject: [PATCH 31/31] Fix disabled style --- data/Display.css | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/data/Display.css b/data/Display.css index 77b6b06c..2f0b057f 100644 --- a/data/Display.css +++ b/data/Display.css @@ -32,20 +32,6 @@ display-widget label.rotate-270 { transform: rotate(270deg); } -display-widget.disabled { - background-color: alpha(@SLATE_100, 0.75); - border: 1px solid alpha(@SLATE_500, 0.75); - color: @SLATE_700; -} - -display-widget.disabled button.flat.image-button:focus { - background: alpha(@SLATE_700, 0.25); -} - -display-widget.disabled button.flat.image-button:checked { - background: alpha(@SLATE_700, 0.5); -} - display-widget.color-0 { background-color: alpha(@BLUEBERRY_100, 0.75); border: 1px solid alpha(@BLUEBERRY_500, 0.75); @@ -143,3 +129,17 @@ display-widget.color-6 button.flat.image-button:focus { display-widget.color-6 button.flat.image-button:checked { background: alpha(@COCOA_500, 0.75); } + +display-widget.disabled { + background-color: alpha(@SLATE_100, 0.75); + border: 1px solid alpha(@SLATE_500, 0.75); + color: @SLATE_700; +} + +display-widget.disabled button.flat.image-button:focus { + background: alpha(@SLATE_700, 0.25); +} + +display-widget.disabled button.flat.image-button:checked { + background: alpha(@SLATE_700, 0.5); +}