-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Stanislav Malishevskiy <[email protected]>
- Loading branch information
1 parent
b09556f
commit f8c0046
Showing
12 changed files
with
235 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<interface> | ||
<requires lib="gtk" version="4.0"/> | ||
<template class="DinoUiChangePasswordDialog"> | ||
<property name="title" translatable="1">Change password</property> | ||
<property name="default-width">430</property> | ||
<property name="default-height">270</property> | ||
<property name="modal">True</property> | ||
<child type="titlebar"> | ||
<object class="GtkHeaderBar"> | ||
<property name="show-title-buttons">False</property> | ||
<child> | ||
<object class="GtkButton" id="cancel_button"> | ||
<property name="label" translatable="yes">Cancel</property> | ||
</object> | ||
</child> | ||
<child type="end"> | ||
<object class="GtkButton" id="change_password_button"> | ||
<property name="sensitive">0</property> | ||
<style> | ||
<class name="suggested-action"/> | ||
</style> | ||
<child> | ||
<object class="GtkStack" id="change_password_stack"> | ||
<child> | ||
<object class="GtkStackPage"> | ||
<property name="name">label</property> | ||
<property name="child"> | ||
<object class="GtkLabel" > | ||
<property name="label" translatable="1">Change</property> | ||
</object> | ||
</property> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkStackPage"> | ||
<property name="name">spinner</property> | ||
<property name="child"> | ||
<object class="GtkSpinner"> | ||
<property name="spinning">True</property> | ||
</object> | ||
</property> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="AdwPreferencesPage"> | ||
<child> | ||
<object class="AdwPreferencesGroup"> | ||
<child> | ||
<object class="AdwPasswordEntryRow" id="current_password_entry"> | ||
<property name="title" translatable="yes">Current password</property> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="AdwPasswordEntryRow" id="new_password_entry"> | ||
<property name="title" translatable="yes">New password</property> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="AdwPasswordEntryRow" id="confirm_new_password_entry"> | ||
<property name="title" translatable="yes">Confirm password</property> | ||
</object> | ||
</child> | ||
<child> | ||
<object class="GtkLabel" id="change_password_error_label"> | ||
<property name="halign">center</property> | ||
<property name="hexpand">True</property> | ||
<property name="margin-top">7</property> | ||
<attributes> | ||
<attribute name="scale" value="0.9"></attribute> | ||
</attributes> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</object> | ||
</child> | ||
</template> | ||
</interface> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
main/src/windows/preferences_window/change_password_dialog.vala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Gee; | ||
using Gtk; | ||
|
||
using Dino.Entities; | ||
using Xmpp; | ||
|
||
namespace Dino.Ui{ | ||
|
||
[GtkTemplate (ui = "/im/dino/Dino/preferences_window/change_password_dialog.ui")] | ||
public class ChangePasswordDialog : Gtk.Dialog { | ||
|
||
[GtkChild] private unowned Button change_password_button; | ||
[GtkChild] private unowned Stack change_password_stack; | ||
[GtkChild] private unowned Button cancel_button; | ||
[GtkChild] private unowned Adw.PasswordEntryRow current_password_entry; | ||
[GtkChild] private unowned Adw.PasswordEntryRow new_password_entry; | ||
[GtkChild] private unowned Adw.PasswordEntryRow confirm_new_password_entry; | ||
[GtkChild] private unowned Label change_password_error_label; | ||
|
||
private ViewModel.ChangePasswordDialog model; | ||
|
||
public ChangePasswordDialog(ViewModel.ChangePasswordDialog model) { | ||
Object(use_header_bar : 1); | ||
this.model = model; | ||
|
||
Util.force_error_color(change_password_error_label); | ||
cancel_button.clicked.connect(() => { close(); }); | ||
current_password_entry.changed.connect(is_form_filled); | ||
new_password_entry.changed.connect(is_form_filled); | ||
confirm_new_password_entry.changed.connect(is_form_filled); | ||
change_password_button.clicked.connect(on_change_password_button_clicked); | ||
} | ||
|
||
private void is_form_filled(){ | ||
if (current_password_entry.get_text().length > 0 | ||
&& new_password_entry.get_text().length > 0 | ||
&& confirm_new_password_entry.get_text().length > 0 | ||
&& new_password_entry.get_text() == confirm_new_password_entry.get_text()){ | ||
change_password_button.sensitive = true; | ||
} else { | ||
change_password_button.sensitive = false; | ||
} | ||
} | ||
|
||
private async void on_change_password_button_clicked(){ | ||
string? pw_input = current_password_entry.get_text(); | ||
string? new_pw_input = new_password_entry.get_text(); | ||
|
||
if (pw_input != null && model.account.password == pw_input){ | ||
change_password_button.sensitive = false; | ||
change_password_stack.visible_child_name = "spinner"; | ||
string? ret = yield model.change_password(new_pw_input); | ||
change_password_button.sensitive = true; | ||
change_password_stack.visible_child_name = "label"; | ||
if (ret == null) { | ||
close(); | ||
} | ||
|
||
change_password_error_label.label = "Error: %s".printf(ret); | ||
|
||
} else { | ||
change_password_error_label.label = "Wrong current password"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters