// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/classes/gui/dialogs/file/filedlg_gtk.cpp
// Function: smooth::GUI::Dialogs::FileSelection::ShowDialog()
const Error &S::GUI::Dialogs::FileSelection::ShowDialog()
{
	/* Create file chooser dialog.
	 */
	GtkWidget	*dialog = NULL;

	if (mode == SFM_OPEN)
	{
		dialog = gtk_file_chooser_dialog_new(caption, NULL, GTK_FILE_CHOOSER_ACTION_OPEN,
						     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
						     NULL);

		if (flags & SFD_ALLOWMULTISELECT) gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), True);
	}
	else if (mode == SFM_SAVE)
	{
		dialog = gtk_file_chooser_dialog_new(caption, NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
						     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						     GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
						     NULL);

		if (flags & SFD_CONFIRMOVERWRITE) gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), True);
	}

	if (defPath != NIL) gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), defPath);
	if (defFile != NIL) gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), defFile);

	/* Add file filters.
	 */
	for (int i = 0; i < filters.Length(); i++)
	{
		GtkFileFilter		*filter = gtk_file_filter_new();
		const Array<String>	&patterns = filters.GetNth(i).Explode(";");

		foreach (const String &pattern, patterns)
		{
			/* Make patterns case insensitive.
			 */
			String	 converted = pattern.Head(		     pattern.FindLast(".") + 1);
			String	 extension = pattern.Tail(pattern.Length() - pattern.FindLast(".") - 1).ToLower();

			for (Int i = 0; i < extension.Length(); i++)
			{
				if (extension[i] >= 'a' && extension[i] <= 'z') converted.Append("[").Append(extension.SubString(i, 1)).Append(extension.SubString(i, 1).ToUpper()).Append("]");
				else						converted.Append(extension.SubString(i, 1));
			}

			gtk_file_filter_add_pattern(filter, converted.Trim());
		}

		gtk_file_filter_set_name(filter, filterNames.GetNth(i));

		gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
	}

	/* Run dialog and check result.
	 */
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		GSList	*list = gtk_file_chooser_get_uris(GTK_FILE_CHOOSER(dialog));
		GSList	*current = list;

		while (current != NULL)
		{
			String	 file = String((char *) current->data).Replace("file://", NIL);

			for (Int i = 0; i < file.Length() - 2; i++)
			{
				if (file[i] == '%')
				{
					file[i] = (Int64) Number::FromHexString(file.SubString(i + 1, 2));
					file = file.Head(i + 1).Append(file.Tail(file.Length() - i - 3));
				}
			}

			file.ImportFrom("UTF-8", file.ConvertTo("ISO-8859-1"));
			files.Add(file);

			g_free(current->data);

			current = current->next;
		}

		g_slist_free(list);
	}
	else
	{
		error = Error();
	}

	gtk_widget_destroy(dialog);

	/* Wait for GTK to finish pending actions.
	 */
	while (gtk_events_pending()) gtk_main_iteration();

	return error;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, (%rsp)
movzwl 0x6f2(%rdi), %eax
cmpl $0x1, %eax
je 0xbb562
testl %eax, %eax
jne 0xbb5ca
movq (%rsp), %rbx
leaq 0x5b8(%rbx), %rdi
callq 0x585e0
leaq 0x57902(%rip), %rcx     # 0x112e12
leaq 0x5790d(%rip), %r9      # 0x112e24
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0xfffffffa, %r8d       # imm = 0xFFFFFFFA
xorl %eax, %eax
pushq $0x0
pushq $-0x3
callq 0x58960
addq $0x10, %rsp
movq %rax, %r15
testb $0x2, 0x6f1(%rbx)
je 0xbb5cd
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movl $0x1, %esi
callq 0x56110
jmp 0xbb5cd
movq (%rsp), %rbx
leaq 0x5b8(%rbx), %rdi
callq 0x585e0
leaq 0x57899(%rip), %rcx     # 0x112e12
leaq 0x578ad(%rip), %r9      # 0x112e2d
movq %rax, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0xfffffffa, %r8d       # imm = 0xFFFFFFFA
xorl %eax, %eax
pushq $0x0
pushq $-0x3
callq 0x58960
addq $0x10, %rsp
movq %rax, %r15
testb $0x2, 0x6f0(%rbx)
je 0xbb5cd
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movl $0x1, %esi
callq 0x55030
jmp 0xbb5cd
xorl %r15d, %r15d
movq (%rsp), %rax
leaq 0x710(%rax), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0xbb60c
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %r14
movq %rbx, %rdi
callq 0x585e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x56180
movq (%rsp), %rax
leaq 0x728(%rax), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0xbb64b
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %r14
movq %rbx, %rdi
callq 0x585e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x55340
movq %r15, 0x28(%rsp)
movq (%rsp), %rax
cmpl $0x0, 0x648(%rax)
jle 0xbb98c
movq (%rsp), %rax
leaq 0x640(%rax), %rcx
movq %rcx, 0x18(%rsp)
addq $0x5e8, %rax            # imm = 0x5E8
movq %rax, 0x78(%rsp)
xorl %ebx, %ebx
leaq 0xc8(%rsp), %r14
leaq 0x60(%rsp), %r12
leaq 0x48(%rsp), %rbp
callq 0x568a0
movq %rax, 0x10(%rsp)
movq 0x18(%rsp), %rdi
movl %ebx, 0x20(%rsp)
movl %ebx, %esi
callq 0x6b610
movq %rax, %rbx
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0x3bc62(%rip), %rsi     # 0xf731e
callq 0x579f0
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x57f10
movq %r15, %rdi
callq 0x59200
cmpl $0x0, 0xd0(%rsp)
jle 0xbb924
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
incl %esi
leaq 0xc8(%rsp), %rdi
movl %esi, 0xc(%rsp)
callq 0x64250
movq %rax, %r14
movq %r12, %rdi
leaq 0x6df79(%rip), %rsi     # 0x129683
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58a10
incl %eax
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x58b00
movq %r12, %rdi
callq 0x59200
movq %r14, %rdi
callq 0x57180
movl %eax, %ebx
leaq 0x80(%rsp), %r15
movq %r15, %rdi
leaq 0x6df34(%rip), %rsi     # 0x129683
callq 0x579f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x58a10
notl %eax
addl %eax, %ebx
movq %rbp, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x57f90
movq %r12, %rdi
movq %rbp, %rsi
callq 0x58090
movq %rbp, %rdi
callq 0x59200
leaq 0x80(%rsp), %rdi
callq 0x59200
xorl %r14d, %r14d
movq %r12, %rdi
callq 0x57180
cmpl %eax, %r14d
jge 0xbb8d3
movq %r12, %rdi
movl %r14d, %esi
callq 0x58990
cmpl $0x61, (%rax)
jl 0xbb8a3
movq %r12, %rdi
movl %r14d, %esi
callq 0x58990
cmpl $0x7a, (%rax)
jg 0xbb8a3
movq %rbp, %rdi
leaq 0x37a7f(%rip), %rsi     # 0xf3255
callq 0x579f0
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x562f0
movq %rax, %rbx
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x58f50
movq %rbx, %rdi
movq %r15, %rsi
callq 0x562f0
movq %rax, %rbx
leaq 0x98(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x58f50
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x55dc0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x562f0
movq %rax, %rbx
leaq 0x120(%rsp), %r15
movq %r15, %rdi
leaq 0x6121c(%rip), %rsi     # 0x11ca7e
callq 0x579f0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x562f0
movq %r15, %rdi
callq 0x59200
leaq 0xb0(%rsp), %rdi
callq 0x59200
leaq 0x98(%rsp), %rdi
callq 0x59200
leaq 0x80(%rsp), %rdi
callq 0x59200
jmp 0xbb8c3
movq %rbp, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x58f50
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x562f0
movq %rbp, %rdi
callq 0x59200
incl %r14d
jmp 0xbb793
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
callq 0x58e90
movq %rbp, %rdi
callq 0x585e0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x57280
movq %rbp, %rdi
callq 0x59200
movq %r12, %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
callq 0x59200
movl 0xd0(%rsp), %eax
decl %eax
movl 0xc(%rsp), %esi
cmpl %eax, %esi
jl 0xbb6ea
movq 0x78(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x6b610
movq %rax, %rdi
callq 0x585e0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x58390
callq 0x577f0
movq 0x28(%rsp), %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x565d0
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x63e3c
movl 0x20(%rsp), %ebx
incl %ebx
movq (%rsp), %rax
cmpl 0x648(%rax), %ebx
jl 0xbb690
callq 0x571a0
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
callq 0x55c40
cmpl $-0x3, %eax
jne 0xbbbb8
callq 0x577f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
callq 0x55230
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0xbbba7
movq (%rsp), %rax
addq $0x698, %rax            # imm = 0x698
movq %rax, 0x20(%rsp)
leaq 0x30(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0x48(%rsp), %rbx
leaq 0xc8(%rsp), %r15
movq 0x18(%rsp), %r14
movq %r14, 0x10(%rsp)
movq (%r14), %rsi
movq %r13, %rdi
callq 0x579f0
movq %rbp, %rdi
leaq 0x57419(%rip), %rsi     # 0x112e36
callq 0x579f0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x58e20
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x575f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x570b0
movq %rbx, %rdi
callq 0x59200
movq %rbp, %rdi
callq 0x59200
movq %r13, %rdi
callq 0x59200
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x57180
addl $-0x2, %eax
cmpl %eax, %r12d
jge 0xbbb52
movq %r15, %rdi
movl %r12d, %esi
callq 0x58990
cmpl $0x25, (%rax)
jne 0xbbb4a
movq %r15, %rsi
movq %rbp, %r15
movq %r13, %rbp
leal 0x1(%r12), %edx
movq %r13, %rdi
movq %rsi, %r14
movl %edx, 0xc(%rsp)
movl $0x2, %ecx
callq 0x58f50
movq %r15, %rbx
movq %r15, %rdi
movq %rbp, %r13
movq %rbp, %rsi
callq 0x55a40
movq %rbx, %rdi
callq 0x58f10
movq %rax, %rbp
movq %r14, %rdi
movl %r12d, %esi
callq 0x58990
movl %ebp, (%rax)
movq %r15, %rdi
callq 0x58d60
movq %r13, %rdi
callq 0x59200
movq %r13, %rdi
movq %r14, %rsi
movl 0xc(%rsp), %edx
callq 0x58b00
movq %r14, %rdi
callq 0x57180
movq %r15, %rbp
movq %r14, %r15
subl %r12d, %eax
addl $-0x3, %eax
movq %rbp, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x57f90
movq %r13, %rdi
movq %rbp, %rsi
callq 0x562f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x555f0
movq %rbp, %rdi
callq 0x59200
movq %r13, %rdi
callq 0x59200
movl 0xc(%rsp), %eax
movl %eax, %r12d
leaq 0x48(%rsp), %rbx
jmp 0xbba60
incl %r12d
jmp 0xbba60
movq %r15, %rdi
leaq 0x560e5(%rip), %rsi     # 0x111c41
callq 0x57940
movq %r15, %rdi
leaq 0x5676b(%rip), %rsi     # 0x1122d6
movq %rax, %rdx
callq 0x56950
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x642ac
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x55b40
movq 0x10(%rsp), %r14
movq 0x8(%r14), %r14
movq %r15, %rdi
callq 0x59200
testq %r14, %r14
jne 0xbba03
movq 0x18(%rsp), %rdi
callq 0x572a0
movq 0x28(%rsp), %rbx
jmp 0xbbbc6
movq (%rsp), %rax
movl $0xffffffff, 0x5e0(%rax) # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x55580
callq 0x58500
testl %eax, %eax
je 0xbbbde
callq 0x55060
jmp 0xbbbce
movq (%rsp), %rax
addq $0x5d8, %rax            # imm = 0x5D8
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xbbc20
movq %rax, %rbx
jmp 0xbbc16
movq %rax, %rbx
jmp 0xbbc20
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
jmp 0xbbc94
jmp 0xbbc89
jmp 0xbbc68
movq %rax, %rbx
jmp 0xbbc46
jmp 0xbbc89
jmp 0xbbc89
movq %rax, %rbx
jmp 0xbbc55
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x58d60
jmp 0xbbc55
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
callq 0x59200
jmp 0xbbc8c
jmp 0xbbd1d
jmp 0xbbc68
movq %rax, %rbx
jmp 0xbbd34
jmp 0xbbc72
movq %rax, %rbx
jmp 0xbbd2a
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
jmp 0xbbcb0
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x59200
jmp 0xbbd41
jmp 0xbbd0e
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0xbbd2f
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0xbbd25
jmp 0xbbd1d
jmp 0xbbd0e
jmp 0xbbcfa
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x59200
jmp 0xbbcde
jmp 0xbbcdb
movq %rax, %rbx
jmp 0xbbceb
jmp 0xbbd0e
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x59200
leaq 0x98(%rsp), %rdi
callq 0x59200
jmp 0xbbcfd
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x59200
jmp 0xbbd11
jmp 0xbbd1d
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
jmp 0xbbd20
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x30(%rsp), %rdi
callq 0x59200
leaq 0xc8(%rsp), %rdi
callq 0x63e3c
movq %rbx, %rdi
callq 0x57090
nopl (%rax)