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; Timeout = 4500;
Urgency = Urgency.Low; Urgency = Urgency.Low;
Show (); 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 // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk;
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
@ -85,10 +86,20 @@ namespace SparkleShare {
public static string CombineMore (params string [] Parts) { public static string CombineMore (params string [] Parts) {
string NewPath = ""; string NewPath = "";
foreach (string Part in Parts) foreach (string Part in Parts)
NewPath = Path.Combine(NewPath, Part); NewPath = Path.Combine (NewPath, Part);
return NewPath; 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 SparklePath = Path.Combine (HomePath ,"SparkleShare");
public static string SparkleConfigPath = 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 = public static string SparkleAvatarPath =
Path.Combine (SparkleConfigPath, "avatars"); Path.Combine (SparkleConfigPath, "avatars");

View file

@ -33,15 +33,12 @@ namespace SparkleShare {
public SparkleSpinner () : base () { 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; CycleDuration = 750;
CurrentStep = 0; CurrentStep = 0;
Size = 48;
Gdk.Pixbuf SpinnerGallery = SparkleHelpers.GetIcon ("process-working",
Size);
int FramesInWidth = SpinnerGallery.Width / Size; int FramesInWidth = SpinnerGallery.Width / Size;
int FramesInHeight = SpinnerGallery.Height / Size; int FramesInHeight = SpinnerGallery.Height / Size;

View file

@ -138,15 +138,14 @@ namespace SparkleShare {
// Creates a visual list of repositories // Creates a visual list of repositories
public VBox CreateReposList() { public VBox CreateReposList() {
string FolderIcon = Gdk.Pixbuf FolderIcon = SparkleHelpers.GetIcon ("folder", 32);
"/usr/share/icons/gnome/32x32/places/folder.png";
TreeIter ReposIter; TreeIter ReposIter;
foreach (SparkleRepo SparkleRepo in Repositories) { foreach (SparkleRepo SparkleRepo in Repositories) {
ReposIter = ReposStore.Prepend (); ReposIter = ReposStore.Prepend ();
ReposStore.SetValue (ReposIter, 0, new Gdk.Pixbuf (FolderIcon)); ReposStore.SetValue (ReposIter, 0, FolderIcon);
ReposStore.SetValue (ReposIter, 1, SparkleRepo.Name + " \n" + ReposStore.SetValue (ReposIter, 1, SparkleRepo.Name + " \n" +
SparkleRepo.Domain + " "); SparkleRepo.Domain + " ");
@ -200,9 +199,11 @@ namespace SparkleShare {
AddRemoveButtons.PackStart (AddButton, true, true, 0); 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 (); Button RemoveButton = new Button ();
RemoveButton.Image = RemoveImage; RemoveButton.Add (RemoveIcon);
AddRemoveButtons.PackStart (RemoveButton, false, false, 0); AddRemoveButtons.PackStart (RemoveButton, false, false, 0);
ScrolledWindow.AddWithViewport (ReposView); ScrolledWindow.AddWithViewport (ReposView);
@ -285,8 +286,8 @@ namespace SparkleShare {
public ScrolledWindow CreateEventLog() { public ScrolledWindow CreateEventLog() {
ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf), ListStore LogStore = new ListStore (typeof (Gdk.Pixbuf),
typeof (string), typeof (string),
typeof (string)); typeof (string));
Process Process = new Process(); Process Process = new Process();
Process.EnableRaisingEvents = false; Process.EnableRaisingEvents = false;
@ -323,25 +324,21 @@ namespace SparkleShare {
string Message = Parts [1]; string Message = Parts [1];
string TimeAgo = Parts [2]; string TimeAgo = Parts [2];
string IconFile = string IconFile = "document-edited";
"/usr/share/icons/hicolor/16x16/status/document-edited.png";
if (Message.IndexOf (" added ") > -1) if (Message.IndexOf (" added ") > -1)
IconFile = IconFile = "document-added";
"/usr/share/icons/hicolor/16x16/status/document-added.png";
if (Message.IndexOf (" deleted ") > -1) if (Message.IndexOf (" deleted ") > -1)
IconFile = IconFile = "document-removed";
"/usr/share/icons/hicolor/16x16/status/document-removed.png";
if (Message.IndexOf (" moved ") > -1 || if (Message.IndexOf (" moved ") > -1 ||
Message.IndexOf (" renamed ") > -1) Message.IndexOf (" renamed ") > -1)
IconFile = "document-moved";
IconFile = Gdk.Pixbuf ChangeIcon = SparkleHelpers.GetIcon (IconFile, 16);
"/usr/share/icons/hicolor/16x16/status/document-moved.png";
Iter = LogStore.Append (); Iter = LogStore.Append ();
LogStore.SetValue (Iter, 0, new Gdk.Pixbuf (IconFile)); LogStore.SetValue (Iter, 0, ChangeIcon);
LogStore.SetValue (Iter, 1, Message); LogStore.SetValue (Iter, 1, Message);
LogStore.SetValue (Iter, 2, " " + TimeAgo); LogStore.SetValue (Iter, 2, " " + TimeAgo);