From 19771e874a5a449bfd44f6266335c55c50b83d65 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Mon, 10 May 2010 14:42:46 +0100 Subject: [PATCH] Use an icon theme to look up icons --- SparkleShare/SparkleBubble.cs | 2 +- SparkleShare/SparkleHelpers.cs | 13 ++++++++++++- SparkleShare/SparklePaths.cs | 6 +++++- SparkleShare/SparkleSpinner.cs | 11 ++++------- SparkleShare/SparkleWindow.cs | 31 ++++++++++++++----------------- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/SparkleShare/SparkleBubble.cs b/SparkleShare/SparkleBubble.cs index 917328e8..eb194cda 100644 --- a/SparkleShare/SparkleBubble.cs +++ b/SparkleShare/SparkleBubble.cs @@ -24,7 +24,7 @@ namespace SparkleShare { Timeout = 4500; Urgency = Urgency.Low; Show (); -// StatusIcon = SparkleUI.NotificationIcon; +// StatusIcon = SparkleUI.NotificationIcon; // Doesn't work for some reason :( } } diff --git a/SparkleShare/SparkleHelpers.cs b/SparkleShare/SparkleHelpers.cs index 2e260c48..6509a442 100644 --- a/SparkleShare/SparkleHelpers.cs +++ b/SparkleShare/SparkleHelpers.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +using Gtk; using System; using System.IO; using System.Net; @@ -85,10 +86,20 @@ namespace SparkleShare { public static string CombineMore (params string [] Parts) { string NewPath = ""; foreach (string Part in Parts) - NewPath = Path.Combine(NewPath, Part); + NewPath = Path.Combine (NewPath, Part); return NewPath; } + + public static IconTheme SparkleTheme = new IconTheme (); + + // Looks up an icon from the system's theme + public static Gdk.Pixbuf GetIcon (string Name, int Size) { +// SparkleTheme.AppendSearchPath (SparklePaths.SparkleInstallPath); + return SparkleTheme.LoadIcon (Name, Size, + IconLookupFlags.GenericFallback); + } + } } diff --git a/SparkleShare/SparklePaths.cs b/SparkleShare/SparklePaths.cs index 576bf167..17ff44b0 100644 --- a/SparkleShare/SparklePaths.cs +++ b/SparkleShare/SparklePaths.cs @@ -29,7 +29,11 @@ namespace SparkleShare { public static string SparklePath = Path.Combine (HomePath ,"SparkleShare"); public static string SparkleConfigPath = - Path.Combine (HomePath, Path.Combine (".config", "sparkleshare")); + SparkleHelpers.CombineMore (HomePath, ".config", "sparkleshare"); + + public static string SparkleInstallPath = + SparkleHelpers.CombineMore ("usr", "share", "sparkleshare", + "icons", "hicolor"); public static string SparkleAvatarPath = Path.Combine (SparkleConfigPath, "avatars"); diff --git a/SparkleShare/SparkleSpinner.cs b/SparkleShare/SparkleSpinner.cs index e81f35e4..038f9d6c 100644 --- a/SparkleShare/SparkleSpinner.cs +++ b/SparkleShare/SparkleSpinner.cs @@ -33,15 +33,12 @@ namespace SparkleShare { public SparkleSpinner () : base () { - Size = 48; - string SpinnerFileName = SparkleHelpers.CombineMore ( - SparklePaths.SparkleIconPath, - Size + "x" + Size, "animations", - "process-working.png"); - - Gdk.Pixbuf SpinnerGallery = new Gdk.Pixbuf (SpinnerFileName); CycleDuration = 750; CurrentStep = 0; + Size = 48; + + Gdk.Pixbuf SpinnerGallery = SparkleHelpers.GetIcon ("process-working", + Size); int FramesInWidth = SpinnerGallery.Width / Size; int FramesInHeight = SpinnerGallery.Height / Size; diff --git a/SparkleShare/SparkleWindow.cs b/SparkleShare/SparkleWindow.cs index da546242..ef66b653 100644 --- a/SparkleShare/SparkleWindow.cs +++ b/SparkleShare/SparkleWindow.cs @@ -138,15 +138,14 @@ namespace SparkleShare { // Creates a visual list of repositories public VBox CreateReposList() { - string FolderIcon = - "/usr/share/icons/gnome/32x32/places/folder.png"; + Gdk.Pixbuf FolderIcon = SparkleHelpers.GetIcon ("folder", 32); TreeIter ReposIter; foreach (SparkleRepo SparkleRepo in Repositories) { ReposIter = ReposStore.Prepend (); - ReposStore.SetValue (ReposIter, 0, new Gdk.Pixbuf (FolderIcon)); + ReposStore.SetValue (ReposIter, 0, FolderIcon); ReposStore.SetValue (ReposIter, 1, SparkleRepo.Name + " \n" + SparkleRepo.Domain + " "); @@ -200,9 +199,11 @@ namespace SparkleShare { AddRemoveButtons.PackStart (AddButton, true, true, 0); - Image RemoveImage = new Image ("/usr/share/icons/gnome/16x16/actions/list-remove.png"); + Image RemoveIcon = new Image ( + SparkleHelpers.GetIcon ("document-removed", 16)); + Button RemoveButton = new Button (); - RemoveButton.Image = RemoveImage; + RemoveButton.Add (RemoveIcon); AddRemoveButtons.PackStart (RemoveButton, false, false, 0); ScrolledWindow.AddWithViewport (ReposView); @@ -285,8 +286,8 @@ namespace SparkleShare { public ScrolledWindow CreateEventLog() { ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf), - typeof (string), - typeof (string)); + typeof (string), + typeof (string)); Process Process = new Process(); Process.EnableRaisingEvents = false; @@ -323,25 +324,21 @@ namespace SparkleShare { string Message = Parts [1]; string TimeAgo = Parts [2]; - string IconFile = - "/usr/share/icons/hicolor/16x16/status/document-edited.png"; + string IconFile = "document-edited"; if (Message.IndexOf (" added ‘") > -1) - IconFile = - "/usr/share/icons/hicolor/16x16/status/document-added.png"; + IconFile = "document-added"; if (Message.IndexOf (" deleted ‘") > -1) - IconFile = - "/usr/share/icons/hicolor/16x16/status/document-removed.png"; + IconFile = "document-removed"; if (Message.IndexOf (" moved ‘") > -1 || Message.IndexOf (" renamed ‘") > -1) + IconFile = "document-moved"; - IconFile = - "/usr/share/icons/hicolor/16x16/status/document-moved.png"; - + Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16); Iter = LogStore.Append (); - LogStore.SetValue (Iter, 0, new Gdk.Pixbuf (IconFile)); + LogStore.SetValue (Iter, 0, ChangeIcon); LogStore.SetValue (Iter, 1, Message); LogStore.SetValue (Iter, 2, " " + TimeAgo);