Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/FileDialog.d @ 51:c01d033c633a
[swt lin]
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 19:58:06 +0100 |
parents | d5075f5226e5 |
children |
comparison
equal
deleted
inserted
replaced
50:d5075f5226e5 | 51:c01d033c633a |
---|---|
121 auto name = cast(char*)OS.g_slist_data (current); | 121 auto name = cast(char*)OS.g_slist_data (current); |
122 uint items_written; | 122 uint items_written; |
123 char* utf8Ptr = OS.g_filename_to_utf8 (name, -1, null, &items_written, null); | 123 char* utf8Ptr = OS.g_filename_to_utf8 (name, -1, null, &items_written, null); |
124 OS.g_free (name); | 124 OS.g_free (name); |
125 if (utf8Ptr !is null) { | 125 if (utf8Ptr !is null) { |
126 fullPath = utf8Ptr[ 0 .. items_written ].dup; | 126 fullPath = utf8Ptr[ 0 .. items_written ]._idup(); |
127 int start = fullPath.lastIndexOf( SEPARATOR); | 127 int start = fullPath.lastIndexOf( SEPARATOR); |
128 fileNames [writePos++] = fullPath[ start + 1 .. $ ].dup; | 128 fileNames [writePos++] = fullPath[ start + 1 .. $ ]._idup(); |
129 OS.g_free (utf8Ptr); | 129 OS.g_free (utf8Ptr); |
130 } | 130 } |
131 current = OS.g_slist_next (current); | 131 current = OS.g_slist_next (current); |
132 } | 132 } |
133 if (writePos !is 0 && writePos !is listLength) { | 133 if (writePos !is 0 && writePos !is listLength) { |
141 if (path !is null) { | 141 if (path !is null) { |
142 uint items_written; | 142 uint items_written; |
143 auto utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, &items_written, null); | 143 auto utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, &items_written, null); |
144 OS.g_free (path); | 144 OS.g_free (path); |
145 if (utf8Ptr !is null) { | 145 if (utf8Ptr !is null) { |
146 fullPath = utf8Ptr[ 0 .. items_written ].dup; | 146 fullPath = utf8Ptr[ 0 .. items_written ]._idup(); |
147 fileNames = new String [1]; | 147 fileNames = new String [1]; |
148 int start = fullPath.lastIndexOf( SEPARATOR); | 148 int start = fullPath.lastIndexOf( SEPARATOR); |
149 fileNames[0] = fullPath[ start + 1 .. $ ]; | 149 fileNames[0] = fullPath[ start + 1 .. $ ]; |
150 OS.g_free (utf8Ptr); | 150 OS.g_free (utf8Ptr); |
151 } | 151 } |
154 filterIndex = -1; | 154 filterIndex = -1; |
155 auto filter = OS.gtk_file_chooser_get_filter (handle); | 155 auto filter = OS.gtk_file_chooser_get_filter (handle); |
156 if (filter !is null) { | 156 if (filter !is null) { |
157 auto filterNamePtr = OS.gtk_file_filter_get_name (filter); | 157 auto filterNamePtr = OS.gtk_file_filter_get_name (filter); |
158 if (filterNamePtr !is null) { | 158 if (filterNamePtr !is null) { |
159 String filterName = fromStringz(filterNamePtr).dup; | 159 String filterName = fromStringz(filterNamePtr)._idup(); |
160 //OS.g_free (filterNamePtr); //GTK owns this pointer - do not free | 160 //OS.g_free (filterNamePtr); //GTK owns this pointer - do not free |
161 for (int i = 0; i < filterExtensions.length; i++) { | 161 for (int i = 0; i < filterExtensions.length; i++) { |
162 if (filterNames.length > 0) { | 162 if (filterNames.length > 0) { |
163 if (filterNames[i].equals(filterName)) { | 163 if (filterNames[i].equals(filterName)) { |
164 filterIndex = i; | 164 filterIndex = i; |
183 String computeResultClassicDialog () { | 183 String computeResultClassicDialog () { |
184 filterIndex = -1; | 184 filterIndex = -1; |
185 GtkFileSelection* selection = cast(GtkFileSelection*)handle; | 185 GtkFileSelection* selection = cast(GtkFileSelection*)handle; |
186 auto entry = selection.selection_entry; | 186 auto entry = selection.selection_entry; |
187 auto entryText = OS.gtk_entry_get_text (entry); | 187 auto entryText = OS.gtk_entry_get_text (entry); |
188 String txt = fromStringz( entryText ); | 188 String txt = fromStringz( entryText )._idup(); |
189 if (txt.length is 0) { | 189 if (txt.length is 0) { |
190 auto fileList = selection.file_list; | 190 auto fileList = selection.file_list; |
191 auto listSelection = OS.gtk_tree_view_get_selection (fileList); | 191 auto listSelection = OS.gtk_tree_view_get_selection (fileList); |
192 void* model; | 192 void* model; |
193 auto selectedList = OS.gtk_tree_selection_get_selected_rows (listSelection, &model); | 193 auto selectedList = OS.gtk_tree_selection_get_selected_rows (listSelection, &model); |
213 } | 213 } |
214 | 214 |
215 auto fileNamePtr = OS.gtk_file_selection_get_filename (handle); | 215 auto fileNamePtr = OS.gtk_file_selection_get_filename (handle); |
216 uint items_written; | 216 uint items_written; |
217 auto utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, &items_written, null); | 217 auto utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, &items_written, null); |
218 String osAnswer = utf8Ptr[ 0 .. items_written ].dup; | 218 String osAnswer = utf8Ptr[ 0 .. items_written ]._idup(); |
219 OS.g_free (utf8Ptr); | 219 OS.g_free (utf8Ptr); |
220 | 220 |
221 if (osAnswer.length is 0) return null; | 221 if (osAnswer.length is 0) return null; |
222 int separatorIndex = osAnswer.lastIndexOf( SEPARATOR); | 222 int separatorIndex = osAnswer.lastIndexOf( SEPARATOR); |
223 if (separatorIndex+1 is osAnswer.length ) return null; | 223 if (separatorIndex+1 is osAnswer.length ) return null; |
237 namePtr = namesPtr1[length_]; | 237 namePtr = namesPtr1[length_]; |
238 } | 238 } |
239 fileNames = new String[](length_); | 239 fileNames = new String[](length_); |
240 for (int i = 0; i < length_; i++) { | 240 for (int i = 0; i < length_; i++) { |
241 utf8Ptr = OS.g_filename_to_utf8 (namesPtr [i], -1, null, &items_written, null); | 241 utf8Ptr = OS.g_filename_to_utf8 (namesPtr [i], -1, null, &items_written, null); |
242 String name = utf8Ptr[ 0 .. items_written ].dup; | 242 String name = utf8Ptr[ 0 .. items_written ]._idup(); |
243 int start = name.lastIndexOf( SEPARATOR); | 243 int start = name.lastIndexOf( SEPARATOR); |
244 fileNames [i] = name[ start + 1 .. $ ].dup; | 244 fileNames [i] = name[ start + 1 .. $ ]._idup(); |
245 OS.g_free (utf8Ptr); | 245 OS.g_free (utf8Ptr); |
246 } | 246 } |
247 OS.g_strfreev (namesPtr); | 247 OS.g_strfreev (namesPtr); |
248 } | 248 } |
249 return answer; | 249 return answer; |