// File: /workspace/github_c_makefile_star2_O2/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
subq $0x18, %rsp
movq 0x2f6496(%rip), %rsi    # 0x324e70
andq $0x0, 0x8(%rsp)
movl $0xfffffffd, (%rsp)     # imm = 0xFFFFFFFD
leaq 0x68a18(%rip), %rdi     # 0x97406
leaq 0x68a22(%rip), %rcx     # 0x97417
leaq 0x68a23(%rip), %r9      # 0x9741f
pushq $0x2
popq %rdx
pushq $-0x6
popq %r8
xorl %eax, %eax
callq 0x9020
movq %rax, %r14
callq 0x8b50
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x84f0
callq 0x8980
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8060
movq %rax, %rbp
leaq 0x689d7(%rip), %rdi     # 0x97427
callq 0x8940
movq %rax, %r13
movq %rax, %rdi
callq 0x9010
pushq $0x7
popq %rbx
movq %r13, %rdi
movl %ebx, %esi
callq 0x8610
movq %r13, %rdi
movl %ebx, %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 0x2eadf
movq %r14, %rdi
movq %r15, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8bf0
movq %rax, %rbp
jmp 0x2eae1
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x81e0
testq %rbp, %rbp
je 0x2ebed
andq $0x0, 0x10(%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 %rbp, %rsi
xorl %edx, %edx
callq 0x9160
movq 0x2f63d9(%rip), %rdi    # 0x324f08
leaq 0x68792(%rip), %rsi     # 0x972c8
leaq 0x37a(%rip), %rdx       # 0x2eeb7
movq %r14, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x82d0
movq %rax, %r12
movq 0x2f63a3(%rip), %rbx    # 0x324ef8
callq 0x9180
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x9010
leaq 0x348(%rip), %rsi       # 0x2eebf
movq %r15, %rdi
callq 0x8770
movq %r15, %rdi
callq 0x8180
testl %eax, %eax
jne 0x2eb92
callq 0x8040
jmp 0x2eb7f
leaq 0x10(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8900
movq 0x2f634f(%rip), %rdi    # 0x324ef8
movq %r13, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8200
movq 0x2f6348(%rip), %rdi    # 0x324f08
movq %r12, %rsi
callq 0x8fb0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x2ebd5
callq 0x8600
movq %r14, %rdi
callq 0x8eb0
movq %r15, %rdi
callq 0x8eb0
movq %rbp, %rdi
callq 0x8320
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq