SparkleShare/SparkleShare/SparkleWindow.cs

135 lines
3.6 KiB
C#
Raw Normal View History

// SparkleShare, a collaboration and sharing tool.
2010-07-04 18:11:41 +00:00
// Copyright (C) 2010 Hylke Bons <hylkebons@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2010-07-04 18:11:41 +00:00
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
2010-07-24 21:31:24 +00:00
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-07-04 18:11:41 +00:00
2010-07-04 18:11:41 +00:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Timers;
using Gtk;
using Mono.Unix;
using SparkleLib;
2011-03-15 14:47:46 +00:00
namespace SparkleShare {
2011-03-15 14:47:46 +00:00
public class SparkleWindow : Window {
2011-03-15 14:47:46 +00:00
private HBox HBox;
private VBox VBox;
private VBox Wrapper;
private HButtonBox Buttons;
2011-03-15 14:47:46 +00:00
2010-08-14 14:08:04 +00:00
public SparkleWindow () : base ("")
{
2011-05-28 16:24:17 +00:00
Title = Catalog.GetString ("SparkleShare Setup");
BorderWidth = 0;
IconName = "folder-sparkleshare";
Resizable = false;
WindowPosition = WindowPosition.Center;
2010-07-04 18:11:41 +00:00
SetSizeRequest (680, 440);
2010-07-04 18:11:41 +00:00
DeleteEvent += delegate (object o, DeleteEventArgs args) {
args.RetVal = true;
Close ();
};
2010-07-04 18:11:41 +00:00
HBox = new HBox (false, 6);
2010-07-04 18:11:41 +00:00
VBox = new VBox (false, 0);
2010-07-04 18:11:41 +00:00
Wrapper = new VBox (false, 0) {
BorderWidth = 30
};
Buttons = CreateButtonBox ();
VBox.PackStart (Wrapper, true, true, 0);
VBox.PackStart (Buttons, false, false, 0);
EventBox box = new EventBox ();
Gdk.Color bg_color = new Gdk.Color ();
Gdk.Color.Parse ("#2e3336", ref bg_color);
box.ModifyBg (StateType.Normal, bg_color);
string image_path = SparkleHelpers.CombineMore (Defines.DATAROOTDIR, "sparkleshare",
"pixmaps", "side-splash.png");
2010-07-04 18:11:41 +00:00
Image side_splash = new Image (image_path) {
Yalign = 1
};
2010-07-04 18:11:41 +00:00
box.Add (side_splash);
2010-07-04 18:11:41 +00:00
HBox.PackStart (box, false, false, 0);
HBox.PackStart (VBox, true, true, 0);
2010-07-23 00:01:01 +00:00
base.Add (HBox);
}
2010-07-04 18:11:41 +00:00
private HButtonBox CreateButtonBox ()
{
return new HButtonBox () {
BorderWidth = 12,
Layout = ButtonBoxStyle.End,
Spacing = 6
};
}
2010-07-04 18:11:41 +00:00
public void AddButton (Button button)
{
Buttons.Add (button);
ShowAll ();
}
2010-07-04 18:11:41 +00:00
new public void Add (Widget widget)
{
Wrapper.PackStart (widget, true, true, 0);
ShowAll ();
}
2010-07-04 18:11:41 +00:00
2011-03-16 00:01:20 +00:00
public void Reset ()
{
if (Wrapper.Children.Length > 0)
Wrapper.Remove (Wrapper.Children [0]);
2011-03-16 00:01:20 +00:00
foreach (Button button in Buttons)
Buttons.Remove (button);
2011-03-16 00:01:20 +00:00
ShowAll ();
}
new public void ShowAll ()
{
Present ();
base.ShowAll ();
}
2010-07-04 18:11:41 +00:00
public void Close ()
{
HideAll ();
}
}
2010-07-04 18:11:41 +00:00
}