25
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.program.Program;
|
|
14
|
|
15 import org.eclipse.swt.SWT;
|
|
16 import org.eclipse.swt.graphics.ImageData;
|
|
17 import org.eclipse.swt.internal.Compatibility;
|
|
18 import org.eclipse.swt.internal.Converter;
|
|
19 import org.eclipse.swt.internal.Library;
|
|
20 import org.eclipse.swt.internal.gtk.OS;
|
|
21 import org.eclipse.swt.widgets.Display;
|
|
22 import org.eclipse.swt.widgets.Event;
|
|
23 import org.eclipse.swt.widgets.Listener;
|
|
24 import java.lang.all;
|
|
25
|
48
|
26 version(Tango){
|
25
|
27 import tango.sys.SharedLib;
|
|
28 import tango.core.Array;
|
|
29 import tango.io.device.File;
|
|
30 import tango.io.stream.Lines;
|
48
|
31 } else { // Phobos
|
|
32 }
|
25
|
33
|
|
34 version( build ){
|
|
35 pragma(link, "gnomeui-2" );
|
|
36 }
|
|
37
|
|
38 private extern(C) {
|
|
39 alias int GnomeIconLookupResultFlags;
|
|
40 alias int GnomeIconLookupFlags;
|
|
41 GnomeIconTheme *gnome_icon_theme_new ();
|
|
42 char *gnome_icon_lookup (
|
|
43 GtkIconTheme *icon_theme,
|
|
44 void *thumbnail_factory,
|
|
45 char *file_uri,
|
|
46 char *custom_icon,
|
|
47 void *file_info,
|
|
48 char *mime_type,
|
|
49 GnomeIconLookupFlags flags,
|
|
50 GnomeIconLookupResultFlags *result);
|
|
51 int gnome_vfs_init();
|
|
52 char* gnome_icon_theme_lookup_icon(GnomeIconTheme *theme,char *icon_name,int size, GnomeIconData **icon_data, int *base_size) ;
|
|
53
|
|
54 alias void GnomeIconTheme;
|
|
55 alias void GnomeIconData;
|
|
56
|
|
57 struct GnomeVFSMimeApplication{
|
|
58 /*< public > */
|
|
59 char *id;
|
|
60 char *name;
|
|
61
|
|
62 /*< private > */
|
|
63 char *command;
|
|
64 int can_open_multiple_files;
|
|
65 int expects_uris;
|
|
66 GList *supported_uri_schemes;
|
|
67 int requires_terminal;
|
|
68
|
|
69 /* Padded to avoid future breaks in ABI compatibility */
|
|
70 void * reserved1;
|
|
71
|
|
72 void * priv;
|
|
73 }
|
|
74 }
|
|
75
|
|
76 struct GNOME {
|
|
77 private static extern(C){
|
|
78 enum {
|
|
79 GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
|
|
80 GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
|
|
81 GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
|
|
82 GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
|
|
83 }
|
|
84 enum {
|
|
85 GNOME_VFS_MAKE_URI_DIR_NONE = 0,
|
|
86 GNOME_VFS_MAKE_URI_DIR_HOMEDIR = 1 << 0,
|
|
87 GNOME_VFS_MAKE_URI_DIR_CURRENT = 1 << 1
|
|
88 }
|
|
89 alias int GnomeVFSMakeURIDirs;
|
|
90 enum {
|
|
91 GNOME_VFS_OK,
|
|
92 GNOME_VFS_ERROR_NOT_FOUND,
|
|
93 GNOME_VFS_ERROR_GENERIC,
|
|
94 GNOME_VFS_ERROR_INTERNAL,
|
|
95 GNOME_VFS_ERROR_BAD_PARAMETERS,
|
|
96 GNOME_VFS_ERROR_NOT_SUPPORTED,
|
|
97 GNOME_VFS_ERROR_IO,
|
|
98 GNOME_VFS_ERROR_CORRUPTED_DATA,
|
|
99 GNOME_VFS_ERROR_WRONG_FORMAT,
|
|
100 GNOME_VFS_ERROR_BAD_FILE,
|
|
101 GNOME_VFS_ERROR_TOO_BIG,
|
|
102 GNOME_VFS_ERROR_NO_SPACE,
|
|
103 GNOME_VFS_ERROR_READ_ONLY,
|
|
104 GNOME_VFS_ERROR_INVALID_URI,
|
|
105 GNOME_VFS_ERROR_NOT_OPEN,
|
|
106 GNOME_VFS_ERROR_INVALID_OPEN_MODE,
|
|
107 GNOME_VFS_ERROR_ACCESS_DENIED,
|
|
108 GNOME_VFS_ERROR_TOO_MANY_OPEN_FILES,
|
|
109 GNOME_VFS_ERROR_EOF,
|
|
110 GNOME_VFS_ERROR_NOT_A_DIRECTORY,
|
|
111 GNOME_VFS_ERROR_IN_PROGRESS,
|
|
112 GNOME_VFS_ERROR_INTERRUPTED,
|
|
113 GNOME_VFS_ERROR_FILE_EXISTS,
|
|
114 GNOME_VFS_ERROR_LOOP,
|
|
115 GNOME_VFS_ERROR_NOT_PERMITTED,
|
|
116 GNOME_VFS_ERROR_IS_DIRECTORY,
|
|
117 GNOME_VFS_ERROR_NO_MEMORY,
|
|
118 GNOME_VFS_ERROR_HOST_NOT_FOUND,
|
|
119 GNOME_VFS_ERROR_INVALID_HOST_NAME,
|
|
120 GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS,
|
|
121 GNOME_VFS_ERROR_LOGIN_FAILED,
|
|
122 GNOME_VFS_ERROR_CANCELLED,
|
|
123 GNOME_VFS_ERROR_DIRECTORY_BUSY,
|
|
124 GNOME_VFS_ERROR_DIRECTORY_NOT_EMPTY,
|
|
125 GNOME_VFS_ERROR_TOO_MANY_LINKS,
|
|
126 GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM,
|
|
127 GNOME_VFS_ERROR_NOT_SAME_FILE_SYSTEM,
|
|
128 GNOME_VFS_ERROR_NAME_TOO_LONG,
|
|
129 GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE,
|
|
130 GNOME_VFS_ERROR_SERVICE_OBSOLETE,
|
|
131 GNOME_VFS_ERROR_PROTOCOL_ERROR,
|
|
132 GNOME_VFS_ERROR_NO_MASTER_BROWSER,
|
|
133 GNOME_VFS_ERROR_NO_DEFAULT,
|
|
134 GNOME_VFS_ERROR_NO_HANDLER,
|
|
135 GNOME_VFS_ERROR_PARSE,
|
|
136 GNOME_VFS_ERROR_LAUNCH,
|
|
137 GNOME_VFS_ERROR_TIMEOUT,
|
|
138 GNOME_VFS_ERROR_NAMESERVER,
|
|
139 GNOME_VFS_ERROR_LOCKED,
|
|
140 GNOME_VFS_ERROR_DEPRECATED_FUNCTION,
|
|
141 GNOME_VFS_ERROR_INVALID_FILENAME,
|
|
142 GNOME_VFS_ERROR_NOT_A_SYMBOLIC_LINK,
|
|
143 GNOME_VFS_NUM_ERRORS
|
|
144 }
|
|
145 alias int GnomeVFSResult;
|
|
146
|
|
147 enum {
|
|
148 GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS,
|
|
149 GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_PATHS,
|
|
150 GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS_FOR_NON_FILES
|
|
151 }
|
|
152
|
|
153 alias GtkIconTheme GnomeIconTheme;
|
|
154 alias .gnome_icon_theme_lookup_icon gnome_icon_theme_lookup_icon;
|
|
155 alias .gnome_vfs_init gnome_vfs_init;
|
|
156 alias .gnome_icon_lookup gnome_icon_lookup;
|
|
157 alias .gnome_icon_theme_new gnome_icon_theme_new;
|
|
158
|
|
159
|
|
160 GnomeVFSMimeApplication * function ( char *mime_type ) gnome_vfs_mime_get_default_application;
|
|
161 char* function(char*, int ) gnome_vfs_make_uri_from_input_with_dirs;
|
|
162 GnomeVFSResult function( GnomeVFSMimeApplication*, GList*) gnome_vfs_mime_application_launch;
|
|
163 void function(GnomeVFSMimeApplication*) gnome_vfs_mime_application_free;
|
|
164 GList* function(char*) gnome_vfs_mime_get_extensions_list;
|
|
165 void function(GList*) gnome_vfs_mime_extensions_list_free;
|
|
166 void function(GList*) gnome_vfs_mime_registered_mime_type_list_free;
|
|
167 GnomeVFSResult function(char*) gnome_vfs_url_show;
|
|
168 char* function(char*) gnome_vfs_make_uri_from_input;
|
|
169 GList* function() gnome_vfs_get_registered_mime_types;
|
|
170 char* function(char*) gnome_vfs_mime_type_from_name;
|
|
171 }
|
|
172 }
|
|
173
|
|
174 /**
|
|
175 * Instances of this class represent programs and
|
|
176 * their associated file extensions in the operating
|
|
177 * system.
|
|
178 *
|
|
179 * @see <a href="http://www.eclipse.org/swt/snippets/#program">Program snippets</a>
|
|
180 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
|
|
181 */
|
|
182 public final class Program {
|
|
183 String name;
|
|
184 String command;
|
|
185 String iconPath;
|
|
186 Display display;
|
|
187
|
|
188 /* Gnome specific
|
|
189 * true if command expects a URI
|
|
190 * false if expects a path
|
|
191 */
|
|
192 bool gnomeExpectUri;
|
|
193
|
|
194 static int /*long*/ cdeShell;
|
|
195
|
|
196 static const String[] CDE_ICON_EXT = [ ".m.pm"[], ".l.pm", ".s.pm", ".t.pm" ];
|
|
197 static const String[] CDE_MASK_EXT = [ ".m_m.bm"[], ".l_m.bm", ".s_m.bm", ".t_m.bm" ];
|
|
198 static const String DESKTOP_DATA = "Program_DESKTOP";
|
|
199 static const String ICON_THEME_DATA = "Program_GNOME_ICON_THEME";
|
|
200 static const String PREFIX_HTTP = "http://"; //$NON-NLS-1$
|
|
201 static const String PREFIX_HTTPS = "https://"; //$NON-NLS-1$
|
|
202 static const int DESKTOP_UNKNOWN = 0;
|
|
203 static const int DESKTOP_GNOME = 1;
|
|
204 static const int DESKTOP_GNOME_24 = 2;
|
|
205 static const int DESKTOP_CDE = 3;
|
|
206 static const int PREFERRED_ICON_SIZE = 16;
|
|
207
|
|
208 /**
|
|
209 * Prevents uninitialized instances from being created outside the package.
|
|
210 */
|
|
211 this() {
|
|
212 }
|
|
213
|
|
214 /* Determine the desktop for the given display. */
|
|
215 static int getDesktop(Display display) {
|
|
216 if (display is null) return DESKTOP_UNKNOWN;
|
|
217 ValueWrapperInt desktopValue = cast(ValueWrapperInt)display.getData(DESKTOP_DATA);
|
|
218 if (desktopValue !is null) return desktopValue.value;
|
|
219 int desktop = DESKTOP_UNKNOWN;
|
|
220
|
|
221 /* Get the list of properties on the root window. */
|
|
222 void* xDisplay = OS.GDK_DISPLAY();
|
|
223 uint rootWindow = OS.XDefaultRootWindow(xDisplay);
|
|
224 int numProp;
|
|
225 uint* propList = OS.XListProperties(xDisplay, rootWindow, &numProp);
|
|
226 uint[] property = new uint[numProp];
|
|
227 if (propList !is null) {
|
|
228 property[ 0 .. numProp ] = propList[ 0 .. numProp ];
|
|
229 OS.XFree(propList);
|
|
230 }
|
|
231
|
|
232 /*
|
|
233 * Feature in Linux Desktop. There is currently no official way to
|
|
234 * determine whether the Gnome window manager or gnome-vfs is
|
|
235 * available. Earlier versions including Red Hat 9 and Suse 9 provide
|
|
236 * a documented Gnome specific property on the root window
|
|
237 * WIN_SUPPORTING_WM_CHECK. This property is no longer supported in newer
|
|
238 * versions such as Fedora Core 2.
|
|
239 * The workaround is to simply check that the window manager is a
|
|
240 * compliant one (property _NET_SUPPORTING_WM_CHECK) and to attempt to load
|
|
241 * our native library that depends on gnome-vfs.
|
|
242 */
|
|
243 if (desktop is DESKTOP_UNKNOWN) {
|
|
244 String gnomeName = "_NET_SUPPORTING_WM_CHECK";
|
|
245 int /*long*/ gnome = OS.XInternAtom(xDisplay, gnomeName.ptr, true);
|
|
246 if (gnome !is OS.None && (OS.GTK_VERSION >= OS.buildVERSION (2, 2, 0)) && gnome_init()) {
|
|
247 desktop = DESKTOP_GNOME;
|
|
248 int icon_theme = cast(int)GNOME.gnome_icon_theme_new();
|
|
249 display.setData(ICON_THEME_DATA, new ValueWrapperInt(icon_theme));
|
|
250 display.addListener(SWT.Dispose, new class(display) Listener {
|
|
251 Display display;
|
|
252 this( Display display ){ this.display = display; }
|
|
253 public void handleEvent(Event event) {
|
|
254 ValueWrapperInt gnomeIconTheme = cast(ValueWrapperInt)display.getData(ICON_THEME_DATA);
|
|
255 if (gnomeIconTheme is null) return;
|
|
256 display.setData(ICON_THEME_DATA, null);
|
|
257 /*
|
|
258 * Note. gnome_icon_theme_new uses g_object_new to allocate the
|
|
259 * data it returns. Use g_object_unref to free the pointer it returns.
|
|
260 */
|
|
261 if (gnomeIconTheme.value !is 0) OS.g_object_unref( cast(void*)gnomeIconTheme.value);
|
|
262 }
|
|
263 });
|
|
264 /* Check for libgnomevfs-2 version 2.4 */
|
|
265 String buffer = "libgnomevfs-2.so.0";
|
|
266 auto libgnomevfs = SharedLib.load(buffer );
|
|
267 if (libgnomevfs !is null) {
|
|
268 buffer = "gnome_vfs_url_show";
|
|
269 void* gnome_vfs_url_show = libgnomevfs.getSymbol( buffer.ptr );
|
|
270 if (gnome_vfs_url_show !is null) {
|
|
271 desktop = DESKTOP_GNOME_24;
|
|
272 }
|
|
273 *cast(void**)&GNOME.gnome_vfs_mime_get_default_application = libgnomevfs.getSymbol( "gnome_vfs_mime_get_default_application" );
|
|
274 *cast(void**)&GNOME.gnome_vfs_make_uri_from_input_with_dirs = libgnomevfs.getSymbol( "gnome_vfs_make_uri_from_input_with_dirs" );
|
|
275 *cast(void**)&GNOME.gnome_vfs_mime_application_launch = libgnomevfs.getSymbol( "gnome_vfs_mime_application_launch" );
|
|
276 *cast(void**)&GNOME.gnome_vfs_mime_application_free = libgnomevfs.getSymbol( "gnome_vfs_mime_application_free" );
|
|
277 *cast(void**)&GNOME.gnome_vfs_url_show = libgnomevfs.getSymbol( "gnome_vfs_url_show" );
|
|
278 *cast(void**)&GNOME.gnome_vfs_make_uri_from_input = libgnomevfs.getSymbol( "gnome_vfs_make_uri_from_input" );
|
|
279 *cast(void**)&GNOME.gnome_vfs_get_registered_mime_types = libgnomevfs.getSymbol( "gnome_vfs_get_registered_mime_types" );
|
|
280 *cast(void**)&GNOME.gnome_vfs_mime_get_extensions_list = libgnomevfs.getSymbol( "gnome_vfs_mime_get_extensions_list" );
|
|
281 *cast(void**)&GNOME.gnome_vfs_mime_extensions_list_free = libgnomevfs.getSymbol( "gnome_vfs_mime_extensions_list_free" );
|
|
282 *cast(void**)&GNOME.gnome_vfs_mime_registered_mime_type_list_free = libgnomevfs.getSymbol( "gnome_vfs_mime_registered_mime_type_list_free" );
|
|
283 *cast(void**)&GNOME.gnome_vfs_mime_type_from_name = libgnomevfs.getSymbol( "gnome_vfs_mime_type_from_name" );
|
|
284 }
|
|
285 }
|
|
286 }
|
|
287
|
|
288 // PORTING CDE not supported
|
|
289 /+
|
|
290 /*
|
|
291 * On CDE, the atom below may exist without DTWM running. If the atom
|
|
292 * below is defined, the CDE database exists and the available
|
|
293 * applications can be queried.
|
|
294 */
|
|
295 if (desktop is DESKTOP_UNKNOWN) {
|
|
296 String cdeName = "_DT_SM_PREFERENCES";
|
|
297 int /*long*/ cde = OS.XInternAtom(xDisplay, cdeName.ptr, true);
|
|
298 for (int index = 0; desktop is DESKTOP_UNKNOWN && index < property.length; index++) {
|
|
299 if (property[index] is OS.None) continue; /* do not match atoms that do not exist */
|
|
300 if (property[index] is cde && cde_init(display)) desktop = DESKTOP_CDE;
|
|
301 }
|
|
302 }
|
|
303 +/
|
|
304
|
|
305 display.setData(DESKTOP_DATA, new ValueWrapperInt(desktop));
|
|
306 return desktop;
|
|
307 }
|
|
308
|
|
309 // PORTING CDE not supported
|
|
310 /+
|
|
311 bool cde_execute(String fileName) {
|
|
312 /* Use the character encoding for the default locale */
|
|
313 char* action = toStringz(command);
|
|
314 char* ptr = cast(char*)OS.g_malloc(fileName.length+1);
|
|
315 ptr[ 0 .. fileName.length ] = fileName;
|
|
316 ptr[ fileName.length ] = 0;
|
|
317 DtActionArg args = new DtActionArg();
|
|
318 args.argClass = CDE.DtACTION_FILE;
|
|
319 args.name = ptr;
|
|
320 long actionID = CDE.DtActionInvoke(cdeShell, action, args, 1, null, null, null, 1, 0, 0);
|
|
321 OS.g_free(ptr);
|
|
322 return actionID !is 0;
|
|
323 }
|
|
324
|
|
325 static String cde_getAction(String dataType) {
|
|
326 String action = null;
|
|
327 String actions = cde_getAttribute(dataType, CDE.DtDTS_DA_ACTION_LIST);
|
|
328 if (actions !is null) {
|
|
329 int index = actions.indexOf("Open");
|
|
330 if (index !is -1) {
|
|
331 action = actions.substring(index, index + 4);
|
|
332 } else {
|
|
333 index = actions.indexOf(",");
|
|
334 action = index !is -1 ? actions.substring(0, index) : actions;
|
|
335 }
|
|
336 }
|
|
337 return action;
|
|
338 }
|
|
339
|
|
340 static String cde_getAttribute(String dataType, String attrName) {
|
|
341 /* Use the character encoding for the default locale */
|
|
342 byte[] dataTypeBuf = Converter.wcsToMbcs(null, dataType, true);
|
|
343 byte[] attrNameBuf = Converter.wcsToMbcs(null, attrName, true);
|
|
344 byte[] optNameBuf = null;
|
|
345 int /*long*/ attrValue = CDE.DtDtsDataTypeToAttributeValue(dataTypeBuf, attrNameBuf, optNameBuf);
|
|
346 if (attrValue is 0) return null;
|
|
347 int length = OS.strlen(attrValue);
|
|
348 byte[] attrValueBuf = new byte[length];
|
|
349 OS.memmove(attrValueBuf, attrValue, length);
|
|
350 CDE.DtDtsFreeAttributeValue(attrValue);
|
|
351 /* Use the character encoding for the default locale */
|
|
352 return new String(Converter.mbcsToWcs(null, attrValueBuf));
|
|
353 }
|
|
354
|
|
355 static String[][ String ] cde_getDataTypeInfo() {
|
|
356 String[][ String ] dataTypeInfo;
|
|
357 int index;
|
|
358 int /*long*/ dataTypeList = CDE.DtDtsDataTypeNames();
|
|
359 if (dataTypeList !is 0) {
|
|
360 /* For each data type name in the list */
|
|
361 index = 0;
|
|
362 int /*long*/ [] dataType = new int /*long*/ [1];
|
|
363 OS.memmove(dataType, dataTypeList + (index++ * 4), 4);
|
|
364 while (dataType[0] !is 0) {
|
|
365 int length = OS.strlen(dataType[0]);
|
|
366 byte[] dataTypeBuf = new byte[length];
|
|
367 OS.memmove(dataTypeBuf, dataType[0], length);
|
|
368 /* Use the character encoding for the default locale */
|
|
369 String dataTypeName = new String(Converter.mbcsToWcs(null, dataTypeBuf));
|
|
370
|
|
371 /* The data type is valid if it is not an action, and it has an extension and an action. */
|
|
372 String extension = cde_getExtension(dataTypeName);
|
|
373 if (!CDE.DtDtsDataTypeIsAction(dataTypeBuf) &&
|
|
374 extension !is null && cde_getAction(dataTypeName) !is null) {
|
|
375 String[] exts;
|
|
376 exts ~= extension;
|
|
377 dataTypeInfo[ dataTypeName ] = exts;
|
|
378 }
|
|
379 OS.memmove(dataType, dataTypeList + (index++ * 4), 4);
|
|
380 }
|
|
381 CDE.DtDtsFreeDataTypeNames(dataTypeList);
|
|
382 }
|
|
383
|
|
384 return dataTypeInfo;
|
|
385 }
|
|
386
|
|
387 static String cde_getExtension(String dataType) {
|
|
388 String fileExt = cde_getAttribute(dataType, CDE.DtDTS_DA_NAME_TEMPLATE);
|
|
389 if (fileExt is null || fileExt.indexOf("%s.") is -1) return null;
|
|
390 int dot = fileExt.indexOf(".");
|
|
391 return fileExt.substring(dot);
|
|
392 }
|
|
393
|
|
394 /**
|
|
395 * CDE - Get Image Data
|
|
396 *
|
|
397 * This method returns the image data of the icon associated with
|
|
398 * the data type. Since CDE supports multiple sizes of icons, several
|
|
399 * attempts are made to locate an icon of the desired size and format.
|
|
400 * CDE supports the sizes: tiny, small, medium and large. The best
|
|
401 * search order is medium, large, small and then tiny. Althoug CDE supports
|
|
402 * colour and monochrome bitmaps, only colour icons are tried. (The order is
|
|
403 * defined by the cdeIconExt and cdeMaskExt arrays above.)
|
|
404 */
|
|
405 ImageData cde_getImageData() {
|
|
406 // TODO
|
|
407 return null;
|
|
408 }
|
|
409
|
|
410 static String cde_getMimeType(String extension) {
|
|
411 String mimeType = null;
|
|
412 String[][ String ] mimeInfo = cde_getDataTypeInfo();
|
|
413 if (mimeInfo is null) return null;
|
|
414 String[] keys = mimeInfo.keys();
|
|
415 int keyIdx = 0;
|
|
416 while (mimeType is null && keyIdx < keys.length ) {
|
|
417 String type = keys[ keyIdx ];
|
|
418 String[] mimeExts = mimeInfo[type];
|
|
419 for (int index = 0; index < mimeExts.length; index++){
|
|
420 if (extension.equals(mimeExts[index])) {
|
|
421 mimeType = type;
|
|
422 break;
|
|
423 }
|
|
424 }
|
|
425 keyIdx++;
|
|
426 }
|
|
427 return mimeType;
|
|
428 }
|
|
429
|
|
430 static Program cde_getProgram(Display display, String mimeType) {
|
|
431 Program program = new Program();
|
|
432 program.display = display;
|
|
433 program.name = mimeType;
|
|
434 program.command = cde_getAction(mimeType);
|
|
435 program.iconPath = cde_getAttribute(program.name, CDE.DtDTS_DA_ICON);
|
|
436 return program;
|
|
437 }
|
|
438
|
|
439 static bool cde_init(Display display) {
|
|
440 try {
|
|
441 Library.loadLibrary("swt-cde");
|
|
442 } catch (Throwable e) {
|
|
443 return false;
|
|
444 }
|
|
445
|
|
446 /* Use the character encoding for the default locale */
|
|
447 CDE.XtToolkitInitialize();
|
|
448 int /*long*/ xtContext = CDE.XtCreateApplicationContext ();
|
|
449 int /*long*/ xDisplay = OS.GDK_DISPLAY();
|
|
450 byte[] appName = Converter.wcsToMbcs(null, "CDE", true);
|
|
451 byte[] appClass = Converter.wcsToMbcs(null, "CDE", true);
|
|
452 int /*long*/ [] argc = [0];
|
|
453 CDE.XtDisplayInitialize(xtContext, xDisplay, appName, appClass, 0, 0, argc, 0);
|
|
454 int /*long*/ widgetClass = CDE.topLevelShellWidgetClass ();
|
|
455 cdeShell = CDE.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
|
|
456 CDE.XtSetMappedWhenManaged (cdeShell, false);
|
|
457 CDE.XtResizeWidget (cdeShell, 10, 10, 0);
|
|
458 CDE.XtRealizeWidget (cdeShell);
|
|
459 bool initOK = CDE.DtAppInitialize(xtContext, xDisplay, cdeShell, appName, appName);
|
|
460 if (initOK) CDE.DtDbLoad();
|
|
461 return initOK;
|
|
462 }
|
|
463 +/
|
|
464
|
|
465 static String[] parseCommand(String cmd) {
|
|
466 String[] args;
|
|
467 int sIndex = 0;
|
|
468 int eIndex;
|
|
469 while (sIndex < cmd.length) {
|
|
470 /* Trim initial white space of argument. */
|
|
471 while (sIndex < cmd.length && Compatibility.isWhitespace(cmd.charAt(sIndex))) {
|
|
472 sIndex++;
|
|
473 }
|
|
474 if (sIndex < cmd.length) {
|
|
475 /* If the command is a quoted string */
|
|
476 if (cmd.charAt(sIndex) is '"' || cmd.charAt(sIndex) is '\'') {
|
|
477 /* Find the terminating quote (or end of line).
|
|
478 * This code currently does not handle escaped characters (e.g., " a\"b").
|
|
479 */
|
|
480 eIndex = sIndex + 1;
|
|
481 while (eIndex < cmd.length && cmd.charAt(eIndex) !is cmd.charAt(sIndex)) eIndex++;
|
|
482 if (eIndex >= cmd.length) {
|
|
483 /* The terminating quote was not found
|
|
484 * Add the argument as is with only one initial quote.
|
|
485 */
|
|
486 args ~= cmd.substring(sIndex, eIndex);
|
|
487 } else {
|
|
488 /* Add the argument, trimming off the quotes. */
|
|
489 args ~= cmd.substring(sIndex + 1, eIndex);
|
|
490 }
|
|
491 sIndex = eIndex + 1;
|
|
492 }
|
|
493 else {
|
|
494 /* Use white space for the delimiters. */
|
|
495 eIndex = sIndex;
|
|
496 while (eIndex < cmd.length && !Compatibility.isWhitespace( firstCodePoint( cmd[ eIndex .. $ ]))) eIndex++;
|
|
497 args ~= cmd.substring(sIndex, eIndex);
|
|
498 sIndex = eIndex + 1;
|
|
499 }
|
|
500 }
|
|
501 }
|
|
502
|
|
503 String[] strings = new String[args.length];
|
|
504 for (int index =0; index < args.length; index++) {
|
|
505 strings[index] = args[index];
|
|
506 }
|
|
507 return strings;
|
|
508 }
|
|
509
|
|
510 /**
|
|
511 * GNOME 2.4 - Execute the program for the given file.
|
|
512 */
|
|
513 bool gnome_24_execute(String fileName) {
|
|
514 char* mimeTypeBuffer = toStringz(name);
|
|
515 auto ptr = GNOME.gnome_vfs_mime_get_default_application(mimeTypeBuffer);
|
|
516 char* fileNameBuffer = toStringz(fileName);
|
|
517 char* uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT);
|
|
518 GList* list = OS.g_list_append( null, uri);
|
|
519 int result = GNOME.gnome_vfs_mime_application_launch(ptr, list);
|
|
520 GNOME.gnome_vfs_mime_application_free(ptr);
|
|
521 OS.g_free(uri);
|
|
522 OS.g_list_free(list);
|
|
523 return result is GNOME.GNOME_VFS_OK;
|
|
524 }
|
|
525
|
|
526 /**
|
|
527 * GNOME 2.4 - Launch the default program for the given file.
|
|
528 */
|
|
529 static bool gnome_24_launch(String fileName) {
|
|
530 char* fileNameBuffer = toStringz(fileName);
|
|
531 char* uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT);
|
|
532 int result = GNOME.gnome_vfs_url_show(uri);
|
|
533 OS.g_free(uri);
|
|
534 return (result is GNOME.GNOME_VFS_OK);
|
|
535 }
|
|
536
|
|
537 /**
|
|
538 * GNOME 2.2 - Execute the program for the given file.
|
|
539 */
|
|
540 bool gnome_execute(String fileName) {
|
|
541 if (gnomeExpectUri) {
|
|
542 /* Convert the given path into a URL */
|
|
543 char* fileNameBuffer = toStringz(fileName);
|
|
544 char* uri = GNOME.gnome_vfs_make_uri_from_input(fileNameBuffer);
|
|
545 if (uri !is null) {
|
|
546 fileName = fromStringz( uri ).dup;
|
|
547 OS.g_free(uri);
|
|
548 }
|
|
549 }
|
|
550
|
|
551 /* Parse the command into its individual arguments. */
|
|
552 String[] args = parseCommand(command);
|
|
553 int fileArg = -1;
|
|
554 int index;
|
|
555 for (index = 0; index < args.length; index++) {
|
|
556 int j = args[index].indexOf("%f");
|
|
557 if (j !is -1) {
|
|
558 String value = args[index];
|
|
559 fileArg = index;
|
|
560 args[index] = value.substring(0, j) ~ fileName ~ value.substring(j + 2);
|
|
561 }
|
|
562 }
|
|
563
|
|
564 /* If a file name was given but the command did not have "%f" */
|
|
565 if ((fileName.length > 0) && (fileArg < 0)) {
|
|
566 String[] newArgs = new String[args.length + 1];
|
|
567 for (index = 0; index < args.length; index++) newArgs[index] = args[index];
|
|
568 newArgs[args.length] = fileName;
|
|
569 args = newArgs;
|
|
570 }
|
|
571
|
|
572 /* Execute the command. */
|
|
573 try {
|
|
574 Compatibility.exec(args);
|
|
575 } catch (IOException e) {
|
|
576 return false;
|
|
577 }
|
|
578 return true;
|
|
579 }
|
|
580
|
|
581 /**
|
|
582 * GNOME - Get Image Data
|
|
583 *
|
|
584 */
|
|
585 ImageData gnome_getImageData() {
|
|
586 if (iconPath is null) return null;
|
|
587 try {
|
|
588 return new ImageData(iconPath);
|
|
589 } catch (Exception e) {}
|
|
590 return null;
|
|
591 }
|
|
592
|
|
593 /++
|
|
594 + SWT Extension
|
|
595 + This is a temporary workaround until SWT will get the real implementation.
|
|
596 +/
|
|
597 static String[][ String ] gnome24_getMimeInfo() {
|
|
598 scope file = new tango.io.device.File.File ("/usr/share/mime/globs");
|
|
599 scope it = new Lines!(char)(file);
|
|
600 // process file one line at a time
|
|
601 String[][ String ] mimeInfo;
|
|
602 foreach (line; it ){
|
|
603 int colon = line.indexOf(':');
|
|
604 if( colon is line.length ){
|
|
605 continue;
|
|
606 }
|
|
607 if( line.length < colon+3 || line[colon+1 .. colon+3 ] != "*." ){
|
|
608 continue;
|
|
609 }
|
|
610 String mimeType = line[0..colon].dup;
|
|
611 String ext = line[colon+3 .. $].dup;
|
|
612 if( auto exts = mimeType in mimeInfo ){
|
|
613 mimeInfo[ mimeType ] = *exts ~ ext;
|
|
614 }
|
|
615 else{
|
|
616 mimeInfo[ mimeType ] = [ ext ];
|
|
617 }
|
|
618 }
|
|
619 return mimeInfo;
|
|
620 }
|
|
621 /**
|
|
622 * GNOME - Get mime types
|
|
623 *
|
|
624 * Obtain the registered mime type information and
|
|
625 * return it in a map. The key of each entry
|
|
626 * in the map is the mime type name. The value is
|
|
627 * a vector of the associated file extensions.
|
|
628 */
|
|
629 static String[][ String ] gnome_getMimeInfo() {
|
|
630 String[][ String ] mimeInfo;
|
|
631 GList* mimeList = GNOME.gnome_vfs_get_registered_mime_types();
|
|
632 GList* mimeElement = mimeList;
|
|
633 while (mimeElement !is null) {
|
|
634 char* mimePtr = cast(char*) OS.g_list_data(mimeElement);
|
|
635 String mimeTypeBuffer = fromStringz(mimePtr).dup;
|
|
636 String mimeType = mimeTypeBuffer;//new String(Converter.mbcsToWcs(null, mimeTypeBuffer));
|
|
637 GList* extensionList = GNOME.gnome_vfs_mime_get_extensions_list(mimePtr);
|
|
638 if (extensionList !is null) {
|
|
639 String[] extensions;
|
|
640 GList* extensionElement = extensionList;
|
|
641 while (extensionElement !is null) {
|
|
642 char* extensionPtr = cast(char*) OS.g_list_data(extensionElement);
|
|
643 String extensionBuffer = fromStringz(extensionPtr).dup;
|
|
644 String extension = extensionBuffer;
|
|
645 extension = '.' ~ extension;
|
|
646 extensions ~= extension;
|
|
647 extensionElement = OS.g_list_next(extensionElement);
|
|
648 }
|
|
649 GNOME.gnome_vfs_mime_extensions_list_free(extensionList);
|
|
650 if (extensions.length > 0) mimeInfo[ mimeType ] = extensions;
|
|
651 }
|
|
652 mimeElement = OS.g_list_next(mimeElement);
|
|
653 }
|
|
654 if (mimeList !is null) GNOME.gnome_vfs_mime_registered_mime_type_list_free(mimeList);
|
|
655 return mimeInfo;
|
|
656 }
|
|
657
|
|
658 static String gnome_getMimeType(String extension) {
|
|
659 String mimeType = null;
|
|
660 String fileName = "swt" ~ extension;
|
|
661 char* extensionBuffer = toStringz(fileName);
|
|
662 char* typeName = GNOME.gnome_vfs_mime_type_from_name(extensionBuffer);
|
|
663 if (typeName !is null) {
|
|
664 mimeType = fromStringz(typeName).dup;
|
|
665 }
|
|
666 return mimeType;
|
|
667 }
|
|
668
|
|
669 static Program gnome_getProgram(Display display, String mimeType) {
|
|
670 Program program = null;
|
|
671 char* mimeTypeBuffer = toStringz(mimeType);
|
|
672 GnomeVFSMimeApplication* ptr = GNOME.gnome_vfs_mime_get_default_application(mimeTypeBuffer);
|
|
673 if (ptr !is null) {
|
|
674 program = new Program();
|
|
675 program.display = display;
|
|
676 program.name = mimeType;
|
|
677 GnomeVFSMimeApplication* application = ptr;
|
|
678 String buffer = fromStringz(application.command).dup;
|
|
679 program.command = buffer;
|
|
680 program.gnomeExpectUri = application.expects_uris is GNOME.GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS;
|
|
681
|
26
|
682 buffer = fromStringz( application.id) ~ '\0';
|
25
|
683 ValueWrapperInt gnomeIconTheme = cast(ValueWrapperInt)display.getData(ICON_THEME_DATA);
|
|
684 char* icon_name = GNOME.gnome_icon_lookup( cast(GtkIconTheme*) gnomeIconTheme.value, null, null, buffer.ptr, null, mimeTypeBuffer,
|
|
685 GNOME.GNOME_ICON_LOOKUP_FLAGS_NONE, null);
|
|
686 char* path = null;
|
|
687 if (icon_name !is null) path = GNOME.gnome_icon_theme_lookup_icon(cast(GtkIconTheme*)gnomeIconTheme.value, icon_name, PREFERRED_ICON_SIZE, null, null);
|
|
688 if (path !is null) {
|
|
689 program.iconPath = fromStringz( path).dup;
|
|
690 OS.g_free(path);
|
|
691 }
|
|
692 if (icon_name !is null) OS.g_free(icon_name);
|
|
693 GNOME.gnome_vfs_mime_application_free(ptr);
|
|
694 }
|
|
695 return program;
|
|
696 }
|
|
697
|
|
698 static bool gnome_init() {
|
|
699 return cast(bool) GNOME.gnome_vfs_init();
|
|
700 }
|
|
701
|
|
702 /**
|
|
703 * Finds the program that is associated with an extension.
|
|
704 * The extension may or may not begin with a '.'. Note that
|
|
705 * a <code>Display</code> must already exist to guarantee that
|
|
706 * this method returns an appropriate result.
|
|
707 *
|
|
708 * @param extension the program extension
|
|
709 * @return the program or <code>null</code>
|
|
710 *
|
|
711 */
|
|
712 public static Program findProgram(String extension) {
|
|
713 return findProgram(Display.getCurrent(), extension);
|
|
714 }
|
|
715
|
|
716 /*
|
|
717 * API: When support for multiple displays is added, this method will
|
|
718 * become public and the original method above can be deprecated.
|
|
719 */
|
|
720 static Program findProgram(Display display, String extension) {
|
|
721 // SWT extension: allow null for zero length string
|
|
722 //if (extension is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
|
|
723 if (extension.length is 0) return null;
|
|
724 if (extension.charAt(0) !is '.') extension = "." ~ extension;
|
|
725 int desktop = getDesktop(display);
|
|
726 String mimeType = null;
|
|
727 switch (desktop) {
|
|
728 case DESKTOP_GNOME_24:
|
|
729 case DESKTOP_GNOME: mimeType = gnome_getMimeType(extension); break;
|
|
730 //case DESKTOP_CDE: mimeType = cde_getMimeType(extension); break;
|
|
731 default:
|
|
732 }
|
|
733 if (mimeType is null) return null;
|
|
734 Program program = null;
|
|
735 switch (desktop) {
|
|
736 case DESKTOP_GNOME_24:
|
|
737 case DESKTOP_GNOME: program = gnome_getProgram(display, mimeType); break;
|
|
738 //case DESKTOP_CDE: program = cde_getProgram(display, mimeType); break;
|
|
739 default:
|
|
740 }
|
|
741 return program;
|
|
742 }
|
|
743
|
|
744 /**
|
|
745 * Answer all program extensions in the operating system. Note
|
|
746 * that a <code>Display</code> must already exist to guarantee
|
|
747 * that this method returns an appropriate result.
|
|
748 *
|
|
749 * @return an array of extensions
|
|
750 */
|
|
751 public static String[] getExtensions() {
|
|
752 return getExtensions(Display.getCurrent());
|
|
753 }
|
|
754
|
|
755 /*
|
|
756 * API: When support for multiple displays is added, this method will
|
|
757 * become public and the original method above can be deprecated.
|
|
758 */
|
|
759 static String[] getExtensions(Display display) {
|
|
760 int desktop = getDesktop(display);
|
|
761 String[][ String ] mimeInfo = null;
|
|
762 switch (desktop) {
|
|
763 case DESKTOP_GNOME_24: mimeInfo = gnome24_getMimeInfo(); break;
|
|
764 case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break;
|
|
765 //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break;
|
|
766 default:
|
|
767 }
|
|
768 if (mimeInfo is null) return null;
|
|
769
|
|
770 /* Create a unique set of the file extensions. */
|
|
771 String[] extensions;
|
|
772 String[] keys = mimeInfo.keys;
|
|
773 int keyIdx = 0;
|
|
774 while ( keyIdx < keys.length ) {
|
|
775 String mimeType = keys[ keyIdx ];
|
|
776 String[] mimeExts = mimeInfo[mimeType];
|
|
777 for (int index = 0; index < mimeExts.length; index++){
|
|
778 if (!extensions.contains(mimeExts[index])) {
|
|
779 extensions ~= mimeExts[index];
|
|
780 }
|
|
781 }
|
|
782 keyIdx++;
|
|
783 }
|
|
784
|
|
785 /* Return the list of extensions. */
|
|
786 String[] extStrings = new String[]( extensions.length );
|
|
787 for (int index = 0; index < extensions.length; index++) {
|
|
788 extStrings[index] = extensions[index];
|
|
789 }
|
|
790 return extStrings;
|
|
791 }
|
|
792
|
|
793 /**
|
|
794 * Answers all available programs in the operating system. Note
|
|
795 * that a <code>Display</code> must already exist to guarantee
|
|
796 * that this method returns an appropriate result.
|
|
797 *
|
|
798 * @return an array of programs
|
|
799 */
|
|
800 public static Program[] getPrograms() {
|
|
801 return getPrograms(Display.getCurrent());
|
|
802 }
|
|
803
|
|
804 /*
|
|
805 * API: When support for multiple displays is added, this method will
|
|
806 * become public and the original method above can be deprecated.
|
|
807 */
|
|
808 static Program[] getPrograms(Display display) {
|
|
809 int desktop = getDesktop(display);
|
|
810 String[][ String ] mimeInfo = null;
|
|
811 switch (desktop) {
|
|
812 case DESKTOP_GNOME_24: break;
|
|
813 case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break;
|
|
814 //case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break;
|
|
815 default:
|
|
816 }
|
|
817 if (mimeInfo is null) return new Program[0];
|
|
818 Program[] programs;
|
|
819 String[] keys = mimeInfo.keys;
|
|
820 int keyIdx = 0;
|
|
821 while ( keyIdx < keys.length ) {
|
|
822 String mimeType = keys[ keyIdx ];
|
|
823 Program program = null;
|
|
824 switch (desktop) {
|
|
825 case DESKTOP_GNOME: program = gnome_getProgram(display, mimeType); break;
|
|
826 //case DESKTOP_CDE: program = cde_getProgram(display, mimeType); break;
|
|
827 default:
|
|
828 }
|
|
829 if (program !is null) programs ~= program;
|
|
830 keyIdx++;
|
|
831 }
|
|
832 Program[] programList = new Program[programs.length];
|
|
833 for (int index = 0; index < programList.length; index++) {
|
|
834 programList[index] = programs[index];
|
|
835 }
|
|
836 return programList;
|
|
837 }
|
|
838
|
|
839 /**
|
|
840 * Launches the operating system executable associated with the file or
|
|
841 * URL (http:// or https://). If the file is an executable then the
|
|
842 * executable is launched. Note that a <code>Display</code> must already
|
|
843 * exist to guarantee that this method returns an appropriate result.
|
|
844 *
|
|
845 * @param fileName the file or program name or URL (http:// or https://)
|
|
846 * @return <code>true</code> if the file is launched, otherwise <code>false</code>
|
|
847 *
|
|
848 * @exception IllegalArgumentException <ul>
|
|
849 * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
|
|
850 * </ul>
|
|
851 */
|
|
852 public static bool launch(String fileName) {
|
|
853 return launch(Display.getCurrent(), fileName);
|
|
854 }
|
|
855
|
|
856 /*
|
|
857 * API: When support for multiple displays is added, this method will
|
|
858 * become public and the original method above can be deprecated.
|
|
859 */
|
|
860 static bool launch (Display display, String fileName) {
|
|
861 if (fileName is null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
|
|
862 switch (getDesktop (display)) {
|
|
863 case DESKTOP_GNOME_24:
|
|
864 if (gnome_24_launch (fileName)) return true;
|
|
865 default:
|
|
866 int index = fileName.lastIndexOf ('.');
|
|
867 if (index !is -1) {
|
|
868 String extension = fileName.substring (index);
|
|
869 Program program = Program.findProgram (display, extension);
|
|
870 if (program !is null && program.execute (fileName)) return true;
|
|
871 }
|
|
872 String lowercaseName = fileName.toLowerCase ();
|
|
873 if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) {
|
|
874 Program program = Program.findProgram (display, ".html"); //$NON-NLS-1$
|
|
875 if (program is null) {
|
|
876 program = Program.findProgram (display, ".htm"); //$NON-NLS-1$
|
|
877 }
|
|
878 if (program !is null && program.execute (fileName)) return true;
|
|
879 }
|
|
880 break;
|
|
881 }
|
|
882 try {
|
|
883 Compatibility.exec (fileName);
|
|
884 return true;
|
|
885 } catch (IOException e) {
|
|
886 return false;
|
|
887 }
|
|
888 }
|
|
889
|
|
890 /**
|
|
891 * Compares the argument to the receiver, and returns true
|
|
892 * if they represent the <em>same</em> object using a class
|
|
893 * specific comparison.
|
|
894 *
|
|
895 * @param other the object to compare with this object
|
|
896 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
|
|
897 *
|
|
898 * @see #hashCode()
|
|
899 */
|
26
|
900 public override equals_t opEquals(Object other) {
|
25
|
901 if (this is other) return true;
|
|
902 if (!(cast(Program)other)) return false;
|
|
903 Program program = cast(Program)other;
|
|
904 return display is program.display && name.equals(program.name) && command.equals(program.command);
|
|
905 }
|
|
906
|
|
907 /**
|
|
908 * Executes the program with the file as the single argument
|
|
909 * in the operating system. It is the responsibility of the
|
|
910 * programmer to ensure that the file contains valid data for
|
|
911 * this program.
|
|
912 *
|
|
913 * @param fileName the file or program name
|
|
914 * @return <code>true</code> if the file is launched, otherwise <code>false</code>
|
|
915 *
|
|
916 * @exception IllegalArgumentException <ul>
|
|
917 * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
|
|
918 * </ul>
|
|
919 */
|
|
920 public bool execute(String fileName) {
|
|
921 if (fileName is null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
|
|
922 int desktop = getDesktop(display);
|
|
923 switch (desktop) {
|
|
924 case DESKTOP_GNOME_24: return gnome_24_execute(fileName);
|
|
925 case DESKTOP_GNOME: return gnome_execute(fileName);
|
|
926 //case DESKTOP_CDE: return cde_execute(fileName);
|
|
927 default:
|
|
928 }
|
|
929 return false;
|
|
930 }
|
|
931
|
|
932 /**
|
|
933 * Returns the receiver's image data. This is the icon
|
|
934 * that is associated with the receiver in the operating
|
|
935 * system.
|
|
936 *
|
|
937 * @return the image data for the program, may be null
|
|
938 */
|
|
939 public ImageData getImageData() {
|
|
940 switch (getDesktop(display)) {
|
|
941 case DESKTOP_GNOME_24:
|
|
942 case DESKTOP_GNOME: return gnome_getImageData();
|
|
943 //case DESKTOP_CDE: return cde_getImageData();
|
|
944 default:
|
|
945 }
|
|
946 return null;
|
|
947 }
|
|
948
|
|
949 /**
|
|
950 * Returns the receiver's name. This is as short and
|
|
951 * descriptive a name as possible for the program. If
|
|
952 * the program has no descriptive name, this string may
|
|
953 * be the executable name, path or empty.
|
|
954 *
|
|
955 * @return the name of the program
|
|
956 */
|
|
957 public String getName() {
|
|
958 return name;
|
|
959 }
|
|
960
|
|
961 /**
|
|
962 * Returns an integer hash code for the receiver. Any two
|
|
963 * objects that return <code>true</code> when passed to
|
|
964 * <code>equals</code> must return the same value for this
|
|
965 * method.
|
|
966 *
|
|
967 * @return the receiver's hash
|
|
968 *
|
|
969 * @see #equals(Object)
|
|
970 */
|
|
971 public override hash_t toHash() {
|
|
972 return .toHash(name) ^ .toHash(command) ^ display.toHash();
|
|
973 }
|
|
974
|
|
975 /**
|
|
976 * Returns a string containing a concise, human-readable
|
|
977 * description of the receiver.
|
|
978 *
|
|
979 * @return a string representation of the program
|
|
980 */
|
|
981 public String toString() {
|
|
982 return Format( "Program {{{}}", name );
|
|
983 }
|
|
984 }
|