PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 17
 18using System;
 19using System.Collections.Generic;
 20using System.Diagnostics;
 21using System.IO;
 22using System.Text.RegularExpressions;
 23using System.Timers;
 24
 25using Gtk;
 26using Mono.Unix;
 27
 28namespace SparkleShare {
 29
 30    public class SparkleSetupWindow : Window    {
 31
 32        private HBox HBox;
 33        private VBox VBox;
 34        private VBox Wrapper;
 35        private HButtonBox Buttons;
 36
 37        public string Header;
 38        public string Description;
 39
 40        public Container Content;
 41
 42        public SparkleSetupWindow () : base ("")
 43        {
 44            Title          = Catalog.GetString ("SparkleShare Setup");
 45            BorderWidth    = 0;
 46            IconName       = "folder-sparkleshare";
 47            Resizable      = false;
 48            WindowPosition = WindowPosition.Center;
 49            Deletable      = false;
 50
 51            SetSizeRequest (680, 440);
 52
 53            DeleteEvent += delegate (object o, DeleteEventArgs args) {
 54                args.RetVal = true;
 55                Close ();
 56            };
 57
 58            HBox = new HBox (false, 6);
 59
 60                VBox = new VBox (false, 0);
 61
 62                    Wrapper = new VBox (false, 0) {
 63                        BorderWidth = 30
 64                    };
 65
 66                    Buttons = CreateButtonBox ();
 67
 68                VBox.PackStart (Wrapper, true, true, 0);
 69                VBox.PackStart (Buttons, false, false, 0);
 70
 71                EventBox box = new EventBox ();
 72                Gdk.Color bg_color = new Gdk.Color ();
 73                Gdk.Color.Parse ("#000", ref bg_color);
 74                box.ModifyBg (StateType.Normal, bg_color);
 75
 76                Image side_splash = SparkleUIHelpers.GetImage ("side-splash.png");
 77                side_splash.Yalign = 1;
 78
 79            box.Add (side_splash);
 80
 81            HBox.PackStart (box, false, false, 0);
 82            HBox.PackStart (VBox, true, true, 0);
 83
 84            base.Add (HBox);
 85        }
 86
 87
 88        private HButtonBox CreateButtonBox ()
 89        {
 90            return new HButtonBox () {
 91                BorderWidth = 12,
 92                Layout      = ButtonBoxStyle.End,
 93                Spacing     = 6
 94            };
 95        }
 96
 97
 98        public void AddButton (Button button)
 99        {
100            Buttons.Add (button);
101            ShowAll ();
102        }
103
104
105        new public void Add (Widget widget)
106        {
107            Label header = new Label ("<span size='large'><b>" + Header + "</b></span>") {
108                UseMarkup = true,
109                Xalign = 0
110            };
111
112            Label description = new Label (Description) {
113                Xalign = 0,
114                Wrap   = true
115            };
116
117            VBox layout_vertical = new VBox (false, 0);
118            layout_vertical.PackStart (header, false, false, 0);
119
120            if (!string.IsNullOrEmpty (Description))
121                layout_vertical.PackStart (description, false, false, 21);
122
123            if (widget != null)
124                layout_vertical.PackStart (widget, true, true, 0);
125
126            Wrapper.PackStart (layout_vertical, true, true, 0);
127            ShowAll ();
128        }
129
130
131        public void Reset ()
132        {
133            Header      = "";
134            Description = "";
135
136            if (Wrapper.Children.Length > 0)
137                Wrapper.Remove (Wrapper.Children [0]);
138
139            foreach (Button button in Buttons)
140                Buttons.Remove (button);
141
142            ShowAll ();
143        }
144        
145        new public void ShowAll ()
146        {
147            Present ();
148            base.ShowAll ();
149        }
150
151        public void Close ()
152        {
153            HideAll ();
154        }
155    }
156}