Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@novell.com>2010-11-03 13:01:55 +0300
committerMike Krüger <mkrueger@novell.com>2010-11-03 13:01:55 +0300
commit5c88e0a38c4cad47a935f517a231d4335a4a1c42 (patch)
tree517655b8da55eb89f53721a253103d5ab76a94df /main/src/addins/GnomePlatform
parent2571a76d10525769a5a6bdd4e5df362dff63720a (diff)
Revert "[Mac] Native Open With and file icons"
This reverts commit 166d2da8fa0952fec9295960c615bf38ecccef06.
Diffstat (limited to 'main/src/addins/GnomePlatform')
-rw-r--r--main/src/addins/GnomePlatform/Gio.cs20
-rw-r--r--main/src/addins/GnomePlatform/GnomePlatform.cs72
2 files changed, 22 insertions, 70 deletions
diff --git a/main/src/addins/GnomePlatform/Gio.cs b/main/src/addins/GnomePlatform/Gio.cs
index e2dcb42aed..89eed2f66b 100644
--- a/main/src/addins/GnomePlatform/Gio.cs
+++ b/main/src/addins/GnomePlatform/Gio.cs
@@ -70,14 +70,12 @@ namespace MonoDevelop.Platform {
public IntPtr prev;
}
- static GnomeDesktopApplication AppFromAppInfoPtr (IntPtr handle, DesktopApplication defaultApp)
+ static DesktopApplication AppFromAppInfoPtr (IntPtr handle)
{
string id = GLib.Marshaller.Utf8PtrToString (g_app_info_get_id (handle));
string name = GLib.Marshaller.Utf8PtrToString (g_app_info_get_name (handle));
string executable = GLib.Marshaller.Utf8PtrToString (g_app_info_get_executable (handle));
-
- if (!string.IsNullOrEmpty (name) && !string.IsNullOrEmpty (executable) && !executable.Contains ("monodevelop "))
- return new GnomeDesktopApplication (executable, name, defaultApp != null && defaultApp.Id == id);
+ return new DesktopApplication (id, name, executable);
}
static IntPtr ContentTypeFromMimeType (string mime_type)
@@ -93,31 +91,29 @@ namespace MonoDevelop.Platform {
return content_type;
}
- static DesktopApplication GetDefaultForType (string mime_type)
+ public static DesktopApplication GetDefaultForType (string mime_type)
{
IntPtr content_type = ContentTypeFromMimeType (mime_type);
IntPtr ret = g_app_info_get_default_for_type (content_type, false);
GLib.Marshaller.Free (content_type);
- return ret == IntPtr.Zero ? null : AppFromAppInfoPtr (ret, null);
+ return ret == IntPtr.Zero ? new DesktopApplication () : AppFromAppInfoPtr (ret);
}
- public static System.Collections.IList<DesktopApplication> GetAllForType (string mime_type)
+ public static DesktopApplication[] GetAllForType (string mime_type)
{
- var def = GetDefaultForType (mime_type);
-
IntPtr content_type = ContentTypeFromMimeType (mime_type);
IntPtr ret = g_app_info_get_all_for_type (content_type);
GLib.Marshaller.Free (content_type);
IntPtr l = ret;
- var apps = new System.Collections.Generic.List<DesktopApplication> ();
+ ArrayList apps = new ArrayList ();
while (l != IntPtr.Zero) {
GList node = (GList) Marshal.PtrToStructure (l, typeof (GList));
if (node.data != IntPtr.Zero)
- apps.Add (AppFromAppInfoPtr (node.data, def));
+ apps.Add (AppFromAppInfoPtr (node.data));
l = node.next;
}
g_list_free (ret);
- return apps;
+ return (DesktopApplication[]) apps.ToArray (typeof (DesktopApplication));
}
public static string GetMimeTypeDescription (string mime_type)
diff --git a/main/src/addins/GnomePlatform/GnomePlatform.cs b/main/src/addins/GnomePlatform/GnomePlatform.cs
index 41a847aa1e..af4e3bcee7 100644
--- a/main/src/addins/GnomePlatform/GnomePlatform.cs
+++ b/main/src/addins/GnomePlatform/GnomePlatform.cs
@@ -55,43 +55,32 @@ namespace MonoDevelop.Platform
//apparently Gnome.Icon needs GnomeVFS initialized even when we're using GIO.
Gnome.Vfs.Vfs.Initialize ();
}
-
- DesktopApplication GetGnomeVfsDefaultApplication (string mimeType)
+
+
+ public override DesktopApplication GetDefaultApplication (string mimeType)
{
+ if (useGio)
+ return Gio.GetDefaultForType (mimeType);
+
var app = Gnome.Vfs.Mime.GetDefaultApplication (mimeType);
if (app != null)
return (DesktopApplication) Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
else
- return null;
+ return new DesktopApplication ();
}
- IEnumerable<DesktopApplication> GetGnomeVfsApplications ()
+ public override DesktopApplication [] GetAllApplications (string mimeType)
{
- var def = GetGnomeVfsDefaultApplication (mimeType);
+ if (useGio)
+ return Gio.GetAllForType (mimeType);
+
var list = new List<DesktopApplication> ();
var apps = Gnome.Vfs.Mime.GetAllApplications (mimeType);
foreach (var app in apps) {
- var dap = (GnomeVfsApp) Marshal.PtrToStructure (app.Handle, typeof(GnomeVfsApp));
- if (!string.IsNullOrEmpty (dap.Command) && !string.IsNullOrEmpty (dap.DisplayName) && !dap.Command.Contains ("monodevelop ")) {
- var isDefault = def != null && def.Id == dap.Command;
- list.Add (new GnomeDesktopApplication (dap.Command, dap.DisplayName, isDefault));
- }
+ var dap = (DesktopApplication) Marshal.PtrToStructure (app.Handle, typeof(DesktopApplication));
+ list.Add (dap);
}
- return list;
- }
-
- public override IEnumerable<DesktopApplication> GetApplications (string filename)
- {
- var mimeType = DesktopService.GetMimeTypeForUri (fileName);
-
- if (useGio)
- return Gio.GetAllForType (mimeType);
- else
- return GetGnomeVfsApplications (mimeType);
- }
-
- struct GnomeVfsApp {
- public string Id, DisplayName, Command;
+ return list.ToArray ();
}
protected override string OnGetMimeTypeDescription (string mt)
@@ -344,37 +333,4 @@ namespace MonoDevelop.Platform
Runtime.ProcessService.StartProcess (TerminalCommand, "", directory, null);
}
}
-
- class GnomeDesktopApplication : DesktopApplication
- {
- public GnomeDesktopApplication (string command, string displayName) : base (command, displayName)
- {
- }
-
- string Command {
- get { return Id; }
- }
-
- public abstract void Launch (params string[] files)
- {
- // TODO: implement all other cases
- if (Command.IndexOf ("%f") != -1) {
- foreach (string s in files) {
- string cmd = Command.Replace ("%f", "\"" + s + "\"");
- Process.Start (cmd);
- }
- }
- else if (Command.IndexOf ("%F") != -1) {
- string[] fs = new string [files.Length];
- for (int n=0; n<files.Length; n++) {
- fs [n] = "\"" + files [n] + "\"";
- }
- string cmd = Command.Replace ("%F", string.Join (" ", fs));
- Process.Start (cmd);
- } else {
- foreach (string s in files) {
- Process.Start (Command, "\"" + s + "\"");
- }
- }
- }
}