// File: /workspace/github_cpp_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movq %rdi, %r12
movl $0x68, %edi
callq 0x81a0
movq %rax, %r14
movq %rax, %rdi
callq 0x2810c
movl 0x5c(%r14), %ebp
movl 0x60(%r14), %r15d
movb 0x64(%r14), %r13b
movq %r12, %rdi
callq 0x8870
movq %rax, %r12
movq %rax, 0x20(%rbx)
callq 0x8f40
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
callq 0x8150
movq 0x244fd(%rip), %rsi     # 0x38858
movq %rax, %rdi
callq 0x82b0
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
movl $0x1, %esi
callq 0x8780
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x8db0
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1528c(%rip), %rsi     # 0x29631
leaq 0x15289(%rip), %rdx     # 0x29635
leaq 0x60(%rsp), %rdi
callq 0xd5b4
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x14c7a(%rip), %rsi     # 0x29041
leaq 0x14c76(%rip), %rdx     # 0x29044
leaq 0x40(%rsp), %rdi
callq 0xd5b4
leaq 0x30(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0xd524
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movl $0x20, %r8d
movl $0x20, %r9d
callq 0xd780
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x14434
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x1444b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8170
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x14462
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xd524
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq (%rsp), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x8a00
testb %r13b, %r13b
je 0x144b9
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x8150
movq %rax, %rdi
callq 0x82c0
movq %rbx, %rdi
callq 0x14634
movq %rbx, %rdi
callq 0x147c4
movq %rbx, %rdi
callq 0x1487e
movl $0x50, %edi
callq 0x81a0
movq %rax, %r14
movq %rax, %rdi
movq %rbx, %rsi
callq 0x15356
movq 0x20(%r14), %r15
movq 0x28(%rbx), %r12
callq 0x89d0
movq %r12, %rdi
movq %rax, %rsi
callq 0x8150
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x2, %r8d
movl $0x1, %r9d
callq 0x8ac0
movq 0x20(%rbx), %rdi
callq 0x8c70
movq %r14, %rdi
callq 0x158b8
movq 0x20(%rbx), %rdi
leaq 0x15108(%rip), %rsi     # 0x29640
leaq 0x545(%rip), %rdx       # 0x14a84
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x82a0
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x14562
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x80(%rsp), %rdi
callq 0xd936
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x50, %esi
movq %r14, %rdi
callq 0x8170
jmp 0x14608
jmp 0x14605
movq %rax, %rbx
jmp 0x1461e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %rbp, %rdi
je 0x145bc
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x145bc
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x145d8
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8170
jmp 0x145d8
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x1462b
movq 0x70(%rsp), %rsi
incq %rsi
jmp 0x145fc
movq %rax, %rbx
jmp 0x1462b
movq %rax, %rbx
movl $0x68, %esi
movq %r14, %rdi
callq 0x8170
jmp 0x1462b
jmp 0x14605
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x1461e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8170
leaq 0x80(%rsp), %rdi
callq 0xd936
movq %rbx, %rdi
callq 0x87b0
nop