Use an icon theme to look up icons

This commit is contained in:
Hylke Bons 2010-05-10 14:42:46 +01:00
parent 18d0958815
commit 19771e874a
5 changed files with 36 additions and 27 deletions

View file

@ -24,7 +24,7 @@ namespace SparkleShare {
Timeout = 4500;
Urgency = Urgency.Low;
Show ();
// StatusIcon = SparkleUI.NotificationIcon;
// StatusIcon = SparkleUI.NotificationIcon; // Doesn't work for some reason :(
}
}

View file

@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
}
}
}

View file

@ -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");

View file

@ -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;

View file

@ -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);