From a502bb8d4c84246068ed63c413ad8c9cb9574710 Mon Sep 17 00:00:00 2001 From: lenemter Date: Thu, 31 Oct 2024 17:33:18 +0300 Subject: [PATCH 1/2] MainWindow: Separate the container background from the window --- data/Application.css | 9 ++++++--- src/MainWindow.vala | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/data/Application.css b/data/Application.css index cbd3b266..86a8ed37 100644 --- a/data/Application.css +++ b/data/Application.css @@ -1,8 +1,12 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2023 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2023-2024 elementary, Inc. (https://elementary.io) */ +dock-window { + margin: 16px 0 9px 0; +} + dock { background: alpha(@bg_color, 0.6); border-radius: 9px; @@ -14,8 +18,7 @@ dock { 0 0 0 1px alpha(@borders, 0.4), 0 1px 3px alpha(black, 0.10), 0 3px 9px alpha(black, 0.15); - margin: 9px; - margin-top: 0; + padding: 9px } launcher { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 460b5946..29b50885 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -1,8 +1,14 @@ /* * SPDX-License-Identifier: GPL-3.0 - * SPDX-FileCopyrightText: 2022 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2022-2024 elementary, Inc. (https://elementary.io) */ +public class Dock.Container : Gtk.Box { + class construct { + set_css_name ("dock"); + } +} + public class Dock.MainWindow : Gtk.ApplicationWindow { private static Settings settings = new Settings ("io.elementary.dock"); @@ -10,17 +16,29 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { private Pantheon.Desktop.Panel? panel; class construct { - set_css_name ("dock"); + set_css_name ("dock-window"); } construct { var launcher_manager = LauncherManager.get_default (); - child = launcher_manager; overflow = VISIBLE; resizable = false; titlebar = new Gtk.Label ("") { visible = false }; + var overlay = new Gtk.Overlay () { + child = new Dock.Container () + }; + overlay.add_overlay (launcher_manager); + + var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); + size_group.add_widget (overlay.child); + size_group.add_widget (launcher_manager); + + child = overlay; + + remove_css_class("background"); + // Fixes DnD reordering of launchers failing on a very small line between two launchers var drop_target_launcher = new Gtk.DropTarget (typeof (Launcher), MOVE); launcher_manager.add_controller (drop_target_launcher); From e202ea381ff0026c9fd9b55723e10c06dabd366b Mon Sep 17 00:00:00 2001 From: lenemter Date: Thu, 31 Oct 2024 17:56:06 +0300 Subject: [PATCH 2/2] Add support for styles --- data/Application.css | 25 ++++++++++++++++++++++++- data/dock.gschema.xml | 14 +++++++++++++- src/MainWindow.vala | 31 ++++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/data/Application.css b/data/Application.css index 86a8ed37..ede3b82a 100644 --- a/data/Application.css +++ b/data/Application.css @@ -7,6 +7,10 @@ dock-window { margin: 16px 0 9px 0; } +dock-window.traditional { + margin: 16px 0 0 0; +} + dock { background: alpha(@bg_color, 0.6); border-radius: 9px; @@ -18,7 +22,26 @@ dock { 0 0 0 1px alpha(@borders, 0.4), 0 1px 3px alpha(black, 0.10), 0 3px 9px alpha(black, 0.15); - padding: 9px + padding: 9px; +} + +dock.traditional { + background: alpha(@bg_color, 0.7); + border-radius: 6px 6px 0 0; + box-shadow: + inset 0 -1px 0 0 alpha(@highlight_color, 0.2), + inset 0 1px 0 0 alpha(@highlight_color, 0.3), + inset 1px 0 0 0 alpha(@highlight_color, 0.07), + inset -1px 0 0 0 alpha(@highlight_color, 0.07), + 0 0 0 1px alpha(@borders, 0.5), + 0 1px 3px alpha(black, 0.12), + 0 1px 2px alpha(black, 0.24); + margin-top: 32px; +} + +dock.transparent { + background:none; + box-shadow: none; } launcher { diff --git a/data/dock.gschema.xml b/data/dock.gschema.xml index 6b50086d..e9e6dfc8 100644 --- a/data/dock.gschema.xml +++ b/data/dock.gschema.xml @@ -8,10 +8,16 @@ + + + + + + 'overlapping-focus-window' - Autohide mode + Autohide mode How autohide should be handled @@ -21,6 +27,12 @@ Logical pixel size of app launcher icons + + 'modern' + Appearance of the dock + Appearance of the dock + + ['gala-multitaskingview.desktop', 'io.elementary.files.desktop', 'org.gnome.Epiphany.desktop', 'io.elementary.mail.desktop', 'io.elementary.tasks.desktop', 'io.elementary.calendar.desktop', 'io.elementary.music.desktop', 'io.elementary.videos.desktop', 'io.elementary.photos.desktop', 'io.elementary.settings.desktop', 'io.elementary.appcenter.desktop', 'io.elementary.installer.desktop'] An ordered array of app id's to show as launchers diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 29b50885..10f2da5a 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -11,6 +11,9 @@ public class Dock.Container : Gtk.Box { public class Dock.MainWindow : Gtk.ApplicationWindow { private static Settings settings = new Settings ("io.elementary.dock"); + + private Dock.Container dock_container; + private string? current_style; private Pantheon.Desktop.Shell? desktop_shell; private Pantheon.Desktop.Panel? panel; @@ -22,23 +25,26 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { construct { var launcher_manager = LauncherManager.get_default (); - overflow = VISIBLE; - resizable = false; - titlebar = new Gtk.Label ("") { visible = false }; + dock_container = new Dock.Container (); var overlay = new Gtk.Overlay () { - child = new Dock.Container () + child = dock_container }; overlay.add_overlay (launcher_manager); var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.BOTH); - size_group.add_widget (overlay.child); + size_group.add_widget (dock_container); size_group.add_widget (launcher_manager); + overflow = VISIBLE; + resizable = false; + titlebar = new Gtk.Label ("") { visible = false }; child = overlay; remove_css_class("background"); + update_style (); + // Fixes DnD reordering of launchers failing on a very small line between two launchers var drop_target_launcher = new Gtk.DropTarget (typeof (Launcher), MOVE); launcher_manager.add_controller (drop_target_launcher); @@ -52,6 +58,21 @@ public class Dock.MainWindow : Gtk.ApplicationWindow { update_panel_x11 (); } }); + + settings.changed["style"].connect (update_style); + } + + private void update_style () { + if (current_style != null) { + remove_css_class (current_style); + dock_container.remove_css_class (current_style); + } + + var new_style = settings.get_string ("style"); + add_css_class (new_style); + dock_container.add_css_class (new_style); + + current_style = new_style; } public void registry_handle_global (Wl.Registry wl_registry, uint32 name, string @interface, uint32 version) {