beagle r4807 - in trunk/beagle: . Util search/Beagle.Search search/Beagle.Search.Tiles



Author: dbera
Date: Sat Jul  5 23:22:21 2008
New Revision: 4807
URL: http://svn.gnome.org/viewvc/beagle?rev=4807&view=rev

Log:
Bump gtk+/# >= 2.10. Use the nice Gnome.Vfs.MimeApplication to open hits instead of our home-cooker GnomeFu. We dont really need gnome prefix since we use the Gnome# API to get what we need - this drops the build dependencies of libgnome-2.0-dev and libgnomevfs-dev.


Modified:
   trunk/beagle/Util/ExternalStringsHack.cs.in
   trunk/beagle/Util/GnomeFu.cs
   trunk/beagle/Util/Makefile.am
   trunk/beagle/configure.in
   trunk/beagle/search/Beagle.Search.Tiles/Tile.cs
   trunk/beagle/search/Beagle.Search/Driver.cs

Modified: trunk/beagle/Util/ExternalStringsHack.cs.in
==============================================================================
--- trunk/beagle/Util/ExternalStringsHack.cs.in	(original)
+++ trunk/beagle/Util/ExternalStringsHack.cs.in	Sat Jul  5 23:22:21 2008
@@ -36,14 +36,11 @@
 			get { return "@datadir@"; }
 		}
 
-		static public string GnomePrefix {
-			get { return "@GNOME_PREFIX@"; }
-		}
-
 		static public string LocaleDir {
 		       get { return "@prefix@/share/locale"; }
 		}
 
+		/* Still need this since we directly do not use KDE C# bindings */
 		static public string KdePrefix {
 			get { return "@KDE_PREFIX@"; }
 		}

Modified: trunk/beagle/Util/GnomeFu.cs
==============================================================================
--- trunk/beagle/Util/GnomeFu.cs	(original)
+++ trunk/beagle/Util/GnomeFu.cs	Sat Jul  5 23:22:21 2008
@@ -37,8 +37,8 @@
 
 		// FIXME: When gtk-sharp 2.5 is a requirement
 		// use Gnome.Vfs.MimeApplication stuff instead
-		[DllImport("libgnomevfs-2")]
-		static extern IntPtr gnome_vfs_mime_get_default_application(string mime_type);
+		//[DllImport("libgnomevfs-2")]
+		//static extern IntPtr gnome_vfs_mime_get_default_application(string mime_type);
 
 		static GnomeFu ()
 		{
@@ -64,75 +64,6 @@
 
 			return icon_info.Filename;
 		}
-
-		public static VFSMimeApplication GetDefaultAction(string mime_type)
-		{
-			IntPtr ptr = gnome_vfs_mime_get_default_application(mime_type);
-			VFSMimeApplication ret = VFSMimeApplication.New(ptr);
-			return ret;
-		}
-
-		public enum VFSMimeApplicationArgumentType
-		{
-			Uris,
-			Path,
-			UrisForNonFiles
-		}
-
-		[StructLayout(LayoutKind.Sequential)]
-		public struct VFSMimeApplication
-		{
-			public string id;
-			public string name;
-			public string command;
-			public bool can_open_multiple_files;
-			public VFSMimeApplicationArgumentType expects_uris;
-			//public List supported_uri_schemes;
-			private IntPtr supported_uri_schemes;
-			public bool requires_terminal;
-	
-			public IntPtr reserved1;
-			public IntPtr reserved2;
-
-			public static VFSMimeApplication Zero = new VFSMimeApplication ();
-	
-			public static VFSMimeApplication New (IntPtr raw)
-			{
-				if(raw == IntPtr.Zero)
-					return VFSMimeApplication.Zero;
-				VFSMimeApplication self = new VFSMimeApplication();
-				self = (VFSMimeApplication) Marshal.PtrToStructure (raw, self.GetType ());
-				return self;
-			}
-
-			//Fixme: Create the supported uri schemes struct
-			public List SupportedUriSchemes {
-				get { return new List (supported_uri_schemes); }
-			}
-
-			public static bool operator == (VFSMimeApplication a, VFSMimeApplication b)
-			{
-				return a.Equals (b);
-			}
-
-			public static bool operator != (VFSMimeApplication a, VFSMimeApplication b)
-			{
-				return ! a.Equals (b);
-			}
-
-			public override bool Equals (object o)
-			{
-				//if (!(o is GnomeVFSMimeApplication))
-				//	 return false;
-				return base.Equals(o)  ;
-			}
-
-			public override int GetHashCode ()
-			{
-				return base.GetHashCode ();
-			}
-		}
-
 	}
 
 }

Modified: trunk/beagle/Util/Makefile.am
==============================================================================
--- trunk/beagle/Util/Makefile.am	(original)
+++ trunk/beagle/Util/Makefile.am	Sat Jul  5 23:22:21 2008
@@ -29,7 +29,6 @@
 		-e "s|\ localstatedir\@|$(localstatedir)|g"	\
 		-e "s|\ datadir\@|$(datadir)|g"			\
 		-e "s|\ VERSION\@|$(VERSION)|g"			\
-		-e "s|\ GNOME_PREFIX\@|$(GNOME_PREFIX)|g"	\
 		-e "s|\ KDE_PREFIX\@|$(KDE_PREFIX)|g"		\
 		-e "s|\ SQLITE_MAJ_VER\@|$(SQLITE_MAJ_VER)|g"	\
 		< $(EXTSTR_IN) > $@

Modified: trunk/beagle/configure.in
==============================================================================
--- trunk/beagle/configure.in	(original)
+++ trunk/beagle/configure.in	Sat Jul  5 23:22:21 2008
@@ -16,11 +16,11 @@
 MONODOC_REQUIRED=1.2.4
 NDESK_DBUS_REQUIRED=0.5.2
 NDESK_DBUS_GLIB_REQUIRED=0.3.0
-GTK_SHARP_REQUIRED=2.6.0
+GTK_SHARP_REQUIRED=2.10.0
 GMIME_SHARP_REQUIRED=2.2.0
 EVOLUTION_SHARP_REQUIRED=0.13.3
 GSF_SHARP_REQUIRED=0.6
-GTK_REQUIRED=2.6.0
+GTK_REQUIRED=2.10.0
 AVAHI_SHARP_REQUIRED=0.6.10
 
 ########################################################################
@@ -215,10 +215,6 @@
 
 if test "x$enable_gui" = "xyes"; then
 
-	# We pinvoke into gnome-vfs directly from Util/GnomeFu.cs, and
-	# we get the GNOME prefix from libgnome-2.0
-	PKG_CHECK_MODULES(GNOME_VFS, gnome-vfs-2.0 libgnome-2.0)
-
 	dnl -------------------------------------------------------
 	dnl Various version requirements
 
@@ -531,9 +527,6 @@
 GAC_PREFIX="`echo $GAC_PREFIX | sed -e 's|::\+|:|g' -e 's|^:\+||' -e 's|:\+$||'`"
 AC_SUBST(GAC_PREFIX)
 
-GNOME_PREFIX="`$PKG_CONFIG --variable=prefix libgnome-2.0`"
-AC_SUBST(GNOME_PREFIX)
-
 dnl ----------------------------------------------
 
 dnl Check if the system has libchm, used by the CHMFilter
@@ -654,9 +647,9 @@
 Filters/Makefile
 tools/Makefile
 tools/beagle-settings.desktop.in
-search/Makefile
 search/icons/Makefile
 search/beagle-search.desktop.in
+search/Makefile
 ImLogViewer/Makefile
 epiphany-extension/Makefile
 firefox-extension/Makefile
@@ -678,7 +671,6 @@
 	Inotify:		  ${enable_inotify}
 
 	Prefix:			  ${prefix}
-	GNOME prefix:             ${GNOME_PREFIX}
 	KDE prefix:		  ${kde_prefix_print}
 
 	evolution-sharp?	  ${enable_evo}

Modified: trunk/beagle/search/Beagle.Search.Tiles/Tile.cs
==============================================================================
--- trunk/beagle/search/Beagle.Search.Tiles/Tile.cs	(original)
+++ trunk/beagle/search/Beagle.Search.Tiles/Tile.cs	Sat Jul  5 23:22:21 2008
@@ -12,6 +12,7 @@
 using Mono.Unix;
 
 using Gtk;
+using Gnome.Vfs;
 using Beagle;
 using Beagle.Util;
 
@@ -323,8 +324,8 @@
 
 		protected void OpenFromMime (Hit hit)
 		{
-			string command = null, item;
-			bool expects_uris = false;
+			string command = null;
+			string uri = null, path = null;
 
 			string mimetype = hit.MimeType;
 
@@ -333,70 +334,46 @@
 			if (mimetype == "inode/directory")
 				mimetype = "x-directory/normal";
 
+			// FIXME: I'm not sure that opening the parent
+			// URI (if present) is the right thing to do in
+			// all cases, but it does work for all our
+			// current cases.
+			if (hit.ParentUri != null)
+				uri = hit.EscapedParentUri;
+			else
+				uri = hit.EscapedUri;
+
 #if ENABLE_DESKTOP_LAUNCH
-			command = "desktop-launch";
-			expects_uris = true;
+			RunDefaultHandler ("desktop-launch", uri);
 #elif ENABLE_XDG_OPEN
-			command = "xdg-open";
-			expects_uris = true;
+			RunDefaultHandler ("xdg-open", uri);
 #else
-			GnomeFu.VFSMimeApplication app;
-			app = GnomeFu.GetDefaultAction (mimetype);
-			if (app.command != null) {
-				command = app.command;
-				expects_uris = (app.expects_uris != GnomeFu.VFSMimeApplicationArgumentType.Path);
-			}
-#endif			
-			if (command == null) {
+			MimeApplication app;
+			app = Mime.GetDefaultApplication (mimetype);
+			bool expect_uris = app.SupportUris ();
+			path = hit.Path;
+
+			if (app == null) {
 				Console.WriteLine ("Can't open MimeType '{0}'", mimetype);
 				return;
 			}
 			
-			if (expects_uris) {
-				// FIXME: I'm not sure that opening the parent
-				// URI (if present) is the right thing to do in
-				// all cases, but it does work for all our
-				// current cases.
-				if (hit.ParentUri != null)
-					item = hit.EscapedParentUri;
-				else
-					item = hit.EscapedUri;
-			} else
-				item = hit.Path;
-
-			// Sometimes the command is 'quoted'
-			if (command.IndexOf ('\'') == 0 && command.LastIndexOf ('\'') == command.Length - 1)
-				command = command.Trim ('\'');
-
-			// This won't work if a program really has a space in
-			// the command filename, but I think other things would
-			// break with that too, and in practice it doesn't seem to
-			// happen.
-			//
-			// A bigger issue is that the arguments are split up by
-			// spaces, so quotation marks used to indicate a single
-			// entry in the argv won't work.  This probably should
-			// be fixed.
-			string[] arguments = null;
-			int idx = command.IndexOf (' ');
-			if (idx != -1) {
-				arguments = command.Substring (idx + 1).Split (' ');
-				command = command.Substring (0, idx);
-			}
+			GLib.List list = new GLib.List ((IntPtr) 0);
+			list.Append (expect_uris ? uri : path);
 
+			Gnome.Vfs.Result result = app.Launch (list);
+			if (result != Gnome.Vfs.Result.Ok)
+				Console.WriteLine ("Error in opening {0}: {1}", uri, result);
+#endif
+		}
+
+		private static void RunDefaultHandler (string command, string uri)
+		{
 			string[] argv;
-			if (arguments == null)
-				argv = new string [] { command, item };
-			else {
-				argv = new string [arguments.Length + 2];
-				argv [0] = command;
-				argv [argv.Length - 1] = item;
-				Array.Copy (arguments, 0, argv, 1, arguments.Length);
-			}
+			argv = new string [] { command, uri };
 
 			Console.WriteLine ("Cmd: {0}", command);
-			Console.WriteLine ("Arg: {0}", String.Join (" ", argv, 1, argv.Length - 2));
-			Console.WriteLine ("Itm: {0}", item);
+			Console.WriteLine ("Uri: {0}", uri);
 
 			SafeProcess p = new SafeProcess ();
 			p.Arguments = argv;
@@ -408,7 +385,7 @@
 			}
 		}
 
-		public void OpenFromUri (Uri uri)
+		public void OpenFromUri (System.Uri uri)
 		{
 			OpenFromUri (UriFu.UriToEscapedString (uri));
 		}

Modified: trunk/beagle/search/Beagle.Search/Driver.cs
==============================================================================
--- trunk/beagle/search/Beagle.Search/Driver.cs	(original)
+++ trunk/beagle/search/Beagle.Search/Driver.cs	Sat Jul  5 23:22:21 2008
@@ -125,6 +125,8 @@
 			Gnome.Program program = new Gnome.Program ("search", "0.0", Gnome.Modules.UI, args);
 			Gtk.IconTheme.Default.AppendSearchPath (System.IO.Path.Combine (ExternalStringsHack.PkgDataDir, "icons"));
 
+			Gnome.Vfs.Vfs.Initialize ();
+
 			// FIXME: Passing these icon and docs enabled properties
 			// sucks. We really need to do something about them.
 			Search search = new Search (icon_enabled, docs_enabled);



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