Skip to content

Commit

Permalink
Merge pull request xou816#494 from Toorero/feature/GtkPasswordEntry
Browse files Browse the repository at this point in the history
Use GtkPasswordEntry
  • Loading branch information
xou816 authored Mar 28, 2022
2 parents cd8d2c4 + 1179ac8 commit f787627
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 55 deletions.
15 changes: 5 additions & 10 deletions po/spot.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: spot\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-13 13:00-0400\n"
"POT-Creation-Date: 2022-03-28 00:21+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -300,27 +300,22 @@ msgid "Login to Spotify Premium"
msgstr ""

#. Placeholder for the username field
#: src/app/components/login/login.ui:64
#: src/app/components/login/login.ui:72
msgid "Username"
msgstr ""

#. Placeholder for the password field
#: src/app/components/login/login.ui:72
#: src/app/components/login/login.ui:89
msgid "Password"
msgstr ""

#. This information is shown when Caps Lock is enabled.
#: src/app/components/login/login.ui:95
msgid "Caps Lock is enabled!"
msgstr ""

#. This error is shown when authentication fails.
#: src/app/components/login/login.ui:126
#: src/app/components/login/login.ui:114
msgid "Authentication failed!"
msgstr ""

#. Log in button label
#: src/app/components/login/login.ui:141
#: src/app/components/login/login.ui:129
msgid "Log in"
msgstr ""

Expand Down
11 changes: 1 addition & 10 deletions src/app/components/login/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ mod imp {
#[template_child]
pub login_button: TemplateChild<gtk::Button>,

#[template_child]
pub caps_lock_info_container: TemplateChild<gtk::Revealer>,

#[template_child]
pub auth_error_container: TemplateChild<gtk::Revealer>,
}
Expand Down Expand Up @@ -87,8 +84,7 @@ impl LoginWindow {
let controller = gtk::EventControllerKey::new();
controller.set_propagation_phase(gtk::PropagationPhase::Capture);
controller.connect_key_pressed(
clone!(@weak self as _self => @default-return gtk::Inhibit(false), move |_, key, _, modifier| {
_self.show_caps_lock_info((modifier == gdk::ModifierType::LOCK_MASK) ^ (key == gdk::Key::Caps_Lock));
clone!(@weak self as _self => @default-return gtk::Inhibit(false), move |_, key, _, _| {
if key == gdk::Key::Return {
_self.submit(&on_submit_clone);
gtk::Inhibit(true)
Expand All @@ -111,11 +107,6 @@ impl LoginWindow {
widget.auth_error_container.set_reveal_child(shown);
}

fn show_caps_lock_info(&self, shown: bool) {
let widget = imp::LoginWindow::from_instance(self);
widget.caps_lock_info_container.set_reveal_child(shown);
}

fn submit<SubmitFn>(&self, on_submit: &SubmitFn)
where
SubmitFn: Fn(&str, &str),
Expand Down
58 changes: 23 additions & 35 deletions src/app/components/login/login.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,50 +59,38 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkEntry" id="username">
<property name="primary-icon-name">avatar-default-symbolic</property>
<property name="placeholder-text" translatable="yes" comments="Placeholder for the username field">Username</property>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">4</property>
<child>
<object class="GtkImage" id="username-icon">
<property name="icon-name">avatar-default-symbolic</property>
</object>
</child>
<child>
<object class="GtkEntry" id="username">
<property name="placeholder-text" translatable="yes" comments="Placeholder for the username field">Username</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkEntry" id="password">
<property name="visibility">0</property>
<property name="invisible-char">●</property>
<property name="primary-icon-name">dialog-password-symbolic</property>
<property name="placeholder-text" translatable="yes" comments="Placeholder for the password field">Password</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="caps_lock_info_container">
<property name="vexpand">1</property>
<property name="transition-type">slide-up</property>
<property name="child">
<object class="GtkBox">
<property name="spacing">8</property>
<property name="orientation">horizontal</property>
<property name="spacing">4</property>
<child>
<object class="GtkImage">
<property name="halign">center</property>
<property name="valign">start</property>
<property name="margin-top">2</property>
<property name="vexpand">1</property>
<property name="icon-name">dialog-information-symbolic</property>
<object class="GtkImage" id="password-icon">
<property name="icon-name">dialog-password-symbolic</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes" comments="This information is shown when Caps Lock is enabled.">Caps Lock is enabled!</property>
<property name="wrap">1</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
</object>
<object class="GtkPasswordEntry" id="password">
<property name="show-peek-icon">1</property>
<property name="placeholder-text" translatable="yes" comments="Placeholder for the password field">Password</property>
</object>
</child>
</object>
</property>
</child>
</object>
</child>
<child>
Expand Down Expand Up @@ -154,4 +142,4 @@
</object>
</child>
</template>
</interface>
</interface>

0 comments on commit f787627

Please sign in to comment.