~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/GnomePlatform/Gio.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
                        public IntPtr prev;
71
71
                }
72
72
 
73
 
                static DesktopApplication AppFromAppInfoPtr (IntPtr handle)
 
73
                static GnomeDesktopApplication AppFromAppInfoPtr (IntPtr handle, DesktopApplication defaultApp)
74
74
                {
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);
 
78
                        
 
79
                        if (!string.IsNullOrEmpty (name) && !string.IsNullOrEmpty (executable) && !executable.Contains ("monodevelop "))
 
80
                                return new GnomeDesktopApplication (executable, name, defaultApp != null && defaultApp.Id == id);
 
81
                        return null;
79
82
                }
80
83
 
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);
100
103
                }
101
104
 
102
 
                public static DesktopApplication[] GetAllForType (string mime_type)
 
105
                public static System.Collections.Generic.IList<DesktopApplication> GetAllForType (string mime_type)
103
106
                {
 
107
                        var def = GetDefaultForType (mime_type);
 
108
                        
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);
107
112
                        IntPtr l = ret;
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);
 
118
                                        if (app != null)
 
119
                                                apps.Add (app);
 
120
                                }
113
121
                                l = node.next;
114
122
                        }
115
123
                        g_list_free (ret);
116
 
                        return (DesktopApplication[]) apps.ToArray (typeof (DesktopApplication));
 
124
                        return apps;
117
125
                }
118
126
 
119
127
                public static string GetMimeTypeDescription (string mime_type)