Add to Library Support for F-spot and Banshee



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Ok, so I cooked up 2 patches to add support for 'Add to Library'
functionality from 2 of beagles sister apps, Banshee and F-spot.

I have also filed these patches with bugs at
F-Spot:
http://bugzilla.gnome.org/show_bug.cgi?id=344535
and Banshee:
http://bugzilla.gnome.org/show_bug.cgi?id=344527

I would appreciate some feedback and discussion especially about what we
should do with the f-spot issue.
- --
Cheers,
Kevin Kubasik
240-838-6616
http://kubasik.net/blog
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iQIVAwUBRIuJIP3xZFNDM330AQg3NhAAsxjfZ9kDlTMP40eFzHyYTwURRGkHAUCU
IeBqCMvnpmu8deaUTYSCZBEyOkaT7eeKJPngntvnhXrcAg+iHnimmXRGxe+qMMrM
YlaxCzw80PN98woWqEPkRIgQ/aOraDMeJFptHyns1AUASyVGAXR+dfOM5/RcL+uK
kCHIcKxMkp44+kTwTGkwEmGHXOpHFJzEl83lRixURnu2UAuhfYMquEDMNkS6Ycfw
FPBD6xbqmA50F+89S8IeDkD6xH7eQDG1orL8pA/BWkk8jtGxCZghJpuwTJMqbQnX
oykWGL47lQC0SQAp6TW94M5MGnrYJyxSqOy8byGzmO1170ntEXS7vr7MbP6shszD
LAdlyL/zaJJ59ThQv7z3cHUjHjZ7dzVWGUei8xsD04oDz136cuyGVnxYSAZjHDxo
uNj/DR78bAXDJ+E/25BTFs8CcYLGPnnkp43RaMEQjlXxlaWWT1I7hdu7HyNoxxy6
HX5+AYCun1nX0D6G2mApt2TkxTH1zCgBNuNG17iODqig7PJhDaoy/TWv/y4Ax1wF
O70jqEJFKh3jlLrfIBH7dSy61loSXXNYgk0iIKLfFc6PhgigZ2wlppry57o8L5or
QDg5MpZyOapazzIFbAO22BRosXlCVIsizPpQ90OKMhrvV9/taivvwnHwTm1hAi/U
avegGFRqGV4=
=r5D4
-----END PGP SIGNATURE-----
Index: configure.in
===================================================================
RCS file: /cvs/gnome/beagle/configure.in,v
retrieving revision 1.247
diff -u -1 -2 -r1.247 configure.in
--- configure.in	31 May 2006 22:22:33 -0000	1.247
+++ configure.in	11 Jun 2006 02:26:42 -0000
@@ -215,24 +215,33 @@
 	AC_SUBST(LIBTRAYICON_LIBS)
 	
 fi
 
 dnl ----------------------------------------------
 
 dnl "Open With" Menu (Requires GTK 2.8)
 	PKG_CHECK_MODULES(OPEN_WITH,
 [
 	gtk-sharp-2.0 >= 2.8
 ],OPEN_WITH=yes,OPEN_WITH=no)
 AM_CONDITIONAL(ENABLE_OPEN_WITH, test "x$OPEN_WITH" != "xno")
+
+dnl ----------------------------------------------
+
+dnl Banshee Import Support
+	PKG_CHECK_MODULES(BANSHEE_IMPORT,
+[
+	banshee >= 0.11
+],BANSHEE_IMPORT=yes,BANSHEE_IMPORT=no)
+AM_CONDITIONAL(ENABLE_BANSHEE, test "x$BANSHEE_IMPORT" != "xno")
 dnl ----------------------------------------------
 
 dnl evolution support
 
 AC_ARG_ENABLE([evolution],
 	AC_HELP_STRING([--disable-evolution], [Disable evolution support (default auto)]),
 	enable_evo=$enableval,
 	enable_evo_sharp=auto)
 
 
 EVO_SHARP_PREFIX=`$PKG_CONFIG --variable=prefix evolution-sharp`
 
@@ -683,20 +692,21 @@
 	Mozilla Extension?	  yes
 	Epiphany Extension?	  ${enable_epiphany_extension}
 
 	Local SqliteClient?	  ${use_local_sqlite}
 	Sqlite version:		  ${SQLITE_MAJ_VER}.x
 
 	Enable WebServices	  no (WebServices are deprecated)
 	Enable libbeagle	  ${enable_libbeagle}
 	Enable python bindings	  ${have_python}
 
 	Enable beagle-search GUI  ${enable_gui}
 	Enable \"Open With\" menu   ${OPEN_WITH}
+	Banshee Import		${BANSHEE_IMPORT}
 "
 echo
 
 if test "x$enable_epiphany_extension" = "xyes"; then
    echo "NOTE: The Beagle Epiphany Extension Is Totally Insecure!"
    echo "      Use it at your own risk!"
    echo
 fi
Index: ./search/Makefile.am
===================================================================
RCS file: /cvs/gnome/beagle/search/Makefile.am,v
retrieving revision 1.17
diff -u -1 -2 -r1.17 Makefile.am
--- ./search/Makefile.am	31 May 2006 22:22:34 -0000	1.17
+++ ./search/Makefile.am	11 Jun 2006 02:26:42 -0000
@@ -1,23 +1,27 @@
 CSC = mcs -debug
 CSFLAGS = -target:exe
 
 if ENABLE_DESKTOP_LAUNCH
 CSFLAGS += -define:ENABLE_DESKTOP_LAUNCH
 endif
 
 if ENABLE_OPEN_WITH
 CSFLAGS += -define:ENABLE_OPEN_WITH
 endif
 
+if ENABLE_BANSHEE
+CSFLAGS += -define:ENABLE_BANSHEE
+endif
+
 pkglib_DATA = Search.exe Search.exe.mdb
 
 BIN_WRAPPERS = beagle-search
 
 beagle-search: beagle-search.in
 	sed -e "s:@pkglibdir@:${pkglibdir}:" < $(srcdir)/beagle-search.in > beagle-search
 	chmod a+x beagle-search
 
 CSFILES =					\
 	$(srcdir)/Category.cs			\
 	$(srcdir)/ConversationCategory.cs	\
 	$(srcdir)/Entry.cs			\
Index: ./search/Tiles/Audio.cs
===================================================================
RCS file: /cvs/gnome/beagle/search/Tiles/Audio.cs,v
retrieving revision 1.6
diff -u -1 -2 -r1.6 Audio.cs
--- ./search/Tiles/Audio.cs	20 May 2006 15:53:01 -0000	1.6
+++ ./search/Tiles/Audio.cs	11 Jun 2006 02:26:42 -0000
@@ -1,15 +1,17 @@
 using System;
 using Mono.Unix;
 
+using Beagle.Util;
+
 namespace Search.Tiles {
 
 	public class AudioActivator : TileActivator {
 
 		public AudioActivator () : base ()
 		{
 			AddSupportedFlavor (new HitFlavor (null, "File", "audio/*"));
 			AddSupportedFlavor (new HitFlavor (null, "File", "application/ogg")); // FIXME: What about videos?
 		}
 
 		public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
 		{
@@ -23,22 +25,31 @@
 		{
 			Group = TileGroup.Audio;
 
 			// FIXME: Show album art if any. Needs implementation in Beagle.Util
 
 			string title = Hit.GetFirstProperty ("fixme:title");
 			if (title != null && title != "")
 				Title = title;
 
 			string artist = Hit.GetFirstProperty ("fixme:artist");
 			if (artist != null && artist != "")
 				Description = artist;
-
-			//AddAction (new TileAction (Catalog.GetString ("Add to Library"), AddToLibrary));
+#if ENABLE_BANSHEE
+			AddAction (new TileAction (Catalog.GetString ("Add to Library"), AddToLibrary));
+#endif
 		}
 
 		// FIXME: Check if Banshee exists and supports this?
 		public void AddToLibrary ()
 		{
+			string path = Hit.FileInfo.FullName;
+			SafeProcess p = new SafeProcess ();
+			p.Arguments = new string [] { "banshee-import", path };
+			try {
+				p.Start ();
+			} catch (Exception e) {
+				Console.WriteLine ( String.Format ("Cannot import file: {0}", path) );
+			}
 		}
 	}
 }
Index: ./search/Tiles/Image.cs
===================================================================
RCS file: /cvs/gnome/beagle/search/Tiles/Image.cs,v
retrieving revision 1.16
diff -u -1 -2 -r1.16 Image.cs
--- ./search/Tiles/Image.cs	26 May 2006 11:14:31 -0000	1.16
+++ ./search/Tiles/Image.cs	11 Jun 2006 02:24:03 -0000
@@ -25,26 +25,27 @@
 		{
 			Group = TileGroup.Image;
 
 			Title = Hit ["beagle:ExactFilename"];
 
 			if (Hit ["beagle:FilenameExtension"].Length > 0)
 				Description = Hit ["beagle:FilenameExtension"].Substring (1).ToUpper ();
 			
 			if (Hit ["fixme:width"] != null && Hit ["fixme:width"] != "")
 				Description += String.Format (" {0}x{1}", Hit ["fixme:width"], Hit ["fixme:height"]);
 
 			Description += String.Format (" ({0})", StringFu.FileLengthToString (Hit.FileInfo.Length));
+			if (SystemInformation.DoesBinExist ("f-spot"))
+				AddAction (new TileAction (Catalog.GetString ("Add to Library"), Gtk.Stock.Add, AddToLibrary));
 
-			// AddAction (new TileAction (Catalog.GetString ("Add to Library"), Gtk.Stock.Add, AddToLibrary));
 			AddAction (new TileAction (Catalog.GetString ("Set as Wallpaper"), SetAsWallpaper));
 		}
 
 		protected override void LoadIcon (Gtk.Image image, int size)
 		{
 			base.LoadIcon (image, size);
 
 			// Draw the F-Spot overlay
 			if (size > 32 && Hit ["fspot:IsIndexed"] == "true") {
 				Gdk.Pixbuf icon = image.Pixbuf;
 				Gdk.Pixbuf emblem = Beagle.Images.GetPixbuf ("emblem-fspot.png", 24, 24);
 
@@ -77,44 +78,43 @@
 
 			details.AddLabelPair (Catalog.GetString ("Modified:"), Utils.NiceVeryLongDate (Hit.FileInfo.LastWriteTime));
 			details.AddLabelPair (Catalog.GetString ("Full Path:"), Hit.Uri.LocalPath);
 
 			if (Hit ["fspot:Description"] != null && Hit ["fspot:Description"] != "") {
 				details.AddNewLine ();
 				details.AddTextLabel (Hit ["fspot:Description"]);
 			}
 
 			return details;
 		}
 		
-#if NOT_YET
-		// FIXME: fspot doesnt allow to import a particular file
-		// only a whole directory
+
+		
 		public void AddToLibrary ()
 		{
-			// FIXME: check if f-spot is installed
+			
 
 			if (Hit ["fspot:IsIndexed"] == "true")
 				return;
 
 			SafeProcess p = new SafeProcess ();
 			p.Arguments = new string[] { "f-spot", "--import", Hit.FileInfo.FullName };
 
 			try {
 				p.Start ();
 			} catch (Exception e) {
 				Console.WriteLine ("Error launching F-Spot: " + e);
 			}
 		}
-#endif
+
 		
 		public void SetAsWallpaper ()
 		{
 			int width = 0;
 			int height = 0;
 
 			if (Hit ["fixme:width"] != null && Hit ["fixme:width"] == "") {
 				width = Int32.Parse (Hit ["fixme:width"]);
 				height = Int32.Parse (Hit ["fixme:height"]);
 			} else {
 				if (! System.IO.File.Exists (Hit.FileInfo.FullName))
 					return;
Index: ./Util/SystemInformation.cs
===================================================================
RCS file: /cvs/gnome/beagle/Util/SystemInformation.cs,v
retrieving revision 1.21
diff -u -1 -2 -r1.21 SystemInformation.cs
--- ./Util/SystemInformation.cs	28 Mar 2006 22:54:55 -0000	1.21
+++ ./Util/SystemInformation.cs	11 Jun 2006 02:24:03 -0000
@@ -323,25 +323,34 @@
 		// From /usr/include/linux/prctl.h
 		private const int PR_SET_NAME = 15;
 
 		public static void SetProcessName(string name)
 		{
 #if OS_LINUX
 			if (prctl (PR_SET_NAME, Encoding.ASCII.GetBytes (name + '\0'), 0, 0, 0) < 0) {
 				Logger.Log.Warn ("Couldn't set process name to '{0}': {1}", name,
 						 Mono.Unix.Native.Stdlib.GetLastError ());
 			}
 #endif
 		}
-
+		
+		public static bool DoesBinExist (string name)
+		{
+			string path = Path.Combine (ExternalStringsHack.Prefix, "bin");
+			path = Path.Combine (path, name);
+			if (File.Exists (path))
+				return true;
+			return false;
+		
+		}
 		///////////////////////////////////////////////////////////////
 
 		public static string MonoRuntimeVersion {
 			get {
 				Type t = typeof (object).Assembly.GetType ("Mono.Runtime");
 
 				string ver = (string) t.InvokeMember ("GetDisplayName",
 								      BindingFlags.InvokeMethod
 								      | BindingFlags.NonPublic
 								      | BindingFlags.Static
 								      | BindingFlags.DeclaredOnly
 								      | BindingFlags.ExactBinding,


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