From 43d2ad2147d2dca0cb7be36c08ffc1df486fcde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 7 Mar 2024 13:25:41 -0800 Subject: [PATCH 01/22] Start build for GTK 4 --- .github/workflows/main.yml | 2 +- src/Cards/UserCard.vala | 2 +- src/MainWindow.vala | 2 +- src/meson.build | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e92c9084d..ad68e5557 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y desktop-file-utils libaccountsservice-dev libclutter-gtk-1.0-dev libgdk-pixbuf2.0-dev libgranite-dev libgtk-3-dev libhandy-1-dev liblightdm-gobject-1-dev libx11-dev meson ${{ matrix.mutter_pkg }} libgnome-desktop-3-dev valac + apt install -y desktop-file-utils libaccountsservice-dev libclutter-gtk-1.0-dev libgdk-pixbuf2.0-dev libgranite-7-dev libgtk-4-dev libadwaita-1-dev liblightdm-gobject-1-dev libx11-dev meson libmutter-10-dev libgnome-desktop-3-dev valac - name: Build env: DESTDIR: out diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index ea9742579..2eca338c8 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -24,7 +24,7 @@ public class Greeter.UserCard : Greeter.BaseCard { private Pantheon.AccountsService greeter_act; private Pantheon.SettingsDaemon.AccountsService settings_act; - private Gtk.GestureMultiPress click_gesture; + private Gtk.GestureClick click_gesture; private Gtk.Revealer form_revealer; private Gtk.Stack login_stack; private Greeter.PasswordEntry password_entry; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 344ad448e..05cf05b33 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -24,7 +24,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private GLib.Queue user_cards; private Gtk.SizeGroup card_size_group; - private Hdy.Carousel carousel; + private Adw.Carousel carousel; private LightDM.Greeter lightdm_greeter; private Greeter.Settings settings; private Gtk.Button guest_login_button; diff --git a/src/meson.build b/src/meson.build index 909954288..bdea217ce 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,9 +1,9 @@ actservice_dep = dependency('accountsservice') gobject_dep = dependency('gobject-2.0') glib_dep = dependency('glib-2.0') -gtk_dep = dependency('gtk+-3.0') -granite_dep = dependency('granite', version: '>= 5.5.0') -hdy_dep = dependency('libhandy-1', version: '>= 1.1.90') +gtk_dep = dependency('gtk4') +granite_dep = dependency('granite-7', version: '>= 7.0.0') +adw_dep = dependency('libadwaita-1', version: '>= 1.0.0') lightdm_dep = dependency('liblightdm-gobject-1') gnome_desktop_dep = dependency('gnome-desktop-3.0') m_dep = meson.get_compiler('c').find_library('m') @@ -30,7 +30,7 @@ executable( 'Widgets/PasswordEntry.vala', 'Widgets/SessionButton.vala', config_header, - dependencies: [ actservice_dep, gobject_dep, glib_dep, gtk_dep, granite_dep, hdy_dep, lightdm_dep, m_dep ], + dependencies: [ actservice_dep, gobject_dep, glib_dep, gtk_dep, granite_dep, adw_dep, lightdm_dep, m_dep ], install : true, install_dir: install_path ) From acef0979265d9ae6ba94de3457116ee25f4905b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 7 Mar 2024 13:49:28 -0800 Subject: [PATCH 02/22] SessionButton: build menu from model --- src/Widgets/SessionButton.vala | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index de4026587..e1b731676 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -21,26 +21,12 @@ public class Greeter.SessionButton : Gtk.MenuButton { construct { - var settings_list = new Gtk.ListBox () { - margin_bottom = 3, - margin_top = 3 - }; - settings_list.set_sort_func ((row1, row2) => { - var child1 = (Gtk.ModelButton) row1.get_child (); - var child2 = (Gtk.ModelButton) row2.get_child (); - - return child1.text.collate (child2.text); - }); - - var settings_popover = new Gtk.Popover (this) { - position = Gtk.PositionType.BOTTOM - }; - settings_popover.add (settings_list); + var menu = new GLib.Menu (); var cog_image = new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.BUTTON); - direction = Gtk.ArrowType.DOWN; - popover = settings_popover; + direction = DOWN; + menu_model = menu; get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); add (cog_image); @@ -54,19 +40,7 @@ public class Greeter.SessionButton : Gtk.MenuButton { GLib.Variant? val = null; string? key = null; while (iter.next ("{sv}", out key, out val)) { - var radio = new Gtk.ModelButton () { - text = key - }; - radio.set_detailed_action_name (Action.print_detailed_name ("session.select", val)); - - settings_list.add (radio); - } - - if (settings_list.get_row_at_index (1) == null) { - destroy (); - } else { - settings_list.show_all (); - settings_list.invalidate_sort (); + menu.append (key, Action.print_detailed_name ("session.select", val)); } } }); From 7d71741ccc2a488987f294e2c0ed204a0f771c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 7 Mar 2024 13:52:58 -0800 Subject: [PATCH 03/22] self destruct --- src/Widgets/SessionButton.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index e1b731676..c5d88900e 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -42,6 +42,10 @@ public class Greeter.SessionButton : Gtk.MenuButton { while (iter.next ("{sv}", out key, out val)) { menu.append (key, Action.print_detailed_name ("session.select", val)); } + + if (menu.get_n_items () = 0) { + destroy (); + } } }); } From 0ce4926208192ded351a16f37f5d4aa613177a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 7 Mar 2024 13:53:52 -0800 Subject: [PATCH 04/22] equality --- src/Widgets/SessionButton.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index c5d88900e..465063311 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -43,7 +43,7 @@ public class Greeter.SessionButton : Gtk.MenuButton { menu.append (key, Action.print_detailed_name ("session.select", val)); } - if (menu.get_n_items () = 0) { + if (menu.get_n_items () == 0) { destroy (); } } From 564302045d3f1d1fe62b2617119c06a35a230289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Thu, 7 Mar 2024 15:48:01 -0800 Subject: [PATCH 05/22] Maybe fix capslock and numlock? --- src/Widgets/CapsLockRevealer.vala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Widgets/CapsLockRevealer.vala b/src/Widgets/CapsLockRevealer.vala index 3306921a4..aecdcbf70 100644 --- a/src/Widgets/CapsLockRevealer.vala +++ b/src/Widgets/CapsLockRevealer.vala @@ -18,7 +18,7 @@ */ public class Greeter.CapsLockRevealer : Gtk.Revealer { - private weak Gdk.Keymap keymap; + private unowned Gdk.Device device; private Gtk.Image caps_lock_image; private Gtk.Image num_lock_image; @@ -48,16 +48,16 @@ public class Greeter.CapsLockRevealer : Gtk.Revealer { add (caps_lock_grid); - keymap = Gdk.Keymap.get_for_display (Gdk.Display.get_default ()); - keymap.state_changed.connect (update_visibility); + device = Gdk.Display.get_default ().get_default_seat ().get_devices (KEYBOARD)[0]; + device.changed.connect (update_visibility); update_visibility (); } private void update_visibility () { unowned string? label = null; - var caps_lock = keymap.get_caps_lock_state (); - var num_lock = keymap.get_num_lock_state (); + var caps_lock = device.caps_lock_state; + var num_lock = device.num_lock_state; reveal_child = caps_lock || num_lock; From d32dd161f7d9947c4113e4364eb0bdc604f4286c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Sun, 10 Mar 2024 14:09:30 -0700 Subject: [PATCH 06/22] minor API stuff --- src/Application.vala | 1 - src/Cards/UserCard.vala | 1 - src/MainWindow.vala | 8 +++----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index c107f55a0..d45cc819b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -44,7 +44,6 @@ public int main (string[] args) { Gtk.init (ref args); var window = new Greeter.MainWindow (); - window.show_all (); try { wingpanel = new Greeter.SubprocessSupervisor ({"io.elementary.wingpanel", "-g"}); diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 314189b75..50a825514 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -285,7 +285,6 @@ public class Greeter.UserCard : Greeter.BaseCard { } main_box.pack_start (background_image); - main_box.show_all (); } private string accent_to_string (int i) { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 3204ead9a..79f4263fc 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -54,7 +54,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { construct { app_paintable = true; decorated = false; - type_hint = Gdk.WindowTypeHint.DESKTOP; get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); settings = new Greeter.Settings (); @@ -98,9 +97,9 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { margin_top = 24, margin_bottom = 24 }; - main_box.add (datetime_widget); - main_box.add (manual_login_stack); - main_box.add (extra_login_grid); + main_box.append (datetime_widget); + main_box.append (manual_login_stack); + main_box.append (extra_login_grid); child = main_box; @@ -499,7 +498,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private void add_card (LightDM.User lightdm_user) { var user_card = new Greeter.UserCard (lightdm_user); - user_card.show_all (); carousel.add (user_card); From 88cfe9354e5528d9862ec58d732537eb0d1b7af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 7 Oct 2024 15:42:40 -0700 Subject: [PATCH 07/22] Merge main, backgroundimage picture --- src/Widgets/BackgroundImage.vala | 62 ++------------------------------ 1 file changed, 3 insertions(+), 59 deletions(-) diff --git a/src/Widgets/BackgroundImage.vala b/src/Widgets/BackgroundImage.vala index c52274ca0..f724e732d 100644 --- a/src/Widgets/BackgroundImage.vala +++ b/src/Widgets/BackgroundImage.vala @@ -1,8 +1,4 @@ -public class Greeter.BackgroundImage : Gtk.EventBox { - private uint last_size_hash = 0; - private Gdk.Pixbuf full_pixbuf; - private Gdk.Pixbuf fitting_pixbuf; - +public class Greeter.BackgroundImage : Gtk.Picture { construct { height_request = 150; } @@ -12,18 +8,7 @@ public class Greeter.BackgroundImage : Gtk.EventBox { path = "/usr/share/backgrounds/elementaryos-default"; } - try { - full_pixbuf = new Gdk.Pixbuf.from_file (path); - } catch (GLib.Error e) { - critical (e.message); - critical ("Fallback to default wallpaper"); - - try { - full_pixbuf = new Gdk.Pixbuf.from_file ("/usr/share/backgrounds/elementaryos-default"); - } catch (GLib.Error e) { - critical (e.message); - } - } + set_filename (path); } public BackgroundImage.from_color (string color) { @@ -42,48 +27,7 @@ public class Greeter.BackgroundImage : Gtk.EventBox { f += 255; full_pixbuf.fill (f); - } - - public override bool draw (Cairo.Context cr) { - var scale = get_scale_factor (); - var width = get_allocated_width () * scale; - var height = get_allocated_height () * scale; - var radius = 5 * scale; // Off-by-one to prevent light bleed - - var new_hash = GLib.int_hash (width) + GLib.int_hash (height); - if (new_hash != last_size_hash) { - last_size_hash = new_hash; - double full_ratio = (double)full_pixbuf.height / (double)full_pixbuf.width; - fitting_pixbuf = new Gdk.Pixbuf (full_pixbuf.colorspace, full_pixbuf.has_alpha, full_pixbuf.bits_per_sample, width, height); - - // Get a scaled pixbuf that preserves aspect ratio but is at least as big as the desired destination pixbuf - Gdk.Pixbuf scaled_pixbuf; - if ((int)(width * full_ratio) < height) { - scaled_pixbuf = full_pixbuf.scale_simple ((int)(width * (1 / full_ratio)), height, Gdk.InterpType.BILINEAR); - } else { - scaled_pixbuf = full_pixbuf.scale_simple (width, (int)(width * full_ratio), Gdk.InterpType.BILINEAR); - } - - // Find the offset we need to center the source pixbuf on the destination - int y = ((height - scaled_pixbuf.height) / 2).abs (); - int x = ((width - scaled_pixbuf.width) / 2).abs (); - - scaled_pixbuf.copy_area (x, y, width, height, fitting_pixbuf, 0, 0); - } - - cr.save (); - cr.scale (1.0 / scale, 1.0 / scale); - cr.new_sub_path (); - cr.arc (width - radius, radius, radius, -Math.PI_2, 0); - cr.line_to (width, height); - cr.line_to (0, height); - cr.arc (radius, radius, radius, Math.PI, Math.PI + Math.PI_2); - cr.close_path (); - Gdk.cairo_set_source_pixbuf (cr, fitting_pixbuf, 0, 0); - cr.clip (); - cr.paint (); - cr.restore (); - return true; + paintable = Gdk.Texture.for_pixbuf (pixbuf); } } From 04839888fb4c43e7ec008adbbe5579309064a247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 7 Oct 2024 15:44:17 -0700 Subject: [PATCH 08/22] Replace style classes --- src/Application.vala | 2 +- src/Cards/ManualCard.vala | 12 ++++++------ src/Cards/UserCard.vala | 10 +++++----- src/Widgets/CapsLockRevealer.vala | 2 +- src/Widgets/SessionButton.vala | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 427c0d66a..34db6e73a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -36,7 +36,7 @@ public class Greeter.Application : Gtk.Application { public override void activate () { add_window (new Greeter.MainWindow ()); - active_window.show_all (); + active_window.present (); } public static int main (string[] args) { diff --git a/src/Cards/ManualCard.vala b/src/Cards/ManualCard.vala index 5d91b7030..3032a6171 100644 --- a/src/Cards/ManualCard.vala +++ b/src/Cards/ManualCard.vala @@ -121,18 +121,18 @@ public class Greeter.ManualCard : Greeter.BaseCard { password_entry.text = ""; unowned var username_entry_style_context = username_entry.get_style_context (); - username_entry_style_context.add_class (Gtk.STYLE_CLASS_ERROR); + username_entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); unowned var password_entry_style_context = password_entry.get_style_context (); - password_entry_style_context.add_class (Gtk.STYLE_CLASS_ERROR); + password_entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); unowned var grid_style_context = main_box.get_style_context (); grid_style_context.add_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { grid_style_context.remove_class ("shake"); - username_entry_style_context.remove_class (Gtk.STYLE_CLASS_ERROR); - password_entry_style_context.remove_class (Gtk.STYLE_CLASS_ERROR); + username_entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); + password_entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); connecting = false; focus_username_entry (); @@ -150,14 +150,14 @@ public class Greeter.ManualCard : Greeter.BaseCard { username_entry.text = ""; unowned var entry_style_context = username_entry.get_style_context (); - entry_style_context.add_class (Gtk.STYLE_CLASS_ERROR); + entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); unowned var grid_style_context = main_box.get_style_context (); grid_style_context.add_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { grid_style_context.remove_class ("shake"); - entry_style_context.remove_class (Gtk.STYLE_CLASS_ERROR); + entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); return Source.REMOVE; }); diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 50a825514..dd555e927 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -105,7 +105,7 @@ public class Greeter.UserCard : Greeter.BaseCard { size_group.add_widget (session_button); var login_button = new Gtk.Button.with_label (_("Log In")); - login_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); + login_button.get_style_context ().add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); bind_property ( "connecting", @@ -122,7 +122,7 @@ public class Greeter.UserCard : Greeter.BaseCard { halign = Gtk.Align.CENTER, margin_top = 3 }; - disabled_box.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + disabled_box.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); disabled_box.add (disabled_icon); disabled_box.add (disabled_message); @@ -512,13 +512,13 @@ public class Greeter.UserCard : Greeter.BaseCard { public override void wrong_credentials () { unowned var entry_style_context = password_entry.get_style_context (); - entry_style_context.add_class (Gtk.STYLE_CLASS_ERROR); + entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); main_box_style_context.add_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { main_box_style_context.remove_class ("shake"); - entry_style_context.remove_class (Gtk.STYLE_CLASS_ERROR); + entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); connecting = false; password_entry.grab_focus (); @@ -530,7 +530,7 @@ public class Greeter.UserCard : Greeter.BaseCard { private static Gtk.CssProvider check_provider; class construct { - set_css_name (Gtk.STYLE_CLASS_CHECK); + set_css_name (Granite.STYLE_CLASS_CHECK); } static construct { diff --git a/src/Widgets/CapsLockRevealer.vala b/src/Widgets/CapsLockRevealer.vala index aecdcbf70..3069719db 100644 --- a/src/Widgets/CapsLockRevealer.vala +++ b/src/Widgets/CapsLockRevealer.vala @@ -41,7 +41,7 @@ public class Greeter.CapsLockRevealer : Gtk.Revealer { var caps_lock_grid = new Gtk.Grid (); caps_lock_grid.column_spacing = 3; caps_lock_grid.halign = Gtk.Align.CENTER; - caps_lock_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + caps_lock_grid.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); caps_lock_grid.add (caps_lock_image); caps_lock_grid.add (num_lock_image); caps_lock_grid.add (lock_label); diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index 465063311..311ad43a5 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -27,7 +27,7 @@ public class Greeter.SessionButton : Gtk.MenuButton { direction = DOWN; menu_model = menu; - get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT); + get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); add (cog_image); // The session action is on the MainWindow toplevel, wait until it is accessible. From 33ad88463756793895e92886ecd207a7b4edb9bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 7 Oct 2024 16:06:49 -0700 Subject: [PATCH 09/22] Solve a lot of errors --- src/Cards/BaseCard.vala | 3 +- src/Cards/ManualCard.vala | 43 ++++++++----------- src/Cards/UserCard.vala | 69 +++++++++++++------------------ src/MainWindow.vala | 10 ++--- src/Widgets/BackgroundImage.vala | 4 +- src/Widgets/CapsLockRevealer.vala | 22 +++++----- src/Widgets/DateTimeWidget.vala | 10 ++--- src/Widgets/SessionButton.vala | 6 +-- 8 files changed, 69 insertions(+), 98 deletions(-) diff --git a/src/Cards/BaseCard.vala b/src/Cards/BaseCard.vala index 66e140149..a621fecd9 100644 --- a/src/Cards/BaseCard.vala +++ b/src/Cards/BaseCard.vala @@ -52,8 +52,7 @@ public abstract class Greeter.BaseCard : Gtk.Box { width_request = 350 }; - add (revealer); - events |= Gdk.EventMask.BUTTON_RELEASE_MASK; + append (revealer); revealer.notify["child-revealed"].connect (() => { if (!revealer.child_revealed) { diff --git a/src/Cards/ManualCard.vala b/src/Cards/ManualCard.vala index 3032a6171..b50590015 100644 --- a/src/Cards/ManualCard.vala +++ b/src/Cards/ManualCard.vala @@ -22,7 +22,7 @@ public class Greeter.ManualCard : Greeter.BaseCard { hexpand = true, margin_bottom = 16 }; - label.get_style_context ().add_class (Granite.STYLE_CLASS_H2_LABEL); + label.add_css_class (Granite.STYLE_CLASS_H2_LABEL); username_entry = new Gtk.Entry () { hexpand = true, @@ -41,8 +41,8 @@ public class Greeter.ManualCard : Greeter.BaseCard { var caps_lock_revealer = new Greeter.CapsLockRevealer (); var password_box = new Gtk.Box (VERTICAL, 6); - password_box.add (password_entry); - password_box.add (caps_lock_revealer); + password_box.append (password_entry); + password_box.append (caps_lock_revealer); var session_button = new Greeter.SessionButton (); @@ -66,12 +66,11 @@ public class Greeter.ManualCard : Greeter.BaseCard { margin_start = 12, margin_end = 12 }; - main_box.add (form_grid); + main_box.append (form_grid); - unowned var main_grid_style_context = main_box.get_style_context (); - main_grid_style_context.add_class (Granite.STYLE_CLASS_CARD); - main_grid_style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - main_grid_style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + main_box.add_css_class (Granite.STYLE_CLASS_CARD); + main_box.add_css_class (Granite.STYLE_CLASS_ROUNDED); + main_box.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); child = main_box; @@ -120,19 +119,14 @@ public class Greeter.ManualCard : Greeter.BaseCard { public override void wrong_credentials () { password_entry.text = ""; - unowned var username_entry_style_context = username_entry.get_style_context (); - username_entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); - - unowned var password_entry_style_context = password_entry.get_style_context (); - password_entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); - - unowned var grid_style_context = main_box.get_style_context (); - grid_style_context.add_class ("shake"); + username_entry.add_css_class (Granite.STYLE_CLASS_ERROR); + password_entry.add_css_class (Granite.STYLE_CLASS_ERROR); + main_box.add_css_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { - grid_style_context.remove_class ("shake"); - username_entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); - password_entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); + main_box.remove_css_class ("shake"); + username_entry.remove_css_class (Granite.STYLE_CLASS_ERROR); + password_entry.remove_css_class (Granite.STYLE_CLASS_ERROR); connecting = false; focus_username_entry (); @@ -149,15 +143,12 @@ public class Greeter.ManualCard : Greeter.BaseCard { username_entry.secondary_icon_name = ""; username_entry.text = ""; - unowned var entry_style_context = username_entry.get_style_context (); - entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); - - unowned var grid_style_context = main_box.get_style_context (); - grid_style_context.add_class ("shake"); + username_entry.add_css_class (Granite.STYLE_CLASS_ERROR); + main_box.add_css_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { - grid_style_context.remove_class ("shake"); - entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); + main_box.remove_css_class ("shake"); + username_entry.remove_css_class (Granite.STYLE_CLASS_ERROR); return Source.REMOVE; }); diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index dd555e927..04b9e8545 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -32,10 +32,6 @@ public class Greeter.UserCard : Greeter.BaseCard { private SelectionCheck logged_in; - private unowned Gtk.StyleContext logged_in_context; - private unowned Gtk.StyleContext main_box_style_context; - private unowned Gtk.StyleContext password_entry_context; - private bool needs_settings_set = false; public UserCard (LightDM.User lightdm_user) { @@ -53,12 +49,10 @@ public class Greeter.UserCard : Greeter.BaseCard { margin_end = 24, }; - unowned var username_label_context = username_label.get_style_context (); - username_label_context.add_class (Granite.STYLE_CLASS_H2_LABEL); - username_label_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + username_label.add_css_class (Granite.STYLE_CLASS_H2_LABEL); + username_label.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); password_entry = new Greeter.PasswordEntry (); - password_entry_context = password_entry.get_style_context (); bind_property ( "connecting", @@ -67,10 +61,7 @@ public class Greeter.UserCard : Greeter.BaseCard { INVERT_BOOLEAN ); - var fingerprint_image = new Gtk.Image.from_icon_name ( - "fingerprint-symbolic", - BUTTON - ); + var fingerprint_image = new Gtk.Image.from_icon_name ("fingerprint-symbolic"); bind_property ( "use-fingerprint", @@ -105,7 +96,7 @@ public class Greeter.UserCard : Greeter.BaseCard { size_group.add_widget (session_button); var login_button = new Gtk.Button.with_label (_("Log In")); - login_button.get_style_context ().add_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); + login_button.add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); bind_property ( "connecting", @@ -114,7 +105,7 @@ public class Greeter.UserCard : Greeter.BaseCard { INVERT_BOOLEAN ); - var disabled_icon = new Gtk.Image.from_icon_name ("changes-prevent-symbolic", MENU); + var disabled_icon = new Gtk.Image.from_icon_name ("changes-prevent-symbolic"); var disabled_message = new Gtk.Label (_("Account disabled")); @@ -122,9 +113,9 @@ public class Greeter.UserCard : Greeter.BaseCard { halign = Gtk.Align.CENTER, margin_top = 3 }; - disabled_box.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); - disabled_box.add (disabled_icon); - disabled_box.add (disabled_message); + disabled_box.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + disabled_box.append (disabled_icon); + disabled_box.append (disabled_message); login_stack = new Gtk.Stack (); login_stack.add_named (password_grid, "password"); @@ -137,8 +128,8 @@ public class Greeter.UserCard : Greeter.BaseCard { margin_start = 24, margin_end = 24 }; - form_box.add (login_stack); - form_box.add (session_button); + form_box.append (login_stack); + form_box.append (session_button); form_revealer = new Gtk.Revealer () { margin_bottom = 12, @@ -157,18 +148,16 @@ public class Greeter.UserCard : Greeter.BaseCard { main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { margin_bottom = 48 }; - // in reverse order because pack_end is used - main_box.pack_end (form_revealer); - main_box.pack_end (username_label); + main_box.append (username_label); + main_box.append (form_revealer); - main_box_style_context = main_box.get_style_context (); - main_box_style_context.add_class (Granite.STYLE_CLASS_CARD); - main_box_style_context.add_class (Granite.STYLE_CLASS_ROUNDED); - main_box_style_context.add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + main_box.add_css_class (Granite.STYLE_CLASS_CARD); + main_box.add_css_class (Granite.STYLE_CLASS_ROUNDED); + main_box.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); update_collapsed_class (); - var avatar = new Hdy.Avatar (64, lightdm_user.display_name, true) { + var avatar = new Adw.Avatar (64, lightdm_user.display_name, true) { margin_top = 6, margin_bottom = 6, margin_start = 6, @@ -188,8 +177,6 @@ public class Greeter.UserCard : Greeter.BaseCard { valign = END }; - logged_in_context = logged_in.get_style_context (); - if (lightdm_user.logged_in) { avatar_overlay.add_overlay (logged_in); @@ -227,7 +214,7 @@ public class Greeter.UserCard : Greeter.BaseCard { return false; }); - click_gesture = new Gtk.GestureMultiPress (this); + click_gesture = new Gtk.GestureClick (); click_gesture.pressed.connect ((n_press, x, y) => { if (!show_input) { focus_requested (); @@ -235,6 +222,8 @@ public class Greeter.UserCard : Greeter.BaseCard { } }); + add_controller (click_gesture); + notify["show-input"].connect (() => { update_collapsed_class (); }); @@ -258,7 +247,7 @@ public class Greeter.UserCard : Greeter.BaseCard { private void set_check_style () { // Override check's accent_color so that it *always* uses user's preferred color var style_provider = Gtk.CssProvider.get_named ("io.elementary.stylesheet." + accent_to_string (prefers_accent_color), null); - logged_in_context.add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + logged_in.get_style_context ().add_provider (style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } private void set_background_image () { @@ -284,7 +273,7 @@ public class Greeter.UserCard : Greeter.BaseCard { background_image = new Greeter.BackgroundImage.from_path (null); } - main_box.pack_start (background_image); + main_box.prepend (background_image); } private string accent_to_string (int i) { @@ -390,9 +379,9 @@ public class Greeter.UserCard : Greeter.BaseCard { private void update_collapsed_class () { if (show_input) { - main_box_style_context.remove_class ("collapsed"); + main_box.remove_css_class ("collapsed"); } else { - main_box_style_context.add_class ("collapsed"); + main_box.add_css_class ("collapsed"); } } @@ -511,14 +500,12 @@ public class Greeter.UserCard : Greeter.BaseCard { } public override void wrong_credentials () { - unowned var entry_style_context = password_entry.get_style_context (); - entry_style_context.add_class (Granite.STYLE_CLASS_ERROR); - - main_box_style_context.add_class ("shake"); + password_entry.add_css_class (Granite.STYLE_CLASS_ERROR); + main_box.add_css_class ("shake"); Timeout.add (ERROR_SHAKE_DURATION, () => { - main_box_style_context.remove_class ("shake"); - entry_style_context.remove_class (Granite.STYLE_CLASS_ERROR); + main_box.remove_css_class ("shake"); + password_entry.remove_css_class (Granite.STYLE_CLASS_ERROR); connecting = false; password_entry.grab_focus (); @@ -530,7 +517,7 @@ public class Greeter.UserCard : Greeter.BaseCard { private static Gtk.CssProvider check_provider; class construct { - set_css_name (Granite.STYLE_CLASS_CHECK); + set_css_name ("check"); } static construct { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index d44473da5..b9a16b0bd 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -54,7 +54,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { } construct { - app_paintable = true; decorated = false; get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -88,7 +87,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { var manual_card = new Greeter.ManualCard (); - carousel = new Hdy.Carousel () { + carousel = new Adw.Carousel () { allow_long_swipes = true, vexpand = true }; @@ -96,8 +95,8 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { var manual_login_stack = new Gtk.Stack () { transition_type = Gtk.StackTransitionType.CROSSFADE }; - manual_login_stack.add (carousel); - manual_login_stack.add (manual_card); + manual_login_stack.add_child (carousel); + manual_login_stack.add_child (manual_card); var main_box = new Gtk.Box (VERTICAL, 24) { margin_top = 24, @@ -275,7 +274,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private void maximize_and_focus () { present (); maximize_window (); - get_style_context ().add_class ("initialized"); + add_css_class ("initialized"); if (current_card != null) { current_card.grab_focus (); @@ -298,7 +297,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { var rect = monitor.get_geometry (); resize (rect.width, rect.height); - move (rect.x, rect.y); } private void create_session_selection_action () { diff --git a/src/Widgets/BackgroundImage.vala b/src/Widgets/BackgroundImage.vala index f724e732d..60cda1242 100644 --- a/src/Widgets/BackgroundImage.vala +++ b/src/Widgets/BackgroundImage.vala @@ -12,7 +12,7 @@ public class Greeter.BackgroundImage : Gtk.Picture { } public BackgroundImage.from_color (string color) { - full_pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); + var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); Gdk.RGBA rgba_color = {}; rgba_color.parse (color); @@ -26,7 +26,7 @@ public class Greeter.BackgroundImage : Gtk.Picture { f <<= 8; f += 255; - full_pixbuf.fill (f); + pixbuf.fill (f); paintable = Gdk.Texture.for_pixbuf (pixbuf); } diff --git a/src/Widgets/CapsLockRevealer.vala b/src/Widgets/CapsLockRevealer.vala index 3069719db..743dbe9f5 100644 --- a/src/Widgets/CapsLockRevealer.vala +++ b/src/Widgets/CapsLockRevealer.vala @@ -27,26 +27,26 @@ public class Greeter.CapsLockRevealer : Gtk.Revealer { construct { transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; - caps_lock_image = new Gtk.Image.from_icon_name ("input-keyboard-capslock-symbolic", Gtk.IconSize.MENU); + caps_lock_image = new Gtk.Image.from_icon_name ("input-keyboard-capslock-symbolic"); caps_lock_image.use_fallback = true; caps_lock_image.visible = false; - num_lock_image = new Gtk.Image.from_icon_name ("input-keyboard-numlock-symbolic", Gtk.IconSize.MENU); + num_lock_image = new Gtk.Image.from_icon_name ("input-keyboard-numlock-symbolic"); num_lock_image.use_fallback = true; num_lock_image.visible = false; lock_label = new Gtk.Label (null); lock_label.use_markup = true; - var caps_lock_grid = new Gtk.Grid (); - caps_lock_grid.column_spacing = 3; - caps_lock_grid.halign = Gtk.Align.CENTER; - caps_lock_grid.get_style_context ().add_class (Granite.STYLE_CLASS_DIM_LABEL); - caps_lock_grid.add (caps_lock_image); - caps_lock_grid.add (num_lock_image); - caps_lock_grid.add (lock_label); + var caps_lock_box = new Gtk.Box (HORIZONTAL, 3) { + halign = CENTER + }; + caps_lock_box.add_css_class (Granite.STYLE_CLASS_DIM_LABEL); + caps_lock_box.append (caps_lock_image); + caps_lock_box.append (num_lock_image); + caps_lock_box.append (lock_label); - add (caps_lock_grid); + child = caps_lock_box; device = Gdk.Display.get_default ().get_default_seat ().get_devices (KEYBOARD)[0]; device.changed.connect (update_visibility); @@ -61,8 +61,6 @@ public class Greeter.CapsLockRevealer : Gtk.Revealer { reveal_child = caps_lock || num_lock; - caps_lock_image.no_show_all = !caps_lock; - num_lock_image.no_show_all = !num_lock; caps_lock_image.visible = caps_lock; num_lock_image.visible = num_lock; diff --git a/src/Widgets/DateTimeWidget.vala b/src/Widgets/DateTimeWidget.vala index 89055894d..fa09efb77 100644 --- a/src/Widgets/DateTimeWidget.vala +++ b/src/Widgets/DateTimeWidget.vala @@ -16,17 +16,17 @@ public class Greeter.DateTimeWidget : Gtk.Box { var css_provider = new Gtk.CssProvider (); css_provider.load_from_resource ("/io/elementary/greeter/DateTime.css"); - Gtk.StyleContext.add_provider_for_screen (Gdk.Screen.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk.StyleContext.add_provider_for_display (Gdk.Display.get_default (), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); time_label = new Gtk.Label (null); - time_label.get_style_context ().add_class ("time"); + time_label.add_css_class ("time"); date_label = new Gtk.Label (null); - date_label.get_style_context ().add_class ("date"); + date_label.add_css_class ("date"); orientation = VERTICAL; - add (time_label); - add (date_label); + append (time_label); + append (date_label); update_labels (); diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index 311ad43a5..6a9da3d8f 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -23,12 +23,10 @@ public class Greeter.SessionButton : Gtk.MenuButton { construct { var menu = new GLib.Menu (); - var cog_image = new Gtk.Image.from_icon_name ("open-menu-symbolic", Gtk.IconSize.BUTTON); - direction = DOWN; + icon_name = "open-menu-symbolic"; menu_model = menu; - get_style_context ().add_class (Granite.STYLE_CLASS_FLAT); - add (cog_image); + add_css_class (Granite.STYLE_CLASS_FLAT); // The session action is on the MainWindow toplevel, wait until it is accessible. hierarchy_changed.connect ((previous_toplevel) => { From 7d6e957058a0dc8db23a1da06932553820cb3fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 8 Oct 2024 12:56:33 -0700 Subject: [PATCH 10/22] rm backgroundimage class --- po/POTFILES | 1 - src/Cards/UserCard.vala | 26 +++++++++++++++++++++---- src/Widgets/BackgroundImage.vala | 33 -------------------------------- src/meson.build | 1 - 4 files changed, 22 insertions(+), 39 deletions(-) delete mode 100644 src/Widgets/BackgroundImage.vala diff --git a/po/POTFILES b/po/POTFILES index 47d1268b1..1ee8320a6 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -30,7 +30,6 @@ src/Settings.vala src/Cards/BaseCard.vala src/Cards/ManualCard.vala src/Cards/UserCard.vala -src/Widgets/BackgroundImage.vala src/Widgets/CapsLockRevealer.vala src/Widgets/DateTimeWidget.vala src/Widgets/PasswordEntry.vala diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 04b9e8545..38182f5c5 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -251,7 +251,10 @@ public class Greeter.UserCard : Greeter.BaseCard { } private void set_background_image () { - Greeter.BackgroundImage background_image; + var background_picture = new Gtk.Picture () { + content_fit = COVER, + height_request = 150 + }; var background_path = lightdm_user.background; var background_exists = ( @@ -266,11 +269,26 @@ public class Greeter.UserCard : Greeter.BaseCard { } if (settings_act.picture_options != 0 && background_exists) { - background_image = new Greeter.BackgroundImage.from_path (background_path); + background_picture.set_filename (background_path); } else if (settings_act.picture_options == 0 && settings_act.primary_color != null) { - background_image = new Greeter.BackgroundImage.from_color (settings_act.primary_color); + Gdk.RGBA rgba_color = {}; + rgba_color.parse (settings_act.primary_color); + + uint32 f = 0x0; + f += (uint) Math.round (rgba_color.red * 255); + f <<= 8; + f += (uint) Math.round (rgba_color.green * 255); + f <<= 8; + f += (uint) Math.round (rgba_color.blue * 255); + f <<= 8; + f += 255; + + pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); + pixbuf.fill (f); + + background_picture.paintable = (Gdk.Texture.for_pixbuf (pixbuf)); } else { - background_image = new Greeter.BackgroundImage.from_path (null); + background_picture.set_filename ("/usr/share/backgrounds/elementaryos-default"); } main_box.prepend (background_image); diff --git a/src/Widgets/BackgroundImage.vala b/src/Widgets/BackgroundImage.vala deleted file mode 100644 index 60cda1242..000000000 --- a/src/Widgets/BackgroundImage.vala +++ /dev/null @@ -1,33 +0,0 @@ -public class Greeter.BackgroundImage : Gtk.Picture { - construct { - height_request = 150; - } - - public BackgroundImage.from_path (string? path) { - if (path == null) { - path = "/usr/share/backgrounds/elementaryos-default"; - } - - set_filename (path); - } - - public BackgroundImage.from_color (string color) { - var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); - - Gdk.RGBA rgba_color = {}; - rgba_color.parse (color); - - uint32 f = 0x0; - f += (uint) Math.round (rgba_color.red * 255); - f <<= 8; - f += (uint) Math.round (rgba_color.green * 255); - f <<= 8; - f += (uint) Math.round (rgba_color.blue * 255); - f <<= 8; - f += 255; - - pixbuf.fill (f); - - paintable = Gdk.Texture.for_pixbuf (pixbuf); - } -} diff --git a/src/meson.build b/src/meson.build index d47072350..ba61bd624 100644 --- a/src/meson.build +++ b/src/meson.build @@ -22,7 +22,6 @@ executable( 'Cards/BaseCard.vala', 'Cards/ManualCard.vala', 'Cards/UserCard.vala', - 'Widgets/BackgroundImage.vala', 'Widgets/CapsLockRevealer.vala', 'Widgets/DateTimeWidget.vala', 'Widgets/PasswordEntry.vala', From 54519b5b38158df0f594b38ae4d0d97d80ba0655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 8 Oct 2024 13:01:17 -0700 Subject: [PATCH 11/22] some usercard fixes --- src/Cards/UserCard.vala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index 38182f5c5..d191f1f3e 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -161,10 +161,16 @@ public class Greeter.UserCard : Greeter.BaseCard { margin_top = 6, margin_bottom = 6, margin_start = 6, - margin_end = 6, - loadable_icon = new FileIcon (File.new_for_path (lightdm_user.image)) + margin_end = 6 }; + var user_icon_file = File.new_for_path (lightdm_user.image); + try { + avatar.custom_image = Gdk.Texture.from_file (user_icon_file ); + } catch (Error e) { + avatar.custom_image = null; + } + var avatar_overlay = new Gtk.Overlay () { halign = CENTER, valign = START, @@ -283,7 +289,7 @@ public class Greeter.UserCard : Greeter.BaseCard { f <<= 8; f += 255; - pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); + var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 1, 1); pixbuf.fill (f); background_picture.paintable = (Gdk.Texture.for_pixbuf (pixbuf)); @@ -291,7 +297,7 @@ public class Greeter.UserCard : Greeter.BaseCard { background_picture.set_filename ("/usr/share/backgrounds/elementaryos-default"); } - main_box.prepend (background_image); + main_box.prepend (background_picture); } private string accent_to_string (int i) { From 2416b17601ccdbbf8bedd62b1479bf66a71ac50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 8 Oct 2024 13:05:09 -0700 Subject: [PATCH 12/22] Fix carousel stuff --- src/MainWindow.vala | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index b9a16b0bd..dfc8ec17c 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -228,11 +228,9 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { }); carousel.page_changed.connect ((index) => { - var children = carousel.get_children (); - - if (children.nth_data (index) is Greeter.UserCard) { + if (carousel.get_nth_page (index) is Greeter.UserCard) { current_user_card_index = (int) index; - switch_to_card ((Greeter.UserCard) children.nth_data (index)); + switch_to_card ((Greeter.UserCard) carousel.get_nth_page (index)); } }); @@ -499,7 +497,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private void add_card (LightDM.User lightdm_user) { var user_card = new Greeter.UserCard (lightdm_user); - carousel.add (user_card); + carousel.append (user_card); user_card.focus_requested.connect (() => { switch_to_card (user_card); @@ -544,7 +542,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { current_card = user_card; - carousel.scroll_to (user_card); + carousel.scroll_to (user_card, true); user_card.set_settings (); user_card.show_input = true; @@ -595,7 +593,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { } carousel.interactive = false; - carousel.scroll_to (current_card); + carousel.scroll_to (current_card, true); } private void go_previous () { @@ -605,7 +603,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { unowned Greeter.UserCard? next_card = user_cards.peek_nth (current_user_card_index - 1); if (next_card != null) { - carousel.scroll_to (next_card); + carousel.scroll_to (next_card, true); } } @@ -616,7 +614,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { unowned Greeter.UserCard? next_card = user_cards.peek_nth (current_user_card_index + 1); if (next_card != null) { - carousel.scroll_to (next_card); + carousel.scroll_to (next_card, true); } } } From f25f577ef7dd81cec53757b33693885c3ae4118c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:24:20 -0700 Subject: [PATCH 13/22] Use has_frame --- src/Widgets/SessionButton.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index 75e1ca79d..90896060b 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -26,7 +26,7 @@ public class Greeter.SessionButton : Gtk.MenuButton { direction = DOWN; icon_name = "open-menu-symbolic"; menu_model = menu; - add_css_class (Granite.STYLE_CLASS_FLAT); + has_frame = false; // The session action is on the MainWindow toplevel, wait until it is accessible. hierarchy_changed.connect ((previous_toplevel) => { From 5927810ddab7d60a19820f439b48424e31a353a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:26:45 -0700 Subject: [PATCH 14/22] Fix icon_press connect --- src/Widgets/PasswordEntry.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widgets/PasswordEntry.vala b/src/Widgets/PasswordEntry.vala index f9bd6a26f..83cb1d8bf 100644 --- a/src/Widgets/PasswordEntry.vala +++ b/src/Widgets/PasswordEntry.vala @@ -29,8 +29,8 @@ public class Greeter.PasswordEntry : Gtk.Entry { visibility = false; input_purpose = Gtk.InputPurpose.PASSWORD; - icon_press.connect ((pos, event) => { - if (pos == Gtk.EntryIconPosition.SECONDARY) { + icon_press.connect ((pos) => { + if (pos == SECONDARY) { activate (); } }); From 6584e5207a150d8d646f0910017430b3fdf9fbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:28:48 -0700 Subject: [PATCH 15/22] SessionButton: try no hierarchy connect --- src/Widgets/SessionButton.vala | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index 90896060b..ad352b03c 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -28,22 +28,19 @@ public class Greeter.SessionButton : Gtk.MenuButton { menu_model = menu; has_frame = false; - // The session action is on the MainWindow toplevel, wait until it is accessible. - hierarchy_changed.connect ((previous_toplevel) => { - var main_window = (Gtk.ApplicationWindow) get_ancestor (typeof (Gtk.ApplicationWindow)); - if (main_window != null) { - var hint = main_window.get_action_state_hint ("select-session"); - var iter = hint.iterator (); - GLib.Variant? val = null; - string? key = null; - while (iter.next ("{sv}", out key, out val)) { - menu.append (key, Action.print_detailed_name ("win.select-session", val)); - } + var main_window = (Gtk.ApplicationWindow) get_ancestor (typeof (Gtk.ApplicationWindow)); + if (main_window != null) { + var hint = main_window.get_action_state_hint ("select-session"); + var iter = hint.iterator (); + GLib.Variant? val = null; + string? key = null; + while (iter.next ("{sv}", out key, out val)) { + menu.append (key, Action.print_detailed_name ("win.select-session", val)); + } - if (menu.get_n_items () == 0) { - destroy (); - } + if (menu.get_n_items () == 0) { + destroy (); } - }); + } } } From b7f27265b6e28e9e18329ee47f98bf81eab7c6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:30:50 -0700 Subject: [PATCH 16/22] Redundant app quit on window destroy --- src/MainWindow.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index a1b0ad80c..ea841cd9f 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -236,10 +236,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { return false; }); - destroy.connect (() => { - Gtk.main_quit (); - }); - load_users.begin (() => { /* A significant delay is required in order for the window and card to be focused at * at boot. TODO: Find whether boot sequence can be tweaked to fix this. From 1b8d6c3b76c2a4f9680f88d61d9e26a38f96e578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:32:35 -0700 Subject: [PATCH 17/22] Fix add controller --- src/MainWindow.vala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MainWindow.vala b/src/MainWindow.vala index ea841cd9f..97d267b56 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -36,8 +36,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private bool installer_mode = false; - private Gtk.EventControllerKey key_controller; - private const uint[] NAVIGATION_KEYS = { Gdk.Key.Up, Gdk.Key.Down, @@ -178,9 +176,12 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { manual_card.do_connect_username.connect (do_connect_username); manual_card.do_connect.connect (do_connect); - key_controller = new Gtk.EventControllerKey (this) { + var key_controller = new Gtk.EventControllerKey () { propagation_phase = CAPTURE }; + + ((Gtk.Widget) this).add_controller (key_controller); + key_controller.key_pressed.connect ((keyval, keycode, state) => { var mods = state & Gtk.accelerator_get_default_mod_mask (); From 5c4b1b3316a521ad5d901eb703a1974df3b5b9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:51:30 -0700 Subject: [PATCH 18/22] Fix some focus stuff --- src/Cards/ManualCard.vala | 16 +++++++++++----- src/Cards/UserCard.vala | 15 ++++++++------- src/MainWindow.vala | 28 +--------------------------- src/Widgets/CapsLockRevealer.vala | 2 +- 4 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/Cards/ManualCard.vala b/src/Cards/ManualCard.vala index 03ac34a2e..12e876365 100644 --- a/src/Cards/ManualCard.vala +++ b/src/Cards/ManualCard.vala @@ -77,13 +77,19 @@ public class Greeter.ManualCard : Greeter.BaseCard { username_entry.activate.connect (() => do_connect_username (username_entry.text)); password_entry.activate.connect (on_login); - grab_focus.connect (() => { - if (username_entry.sensitive) { - username_entry.grab_focus_without_selecting (); - } else { - password_entry.grab_focus_without_selecting (); + + var focus_controller = new Gtk.EventControllerFocus (); + focus_controller.enter.connect (() => { + if (focus_controller.is_focus) { + if (username_entry.sensitive) { + username_entry.grab_focus_without_selecting (); + } else { + password_entry.grab_focus_without_selecting (); + } } }); + + add_controller (focus_controller); } private void on_login () { diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index a9556bdd2..a63ab18fd 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -205,16 +205,12 @@ public class Greeter.UserCard : Greeter.BaseCard { on_act_user_loaded (); - card_overlay.focus.connect ((direction) => { + card_overlay.move_focus.connect ((direction) => { if (direction == LEFT) { go_left (); - return true; } else if (direction == RIGHT) { go_right (); - return true; } - - return false; }); click_gesture = new Gtk.GestureClick (); @@ -242,9 +238,14 @@ public class Greeter.UserCard : Greeter.BaseCard { } }); - grab_focus.connect (() => { - password_entry.grab_focus_without_selecting (); + var focus_controller = new Gtk.EventControllerFocus (); + focus_controller.enter.connect (() => { + if (focus_controller.is_focus) { + password_entry.grab_focus_without_selecting (); + } }); + + add_controller (focus_controller); } private void set_check_style () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 97d267b56..496ba2c43 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -50,8 +50,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { settings = new Greeter.Settings (); create_session_selection_action (); - set_visual (get_screen ().get_rgba_visual ()); - guest_login_button = new Gtk.Button.with_label (_("Log in as Guest")); manual_login_button = new Gtk.ToggleButton.with_label (_("Manual Login…")); @@ -227,16 +225,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { } }); - // regrab focus when dpi changed - get_screen ().monitors_changed.connect (() => { - maximize_and_focus (); - }); - - leave_notify_event.connect (() => { - maximize_and_focus (); - return false; - }); - load_users.begin (() => { /* A significant delay is required in order for the window and card to be focused at * at boot. TODO: Find whether boot sequence can be tweaked to fix this. @@ -269,21 +257,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { } private void maximize_window () { - var display = Gdk.Display.get_default (); - unowned Gdk.Seat seat = display.get_default_seat (); - unowned Gdk.Device? pointer = seat.get_pointer (); - - Gdk.Monitor? monitor; - if (pointer != null) { - int x, y; - pointer.get_position (null, out x, out y); - monitor = display.get_monitor_at_point (x, y); - } else { - monitor = display.get_primary_monitor (); - } - - var rect = monitor.get_geometry (); - resize (rect.width, rect.height); + // We can't move the window so this probably needs to move to compositor? } private void create_session_selection_action () { diff --git a/src/Widgets/CapsLockRevealer.vala b/src/Widgets/CapsLockRevealer.vala index 69d6cb3a8..3de202077 100644 --- a/src/Widgets/CapsLockRevealer.vala +++ b/src/Widgets/CapsLockRevealer.vala @@ -40,7 +40,7 @@ public class Greeter.CapsLockRevealer : Adw.Bin { child = revealer; - device = Gdk.Display.get_default ().get_default_seat ().get_devices (KEYBOARD)[0]; + device = Gdk.Display.get_default ().get_default_seat ().get_keyboard (); device.changed.connect (update_visibility); update_visibility (); From e2310c4d503be74e006510c2e9380fc099287b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:53:30 -0700 Subject: [PATCH 19/22] Can't subclass menubutton --- src/Widgets/SessionButton.vala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Widgets/SessionButton.vala b/src/Widgets/SessionButton.vala index ad352b03c..37f3691cf 100644 --- a/src/Widgets/SessionButton.vala +++ b/src/Widgets/SessionButton.vala @@ -19,14 +19,18 @@ * Authors: Corentin Noël */ -public class Greeter.SessionButton : Gtk.MenuButton { +public class Greeter.SessionButton : Adw.Bin { construct { var menu = new GLib.Menu (); - direction = DOWN; - icon_name = "open-menu-symbolic"; - menu_model = menu; - has_frame = false; + var menu_button = new Gtk.MenuButton () { + direction = DOWN, + has_frame = false, + icon_name = "open-menu-symbolic", + menu_model = menu + }; + + child = menu_button; var main_window = (Gtk.ApplicationWindow) get_ancestor (typeof (Gtk.ApplicationWindow)); if (main_window != null) { From 716fc23d7b9f3a66145b2a553514b3320774e7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 14:54:19 -0700 Subject: [PATCH 20/22] Last compilation problem --- src/Cards/UserCard.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index a63ab18fd..bbfb5441f 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -534,7 +534,7 @@ public class Greeter.UserCard : Greeter.BaseCard { }); } - private class SelectionCheck : Gtk.Spinner { + private class SelectionCheck : Gtk.Widget { class construct { set_css_name ("check"); } From c5f1d8aacb24cca85a258be2fa346eb545dbf3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 15:08:35 -0700 Subject: [PATCH 21/22] Fix some stuff --- data/Application.css | 3 +++ src/MainWindow.vala | 12 +++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/data/Application.css b/data/Application.css index 300c9a922..9be995d37 100644 --- a/data/Application.css +++ b/data/Application.css @@ -4,6 +4,8 @@ */ .background { + background: transparent; + box-shadow: none; opacity: 0; transition: opacity 1s ease; } @@ -12,6 +14,7 @@ opacity: 1; } + .date, .time { color: #fff; diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 496ba2c43..d85f12a59 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -163,7 +163,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { lightdm_greeter.bind_property ("hide-users-hint", manual_login_button, "active", GLib.BindingFlags.SYNC_CREATE); notify["scale-factor"].connect (() => { - maximize_window (); + maximize (); }); lightdm_user_list = LightDM.UserList.get_instance (); @@ -235,7 +235,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { }); }); - maximize_window (); + maximize (); if (settings.activate_numlock) { try { @@ -248,18 +248,16 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow { private void maximize_and_focus () { present (); - maximize_window (); + maximize (); add_css_class ("initialized"); + // We can't move the window that probably need to go to compositor? + if (current_card != null) { current_card.grab_focus (); } } - private void maximize_window () { - // We can't move the window so this probably needs to move to compositor? - } - private void create_session_selection_action () { unowned GLib.List sessions = LightDM.get_sessions (); weak LightDM.Session? first_session = sessions.nth_data (0); From 5b982c6ac3447dc8214523e475a228101259de87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 18 Oct 2024 15:17:01 -0700 Subject: [PATCH 22/22] Fix card overflow --- src/Cards/BaseCard.vala | 7 ------- src/Cards/UserCard.vala | 12 ++++-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/Cards/BaseCard.vala b/src/Cards/BaseCard.vala index a621fecd9..07e15c8ab 100644 --- a/src/Cards/BaseCard.vala +++ b/src/Cards/BaseCard.vala @@ -22,8 +22,6 @@ public abstract class Greeter.BaseCard : Gtk.Box { public signal void do_connect (string? credential = null); - protected static Gtk.CssProvider css_provider; - public bool connecting { get; set; default = false; } public bool need_password { get; set; default = false; } public bool use_fingerprint { get; set; default = false; } @@ -38,11 +36,6 @@ public abstract class Greeter.BaseCard : Gtk.Box { protected Gtk.Revealer revealer; - static construct { - css_provider = new Gtk.CssProvider (); - css_provider.load_from_resource ("/io/elementary/greeter/Card.css"); - } - construct { revealer = new Gtk.Revealer () { halign = CENTER, diff --git a/src/Cards/UserCard.vala b/src/Cards/UserCard.vala index bbfb5441f..a2977f03f 100644 --- a/src/Cards/UserCard.vala +++ b/src/Cards/UserCard.vala @@ -145,7 +145,7 @@ public class Greeter.UserCard : Greeter.BaseCard { ); main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) { - margin_bottom = 48 + overflow = HIDDEN }; main_box.append (username_label); main_box.append (form_revealer); @@ -154,12 +154,7 @@ public class Greeter.UserCard : Greeter.BaseCard { update_collapsed_class (); - var avatar = new Adw.Avatar (64, lightdm_user.display_name, true) { - margin_top = 6, - margin_bottom = 6, - margin_start = 6, - margin_end = 6 - }; + var avatar = new Adw.Avatar (64, lightdm_user.display_name, true); var user_icon_file = File.new_for_path (lightdm_user.image); try { @@ -172,7 +167,8 @@ public class Greeter.UserCard : Greeter.BaseCard { halign = CENTER, valign = START, margin_top = 100, - child = avatar + child = avatar, + overflow = VISIBLE }; logged_in = new SelectionCheck () {