70
70
public IntPtr prev;
73
static DesktopApplication AppFromAppInfoPtr (IntPtr handle)
73
static GnomeDesktopApplication AppFromAppInfoPtr (IntPtr handle, DesktopApplication defaultApp)
75
75
string id = GLib.Marshaller.Utf8PtrToString (g_app_info_get_id (handle));
76
76
string name = GLib.Marshaller.Utf8PtrToString (g_app_info_get_name (handle));
77
77
string executable = GLib.Marshaller.Utf8PtrToString (g_app_info_get_executable (handle));
78
return new DesktopApplication (id, name, executable);
79
if (!string.IsNullOrEmpty (name) && !string.IsNullOrEmpty (executable) && !executable.Contains ("monodevelop "))
80
return new GnomeDesktopApplication (executable, name, defaultApp != null && defaultApp.Id == id);
81
84
static IntPtr ContentTypeFromMimeType (string mime_type)
96
99
IntPtr content_type = ContentTypeFromMimeType (mime_type);
97
100
IntPtr ret = g_app_info_get_default_for_type (content_type, false);
98
101
GLib.Marshaller.Free (content_type);
99
return ret == IntPtr.Zero ? new DesktopApplication () : AppFromAppInfoPtr (ret);
102
return ret == IntPtr.Zero ? null : AppFromAppInfoPtr (ret, null);
102
public static DesktopApplication[] GetAllForType (string mime_type)
105
public static System.Collections.Generic.IList<DesktopApplication> GetAllForType (string mime_type)
107
var def = GetDefaultForType (mime_type);
104
109
IntPtr content_type = ContentTypeFromMimeType (mime_type);
105
110
IntPtr ret = g_app_info_get_all_for_type (content_type);
106
111
GLib.Marshaller.Free (content_type);
108
ArrayList apps = new ArrayList ();
113
var apps = new System.Collections.Generic.List<DesktopApplication> ();
109
114
while (l != IntPtr.Zero) {
110
115
GList node = (GList) Marshal.PtrToStructure (l, typeof (GList));
111
if (node.data != IntPtr.Zero)
112
apps.Add (AppFromAppInfoPtr (node.data));
116
if (node.data != IntPtr.Zero) {
117
var app = AppFromAppInfoPtr (node.data, def);
115
123
g_list_free (ret);
116
return (DesktopApplication[]) apps.ToArray (typeof (DesktopApplication));
119
127
public static string GetMimeTypeDescription (string mime_type)