// File: /workspace/github_c_makefile_star2_O1/jonof[P]jftekwar/src/startgtk_game.c
// Function: on_chooseimportbutton_clicked
static void on_chooseimportbutton_clicked(GtkButton *button, gpointer user_data)
{
    GtkWidget *dialog;
    char *filename = NULL;

    (void)button; (void)user_data;

    dialog = gtk_file_chooser_dialog_new("Import game data", startwin,
        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
        "_Cancel", GTK_RESPONSE_CANCEL,
        "_Import", GTK_RESPONSE_ACCEPT,
        NULL);
    gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);

    GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
    GtkWidget *label = gtk_label_new("Select a folder to search.");
    gtk_widget_show(label);
    gtk_widget_set_margin_top(label, 7);
    gtk_widget_set_margin_bottom(label, 7);
    gtk_container_add(GTK_CONTAINER(content), label);
    gtk_box_reorder_child(GTK_BOX(content), label, 0);

    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
        GtkFileChooser *chooser = GTK_FILE_CHOOSER(dialog);
        filename = gtk_file_chooser_get_filename(chooser);
    }
    gtk_widget_destroy(dialog);

    if (filename) {
        GTask *task = NULL;
        GError *err = NULL;
        GCancellable *cancellable = NULL;
        gulong clickhandlerid;

        cancellable = g_cancellable_new();
        task = g_task_new(NULL, cancellable, NULL, NULL);
        g_task_set_check_cancellable(task, FALSE);

        // Pass the filename as task data.
        g_task_set_task_data(task, (gpointer)filename, NULL);

        // Connect the import status cancel button passing the GCancellable* as user data.
        clickhandlerid = g_signal_connect(controls.importstatuscancelbutton, "clicked",
            G_CALLBACK(on_importstatus_cancelbutton_clicked), (gpointer)cancellable);

        // Show the status window, run the import thread, and while it's running, pump the Gtk queue.
        gtk_widget_show(GTK_WIDGET(controls.importstatuswindow));
        g_task_run_in_thread(task, import_thread_func);
        while (!g_task_get_completed(task)) gtk_main_iteration();

        // Get the return value from the import thread, then hide the status window.
        (void) g_task_propagate_int(task, &err);
        gtk_widget_hide(GTK_WIDGET(controls.importstatuswindow));

        // Disconnect the cancel button and clean up.
        g_signal_handler_disconnect(controls.importstatuscancelbutton, clickhandlerid);
        if (err) g_error_free(err);
        g_object_unref(cancellable);
        g_object_unref(task);

        g_free(filename);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x2fab60(%rip), %rsi    # 0x32be50
leaq 0x7109f(%rip), %rdi     # 0xa2396
leaq 0x710a9(%rip), %rcx     # 0xa23a7
leaq 0x710aa(%rip), %r9      # 0xa23af
xorl %ebx, %ebx
movl $0x2, %edx
movl $0xfffffffa, %r8d       # imm = 0xFFFFFFFA
xorl %eax, %eax
pushq $0x0
pushq $-0x3
callq 0x9020
addq $0x10, %rsp
movq %rax, %r14
callq 0x8b50
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movl $0x1, %esi
callq 0x84f0
callq 0x8980
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8060
movq %rax, %rbp
leaq 0x7104e(%rip), %rdi     # 0xa23b7
callq 0x8940
movq %rax, %r13
movq %rax, %rdi
callq 0x9010
movq %r13, %rdi
movl $0x7, %esi
callq 0x8610
movq %r13, %rdi
movl $0x7, %esi
callq 0x8d90
callq 0x8b90
movq %rbp, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movq %r13, %rsi
callq 0x90c0
callq 0x8a60
movq %rbp, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x81f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8360
cmpl $-0x3, %eax
jne 0x313f9
movq %r14, %rdi
movq %r15, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8bf0
movq %rax, %rbx
movq %r14, %rdi
callq 0x81e0
testq %rbx, %rbx
je 0x31506
movq $0x0, (%rsp)
callq 0x84d0
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x8c70
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
callq 0x8890
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x9160
movq 0x2faa9f(%rip), %rdi    # 0x32bee8
leaq 0x70e08(%rip), %rsi     # 0xa2258
leaq 0x38e(%rip), %rdx       # 0x317e5
movq %r14, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x82d0
movq %rax, %r12
movq 0x2faa69(%rip), %rbp    # 0x32bed8
callq 0x9180
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x9010
leaq 0x35c(%rip), %rsi       # 0x317ed
movq %r15, %rdi
callq 0x8770
movq %r15, %rdi
callq 0x8180
testl %eax, %eax
jne 0x314ac
callq 0x8040
jmp 0x31499
movq %rsp, %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8900
movq 0x2faa17(%rip), %rdi    # 0x32bed8
movq %r13, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8200
movq 0x2faa10(%rip), %rdi    # 0x32bee8
movq %r12, %rsi
callq 0x8fb0
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x314ee
callq 0x8600
movq %r14, %rdi
callq 0x8eb0
movq %r15, %rdi
callq 0x8eb0
movq %rbx, %rdi
callq 0x8320
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq