Rework the KDE stuff, use kde-config at configure time only, and if needed, take guesses at runtime. Also looks in more icon locations. Index: configure.in =================================================================== RCS file: /cvs/gnome/beagle/configure.in,v retrieving revision 1.125 diff -u -B -p -r1.125 configure.in --- configure.in 17 May 2005 19:23:26 -0000 1.125 +++ configure.in 17 May 2005 21:23:11 -0000 @@ -402,6 +402,14 @@ AC_SUBST(CHOOSER_FU_LIBS) dnl ---------------------------------------------- +dnl KDE launcher/icon support + +AC_PATH_PROG(KDE_CONFIG, [kde-config], []) +if test ! "x$PKG_CONFIG" = "xno"; then + KDE_PREFIX=`$KDE_CONFIG --prefix` +fi +AC_SUBST(KDE_PREFIX) + AC_ARG_ENABLE([webservices], AC_HELP_STRING([--enable-webservices], [Enable WebServices (default disabled)]), enable_webservices=$enableval, Index: Util/ExternalStringsHack.cs.in =================================================================== RCS file: /cvs/gnome/beagle/Util/ExternalStringsHack.cs.in,v retrieving revision 1.2 diff -u -B -p -r1.2 ExternalStringsHack.cs.in --- Util/ExternalStringsHack.cs.in 5 Apr 2005 22:32:03 -0000 1.2 +++ Util/ExternalStringsHack.cs.in 17 May 2005 21:23:11 -0000 @@ -31,5 +31,9 @@ namespace Beagle.Util { static public string LocaleDir { get { return "@prefix@/share/locale"; } } + + static public string KdePrefix { + get { return "@KDE_PREFIX@"; } + } } } Index: Util/KdeUtils.cs =================================================================== RCS file: /cvs/gnome/beagle/Util/KdeUtils.cs,v retrieving revision 1.1 diff -u -B -p -r1.1 KdeUtils.cs --- Util/KdeUtils.cs 16 May 2005 17:21:56 -0000 1.1 +++ Util/KdeUtils.cs 17 May 2005 21:23:11 -0000 @@ -33,102 +33,75 @@ namespace Beagle.Util { public static class KdeUtils { private static string [] icon_sizes = { "128x128", "64x64", "48x48", "32x32", "22x22", "16x16" }; - private static string kde_directory = String.Empty; - - // Returns the kde prefix directory, or null if kde-config - // could not be found. - public static string KdePrefix { - get { - if (kde_directory != String.Empty) - return kde_directory; - - Process kde_config = new Process (); - kde_config.StartInfo.FileName = "kde-config"; - kde_config.StartInfo.Arguments = "--prefix"; - kde_config.StartInfo.RedirectStandardInput = false; - kde_config.StartInfo.RedirectStandardOutput = true; - kde_config.StartInfo.UseShellExecute = false; - - try { - kde_config.Start (); - } catch (System.ComponentModel.Win32Exception) { - Logger.Log.Info ("Couldn't find kde-config, not dealing with KDE-related info."); - kde_directory = null; - return kde_directory; - } - - StreamReader pout = kde_config.StandardOutput; - kde_directory = pout.ReadLine (); - pout.Close (); - - // FIXME: Remove WaitForExit call once the zombie process bug (74870) is fixed - kde_config.WaitForExit (); - kde_config.Close (); - - if (! Directory.Exists (kde_directory)) - kde_directory = null; - - return kde_directory; - } - } - - public static string KdeSharePrefix { - get { return Path.Combine (KdePrefix, "share"); } + private static string [] kde_locations = { ExternalStringsHack.KdePrefix, Environment.GetEnvironmentVariable ("KDEDIR"), "/opt/kde3", "/usr" }; + public static string [] KdeLocations { + get { return kde_locations; } } // Finds an icon by its name and returns its absolute path, or null if not found. public static string LookupIcon (string icon_name) { - string icon_prefix = Path.Combine (KdeSharePrefix, "icons"); - string icon_theme_hicolor = Path.Combine (icon_prefix, "hicolor"); - string [] icon_themes = { null, null }; - - if (! Directory.Exists (icon_theme_hicolor)) - icon_theme_hicolor = null; - - // FIXME: We should probably support svg icons at some point - if (! icon_name.EndsWith(".png")) - icon_name = icon_name + ".png"; - - // We try up to 2 icon themes: we first try the theme pointed at by the - // "default.kde" link, and then we try the trusted default "hicolor" theme. - // We handle the situations if either (or both) of these aren't present, or - // if default.kde == hicolor. - - string icon_theme_default = Syscall.readlink (Path.Combine (icon_prefix, "default.kde")); - if (icon_theme_default != null) { - if (! icon_theme_default.StartsWith ("/")) - icon_theme_default = Path.Combine (icon_prefix, icon_theme_default); + foreach (string kde_dir in KdeLocations) { + if (kde_dir == null || kde_dir == String.Empty || !Directory.Exists (kde_dir)) + continue; - if (! Directory.Exists (icon_theme_default) || icon_theme_default == icon_theme_hicolor) - icon_theme_default = null; - } + string kde_share = Path.Combine (kde_dir, "share"); + string icon_prefix = Path.Combine (kde_share, "icons"); + string icon_theme_hicolor = Path.Combine (icon_prefix, "hicolor"); + string [] icon_themes = { null, null }; + + if (! Directory.Exists (icon_theme_hicolor)) + icon_theme_hicolor = null; + + // FIXME: We should probably support svg icons at some point + if (! icon_name.EndsWith(".png")) + icon_name = icon_name + ".png"; + + // We try up to 2 icon themes: we first try the theme pointed at by the + // "default.kde" link, and then we try the trusted default "hicolor" theme. + // We handle the situations if either (or both) of these aren't present, or + // if default.kde == hicolor. + + string icon_theme_default = Syscall.readlink (Path.Combine (icon_prefix, "default.kde")); + if (icon_theme_default != null) { + if (! icon_theme_default.StartsWith ("/")) + icon_theme_default = Path.Combine (icon_prefix, icon_theme_default); - int i = 0; - if (icon_theme_default != null) - icon_themes [i++] = icon_theme_default; - if (icon_theme_hicolor != null) - icon_themes [i++] = icon_theme_hicolor; - if (i == 0) - return null; - - // Loop through all detected themes - foreach (string theme in icon_themes) { - if (theme == null) + if (! Directory.Exists (icon_theme_default) || icon_theme_default == icon_theme_hicolor) + icon_theme_default = null; + } + + int i = 0; + if (icon_theme_default != null) + icon_themes [i++] = icon_theme_default; + if (icon_theme_hicolor != null) + icon_themes [i++] = icon_theme_hicolor; + if (i == 0) continue; - // Try the preset icon sizes - foreach (string size in icon_sizes) { - string icon_dir = Path.Combine (Path.Combine (theme, size), "apps"); - if (! Directory.Exists (icon_dir)) + // Loop through all detected themes + foreach (string theme in icon_themes) { + if (theme == null) continue; - // Check for icon existance - string icon_path = Path.Combine (icon_dir, icon_name); - if (File.Exists (icon_path)) - return icon_path; + // Try the preset icon sizes + foreach (string size in icon_sizes) { + string icon_base = Path.Combine (theme, size); + if (! Directory.Exists (icon_base)) + continue; + + foreach (string icon_subdir in Directory.GetDirectories (icon_base)) { + string icon_dir = Path.Combine (icon_base, icon_subdir); + + // Check for icon existance + string icon_path = Path.Combine (icon_dir, icon_name); + if (File.Exists (icon_path)) + return icon_path; + } + } } + // Only search the first valid path that we find + break; } - return null; } Index: Util/Makefile.am =================================================================== RCS file: /cvs/gnome/beagle/Util/Makefile.am,v retrieving revision 1.52 diff -u -B -p -r1.52 Makefile.am --- Util/Makefile.am 16 May 2005 17:21:56 -0000 1.52 +++ Util/Makefile.am 17 May 2005 21:23:11 -0000 @@ -24,6 +24,7 @@ $(EXTSTR): $(EXTSTR_IN) -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ -e "s|\@VERSION\@|$(VERSION)|g" \ -e "s|\@GNOME_PREFIX\@|$(GNOME_PREFIX)|g" \ + -e "s|\@KDE_PREFIX\@|$(KDE_PREFIX)|g" \ < $(EXTSTR_IN) > $@ CSFILES = \ Index: beagled/LauncherQueryable/LauncherQueryable.cs =================================================================== RCS file: /cvs/gnome/beagle/beagled/LauncherQueryable/LauncherQueryable.cs,v retrieving revision 1.17 diff -u -B -p -r1.17 LauncherQueryable.cs --- beagled/LauncherQueryable/LauncherQueryable.cs 16 May 2005 17:26:48 -0000 1.17 +++ beagled/LauncherQueryable/LauncherQueryable.cs 17 May 2005 21:23:11 -0000 @@ -56,9 +56,13 @@ namespace Beagle.Daemon.LauncherQueryabl Dirs.Add (Path.Combine (PathFinder.HomeDir, ".gnome2/panel2.d/default/launchers")); // Add KDE dirs - path = KdeUtils.KdeSharePrefix; - if (path != null) - Dirs.Add (Path.Combine(path, "applications")); + foreach (string kde_dir in KdeUtils.KdeLocations) { + if (kde_dir == null || kde_dir == String.Empty) + continue; + + string share_dir = Path.Combine (kde_dir, "share"); + Dirs.Add (Path.Combine(share_dir, "applications")); + } Dirs.Add (Path.Combine (PathFinder.HomeDir, ".local/share/applications")); }