/SparkleShare/SparkleSetupWindow.cs

http://github.com/hbons/SparkleShare · C# · 156 lines · 102 code · 39 blank · 15 comment · 4 complexity · 8a7c27478818f87e1345f8e2af958a23 MD5 · raw file

  1. // SparkleShare, a collaboration and sharing tool.
  2. // Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Diagnostics;
  19. using System.IO;
  20. using System.Text.RegularExpressions;
  21. using System.Timers;
  22. using Gtk;
  23. using Mono.Unix;
  24. namespace SparkleShare {
  25. public class SparkleSetupWindow : Window {
  26. private HBox HBox;
  27. private VBox VBox;
  28. private VBox Wrapper;
  29. private HButtonBox Buttons;
  30. public string Header;
  31. public string Description;
  32. public Container Content;
  33. public SparkleSetupWindow () : base ("")
  34. {
  35. Title = Catalog.GetString ("SparkleShare Setup");
  36. BorderWidth = 0;
  37. IconName = "folder-sparkleshare";
  38. Resizable = false;
  39. WindowPosition = WindowPosition.Center;
  40. Deletable = false;
  41. SetSizeRequest (680, 440);
  42. DeleteEvent += delegate (object o, DeleteEventArgs args) {
  43. args.RetVal = true;
  44. Close ();
  45. };
  46. HBox = new HBox (false, 6);
  47. VBox = new VBox (false, 0);
  48. Wrapper = new VBox (false, 0) {
  49. BorderWidth = 30
  50. };
  51. Buttons = CreateButtonBox ();
  52. VBox.PackStart (Wrapper, true, true, 0);
  53. VBox.PackStart (Buttons, false, false, 0);
  54. EventBox box = new EventBox ();
  55. Gdk.Color bg_color = new Gdk.Color ();
  56. Gdk.Color.Parse ("#000", ref bg_color);
  57. box.ModifyBg (StateType.Normal, bg_color);
  58. Image side_splash = SparkleUIHelpers.GetImage ("side-splash.png");
  59. side_splash.Yalign = 1;
  60. box.Add (side_splash);
  61. HBox.PackStart (box, false, false, 0);
  62. HBox.PackStart (VBox, true, true, 0);
  63. base.Add (HBox);
  64. }
  65. private HButtonBox CreateButtonBox ()
  66. {
  67. return new HButtonBox () {
  68. BorderWidth = 12,
  69. Layout = ButtonBoxStyle.End,
  70. Spacing = 6
  71. };
  72. }
  73. public void AddButton (Button button)
  74. {
  75. Buttons.Add (button);
  76. ShowAll ();
  77. }
  78. new public void Add (Widget widget)
  79. {
  80. Label header = new Label ("<span size='large'><b>" + Header + "</b></span>") {
  81. UseMarkup = true,
  82. Xalign = 0
  83. };
  84. Label description = new Label (Description) {
  85. Xalign = 0,
  86. Wrap = true
  87. };
  88. VBox layout_vertical = new VBox (false, 0);
  89. layout_vertical.PackStart (header, false, false, 0);
  90. if (!string.IsNullOrEmpty (Description))
  91. layout_vertical.PackStart (description, false, false, 21);
  92. if (widget != null)
  93. layout_vertical.PackStart (widget, true, true, 0);
  94. Wrapper.PackStart (layout_vertical, true, true, 0);
  95. ShowAll ();
  96. }
  97. public void Reset ()
  98. {
  99. Header = "";
  100. Description = "";
  101. if (Wrapper.Children.Length > 0)
  102. Wrapper.Remove (Wrapper.Children [0]);
  103. foreach (Button button in Buttons)
  104. Buttons.Remove (button);
  105. ShowAll ();
  106. }
  107. new public void ShowAll ()
  108. {
  109. Present ();
  110. base.ShowAll ();
  111. }
  112. public void Close ()
  113. {
  114. HideAll ();
  115. }
  116. }
  117. }