f-spot r4561 - in trunk: . src src/Extensions src/Widgets



Author: sdelcroix
Date: Mon Nov  3 13:43:38 2008
New Revision: 4561
URL: http://svn.gnome.org/viewvc/f-spot?rev=4561&view=rev

Log:
2008-11-03  Stephane Delcroix  <sdelcroix novell com>

	* configure.in: check for gtk-sharp 2.12.6 in which we can use AppInfo

	* src/MainWindow.cs:
	* src/Widgets/OpenWithMenu.cs:
	* src/Extensions/PopupCommands.cs: a lot of ifdef to keep openwith
	working with gnome-vfs on older installations.

Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/Extensions/PopupCommands.cs
   trunk/src/MainWindow.cs
   trunk/src/Widgets/OpenWithMenu.cs

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Mon Nov  3 13:43:38 2008
@@ -108,6 +108,9 @@
 if pkg-config --atleast-version=2.12.2 gtk-sharp-2.0; then
    CSC_DEFINES="$CSC_DEFINES -d:GTK_2_12_2"
 fi
+if pkg-config --atleast-version=2.12.6 gtk-sharp-2.0; then
+   CSC_DEFINES="$CSC_DEFINES -d:GTK_SHARP_2_12_6"
+fi
 if pkg-config --atleast-version=1.2.5 mono; then
    CSC_DEFINES="$CSC_DEFINES -d:MONO_1_2_5"
 fi

Modified: trunk/src/Extensions/PopupCommands.cs
==============================================================================
--- trunk/src/Extensions/PopupCommands.cs	(original)
+++ trunk/src/Extensions/PopupCommands.cs	Mon Nov  3 13:43:38 2008
@@ -61,7 +61,11 @@
 		public Gtk.Menu GetMenu ()
 		{
 			owm = new Widgets.OpenWithMenu (MainWindow.Toplevel.SelectedMimeTypes, "f-spot");
+#if GTK_SHARP_2_12_6
 			owm.ApplicationActivated += delegate (AppInfo app) { MainWindow.Toplevel.HandleOpenWith (this, app); };
+#else
+			owm.ApplicationActivated += delegate (Gnome.Vfs.MimeApplication app) { MainWindow.Toplevel.HandleOpenWith (this, app); };
+#endif
 			return (Gtk.Menu) owm;
 		}
 

Modified: trunk/src/MainWindow.cs
==============================================================================
--- trunk/src/MainWindow.cs	(original)
+++ trunk/src/MainWindow.cs	Mon Nov  3 13:43:38 2008
@@ -3041,7 +3041,11 @@
 		}
 	}
 
+#if GTK_SHARP_2_12_6
 	public void HandleOpenWith (object sender, GLib.AppInfo application)
+#else
+	public void HandleOpenWith (object sender, Gnome.Vfs.MimeApplication application)
+#endif
 	{
 		Photo[] selected = SelectedPhotos ();
 
@@ -3102,7 +3106,11 @@
 			db.Photos.Commit (selected);
 
 		try {
+#if GTK_SHARP_2_12_6
 			application.LaunchUris (uri_list, null);
+#else
+			application.Launch (uri_list);
+#endif
 		} catch (System.Exception) {
 			Log.ErrorFormat ("Failed to lauch {0}", application.Name);
 		}

Modified: trunk/src/Widgets/OpenWithMenu.cs
==============================================================================
--- trunk/src/Widgets/OpenWithMenu.cs	(original)
+++ trunk/src/Widgets/OpenWithMenu.cs	Mon Nov  3 13:43:38 2008
@@ -15,13 +15,19 @@
 
 using Gtk;
 using Gdk;
+#if GTK_SHARP_2_12_6
 using GLib;
+#endif
 
 using Mono.Unix;
 
 namespace FSpot.Widgets {
 	public class OpenWithMenu: Gtk.Menu {
+#if GTK_SHARP_2_12_6
 		public delegate void OpenWithHandler (AppInfo app_info);
+#else
+		public delegate void OpenWithHandler (Gnome.Vfs.MimeApplication app_info);
+#endif
 		public event OpenWithHandler ApplicationActivated;
 
 		public delegate string [] TypeFetcher ();
@@ -42,6 +48,13 @@
 			set { show_icons = value; }
 		}
 
+#if !GTK_SHARP_2_12_6
+		static OpenWithMenu ()
+		{
+			Gnome.Vfs.Vfs.Initialize ();
+		}
+#endif
+
 		public OpenWithMenu (TypeFetcher type_fetcher) : this (type_fetcher, null)
 		{
 		}
@@ -59,7 +72,11 @@
 			for (int i = 0; i < dead_pool.Length; i++)
 				dead_pool [i].Destroy ();
 
+#if GTK_SHARP_2_12_6
 			foreach (AppInfo app in ApplicationsFor (type_fetcher ())) {
+#else
+			foreach (Gnome.Vfs.MimeApplication app in ApplicationsFor (type_fetcher ())) {
+#endif
 				AppMenuItem i = new AppMenuItem (app, show_icons);
 				i.Activated += HandleItemActivated;
 				Append (i);
@@ -74,11 +91,20 @@
 			ShowAll ();
 		}
 
+#if GTK_SHARP_2_12_6
 		AppInfo[] ApplicationsFor (string [] types)
+#else
+		Gnome.Vfs.MimeApplication[] ApplicationsFor (string [] types)
+#endif
 		{
+#if GTK_SHARP_2_12_6
 			List<AppInfo> app_infos = new List<AppInfo> ();
+#else
+			List<Gnome.Vfs.MimeApplication> app_infos = new List<Gnome.Vfs.MimeApplication> ();
+#endif
 			HashSet<string> existing_ids = new HashSet<string> ();
 			foreach (string type in types)
+#if GTK_SHARP_2_12_6
 				foreach (AppInfo appinfo in AppInfoAdapter.GetAllForType (type)) {
 					if (existing_ids.Contains (appinfo.Id))
 						continue;
@@ -89,6 +115,18 @@
 					app_infos.Add (appinfo);
 					existing_ids.Add (appinfo.Id);
 				}
+#else
+				foreach (Gnome.Vfs.MimeApplication appinfo in Gnome.Vfs.Mime.GetAllApplications (type)) {
+					if (existing_ids.Contains (appinfo.DesktopId))
+						continue;
+					if (!appinfo.SupportsUris ())
+						continue;
+					if (ignore_apps != null && ignore_apps.Contains (appinfo.BinaryName))
+						continue;
+					app_infos.Add (appinfo);
+					existing_ids.Add (appinfo.DesktopId);
+				}
+#endif
 			return app_infos.ToArray ();
 		}
 
@@ -102,12 +140,24 @@
 
 		private class AppMenuItem : ImageMenuItem {
 
+#if GTK_SHARP_2_12_6
 			AppInfo app;
+#else
+			Gnome.Vfs.MimeApplication app;
+#endif
+#if GTK_SHARP_2_12_6
 			public AppInfo App {
+#else
+			public Gnome.Vfs.MimeApplication App {
+#endif
 				get { return app; }
 			}
 
+#if GTK_SHARP_2_12_6
 			public AppMenuItem (AppInfo app, bool show_icon) : base (app.Name)
+#else
+			public AppMenuItem (Gnome.Vfs.MimeApplication app, bool show_icon) : base (app.Name)
+#endif
 			{
 				this.app = app;
 
@@ -115,6 +165,7 @@
 					return;
 
 				Pixbuf pixbuf = null;
+#if GTK_SHARP_2_12_6
 				if (app.Icon is ThemedIcon) {
 					try {
 						pixbuf = IconTheme.Default.ChooseIcon ((app.Icon as ThemedIcon).Names, 16, (IconLookupFlags)0).LoadIcon ();
@@ -122,6 +173,16 @@
 					}
 				} else
 					FSpot.Utils.Log.DebugFormat ("Loading icons from {0} is not implemented", app.Icon);
+#else
+				try {
+					if (app.Icon.StartsWith ("/"))
+						pixbuf = new Gdk.Pixbuf (app.Icon, 16, 16);
+					else
+						pixbuf = IconTheme.Default.LoadIcon (app.Icon, 16, (IconLookupFlags)0);
+				} catch (System.Exception) {
+					pixbuf = null;
+				}
+#endif
 
 				if (pixbuf != null)
 					Image = new Gtk.Image (pixbuf);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]