fixed crash on text field editing
This commit is contained in:
parent
ff532f5ed9
commit
458901c029
@ -22,7 +22,6 @@ namespace gtkpp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::onActivate(const std::function<void()>& callback) {
|
void Application::onActivate(const std::function<void()>& callback) {
|
||||||
|
|
||||||
_signalActivate.connect(callback);
|
_signalActivate.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ namespace gtkpp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::addWindow(const std::shared_ptr<Window>& window) {
|
void Application::addWindow(const std::shared_ptr<Window>& window) {
|
||||||
|
_window = window;
|
||||||
gtk_application_add_window(GTK_APPLICATION(_app), GTK_WINDOW(window->gobj()));
|
gtk_application_add_window(GTK_APPLICATION(_app), GTK_WINDOW(window->gobj()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace gtkpp {
|
|||||||
class Application {
|
class Application {
|
||||||
private:
|
private:
|
||||||
AdwApplication* _app;
|
AdwApplication* _app;
|
||||||
|
std::shared_ptr<Window> _window;
|
||||||
sigc::signal<void()> _signalActivate;
|
sigc::signal<void()> _signalActivate;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -3,11 +3,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace gtkpp {
|
namespace gtkpp {
|
||||||
|
|
||||||
void changedCallback(GtkEntry* widget, void* data) {
|
void changedCallback(GtkEntry*, Entry* entry) {
|
||||||
auto entry = reinterpret_cast<Entry*>(data);
|
|
||||||
entry->_signalChanged.emit();
|
entry->_signalChanged.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,4 +32,13 @@ namespace gtkpp {
|
|||||||
_signalChanged.connect(callback);
|
_signalChanged.connect(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Entry::textLength() const {
|
||||||
|
return gtk_entry_get_text_length(GTK_ENTRY(_widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Entry::text() const {
|
||||||
|
auto buffer = gtk_entry_get_buffer(GTK_ENTRY(_widget));
|
||||||
|
return gtk_entry_buffer_get_text(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace gtkpp {
|
|||||||
sigc::signal<void()> _signalChanged;
|
sigc::signal<void()> _signalChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend void changedCallback(GtkEntry* widget, void* data);
|
friend void changedCallback(GtkEntry*, Entry* entry);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Entry();
|
Entry();
|
||||||
@ -24,6 +24,8 @@ namespace gtkpp {
|
|||||||
void setPurpose(GtkInputPurpose purpose);
|
void setPurpose(GtkInputPurpose purpose);
|
||||||
void setVisibility(bool visibility);
|
void setVisibility(bool visibility);
|
||||||
void onChanged(const std::function<void()>& callback);
|
void onChanged(const std::function<void()>& callback);
|
||||||
|
int textLength() const;
|
||||||
|
std::string text() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,4 +10,12 @@ namespace gtkpp {
|
|||||||
_widget = gtk_spinner_new();
|
_widget = gtk_spinner_new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Spinner::start() {
|
||||||
|
gtk_spinner_start(GTK_SPINNER(_widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::stop() {
|
||||||
|
gtk_spinner_stop(GTK_SPINNER(_widget));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ namespace gtkpp {
|
|||||||
class Spinner: public Widget {
|
class Spinner: public Widget {
|
||||||
public:
|
public:
|
||||||
Spinner();
|
Spinner();
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,12 +48,12 @@ LoginWindow::LoginWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoginWindow::loginClicked() {
|
void LoginWindow::loginClicked() {
|
||||||
// auto email = _emailField.get_text();
|
auto email = _loginEntry.text();
|
||||||
// auto password = _passwordField.get_text();
|
auto password = _passwordEntry.text();
|
||||||
//
|
|
||||||
// enableControls(false);
|
enableControls(false);
|
||||||
// _spinner.start();
|
_spinner.start();
|
||||||
//
|
|
||||||
// try {
|
// try {
|
||||||
// User user = co_await Api::login(email, password).scheduleOn(GLibMainContextExecutor::instance());
|
// User user = co_await Api::login(email, password).scheduleOn(GLibMainContextExecutor::instance());
|
||||||
// auto app = this->get_application();
|
// auto app = this->get_application();
|
||||||
@ -70,8 +70,8 @@ void LoginWindow::loginClicked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoginWindow::validateFields() {
|
void LoginWindow::validateFields() {
|
||||||
// bool buttonEnabled = _emailField.get_text_length() > 0 && _passwordField.get_text_length() > 0;
|
bool buttonEnabled = _loginEntry.textLength() > 3 && _passwordEntry.textLength() > 3;
|
||||||
// _loginButton.set_sensitive(buttonEnabled);
|
_loginButton.setEnabled(buttonEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginWindow::showError(const std::string& message) {
|
void LoginWindow::showError(const std::string& message) {
|
||||||
@ -88,7 +88,7 @@ void LoginWindow::showError(const std::string& message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoginWindow::enableControls(bool enable) {
|
void LoginWindow::enableControls(bool enable) {
|
||||||
// _loginButton.set_sensitive(enable);
|
_loginButton.setEnabled(enable);
|
||||||
// _emailField.set_sensitive(enable);
|
_loginEntry.setEnabled(enable);
|
||||||
// _passwordField.set_sensitive(enable);
|
_passwordEntry.setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user