55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
//
|
|
// Created by selim on 10.05.2022.
|
|
//
|
|
|
|
#include "Window.h"
|
|
|
|
namespace gtkpp {
|
|
|
|
bool operator==(const Window& wnd1, const Window& wnd2) {
|
|
return wnd1._window == wnd2._window;
|
|
}
|
|
|
|
Window::Window(std::shared_ptr<Application> app, bool isAppWindow) {
|
|
if(isAppWindow) {
|
|
_window = GTK_WINDOW(adw_application_window_new(GTK_APPLICATION(app->gobj())));
|
|
} else {
|
|
_window = GTK_WINDOW(adw_window_new());
|
|
}
|
|
|
|
_app = app;
|
|
_builder = nullptr;
|
|
}
|
|
|
|
Window::Window(std::shared_ptr<Application> app, const char* resourceName) {
|
|
_app = app;
|
|
_builder = gtk_builder_new_from_resource(resourceName);
|
|
_window = GTK_WINDOW(gtk_builder_get_object(_builder, "adw_main_window"));
|
|
}
|
|
|
|
void Window::show() {
|
|
gtk_window_present(GTK_WINDOW(_window));
|
|
}
|
|
|
|
void Window::setTitle(const std::string &title) {
|
|
gtk_window_set_title(GTK_WINDOW(_window), title.c_str());
|
|
}
|
|
|
|
GtkWindow *Window::gobj() const {
|
|
return _window;
|
|
}
|
|
|
|
void Window::setDefaultSize(int width, int height) {
|
|
gtk_window_set_default_size(GTK_WINDOW(_window), width, height);
|
|
}
|
|
|
|
std::shared_ptr<Application> Window::application() const {
|
|
return _app.lock();
|
|
}
|
|
|
|
void Window::hide() {
|
|
gtk_window_close(GTK_WINDOW(_window));
|
|
}
|
|
|
|
}
|