// File: /workspace/github_c_makefile_star2_O1/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 0xbc4ee
testl %eax, %eax
jne 0xbc556
movq (%rsp), %rbx
leaq 0x5b8(%rbx), %rdi
callq 0x585e0
leaq 0x57776(%rip), %rcx     # 0x113c12
leaq 0x57781(%rip), %r9      # 0x113c24
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 0xbc559
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movl $0x1, %esi
callq 0x56110
jmp 0xbc559
movq (%rsp), %rbx
leaq 0x5b8(%rbx), %rdi
callq 0x585e0
leaq 0x5770d(%rip), %rcx     # 0x113c12
leaq 0x57721(%rip), %r9      # 0x113c2d
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 0xbc559
callq 0x577f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movl $0x1, %esi
callq 0x55030
jmp 0xbc559
xorl %r15d, %r15d
movq (%rsp), %rax
leaq 0x710(%rax), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56bd0
testb %al, %al
je 0xbc598
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 0xbc5d7
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, 0x40(%rsp)
movq (%rsp), %rax
cmpl $0x0, 0x648(%rax)
jle 0xbc918
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 0x6b6a6
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, %rdi
leaq 0x3bb32(%rip), %rsi     # 0xf817a
callq 0x579f0
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x57f10
movq %r15, %rdi
callq 0x59200
cmpl $0x0, 0xd0(%rsp)
jle 0xbc8b0
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
incl %esi
leaq 0xc8(%rsp), %rdi
movl %esi, 0xc(%rsp)
callq 0x64224
movq %rax, %r14
movq %r12, %rdi
leaq 0x6ddcd(%rip), %rsi     # 0x12a463
callq 0x579f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x58a10
incl %eax
leaq 0x28(%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 0x6dd88(%rip), %rsi     # 0x12a463
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 0xbc85f
movq %r12, %rdi
movl %r14d, %esi
callq 0x58990
cmpl $0x61, (%rax)
jl 0xbc82f
movq %r12, %rdi
movl %r14d, %esi
callq 0x58990
cmpl $0x7a, (%rax)
jg 0xbc82f
movq %rbp, %rdi
leaq 0x37af3(%rip), %rsi     # 0xf4255
callq 0x579f0
leaq 0x28(%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 0x61080(%rip), %rsi     # 0x11d86e
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 0xbc84f
movq %rbp, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x58f50
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x562f0
movq %rbp, %rdi
callq 0x59200
incl %r14d
jmp 0xbc71f
movq %rbp, %rdi
leaq 0x28(%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 0x28(%rsp), %rdi
callq 0x59200
movl 0xd0(%rsp), %eax
decl %eax
movl 0xc(%rsp), %esi
cmpl %eax, %esi
jl 0xbc676
movq 0x78(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x6b6a6
movq %rax, %rdi
callq 0x585e0
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x58390
callq 0x577f0
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x565d0
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x63e08
movl 0x20(%rsp), %ebx
incl %ebx
movq (%rsp), %rax
cmpl 0x648(%rax), %ebx
jl 0xbc61c
callq 0x571a0
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
callq 0x55c40
cmpl $-0x3, %eax
jne 0xbcb44
callq 0x577f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x55410
movq %rax, %rdi
callq 0x55230
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0xbcb33
movq (%rsp), %rax
addq $0x698, %rax            # imm = 0x698
movq %rax, 0x20(%rsp)
leaq 0x28(%rsp), %r14
leaq 0x60(%rsp), %r13
leaq 0x48(%rsp), %rbx
leaq 0xc8(%rsp), %rbp
movq 0x18(%rsp), %r15
movq %r15, 0x10(%rsp)
movq (%r15), %rsi
movq %r14, %rdi
callq 0x579f0
movq %r13, %rdi
leaq 0x5728d(%rip), %rsi     # 0x113c36
callq 0x579f0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x58e20
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x575f0
movq %rbp, %rdi
movq %rax, %rsi
callq 0x570b0
movq %rbx, %rdi
callq 0x59200
movq %r13, %rdi
callq 0x59200
movq %r14, %rdi
callq 0x59200
xorl %r12d, %r12d
movl $0xfffffffd, 0xc(%rsp)  # imm = 0xFFFFFFFD
movq %rbp, %rdi
callq 0x57180
addl $-0x2, %eax
cmpl %eax, %r12d
jge 0xbcade
movq %rbp, %rdi
movl %r12d, %esi
callq 0x58990
cmpl $0x25, (%rax)
jne 0xbcad2
movq %r14, %rbx
leal 0x1(%r12), %r14d
movq %rbx, %rdi
movq %rbp, %r15
movq %rbp, %rsi
movl %r14d, %edx
movl $0x2, %ecx
callq 0x58f50
movq %r13, %rdi
movq %rbx, %rsi
callq 0x55a40
movq %r13, %rbx
movq %r13, %rdi
callq 0x58f10
movq %rax, %rbp
movq %r15, %rdi
movl %r12d, %esi
callq 0x58990
movl %ebp, (%rax)
movq %rbx, %rdi
callq 0x58d60
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
callq 0x59200
movq %rbp, %rdi
movq %r15, %rsi
movl %r14d, %edx
callq 0x58b00
movq %r15, %rbp
movq %r15, %rdi
callq 0x57180
addl 0xc(%rsp), %eax
movq %rbx, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x57f90
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x562f0
movq %rbx, %r13
movq %rbp, %rdi
movq %rax, %rsi
callq 0x555f0
movq %r13, %rdi
callq 0x59200
movq %r14, %rdi
callq 0x59200
leaq 0x48(%rsp), %rbx
incl %r12d
decl 0xc(%rsp)
jmp 0xbc9f4
movq %rbp, %rdi
leaq 0x55fb9(%rip), %rsi     # 0x112aa1
callq 0x57940
movq %rbp, %rdi
leaq 0x5662f(%rip), %rsi     # 0x113126
movq %rax, %rdx
callq 0x56950
movq 0x20(%rsp), %rdi
movq %rbp, %rsi
callq 0x64280
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x55b40
movq 0x10(%rsp), %r15
movq 0x8(%r15), %r15
movq %rbp, %rdi
callq 0x59200
testq %r15, %r15
jne 0xbc98f
movq 0x18(%rsp), %rdi
callq 0x572a0
movq 0x40(%rsp), %rbx
jmp 0xbcb52
movq (%rsp), %rax
movl $0xffffffff, 0x5e0(%rax) # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x55580
callq 0x58500
testl %eax, %eax
je 0xbcb6a
callq 0x55060
jmp 0xbcb5a
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 0xbcbac
movq %rax, %rbx
jmp 0xbcba2
movq %rax, %rbx
jmp 0xbcbac
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x28(%rsp), %rdi
jmp 0xbcc20
jmp 0xbcc15
jmp 0xbcbf4
movq %rax, %rbx
jmp 0xbcbd2
jmp 0xbcc15
jmp 0xbcc15
movq %rax, %rbx
jmp 0xbcbe1
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x58d60
jmp 0xbcbe1
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x28(%rsp), %rdi
callq 0x59200
jmp 0xbcc18
jmp 0xbcca9
jmp 0xbcbf4
movq %rax, %rbx
jmp 0xbccc0
jmp 0xbcbfe
movq %rax, %rbx
jmp 0xbccb6
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
jmp 0xbcc3c
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x59200
jmp 0xbcccd
jmp 0xbcc9a
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0xbccbb
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0xbccb1
jmp 0xbcca9
jmp 0xbcc9a
jmp 0xbcc86
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x59200
jmp 0xbcc6a
jmp 0xbcc67
movq %rax, %rbx
jmp 0xbcc77
jmp 0xbcc9a
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x59200
leaq 0x98(%rsp), %rdi
callq 0x59200
jmp 0xbcc89
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x59200
jmp 0xbcc9d
jmp 0xbcca9
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x59200
jmp 0xbccac
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x59200
leaq 0x28(%rsp), %rdi
callq 0x59200
leaq 0xc8(%rsp), %rdi
callq 0x63e08
movq %rbx, %rdi
callq 0x57090
nopl (%rax)