config: port linux UI to use new config

This commit is contained in:
Hylke Bons 2011-07-24 15:48:30 +01:00
parent 870bc4d8bf
commit e03377dc91
3 changed files with 28 additions and 20 deletions

View file

@ -73,7 +73,9 @@ namespace SparkleShare {
// from the Internet category if needed
public override void InstallLauncher ()
{
string apps_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".local", "share", "applications");
string apps_path = Path.Combine (SparkleConfig.DefaultConfig.HomePath,
".local", "share", "applications");
string desktopfile_path = SparkleHelpers.CombineMore (apps_path, "sparkleshare.desktop");
if (!File.Exists (desktopfile_path)) {
@ -104,8 +106,8 @@ namespace SparkleShare {
// list of bookmarked places
public override void AddToBookmarks ()
{
string bookmarks_file_path = Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks");
string sparkleshare_bookmark = "file://" + SparklePaths.SparklePath + " SparkleShare";
string bookmarks_file_path = Path.Combine (SparkleConfig.DefaultConfig.HomePath, ".gtk-bookmarks");
string sparkleshare_bookmark = "file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare";
if (File.Exists (bookmarks_file_path)) {
StreamReader reader = new StreamReader (bookmarks_file_path);
@ -114,12 +116,12 @@ namespace SparkleShare {
if (!bookmarks.Contains (sparkleshare_bookmark)) {
TextWriter writer = File.AppendText (bookmarks_file_path);
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
writer.WriteLine ("file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare");
writer.Close ();
}
} else {
StreamWriter writer = new StreamWriter (bookmarks_file_path);
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
writer.WriteLine ("file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare");
writer.Close ();
}
}
@ -128,12 +130,12 @@ namespace SparkleShare {
// Creates the SparkleShare folder in the user's home folder
public override bool CreateSparkleShareFolder ()
{
if (!Directory.Exists (SparklePaths.SparklePath)) {
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
Directory.CreateDirectory (SparklePaths.SparklePath);
SparkleHelpers.DebugInfo ("Controller", "Created '" + SparklePaths.SparklePath + "'");
Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath);
SparkleHelpers.DebugInfo ("Controller", "Created '" + SparkleConfig.DefaultConfig.FoldersPath + "'");
string gvfs_command_path = SparkleHelpers.CombineMore (Path.VolumeSeparatorChar.ToString (),
string gvfs_command_path = Path.Combine (Path.VolumeSeparatorChar.ToString (),
"usr", "bin", "gvfs-set-attribute");
// Add a special icon to the SparkleShare folder
@ -145,12 +147,12 @@ namespace SparkleShare {
process.StartInfo.FileName = "gvfs-set-attribute";
// Clear the custom (legacy) icon path
process.StartInfo.Arguments = "-t unset " + SparklePaths.SparklePath + " metadata::custom-icon";
process.StartInfo.Arguments = "-t unset " + SparkleConfig.DefaultConfig.FoldersPath + " metadata::custom-icon";
process.Start ();
process.WaitForExit ();
// Give the SparkleShare folder an icon name, so that it scales
process.StartInfo.Arguments = SparklePaths.SparklePath + " metadata::custom-icon-name 'folder-sparkleshare'";
process.StartInfo.Arguments = SparkleConfig.DefaultConfig.FoldersPath + " metadata::custom-icon-name 'folder-sparkleshare'";
process.Start ();
process.WaitForExit ();
}
@ -164,13 +166,13 @@ namespace SparkleShare {
public override string EventLogHTML {
get {
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
string path = Path.Combine (Defines.PREFIX,
"share", "sparkleshare", "html", "event-log.html");
string html = String.Join (Environment.NewLine, File.ReadAllLines (path));
html = html.Replace ("<!-- $jquery-url -->", "file://" +
SparkleHelpers.CombineMore (Defines.PREFIX, "share", "sparkleshare", "html", "jquery.js"));
Path.Combine (Defines.PREFIX, "share", "sparkleshare", "html", "jquery.js"));
return html;
}
@ -179,7 +181,7 @@ namespace SparkleShare {
public override string DayEntryHTML {
get {
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
string path = Path.Combine (Defines.PREFIX,
"share", "sparkleshare", "html", "day-entry.html");
return String.Join (Environment.NewLine, File.ReadAllLines (path));
@ -189,7 +191,7 @@ namespace SparkleShare {
public override string EventEntryHTML {
get {
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
string path = Path.Combine (Defines.PREFIX,
"share", "sparkleshare", "html", "event-entry.html");
return String.Join (Environment.NewLine, File.ReadAllLines (path));
@ -199,7 +201,7 @@ namespace SparkleShare {
public override void OpenSparkleShareFolder (string subfolder)
{
string folder = Path.Combine (SparklePaths.SparklePath, subfolder);
string folder = Path.Combine (SparkleConfig.DefaultConfig.FoldersPath, subfolder);
Process process = new Process ();
process.StartInfo.FileName = "xdg-open";

View file

@ -240,8 +240,8 @@ namespace SparkleShare {
ListStore folder_store = new ListStore (typeof (string));
foreach (string host in SparkleShare.Controller.FolderPaths)
folder_store.AppendValues (host);
//foreach (string host in SparkleShare.Controller.FolderPaths)
// folder_store.AppendValues (host);
FolderEntry.Completion.Model = folder_store;
FolderEntry.Completion.TextColumn = 0;

View file

@ -40,14 +40,20 @@ namespace SparkleShare {
public static Gdk.Pixbuf GetIcon (string name, int size)
{
IconTheme icon_theme = new IconTheme ();
icon_theme.AppendSearchPath (SparklePaths.SparkleIconPath);
icon_theme.AppendSearchPath (SparklePaths.SparkleLocalIconPath);
icon_theme.AppendSearchPath (
Path.Combine (SparkleUI.AssetsPath, "icons"));
icon_theme.AppendSearchPath (
Path.Combine (SparkleConfig.ConfigPath, "icons"));
try {
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
} catch {
try {
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
} catch {
return null;
}