|
|
@@ -29,6 +29,7 @@ pub const CURRENT_USERNAME_PANEL_ID: &str = "current_username_view_id";
|
|
|
pub const USERNAME_FIELD_ID: &str = "username_field_id";
|
|
|
pub const USERNAME_BUTTON_ID: &str = "username_button_id";
|
|
|
pub const REFRESH_BUTTON_ID: &str = "refresh_button_id";
|
|
|
+pub const QUIT_BUTTON_ID: &str = "quit_button_id";
|
|
|
pub const BLOCKED_WORDS_BUTTON_ID: &str = "blocked_words_view_id";
|
|
|
pub const SERVER_SETTINGS_ADDRESS_FIELD_ID: &str = "server_settings_address_field_id";
|
|
|
pub const SERVER_SETTINGS_REFRESH_FIELD_ID: &str = "server_settings_refresh_field_id";
|
|
|
@@ -79,6 +80,7 @@ pub enum Labels {
|
|
|
Time,
|
|
|
Sender,
|
|
|
Content,
|
|
|
+ QuitButton,
|
|
|
}
|
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
@@ -89,7 +91,7 @@ pub enum Language {
|
|
|
}
|
|
|
|
|
|
impl Labels {
|
|
|
- // TODO: Double check the translations
|
|
|
+ // TODO (low): Double check the translations
|
|
|
pub fn localize<'a>(&self, language: Language) -> String {
|
|
|
let buf: [String; 3];
|
|
|
|
|
|
@@ -210,6 +212,7 @@ impl Labels {
|
|
|
|
|
|
[buf[0].as_str(), buf[1].as_str(), buf[2].as_str()]
|
|
|
}
|
|
|
+ Labels::QuitButton => ["Quit", "Verlaten", "終了する"],
|
|
|
Labels::RefreshButton => ["Refresh", "Vernieuwen", "更新する"],
|
|
|
Labels::InvalidUsernameExplination => {
|
|
|
buf = [
|
|
|
@@ -550,6 +553,11 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
.set_label(Labels::SetUsername.localize(language));
|
|
|
});
|
|
|
|
|
|
+ siv.call_on_name(QUIT_BUTTON_ID, |view: &mut NamedView<Button>| {
|
|
|
+ view.get_mut()
|
|
|
+ .set_label(Labels::QuitButton.localize(language));
|
|
|
+ });
|
|
|
+
|
|
|
siv.call_on_name(REFRESH_BUTTON_ID, |view: &mut NamedView<Button>| {
|
|
|
view.get_mut()
|
|
|
.set_label(Labels::RefreshButton.localize(language));
|
|
|
@@ -788,6 +796,12 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
})
|
|
|
.with_name(USERNAME_BUTTON_ID);
|
|
|
|
|
|
+ // Quit button
|
|
|
+ let quit_button = Button::new("", move |siv| {
|
|
|
+ siv.quit();
|
|
|
+ })
|
|
|
+ .with_name(QUIT_BUTTON_ID);
|
|
|
+
|
|
|
// Refresh button
|
|
|
let refresh_button = Button::new("", move |siv| {
|
|
|
if let Err(e) = actions::load_messages(siv) {
|
|
|
@@ -1025,6 +1039,8 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.child(server_settings_button)
|
|
|
.child(DummyView.full_width())
|
|
|
.child(refresh_button)
|
|
|
+ .child(DummyView.full_width())
|
|
|
+ .child(quit_button)
|
|
|
.full_width(),
|
|
|
);
|
|
|
|