// File: /workspace/github_cpp_makefile_star2_O2/eiskalteschatten[P]developersnotebook/src/windows/MainWindow.cpp
// Function: MainWindow::activate(_GtkApplication*, MainWindow*)
void MainWindow::activate(GtkApplication *app, MainWindow *mw) {
    PreferencesModel *preferences_model = new PreferencesModel();
    int window_width                    = preferences_model->get_window_width();
    int window_height                   = preferences_model->get_window_height();
    bool window_maximized               = preferences_model->get_window_maximized();

    mw->window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(mw->window), Constants::application_name.c_str());
    gtk_window_set_position(GTK_WINDOW(mw->window), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(mw->window), window_width, window_height);

    #ifndef __APPLE__
        Image logo("icon", "svg", mw->get_path_to_exec(), 32, 32);
        std::string path = logo.get_path();
        gtk_window_set_icon_from_file(GTK_WINDOW(mw->window), path.c_str(), NULL);
    #endif

    if (window_maximized) {
        gtk_window_maximize(GTK_WINDOW(mw->window));
    }

    mw->setup_css();
    mw->setup_grid();
    mw->setup_stack();

    MenuBar *menubar_obj = new MenuBar(mw);
    GtkWidget *menubar   = menubar_obj->get_menu_bar();
    gtk_grid_attach(GTK_GRID(mw->grid), menubar, 0, 0, 2, 1);

    gtk_widget_show_all(mw->window);

    menubar_obj->setup_macos_menu_bar();

    g_signal_connect(mw->window, "delete_event", G_CALLBACK(mw->save_and_close_window), NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x68
popq %rdi
callq 0x81c0
movq %rax, %r12
movq %rax, %rdi
callq 0x20ab8
movl 0x5c(%r12), %ebp
movl 0x60(%r12), %r15d
movb 0x64(%r12), %r13b
movq %r14, %rdi
callq 0x88b0
movq %rax, %r12
movq %rax, 0x20(%rbx)
callq 0x8f80
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
callq 0x8150
movq 0x23164(%rip), %rsi     # 0x33888
movq %rax, %rdi
callq 0x82c0
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x87c0
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x8df0
leaq 0x11ed8(%rip), %rsi     # 0x2263b
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xb078
leaq 0x118c8(%rip), %rsi     # 0x22041
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0xb078
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x86e0
leaq 0x90(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x30(%rsp), %rcx
pushq $0x20
popq %r8
movl %r8d, %r9d
callq 0xb2cc
leaq 0x30(%rsp), %rdi
callq 0x9120
leaq 0x50(%rsp), %rdi
callq 0x9120
leaq 0x70(%rsp), %rdi
callq 0x9120
leaq 0xf0(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x86e0
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq 0x10(%rsp), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x8a20
testb %r13b, %r13b
je 0x1081c
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x82d0
movq %rbx, %rdi
callq 0x10950
movq %rbx, %rdi
callq 0x10a6a
movq %rbx, %rdi
callq 0x10b28
pushq $0x50
popq %rdi
callq 0x81c0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x11386
movq 0x20(%r14), %r15
movq 0x28(%rbx), %r12
callq 0x89f0
movq %r12, %rdi
movq %rax, %rsi
callq 0x8150
pushq $0x2
popq %r8
pushq $0x1
popq %r9
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x8b00
movq 0x20(%rbx), %rdi
callq 0x8cc0
movq %r14, %rdi
callq 0x118e4
movq 0x20(%rbx), %rdi
leaq 0x11db5(%rip), %rsi     # 0x2264a
leaq 0x476(%rip), %rdx       # 0x10d12
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x82b0
leaq 0x10(%rsp), %rdi
callq 0x9120
leaq 0x90(%rsp), %rdi
callq 0xb3c8
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x50
popq %rsi
movq %r14, %rdi
callq 0x8190
jmp 0x10930
jmp 0x1092d
movq %rax, %rbx
jmp 0x1093a
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x9120
jmp 0x108fb
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x9120
jmp 0x1090a
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9120
jmp 0x10947
movq %rax, %rbx
jmp 0x10947
movq %rax, %rbx
pushq $0x68
popq %rsi
movq %r12, %rdi
callq 0x8190
jmp 0x10947
jmp 0x1092d
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x9120
leaq 0x90(%rsp), %rdi
callq 0xb3c8
movq %rbx, %rdi
callq 0x87f0
nop