// File: /workspace/github_c_makefile_star2_O3/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 0x2fc856(%rip), %rsi    # 0x32ee70
leaq 0x72f25(%rip), %rdi     # 0xa5546
leaq 0x72f2f(%rip), %rcx     # 0xa5557
leaq 0x72f30(%rip), %r9      # 0xa555f
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, %rbx
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movl $0x1, %esi
callq 0x84f0
callq 0x8980
movq %rax, %r15
movq %r14, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8060
movq %rax, %r13
leaq 0x72ed6(%rip), %rdi     # 0xa5567
callq 0x8940
movq %rax, %r12
movq %rax, %rdi
callq 0x9010
movq %r12, %rdi
movl $0x7, %esi
callq 0x8610
movq %r12, %rdi
movl $0x7, %esi
callq 0x8d90
callq 0x8b90
movq %r13, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movq %r12, %rsi
callq 0x90c0
callq 0x8a60
movq %r13, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x81f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8360
cmpl $-0x3, %eax
jne 0x327d8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8bf0
movq %rax, %rbx
movq %r14, %rdi
callq 0x81e0
testq %rbx, %rbx
je 0x32848
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 0x2fc793(%rip), %rdi    # 0x32ef08
leaq 0x72c8c(%rip), %rsi     # 0xa5408
leaq 0x3aa(%rip), %rdx       # 0x32b2d
movq %r14, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x82d0
movq %rax, %r12
movq 0x2fc75d(%rip), %rbp    # 0x32eef8
callq 0x9180
movq %rax, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x9010
leaq 0x378(%rip), %rsi       # 0x32b35
movq %r15, %rdi
callq 0x8770
movq %r15, %rdi
callq 0x8180
testl %eax, %eax
jne 0x327ee
callq 0x8040
jmp 0x327c5
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81e0
movq %rsp, %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8900
movq 0x2fc6f5(%rip), %rdi    # 0x32eef8
movq %r13, %rsi
callq 0x8160
movq %rax, %rdi
callq 0x8200
movq 0x2fc6ee(%rip), %rdi    # 0x32ef08
movq %r12, %rsi
callq 0x8fb0
movq (%rbp), %rdi
testq %rdi, %rdi
je 0x32830
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