Skip to content

Commit

Permalink
Merge branch 'master' into lenemter/blurred-bg
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Feb 13, 2024
2 parents e7d7dc5 + 85bbb72 commit 04cb35b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 97 deletions.
19 changes: 18 additions & 1 deletion compositor/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ namespace GreeterCompositor {

public GreeterCompositor.SystemBackground system_background { get; private set; }

Meta.PluginInfo info;
private Clutter.Actor fade_in_screen;

private Meta.PluginInfo info;

// Used to toggle screenreader
private GLib.Settings application_settings;
Expand Down Expand Up @@ -81,6 +83,12 @@ namespace GreeterCompositor {
public override void start () {
show_stage ();

fade_in_screen.save_easing_state ();
fade_in_screen.set_easing_duration (1000);
fade_in_screen.set_easing_mode (Clutter.AnimationMode.EASE);
fade_in_screen.opacity = 0;
fade_in_screen.restore_easing_state ();

unowned Meta.Display display = get_display ();
display.gl_video_memory_purged.connect (() => {
refresh_background ();
Expand Down Expand Up @@ -133,6 +141,15 @@ namespace GreeterCompositor {
pointer_locator = new PointerLocator (this);
ui_group.add_child (pointer_locator);

int width, height;
display.get_size (out width, out height);
fade_in_screen = new Clutter.Actor () {
width = width,
height = height,
background_color = Clutter.Color.from_rgba (0, 0, 0, 255),
};
stage.add_child (fade_in_screen);

MaskCorners.init (this);

/*keybindings*/
Expand Down
6 changes: 3 additions & 3 deletions po/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: pantheon-greeter\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-19 17:04+0000\n"
"PO-Revision-Date: 2023-03-07 13:25+0000\n"
"PO-Revision-Date: 2024-02-12 08:12+0000\n"
"Last-Translator: Ryo Nakano <[email protected]>\n"
"Language-Team: Japanese <https://l10n.elementary.io/projects/desktop/greeter/"
"ja/>\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 4.14.2\n"
"X-Generator: Weblate 5.0.2\n"
"X-Launchpad-Export-Date: 2017-03-09 05:44+0000\n"

#: compositor/WindowManager.vala:324
Expand All @@ -28,7 +28,7 @@ msgstr[0] "変更は%i秒後に自動的に元に戻ります。"

#: compositor/WindowManager.vala:331
msgid "Keep new display settings?"
msgstr "新しいディスプレイの設定を維持しますか"
msgstr "新しいディスプレイの設定を維持しますか?"

#: compositor/WindowManager.vala:335
msgid "Keep Settings"
Expand Down
4 changes: 2 additions & 2 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public int main (string[] args) {
var settings_daemon = new Greeter.SettingsDaemon ();
settings_daemon.start ();

Gtk.init (ref args);

Greeter.SubprocessSupervisor compositor;
Greeter.SubprocessSupervisor wingpanel;

Expand All @@ -43,6 +41,8 @@ public int main (string[] args) {
critical (e.message);
}

Gtk.init (ref args);

var window = new Greeter.MainWindow ();
window.show_all ();

Expand Down
11 changes: 0 additions & 11 deletions src/Cards/UserCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class Greeter.UserCard : Greeter.BaseCard {

public LightDM.User lightdm_user { get; construct; }
public bool show_input { get; set; default = false; }
public double reveal_ratio { get; private set; default = 0.0; }
public bool is_24h { get; set; default = true; }

public int prefers_accent_color { get; set; default = 6; }
Expand Down Expand Up @@ -236,20 +235,10 @@ public class Greeter.UserCard : Greeter.BaseCard {
}
});

// This makes all the animations synchronous
form_revealer.size_allocate.connect ((alloc) => {
var total_height = form_box.get_allocated_height () + form_box.margin_top + form_box.margin_bottom;
reveal_ratio = (double)alloc.height / (double)total_height;
});

notify["show-input"].connect (() => {
update_collapsed_class ();
});

notify["child-revealed"].connect (() => {
reveal_ratio = child_revealed ? 1.0 : 0.0;
});

password_entry.activate.connect (on_login);
login_button.clicked.connect (on_login);

Expand Down
133 changes: 53 additions & 80 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {

private GLib.Queue<unowned Greeter.UserCard> user_cards;
private Gtk.SizeGroup card_size_group;
private int index_delta = 0;
private Hdy.Carousel carousel;
private LightDM.Greeter lightdm_greeter;
private Greeter.Settings settings;
private Gtk.Button guest_login_button;
private Gtk.ToggleButton manual_login_button;
private Greeter.DateTimeWidget datetime_widget;
private unowned Greeter.BaseCard current_card;
private unowned LightDM.UserList lightdm_user_list;

private int current_user_card_index = 0;
private unowned Greeter.BaseCard? current_card = null;

private bool installer_mode = false;

private const uint[] NAVIGATION_KEYS = {
Expand Down Expand Up @@ -125,7 +126,8 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
}

manual_login_stack.visible_child = carousel;
current_card = user_cards.peek_nth (index_delta);
current_card = user_cards.peek_nth (current_user_card_index);

try {
lightdm_greeter.authenticate (((UserCard) current_card).lightdm_user.name);
} catch (Error e) {
Expand All @@ -142,23 +144,10 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
}
});

GLib.ActionEntry entries[] = {
GLib.ActionEntry () {
name = "previous",
activate = go_previous
},
GLib.ActionEntry () {
name = "next",
activate = go_next
}
};

card_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
card_size_group.add_widget (extra_login_grid);
card_size_group.add_widget (manual_card);

add_action_entries (entries, this);

lightdm_greeter = new LightDM.Greeter ();
lightdm_greeter.show_message.connect (show_message);
lightdm_greeter.show_prompt.connect (show_prompt);
Expand Down Expand Up @@ -194,47 +183,48 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
manual_card.do_connect.connect (do_connect);

key_press_event.connect ((event) => {
if (!(event.keyval in NAVIGATION_KEYS)) {
// Don't focus if it is a modifier or if search_box is already focused
unowned var current_focus = get_focus ();
if ((event.is_modifier == 0) && (current_focus == null || !current_focus.is_ancestor (current_card))) {
current_card.grab_focus ();
}

return Gdk.EVENT_PROPAGATE;
}

// arrow key is being used to navigate
if (event.keyval in NAVIGATION_KEYS) {
if (current_card is UserCard) {
weak Gtk.Widget? current_focus = get_focus ();
if (current_focus is Gtk.Entry && current_focus.is_ancestor (current_card)) {
if (((Gtk.Entry) current_focus).text == "") {
if (event.keyval == Gdk.Key.Left) {
if (get_style_context ().direction == Gtk.TextDirection.RTL) {
activate_action ("next", null);
} else {
activate_action ("previous", null);
}
return true;
} else if (event.keyval == Gdk.Key.Right) {
if (get_style_context ().direction == Gtk.TextDirection.RTL) {
activate_action ("previous", null);
} else {
activate_action ("next", null);
}
return true;
if (current_card is UserCard) {
unowned var focused_entry = (Gtk.Entry) get_focus ();
if (focused_entry != null && focused_entry.is_ancestor (current_card)) {
if (focused_entry.text == "") {
if (event.keyval == Gdk.Key.Left) {
if (get_style_context ().direction == LTR) {
go_previous ();
} else {
go_next ();
}
return Gdk.EVENT_STOP;
} else if (event.keyval == Gdk.Key.Right) {
if (get_style_context ().direction == LTR) {
go_next ();
} else {
go_previous ();
}
return Gdk.EVENT_STOP;
}
}
}

return false;
}

// Don't focus if it is a modifier or if search_box is already focused
weak Gtk.Widget? current_focus = get_focus ();
if ((event.is_modifier == 0) && (current_focus == null || !current_focus.is_ancestor (current_card))) {
current_card.grab_focus ();
}

return false;
return Gdk.EVENT_PROPAGATE;
});

carousel.page_changed.connect ((index) => {
var children = carousel.get_children ();

if (children.nth_data (index) is Greeter.UserCard) {
current_user_card_index = (int) index;
switch_to_card ((Greeter.UserCard) children.nth_data (index));
}
});
Expand Down Expand Up @@ -473,7 +463,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
}

if (!user_selected) {
unowned Greeter.UserCard user_card = (Greeter.UserCard) user_cards.peek_head ();
unowned var user_card = user_cards.peek_head ();
user_card.show_input = true;
switch_to_card (user_card);
}
Expand Down Expand Up @@ -519,18 +509,18 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
});

user_card.go_left.connect (() => {
if (get_style_context ().direction == Gtk.TextDirection.RTL) {
activate_action ("next", null);
if (get_style_context ().direction == LTR) {
go_previous ();
} else {
activate_action ("previous", null);
go_next ();
}
});

user_card.go_right.connect (() => {
if (get_style_context ().direction == Gtk.TextDirection.RTL) {
activate_action ("previous", null);
if (get_style_context ().direction == LTR) {
go_next ();
} else {
activate_action ("next", null);
go_previous ();
}
});

Expand All @@ -540,37 +530,29 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
user_cards.push_tail (user_card);
}

int next_delta = 0;
weak GLib.Binding? binding = null;
private unowned GLib.Binding? time_format_binding = null;
private void switch_to_card (Greeter.UserCard user_card) {
if (!carousel.interactive) {
return;
}

if (next_delta != index_delta) {
return;
if (current_card != null && current_card is UserCard) {
((UserCard) current_card).show_input = false;
}

current_card = user_card;
if (binding != null) {
binding.unbind ();
if (time_format_binding != null) {
time_format_binding.unbind ();
}
time_format_binding = user_card.bind_property ("is-24h", datetime_widget, "is-24h", GLib.BindingFlags.SYNC_CREATE);

user_card.set_settings ();

binding = user_card.bind_property ("is-24h", datetime_widget, "is-24h", GLib.BindingFlags.SYNC_CREATE);
next_delta = user_cards.index (user_card);
current_card = user_card;

carousel.scroll_to (user_card);

user_card.notify["reveal-ratio"].connect (notify_cb);
user_card.set_settings ();
user_card.show_input = true;
user_card.grab_focus ();

if (index_delta != next_delta) {
((Greeter.UserCard) user_cards.peek_nth (index_delta)).show_input = false;
}

if (user_card.lightdm_user.session != null) {
get_action_group ("session").activate_action ("select", new GLib.Variant.string (user_card.lightdm_user.session));
}
Expand All @@ -590,15 +572,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
}
}

private void notify_cb (GLib.Object obj, GLib.ParamSpec spec) {
unowned var user_card = (Greeter.UserCard) obj;
if (user_card.reveal_ratio == 1.0) {
index_delta = next_delta;
user_card.notify["reveal-ratio"].disconnect (notify_cb);
return;
}
}

private void do_connect_username (string username) {
if (lightdm_greeter.in_authentication) {
try {
Expand Down Expand Up @@ -628,23 +601,23 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
carousel.scroll_to (current_card);
}

private void go_previous (GLib.SimpleAction action, GLib.Variant? parameter) {
private void go_previous () {
if (!carousel.interactive) {
return;
}

unowned Greeter.UserCard? next_card = user_cards.peek_nth (index_delta - 1);
unowned Greeter.UserCard? next_card = user_cards.peek_nth (current_user_card_index - 1);
if (next_card != null) {
carousel.scroll_to (next_card);
}
}

private void go_next (GLib.SimpleAction action, GLib.Variant? parameter) {
private void go_next () {
if (!carousel.interactive) {
return;
}

unowned Greeter.UserCard? next_card = user_cards.peek_nth (index_delta + 1);
unowned Greeter.UserCard? next_card = user_cards.peek_nth (current_user_card_index + 1);
if (next_card != null) {
carousel.scroll_to (next_card);
}
Expand Down

0 comments on commit 04cb35b

Please sign in to comment.