linux controller uihelpers window: fix whitespace, style, and remove obsolete code
This commit is contained in:
parent
c16b883ab2
commit
9901ca56ba
|
@ -14,8 +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 Mono.Unix;
|
||||
using SparkleLib;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -24,218 +23,183 @@ using System.Runtime.InteropServices;
|
|||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
using Mono.Unix;
|
||||
using SparkleLib;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleLinController : SparkleController {
|
||||
public class SparkleLinController : SparkleController {
|
||||
|
||||
public SparkleLinController () : base ()
|
||||
{
|
||||
public SparkleLinController () : base ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates a .desktop entry in autostart folder to
|
||||
// start SparkleShare automatically at login
|
||||
public override void EnableSystemAutostart ()
|
||||
{
|
||||
|
||||
string autostart_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".config", "autostart");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (autostart_path, "sparkleshare.desktop");
|
||||
// Creates a .desktop entry in autostart folder to
|
||||
// start SparkleShare automatically at login
|
||||
public override void EnableSystemAutostart ()
|
||||
{
|
||||
string autostart_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".config", "autostart");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (autostart_path, "sparkleshare.desktop");
|
||||
|
||||
if (!File.Exists (desktopfile_path)) {
|
||||
if (!File.Exists (desktopfile_path)) {
|
||||
if (!Directory.Exists (autostart_path))
|
||||
Directory.CreateDirectory (autostart_path);
|
||||
|
||||
if (!Directory.Exists (autostart_path))
|
||||
Directory.CreateDirectory (autostart_path);
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"X-GNOME-Autostart-enabled=true\n" +
|
||||
"Categories=Network");
|
||||
writer.Close ();
|
||||
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"X-GNOME-Autostart-enabled=true\n" +
|
||||
"Categories=Network");
|
||||
writer.Close ();
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
UnixFileInfo file_info = new UnixFileInfo (desktopfile_path);
|
||||
file_info.Create (FileAccessPermissions.UserReadWriteExecute);
|
||||
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
UnixFileInfo file_info = new UnixFileInfo (desktopfile_path);
|
||||
file_info.Create (FileAccessPermissions.UserReadWriteExecute);
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created: " + desktopfile_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created: " + desktopfile_path);
|
||||
// Installs a launcher so the user can launch SparkleShare
|
||||
// from the Internet category if needed
|
||||
public override void InstallLauncher ()
|
||||
{
|
||||
string apps_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".local", "share", "applications");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (apps_path, "sparkleshare.desktop");
|
||||
|
||||
}
|
||||
if (!File.Exists (desktopfile_path)) {
|
||||
if (!Directory.Exists (apps_path))
|
||||
Directory.CreateDirectory (apps_path);
|
||||
|
||||
}
|
||||
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Comment=Share documents\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"Categories=Network;");
|
||||
writer.Close ();
|
||||
|
||||
// Installs a launcher so the user can launch SparkleShare
|
||||
// from the Internet category if needed
|
||||
public override void InstallLauncher ()
|
||||
{
|
||||
|
||||
string apps_path = SparkleHelpers.CombineMore (SparklePaths.HomePath, ".local", "share", "applications");
|
||||
string desktopfile_path = SparkleHelpers.CombineMore (apps_path, "sparkleshare.desktop");
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
UnixFileInfo file_info = new UnixFileInfo (desktopfile_path);
|
||||
file_info.FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute;
|
||||
|
||||
if (!File.Exists (desktopfile_path)) {
|
||||
|
||||
if (!Directory.Exists (apps_path))
|
||||
Directory.CreateDirectory (apps_path);
|
||||
|
||||
TextWriter writer = new StreamWriter (desktopfile_path);
|
||||
writer.WriteLine ("[Desktop Entry]\n" +
|
||||
"Type=Application\n" +
|
||||
"Name=SparkleShare\n" +
|
||||
"Comment=Share documents\n" +
|
||||
"Exec=sparkleshare start\n" +
|
||||
"Icon=folder-sparkleshare\n" +
|
||||
"Terminal=false\n" +
|
||||
"Categories=Network;");
|
||||
writer.Close ();
|
||||
|
||||
// Give the launcher the right permissions so it can be launched by the user
|
||||
UnixFileInfo file_info = new UnixFileInfo (desktopfile_path);
|
||||
file_info.FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute;
|
||||
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created '" + desktopfile_path + "'");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created '" + desktopfile_path + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Adds the SparkleShare folder to the user's
|
||||
// list of bookmarked places
|
||||
public override void AddToBookmarks ()
|
||||
{
|
||||
// Adds the SparkleShare folder to the user's
|
||||
// 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 (SparklePaths.HomePath, ".gtk-bookmarks");
|
||||
string sparkleshare_bookmark = "file://" + SparklePaths.SparklePath + " SparkleShare";
|
||||
if (File.Exists (bookmarks_file_path)) {
|
||||
StreamReader reader = new StreamReader (bookmarks_file_path);
|
||||
string bookmarks = reader.ReadToEnd ();
|
||||
reader.Close ();
|
||||
|
||||
if (File.Exists (bookmarks_file_path)) {
|
||||
|
||||
StreamReader reader = new StreamReader (bookmarks_file_path);
|
||||
string bookmarks = reader.ReadToEnd ();
|
||||
reader.Close ();
|
||||
|
||||
if (!bookmarks.Contains (sparkleshare_bookmark)) {
|
||||
|
||||
TextWriter writer = File.AppendText (bookmarks_file_path);
|
||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
||||
writer.Close ();
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
StreamWriter writer = new StreamWriter (bookmarks_file_path);
|
||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
||||
writer.Close ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (!bookmarks.Contains (sparkleshare_bookmark)) {
|
||||
TextWriter writer = File.AppendText (bookmarks_file_path);
|
||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
||||
writer.Close ();
|
||||
}
|
||||
} else {
|
||||
StreamWriter writer = new StreamWriter (bookmarks_file_path);
|
||||
writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare");
|
||||
writer.Close ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Creates the SparkleShare folder in the user's home folder
|
||||
public override bool CreateSparkleShareFolder ()
|
||||
{
|
||||
// Creates the SparkleShare folder in the user's home folder
|
||||
public override bool CreateSparkleShareFolder ()
|
||||
{
|
||||
if (!Directory.Exists (SparklePaths.SparklePath)) {
|
||||
|
||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created '" + SparklePaths.SparklePath + "'");
|
||||
|
||||
if (!Directory.Exists (SparklePaths.SparklePath)) {
|
||||
|
||||
Directory.CreateDirectory (SparklePaths.SparklePath);
|
||||
SparkleHelpers.DebugInfo ("Controller", "Created '" + SparklePaths.SparklePath + "'");
|
||||
string icon_file_path = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "icons", "hicolor",
|
||||
"48x48", "apps", "folder-sparkleshare.png");
|
||||
|
||||
string icon_file_path = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "icons", "hicolor",
|
||||
"48x48", "apps", "folder-sparkleshare.png");
|
||||
string gvfs_command_path = SparkleHelpers.CombineMore (Path.VolumeSeparatorChar.ToString (),
|
||||
"usr", "bin", "gvfs-set-attribute");
|
||||
|
||||
string gvfs_command_path = SparkleHelpers.CombineMore (Path.VolumeSeparatorChar.ToString (),
|
||||
"usr", "bin", "gvfs-set-attribute");
|
||||
// Add a special icon to the SparkleShare folder
|
||||
if (File.Exists (gvfs_command_path)) {
|
||||
Process process = new Process ();
|
||||
|
||||
// Add a special icon to the SparkleShare folder
|
||||
if (File.Exists (gvfs_command_path)) {
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.FileName = "gvfs-set-attribute";
|
||||
process.StartInfo.Arguments = SparklePaths.SparklePath + " metadata::custom-icon " +
|
||||
"file://" + icon_file_path;
|
||||
process.Start ();
|
||||
}
|
||||
|
||||
Process process = new Process ();
|
||||
return true;
|
||||
}
|
||||
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
process.StartInfo.FileName = "gvfs-set-attribute";
|
||||
process.StartInfo.Arguments = SparklePaths.SparklePath + " metadata::custom-icon " +
|
||||
"file://" + icon_file_path;
|
||||
process.Start ();
|
||||
public override string EventLogHTML {
|
||||
get {
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "event-log.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override string DayEntryHTML {
|
||||
get {
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "day-entry.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
public override string EventEntryHTML {
|
||||
get {
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "event-entry.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void OpenSparkleShareFolder (string subfolder)
|
||||
{
|
||||
string open_command_path = SparkleHelpers.CombineMore (Path.VolumeSeparatorChar.ToString (),
|
||||
"usr", "bin", "xdg-open");
|
||||
|
||||
return false;
|
||||
if (!File.Exists (open_command_path))
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override string EventLogHTML {
|
||||
|
||||
get {
|
||||
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "event-log.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override string DayEntryHTML {
|
||||
|
||||
get {
|
||||
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "day-entry.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override string EventEntryHTML {
|
||||
|
||||
get {
|
||||
|
||||
string path = SparkleHelpers.CombineMore (Defines.PREFIX,
|
||||
"share", "sparkleshare", "html", "event-entry.html");
|
||||
|
||||
return String.Join (Environment.NewLine, File.ReadAllLines (path));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void OpenSparkleShareFolder (string subfolder)
|
||||
{
|
||||
|
||||
string open_command_path = SparkleHelpers.CombineMore (Path.VolumeSeparatorChar.ToString (),
|
||||
"usr", "bin", "xdg-open");
|
||||
|
||||
if (!File.Exists (open_command_path))
|
||||
return;
|
||||
|
||||
string folder = SparkleHelpers.CombineMore (SparklePaths.SparklePath, subfolder);
|
||||
|
||||
Process process = new Process ();
|
||||
process.StartInfo.Arguments = folder.Replace (" ", "\\ "); // Escape space-characters
|
||||
process.StartInfo.FileName = "xdg-open";
|
||||
process.Start ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
string folder = SparkleHelpers.CombineMore (SparklePaths.SparklePath, subfolder);
|
||||
|
||||
Process process = new Process ();
|
||||
process.StartInfo.Arguments = folder.Replace (" ", "\\ "); // Escape space-characters
|
||||
process.StartInfo.FileName = "xdg-open";
|
||||
process.Start ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,118 +23,46 @@ using System.Security.Cryptography;
|
|||
using System.Text;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
public static class SparkleUIHelpers {
|
||||
|
||||
// Creates an MD5 hash of input
|
||||
public static string GetMD5 (string s)
|
||||
{
|
||||
MD5 md5 = new MD5CryptoServiceProvider ();
|
||||
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||
Byte[] encodedBytes = md5.ComputeHash (bytes);
|
||||
return BitConverter.ToString (encodedBytes).ToLower ().Replace ("-", "");
|
||||
}
|
||||
public static class SparkleUIHelpers {
|
||||
|
||||
// Creates an MD5 hash of input
|
||||
public static string GetMD5 (string s)
|
||||
{
|
||||
MD5 md5 = new MD5CryptoServiceProvider ();
|
||||
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
|
||||
Byte[] encodedBytes = md5.ComputeHash (bytes);
|
||||
return BitConverter.ToString (encodedBytes).ToLower ().Replace ("-", "");
|
||||
}
|
||||
|
||||
|
||||
// Gets the avatar for a specific email address and size
|
||||
public static string GetAvatar (string email, int size)
|
||||
{
|
||||
// Looks up an icon from the system's theme
|
||||
public static Gdk.Pixbuf GetIcon (string name, int size)
|
||||
{
|
||||
IconTheme icon_theme = new IconTheme ();
|
||||
icon_theme.AppendSearchPath (SparklePaths.SparkleIconPath);
|
||||
icon_theme.AppendSearchPath (SparklePaths.SparkleLocalIconPath);
|
||||
|
||||
string avatar_path = SparkleHelpers.CombineMore (SparklePaths.SparkleLocalIconPath,
|
||||
size + "x" + size, "status");
|
||||
|
||||
if (!Directory.Exists (avatar_path)) {
|
||||
|
||||
Directory.CreateDirectory (avatar_path);
|
||||
SparkleHelpers.DebugInfo ("Config", "Created '" + avatar_path + "'");
|
||||
|
||||
}
|
||||
|
||||
string avatar_file_path = SparkleHelpers.CombineMore (avatar_path, "avatar-" + email);
|
||||
|
||||
if (File.Exists (avatar_file_path)) {
|
||||
|
||||
return avatar_file_path;
|
||||
|
||||
} else {
|
||||
|
||||
// Let's try to get the person's gravatar for next time
|
||||
WebClient web_client = new WebClient ();
|
||||
Uri uri = new Uri ("http://www.gravatar.com/avatar/" + GetMD5 (email) +
|
||||
".jpg?s=" + size + "&d=404");
|
||||
|
||||
string tmp_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleTmpPath, email + size);
|
||||
|
||||
if (!File.Exists (tmp_file_path)) {
|
||||
|
||||
web_client.DownloadFileAsync (uri, tmp_file_path);
|
||||
|
||||
web_client.DownloadFileCompleted += delegate {
|
||||
|
||||
if (File.Exists (avatar_file_path))
|
||||
File.Delete (avatar_file_path);
|
||||
|
||||
FileInfo tmp_file_info = new FileInfo (tmp_file_path);
|
||||
|
||||
if (tmp_file_info.Length > 255)
|
||||
File.Move (tmp_file_path, avatar_file_path);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Fall back to a generic icon if there is no gravatar
|
||||
if (File.Exists (avatar_file_path))
|
||||
return avatar_file_path;
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
|
||||
} catch {
|
||||
try {
|
||||
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Looks up an icon from the system's theme
|
||||
public static Gdk.Pixbuf GetIcon (string name, int size)
|
||||
{
|
||||
|
||||
IconTheme icon_theme = new IconTheme ();
|
||||
icon_theme.AppendSearchPath (SparklePaths.SparkleIconPath);
|
||||
icon_theme.AppendSearchPath (SparklePaths.SparkleLocalIconPath);
|
||||
|
||||
try {
|
||||
|
||||
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
|
||||
|
||||
} catch {
|
||||
|
||||
try {
|
||||
|
||||
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);
|
||||
|
||||
} catch {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Converts a Gdk RGB color to a hex value.
|
||||
// Example: from "rgb:0,0,0" to "#000000"
|
||||
public static string GdkColorToHex (Gdk.Color color)
|
||||
{
|
||||
|
||||
return String.Format ("#{0:X2}{1:X2}{2:X2}",
|
||||
(int) Math.Truncate (color.Red / 256.00),
|
||||
(int) Math.Truncate (color.Green / 256.00),
|
||||
(int) Math.Truncate (color.Blue / 256.00));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Converts a Gdk RGB color to a hex value.
|
||||
// Example: from "rgb:0,0,0" to "#000000"
|
||||
public static string GdkColorToHex (Gdk.Color color)
|
||||
{
|
||||
return String.Format ("#{0:X2}{1:X2}{2:X2}",
|
||||
(int) Math.Truncate (color.Red / 256.00),
|
||||
(int) Math.Truncate (color.Green / 256.00),
|
||||
(int) Math.Truncate (color.Blue / 256.00));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +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 Mono.Unix;
|
||||
using SparkleLib;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -24,127 +22,113 @@ using System.IO;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
|
||||
using Gtk;
|
||||
using Mono.Unix;
|
||||
using SparkleLib;
|
||||
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleWindow : Window {
|
||||
public class SparkleWindow : Window {
|
||||
|
||||
private HBox HBox;
|
||||
private VBox VBox;
|
||||
private VBox Wrapper;
|
||||
private HButtonBox Buttons;
|
||||
private HBox HBox;
|
||||
private VBox VBox;
|
||||
private VBox Wrapper;
|
||||
private HButtonBox Buttons;
|
||||
|
||||
|
||||
public SparkleWindow () : base ("")
|
||||
{
|
||||
public SparkleWindow () : base ("")
|
||||
{
|
||||
Title = "SparkleShare Setup";
|
||||
BorderWidth = 0;
|
||||
IconName = "folder-sparkleshare";
|
||||
Resizable = false;
|
||||
WindowPosition = WindowPosition.Center;
|
||||
|
||||
Title = "SparkleShare Setup";
|
||||
BorderWidth = 0;
|
||||
IconName = "folder-sparkleshare";
|
||||
Resizable = false;
|
||||
WindowPosition = WindowPosition.Center;
|
||||
SetSizeRequest (680, 440);
|
||||
|
||||
SetSizeRequest (680, 440);
|
||||
DeleteEvent += delegate (object o, DeleteEventArgs args) {
|
||||
args.RetVal = true;
|
||||
Close ();
|
||||
};
|
||||
|
||||
DeleteEvent += delegate (object o, DeleteEventArgs args) {
|
||||
HBox = new HBox (false, 6);
|
||||
|
||||
args.RetVal = true;
|
||||
Close ();
|
||||
VBox = new VBox (false, 0);
|
||||
|
||||
};
|
||||
Wrapper = new VBox (false, 0) {
|
||||
BorderWidth = 30
|
||||
};
|
||||
|
||||
HBox = new HBox (false, 6);
|
||||
Buttons = CreateButtonBox ();
|
||||
|
||||
VBox = new VBox (false, 0);
|
||||
VBox.PackStart (Wrapper, true, true, 0);
|
||||
VBox.PackStart (Buttons, false, false, 0);
|
||||
|
||||
Wrapper = new VBox (false, 0) {
|
||||
BorderWidth = 30
|
||||
};
|
||||
EventBox box = new EventBox ();
|
||||
Gdk.Color bg_color = new Gdk.Color ();
|
||||
Gdk.Color.Parse ("#2e3336", ref bg_color);
|
||||
box.ModifyBg (StateType.Normal, bg_color);
|
||||
|
||||
Buttons = CreateButtonBox ();
|
||||
string image_path = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare",
|
||||
"pixmaps", "side-splash.png");
|
||||
|
||||
VBox.PackStart (Wrapper, true, true, 0);
|
||||
VBox.PackStart (Buttons, false, false, 0);
|
||||
Image side_splash = new Image (image_path) {
|
||||
Yalign = 1
|
||||
};
|
||||
|
||||
EventBox box = new EventBox ();
|
||||
Gdk.Color bg_color = new Gdk.Color ();
|
||||
Gdk.Color.Parse ("#2e3336", ref bg_color);
|
||||
box.ModifyBg (StateType.Normal, bg_color);
|
||||
box.Add (side_splash);
|
||||
|
||||
string image_path = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare",
|
||||
"pixmaps", "side-splash.png");
|
||||
HBox.PackStart (box, false, false, 0);
|
||||
HBox.PackStart (VBox, true, true, 0);
|
||||
|
||||
Image side_splash = new Image (image_path) {
|
||||
Yalign = 1
|
||||
};
|
||||
|
||||
box.Add (side_splash);
|
||||
|
||||
HBox.PackStart (box, false, false, 0);
|
||||
HBox.PackStart (VBox, true, true, 0);
|
||||
|
||||
base.Add (HBox);
|
||||
|
||||
}
|
||||
base.Add (HBox);
|
||||
}
|
||||
|
||||
|
||||
private HButtonBox CreateButtonBox ()
|
||||
{
|
||||
|
||||
return new HButtonBox () {
|
||||
BorderWidth = 12,
|
||||
Layout = ButtonBoxStyle.End,
|
||||
Spacing = 6
|
||||
};
|
||||
|
||||
}
|
||||
private HButtonBox CreateButtonBox ()
|
||||
{
|
||||
return new HButtonBox () {
|
||||
BorderWidth = 12,
|
||||
Layout = ButtonBoxStyle.End,
|
||||
Spacing = 6
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public void AddButton (Button button)
|
||||
{
|
||||
|
||||
Buttons.Add (button);
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
public void AddButton (Button button)
|
||||
{
|
||||
Buttons.Add (button);
|
||||
ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
new public void Add (Widget widget)
|
||||
{
|
||||
|
||||
Wrapper.PackStart (widget, true, true, 0);
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
new public void Add (Widget widget)
|
||||
{
|
||||
Wrapper.PackStart (widget, true, true, 0);
|
||||
ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
public void Reset ()
|
||||
{
|
||||
public void Reset ()
|
||||
{
|
||||
if (Wrapper.Children.Length > 0)
|
||||
Wrapper.Remove (Wrapper.Children [0]);
|
||||
|
||||
if (Wrapper.Children.Length > 0)
|
||||
Wrapper.Remove (Wrapper.Children [0]);
|
||||
foreach (Button button in Buttons)
|
||||
Buttons.Remove (button);
|
||||
|
||||
foreach (Button button in Buttons)
|
||||
Buttons.Remove (button);
|
||||
|
||||
ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
new public void ShowAll ()
|
||||
{
|
||||
|
||||
Present ();
|
||||
base.ShowAll ();
|
||||
|
||||
}
|
||||
|
||||
public void Close ()
|
||||
{
|
||||
|
||||
HideAll ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ShowAll ();
|
||||
}
|
||||
|
||||
new public void ShowAll ()
|
||||
{
|
||||
Present ();
|
||||
base.ShowAll ();
|
||||
}
|
||||
|
||||
public void Close ()
|
||||
{
|
||||
HideAll ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue