config: port linux UI to use new config
This commit is contained in:
parent
01320bb1be
commit
a9a035fc28
|
@ -73,7 +73,9 @@ namespace SparkleShare {
|
||||||
// from the Internet category if needed
|
// from the Internet category if needed
|
||||||
public override void InstallLauncher ()
|
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");
|
string desktopfile_path = SparkleHelpers.CombineMore (apps_path, "sparkleshare.desktop");
|
||||||
|
|
||||||
if (!File.Exists (desktopfile_path)) {
|
if (!File.Exists (desktopfile_path)) {
|
||||||
|
@ -104,8 +106,8 @@ namespace SparkleShare {
|
||||||
// list of bookmarked places
|
// list of bookmarked places
|
||||||
public override void AddToBookmarks ()
|
public override void AddToBookmarks ()
|
||||||
{
|
{
|
||||||
string bookmarks_file_path = Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks");
|
string bookmarks_file_path = Path.Combine (SparkleConfig.DefaultConfig.HomePath, ".gtk-bookmarks");
|
||||||
string sparkleshare_bookmark = "file://" + SparklePaths.SparklePath + " SparkleShare";
|
string sparkleshare_bookmark = "file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare";
|
||||||
|
|
||||||
if (File.Exists (bookmarks_file_path)) {
|
if (File.Exists (bookmarks_file_path)) {
|
||||||
StreamReader reader = new StreamReader (bookmarks_file_path);
|
StreamReader reader = new StreamReader (bookmarks_file_path);
|
||||||
|
@ -114,12 +116,12 @@ namespace SparkleShare {
|
||||||
|
|
||||||
if (!bookmarks.Contains (sparkleshare_bookmark)) {
|
if (!bookmarks.Contains (sparkleshare_bookmark)) {
|
||||||
TextWriter writer = File.AppendText (bookmarks_file_path);
|
TextWriter writer = File.AppendText (bookmarks_file_path);
|
||||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
writer.WriteLine ("file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare");
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StreamWriter writer = new StreamWriter (bookmarks_file_path);
|
StreamWriter writer = new StreamWriter (bookmarks_file_path);
|
||||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
writer.WriteLine ("file://" + SparkleConfig.DefaultConfig.FoldersPath + " SparkleShare");
|
||||||
writer.Close ();
|
writer.Close ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,12 +130,12 @@ namespace SparkleShare {
|
||||||
// Creates the SparkleShare folder in the user's home folder
|
// Creates the SparkleShare folder in the user's home folder
|
||||||
public override bool CreateSparkleShareFolder ()
|
public override bool CreateSparkleShareFolder ()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists (SparklePaths.SparklePath)) {
|
if (!Directory.Exists (SparkleConfig.DefaultConfig.FoldersPath)) {
|
||||||
|
|
||||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
Directory.CreateDirectory (SparkleConfig.DefaultConfig.FoldersPath);
|
||||||
SparkleHelpers.DebugInfo ("Controller", "Created '" + SparklePaths.SparklePath + "'");
|
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");
|
"usr", "bin", "gvfs-set-attribute");
|
||||||
|
|
||||||
// Add a special icon to the SparkleShare folder
|
// Add a special icon to the SparkleShare folder
|
||||||
|
@ -145,12 +147,12 @@ namespace SparkleShare {
|
||||||
process.StartInfo.FileName = "gvfs-set-attribute";
|
process.StartInfo.FileName = "gvfs-set-attribute";
|
||||||
|
|
||||||
// Clear the custom (legacy) icon path
|
// 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.Start ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
|
|
||||||
// Give the SparkleShare folder an icon name, so that it scales
|
// 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.Start ();
|
||||||
process.WaitForExit ();
|
process.WaitForExit ();
|
||||||
}
|
}
|
||||||
|
@ -164,13 +166,13 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public override string EventLogHTML {
|
public override string EventLogHTML {
|
||||||
get {
|
get {
|
||||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
string path = Path.Combine (Defines.PREFIX,
|
||||||
"share", "sparkleshare", "html", "event-log.html");
|
"share", "sparkleshare", "html", "event-log.html");
|
||||||
|
|
||||||
string html = String.Join (Environment.NewLine, File.ReadAllLines (path));
|
string html = String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||||
|
|
||||||
html = html.Replace ("<!-- $jquery-url -->", "file://" +
|
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;
|
return html;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +181,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public override string DayEntryHTML {
|
public override string DayEntryHTML {
|
||||||
get {
|
get {
|
||||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
string path = Path.Combine (Defines.PREFIX,
|
||||||
"share", "sparkleshare", "html", "day-entry.html");
|
"share", "sparkleshare", "html", "day-entry.html");
|
||||||
|
|
||||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||||
|
@ -189,7 +191,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public override string EventEntryHTML {
|
public override string EventEntryHTML {
|
||||||
get {
|
get {
|
||||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
string path = Path.Combine (Defines.PREFIX,
|
||||||
"share", "sparkleshare", "html", "event-entry.html");
|
"share", "sparkleshare", "html", "event-entry.html");
|
||||||
|
|
||||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||||
|
@ -199,7 +201,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public override void OpenSparkleShareFolder (string subfolder)
|
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 process = new Process ();
|
||||||
process.StartInfo.FileName = "xdg-open";
|
process.StartInfo.FileName = "xdg-open";
|
||||||
|
|
|
@ -240,8 +240,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
ListStore folder_store = new ListStore (typeof (string));
|
ListStore folder_store = new ListStore (typeof (string));
|
||||||
|
|
||||||
foreach (string host in SparkleShare.Controller.FolderPaths)
|
//foreach (string host in SparkleShare.Controller.FolderPaths)
|
||||||
folder_store.AppendValues (host);
|
// folder_store.AppendValues (host);
|
||||||
|
|
||||||
FolderEntry.Completion.Model = folder_store;
|
FolderEntry.Completion.Model = folder_store;
|
||||||
FolderEntry.Completion.TextColumn = 0;
|
FolderEntry.Completion.TextColumn = 0;
|
||||||
|
|
|
@ -40,14 +40,20 @@ namespace SparkleShare {
|
||||||
public static Gdk.Pixbuf GetIcon (string name, int size)
|
public static Gdk.Pixbuf GetIcon (string name, int size)
|
||||||
{
|
{
|
||||||
IconTheme icon_theme = new IconTheme ();
|
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 {
|
try {
|
||||||
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
|
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
try {
|
try {
|
||||||
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
|
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
|
||||||
|
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue