// File: /workspace/github_cpp_makefile_star2_O2/eiskalteschatten[P]developersnotebook/src/views/ProjectsView.cpp
// Function: delete_project(_GtkWidget*, ProjectsView*)
void delete_project(GtkWidget *widget, ProjectsView *pv) {
    Modal modal("Delete Project", "Are you sure you want to delete the selected project?", pv->main_window);
    int result = modal.show_confirm_modal("Delete Project", "Cancel");

    switch(result) {
        case MODAL_RESPONSE_ACCEPT: {
            int id              = -1;
            gchar *id_char      = nullptr;
            GtkTreeModel *model = nullptr;
            GtkTreeIter tree_iter;

            if (gtk_tree_selection_get_selected(pv->select, &model, &tree_iter)) {
                gtk_tree_model_get(model, &tree_iter, ID_COLUMN, &id_char, -1);
                id = std::stoi(id_char);
                g_free(id_char);
            }

            if (!gtk_tree_selection_get_selected(pv->select, &model, &tree_iter) || id == -1) {
                Modal modal("No Project Selected", "No project was selected to delete.", pv->main_window);
                modal.show_error_modal();
                break;
            }

            ProjectsModel projects_model(id);
            projects_model.delete_single();

            pv->remove_from_list_store(&tree_iter);
        } break;
        default:
        break;
    }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, %rbx
leaq 0x15be1(%rip), %rsi     # 0x2219b
leaq 0xe0(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0xb078
leaq 0x15bd4(%rip), %rsi     # 0x221aa
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xb078
movq (%rbx), %rcx
leaq 0x100(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x20f0c
leaq 0xc0(%rsp), %rdi
callq 0x9120
leaq 0xe0(%rsp), %rdi
callq 0x9120
leaq 0x15b72(%rip), %rsi     # 0x2219b
leaq 0xa0(%rsp), %rdi
leaq 0x150(%rsp), %rdx
callq 0xb078
leaq 0x15b9b(%rip), %rsi     # 0x221e0
leaq 0x80(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0xb078
leaq 0x100(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x21226
movl %eax, %ebp
leaq 0x80(%rsp), %rdi
callq 0x9120
leaq 0xa0(%rsp), %rdi
callq 0x9120
testl %ebp, %ebp
jne 0xc7f6
orl $-0x1, 0xc(%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x18(%rsp), %rsi
andq $0x0, (%rsi)
movq 0x40(%rbx), %rdi
leaq 0x20(%rsp), %rdx
callq 0x8dd0
testl %eax, %eax
je 0xc722
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x10(%rsp), %rcx
pushq $-0x1
popq %r8
xorl %edx, %edx
xorl %eax, %eax
callq 0x8890
movq 0x10(%rsp), %rsi
leaq 0x150(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0xb078
leaq 0x150(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0xe20f
movl %eax, %ebp
movl %eax, 0xc(%rsp)
leaq 0x150(%rsp), %rdi
callq 0x9120
movq 0x10(%rsp), %rdi
callq 0x9118
jmp 0xc725
pushq $-0x1
popq %rbp
movq 0x40(%rbx), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x8dd0
testl %eax, %eax
setne %al
cmpl $-0x1, %ebp
setne %cl
testb %cl, %al
jne 0xc7bd
leaq 0x15a99(%rip), %rsi     # 0x221e7
leaq 0x60(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0xb078
leaq 0x15a97(%rip), %rsi     # 0x221fb
leaq 0x40(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0xb078
movq (%rbx), %rcx
leaq 0x150(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x40(%rsp), %rdx
callq 0x20f0c
leaq 0x40(%rsp), %rdi
callq 0x9120
leaq 0x60(%rsp), %rdi
callq 0x9120
leaq 0x150(%rsp), %rdi
callq 0x2111a
leaq 0x150(%rsp), %rdi
callq 0x21100
jmp 0xc7f6
leaq 0x150(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x1f966
leaq 0x150(%rsp), %rdi
callq 0x122a2
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xc8c8
leaq 0x150(%rsp), %rdi
callq 0x1fd0a
leaq 0x100(%rsp), %rdi
callq 0x21100
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %rbp
retq
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x21100
jmp 0xc8b2
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x9120
jmp 0xc834
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0xc87d
jmp 0xc8af
jmp 0xc8af
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
jmp 0xc87d
jmp 0xc8af
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x1fd0a
jmp 0xc8b2
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9120
jmp 0xc875
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x9120
jmp 0xc8b2
jmp 0xc8af
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x9120
jmp 0xc89b
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x9120
jmp 0xc8bf
movq %rax, %rbx
jmp 0xc8bf
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x21100
movq %rbx, %rdi
callq 0x87f0
nop