summaryrefslogtreecommitdiff
path: root/src/gui_gtk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui_gtk.cc')
-rw-r--r--src/gui_gtk.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gui_gtk.cc b/src/gui_gtk.cc
index 6913921..96fa7a0 100644
--- a/src/gui_gtk.cc
+++ b/src/gui_gtk.cc
@@ -597,6 +597,19 @@ public:
Looper* create_looper() override;
+ void resize(uint32_t width, uint32_t height) override {
+ if (width == width_ && height_ == height) return;
+ width_ = width;
+ height_ = height;
+
+ auto win = window();
+ if (win) {
+ gtk_window_resize(win, width_, height_);
+ } else {
+ notify_resize();
+ }
+ }
+
void set_menu(GuiMenu* menu) override {
assert(menu);
menu_ = menu;
@@ -780,6 +793,27 @@ public:
return ret_file;
}
+ void check_size() {
+ auto win = window();
+ if (!win) {
+ assert(false);
+ return;
+ }
+ gint width, height;
+ gtk_window_get_size(win, &width, &height);
+ if (width < 0 || height < 0) {
+ assert(false);
+ return;
+ }
+ if (static_cast<uint32_t>(width) == width_
+ && static_cast<uint32_t>(height) == height_) {
+ return;
+ }
+ width_ = width;
+ height_ = height;
+ notify_resize();
+ }
+
private:
bool notify_about_to_exit() {
auto it = observers_.notify();
@@ -789,6 +823,13 @@ private:
return true;
}
+ void notify_resize() {
+ auto it = observers_.notify();
+ while (it.has_next()) {
+ it.next()->resize(width_, height_);
+ }
+ }
+
Config* config() override {
return config_.get();
}
@@ -1914,6 +1955,12 @@ G_DEFINE_TYPE(MainApp, main_app, GTK_TYPE_APPLICATION);
G_DEFINE_TYPE(MainAppWindow, main_app_window, GTK_TYPE_APPLICATION_WINDOW);
+gboolean configure_event(GtkWidget*, GdkEvent*, gpointer data) {
+ auto main = reinterpret_cast<GtkGuiMain*>(data);
+ main->check_size();
+ return false;
+}
+
void top_selection_changed(GtkTreeSelection* selection, gpointer data) {
auto main = reinterpret_cast<GtkGuiMain*>(data);
GtkTreeIter iter;
@@ -1934,6 +1981,8 @@ MainAppWindow* main_app_window_new(MainApp *app) {
"application", app, nullptr));
gtk_window_set_default_size(GTK_WINDOW(ret), app->main_->default_width(),
app->main_->default_height());
+ g_signal_connect(G_OBJECT(ret), "configure-event",
+ G_CALLBACK(configure_event), app->main_);
auto box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
ret->paned_ = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
auto listmodel = app->main_->listmodel();