Mercurial > projects > dynamin
comparison dynamin/gui/x_folder_dialog.d @ 45:4eebc294a3ac
Rename DirectoryDialog to FolderDialog.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Thu, 30 Jul 2009 18:10:49 -0500 |
parents | dynamin/gui/x_directory_dialog.d@836a064828e8 |
children | 127b9d99c01c |
comparison
equal
deleted
inserted
replaced
44:ad551ec36b75 | 45:4eebc294a3ac |
---|---|
1 // Written in the D programming language | |
2 // www.digitalmars.com/d/ | |
3 | |
4 /* | |
5 * The contents of this file are subject to the Mozilla Public License Version | |
6 * 1.1 (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * http://www.mozilla.org/MPL/ | |
9 * | |
10 * Software distributed under the License is distributed on an "AS IS" basis, | |
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 * for the specific language governing rights and limitations under the | |
13 * License. | |
14 * | |
15 * The Original Code is the Dynamin library. | |
16 * | |
17 * The Initial Developer of the Original Code is Jordan Miner. | |
18 * Portions created by the Initial Developer are Copyright (C) 2009 | |
19 * the Initial Developer. All Rights Reserved. | |
20 * | |
21 * Contributor(s): | |
22 * Jordan Miner <jminer7@gmail.com> | |
23 * | |
24 */ | |
25 | |
26 module dynamin.gui.x_folder_dialog; | |
27 | |
28 public import Utf = tango.text.convert.Utf; | |
29 public import dynamin.c.glib; | |
30 public import dynamin.c.gtk; | |
31 | |
32 template FolderDialogBackend() { | |
33 DialogResult backend_showDialog() { | |
34 string title = text ? text : "Select Folder"; | |
35 auto dialog = gtk_file_chooser_dialog_new(toCharPtr(title), null, | |
36 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, | |
37 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
38 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, null); | |
39 if(_directory) | |
40 gtk_file_chooser_set_current_folder(dialog, toCharPtr(_directory)); | |
41 scope(exit) { | |
42 gtk_widget_destroy(dialog); | |
43 while(gtk_events_pending()) | |
44 gtk_main_iteration(); | |
45 } | |
46 if(gtk_dialog_run(dialog) == GTK_RESPONSE_ACCEPT) { | |
47 char* folder = gtk_file_chooser_get_filename(dialog); | |
48 _directory = folder[0..strlen(folder)].dup; | |
49 g_free(folder); | |
50 return DialogResult.OK; | |
51 } | |
52 return DialogResult.Cancel; | |
53 } | |
54 } | |
55 |