setup: Fix several bugs in the Add page
This commit is contained in:
parent
70d33e190a
commit
5c89909578
|
@ -19,7 +19,6 @@ SOURCES = \
|
|||
SparkleBubblesController.cs \
|
||||
SparkleController.cs \
|
||||
SparkleControllerBase.cs \
|
||||
SparkleEntry.cs \
|
||||
SparkleEventLog.cs \
|
||||
SparkleEventLogController.cs \
|
||||
SparkleExtensions.cs \
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
// SparkleShare, a collaboration and sharing tool.
|
||||
// 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 private 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
|
||||
// GNU General private License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General private License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
using Gtk;
|
||||
|
||||
// TODO: Remove with Gtk3
|
||||
namespace SparkleShare {
|
||||
|
||||
public class SparkleEntry : Entry {
|
||||
|
||||
|
||||
private string example_text;
|
||||
private bool example_text_active;
|
||||
|
||||
|
||||
public SparkleEntry ()
|
||||
{
|
||||
ExampleTextActive = true;
|
||||
|
||||
FocusGrabbed += delegate { OnEntered (); };
|
||||
ClipboardPasted += delegate { OnEntered (); };
|
||||
|
||||
FocusOutEvent += delegate {
|
||||
if (Text.Equals ("") || Text == null)
|
||||
ExampleTextActive = true;
|
||||
|
||||
if (ExampleTextActive)
|
||||
UseExampleText ();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void OnEntered ()
|
||||
{
|
||||
if (ExampleTextActive) {
|
||||
ExampleTextActive = false;
|
||||
Text = "";
|
||||
UseNormalTextColor ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool ExampleTextActive {
|
||||
get {
|
||||
return this.example_text_active;
|
||||
}
|
||||
|
||||
set {
|
||||
this.example_text_active = value;
|
||||
|
||||
if (this.example_text_active)
|
||||
UseSecondaryTextColor ();
|
||||
else
|
||||
UseNormalTextColor ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string ExampleText
|
||||
{
|
||||
get {
|
||||
return this.example_text;
|
||||
}
|
||||
|
||||
set {
|
||||
this.example_text = value;
|
||||
|
||||
if (this.example_text_active)
|
||||
UseExampleText ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void UseExampleText ()
|
||||
{
|
||||
Text = this.example_text;
|
||||
UseSecondaryTextColor ();
|
||||
}
|
||||
|
||||
|
||||
private void UseSecondaryTextColor ()
|
||||
{
|
||||
ModifyText (StateType.Normal, Style.Foreground (StateType.Insensitive));
|
||||
}
|
||||
|
||||
|
||||
private void UseNormalTextColor ()
|
||||
{
|
||||
ModifyText (StateType.Normal, Style.Foreground (StateType.Normal));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,9 +31,6 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleSetupController Controller = new SparkleSetupController ();
|
||||
|
||||
private string SecondaryTextColor;
|
||||
private string SecondaryTextColorSelected;
|
||||
|
||||
private ProgressBar progress_bar = new ProgressBar ();
|
||||
|
||||
|
||||
|
@ -46,17 +43,6 @@ namespace SparkleShare {
|
|||
|
||||
public SparkleSetup () : base ()
|
||||
{
|
||||
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
||||
SecondaryTextColorSelected =
|
||||
SparkleUIHelpers.GdkColorToHex (
|
||||
MixColors (
|
||||
new TreeView ().Style.Foreground (StateType.Selected),
|
||||
new TreeView ().Style.Background (StateType.Selected),
|
||||
0.15
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Controller.HideWindowEvent += delegate {
|
||||
Application.Invoke (delegate {
|
||||
HideAll ();
|
||||
|
@ -186,8 +172,10 @@ namespace SparkleShare {
|
|||
|
||||
tree.AppendColumn (service_column);
|
||||
|
||||
SparkleEntry path_entry = new SparkleEntry ();
|
||||
SparkleEntry address_entry = new SparkleEntry ();
|
||||
Entry address_entry = new Entry ();
|
||||
Entry path_entry = new Entry ();
|
||||
Label address_example = new Label ("1") { Xalign = 0, UseMarkup = true };
|
||||
Label path_example = new Label ("2") { Xalign = 0, UseMarkup = true };
|
||||
|
||||
|
||||
// Select the first plugin by default
|
||||
|
@ -202,16 +190,9 @@ namespace SparkleShare {
|
|||
Application.Invoke (delegate {
|
||||
address_entry.Text = text;
|
||||
address_entry.Sensitive = (state == FieldState.Enabled);
|
||||
address_example.Markup = "<span size=\"small\" fgcolor=\""
|
||||
+ SecondaryTextColor + "\">" + example_text + "</span>";
|
||||
|
||||
if (string.IsNullOrEmpty (example_text))
|
||||
address_entry.ExampleText = null;
|
||||
else
|
||||
address_entry.ExampleText = example_text;
|
||||
|
||||
if (string.IsNullOrEmpty (text))
|
||||
address_entry.ExampleTextActive = true;
|
||||
else
|
||||
address_entry.ExampleTextActive = false;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -221,20 +202,12 @@ namespace SparkleShare {
|
|||
Application.Invoke (delegate {
|
||||
path_entry.Text = text;
|
||||
path_entry.Sensitive = (state == FieldState.Enabled);
|
||||
|
||||
// TODO: Use small labels like the mac UI
|
||||
if (string.IsNullOrEmpty (example_text))
|
||||
path_entry.ExampleText = null;
|
||||
else
|
||||
path_entry.ExampleText = example_text;
|
||||
|
||||
if (string.IsNullOrEmpty (text))
|
||||
path_entry.ExampleTextActive = true;
|
||||
else
|
||||
path_entry.ExampleTextActive = false;
|
||||
path_example.Markup = "<span size=\"small\" fgcolor=\""
|
||||
+ SecondaryTextColor + "\">" + example_text + "</span>";
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Update the address field text when the selection changes
|
||||
tree.CursorChanged += delegate (object sender, EventArgs e) {
|
||||
Controller.SelectedPluginChanged (tree.SelectedRow);
|
||||
|
@ -291,7 +264,8 @@ namespace SparkleShare {
|
|||
Xalign = 0
|
||||
}, true, true, 0);
|
||||
|
||||
layout_address.PackStart (address_entry, true, true, 0);
|
||||
layout_address.PackStart (address_entry, false, false, 0);
|
||||
layout_address.PackStart (address_example, false, false, 0);
|
||||
|
||||
path_entry.Completion = new EntryCompletion();
|
||||
|
||||
|
@ -312,7 +286,8 @@ namespace SparkleShare {
|
|||
Xalign = 0
|
||||
}, true, true, 0);
|
||||
|
||||
layout_path.PackStart (path_entry, true, true, 0);
|
||||
layout_path.PackStart (path_entry, false, false, 0);
|
||||
layout_path.PackStart (path_example, false, false, 0);
|
||||
|
||||
layout_fields.PackStart (layout_address);
|
||||
layout_fields.PackStart (layout_path);
|
||||
|
@ -330,7 +305,6 @@ namespace SparkleShare {
|
|||
Controller.PageCancelled ();
|
||||
};
|
||||
|
||||
// Sync button
|
||||
Button add_button = new Button (_("Add"));
|
||||
|
||||
add_button.Clicked += delegate {
|
||||
|
@ -340,10 +314,16 @@ namespace SparkleShare {
|
|||
Controller.AddPageCompleted (server, folder_name);
|
||||
};
|
||||
|
||||
Controller.UpdateAddProjectButtonEvent += delegate (bool button_enabled) {
|
||||
Application.Invoke (delegate {
|
||||
add_button.Sensitive = button_enabled;
|
||||
});
|
||||
};
|
||||
|
||||
AddButton (cancel_button);
|
||||
AddButton (add_button);
|
||||
|
||||
Controller.CheckAddPage (address_entry.Text, path_entry.Text, tree.SelectedRow);
|
||||
Controller.CheckAddPage (address_entry.Text, path_entry.Text, 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -629,19 +609,6 @@ namespace SparkleShare {
|
|||
|
||||
(cell as CellRendererText).Markup = markup;
|
||||
}
|
||||
|
||||
|
||||
private Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio)
|
||||
{
|
||||
return new Gdk.Color (
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) +
|
||||
second_color.Red * ratio))) / 65535),
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) +
|
||||
second_color.Green * ratio))) / 65535),
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) +
|
||||
second_color.Blue * ratio))) / 65535)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@ namespace SparkleShare {
|
|||
public string Header;
|
||||
public string Description;
|
||||
|
||||
public string SecondaryTextColor;
|
||||
public string SecondaryTextColorSelected;
|
||||
|
||||
public Container Content;
|
||||
|
||||
public SparkleSetupWindow () : base ("")
|
||||
|
@ -48,20 +51,31 @@ namespace SparkleShare {
|
|||
WindowPosition = WindowPosition.Center;
|
||||
Deletable = false;
|
||||
|
||||
SetSizeRequest (680, 440);
|
||||
SecondaryTextColor = SparkleUIHelpers.GdkColorToHex (Style.Foreground (StateType.Insensitive));
|
||||
|
||||
HBox = new HBox (false, 6);
|
||||
SecondaryTextColorSelected =
|
||||
SparkleUIHelpers.GdkColorToHex (
|
||||
MixColors (
|
||||
new TreeView ().Style.Foreground (StateType.Selected),
|
||||
new TreeView ().Style.Background (StateType.Selected),
|
||||
0.15
|
||||
)
|
||||
);
|
||||
|
||||
SetSizeRequest (680, 400);
|
||||
|
||||
HBox = new HBox (false, 0);
|
||||
|
||||
VBox = new VBox (false, 0);
|
||||
|
||||
Wrapper = new VBox (false, 0) {
|
||||
BorderWidth = 30
|
||||
BorderWidth = 0
|
||||
};
|
||||
|
||||
Buttons = CreateButtonBox ();
|
||||
|
||||
VBox.PackStart (Wrapper, true, true, 0);
|
||||
VBox.PackStart (Buttons, false, false, 0);
|
||||
VBox.PackStart (Buttons, false, false, 15);
|
||||
|
||||
EventBox box = new EventBox ();
|
||||
Gdk.Color bg_color = new Gdk.Color ();
|
||||
|
@ -74,7 +88,7 @@ namespace SparkleShare {
|
|||
box.Add (side_splash);
|
||||
|
||||
HBox.PackStart (box, false, false, 0);
|
||||
HBox.PackStart (VBox, true, true, 0);
|
||||
HBox.PackStart (VBox, true, true, 30);
|
||||
|
||||
base.Add (HBox);
|
||||
}
|
||||
|
@ -83,7 +97,7 @@ namespace SparkleShare {
|
|||
private HButtonBox CreateButtonBox ()
|
||||
{
|
||||
return new HButtonBox () {
|
||||
BorderWidth = 12,
|
||||
BorderWidth = 0,
|
||||
Layout = ButtonBoxStyle.End,
|
||||
Spacing = 6
|
||||
};
|
||||
|
@ -101,7 +115,7 @@ namespace SparkleShare {
|
|||
{
|
||||
Label header = new Label ("<span size='large'><b>" + Header + "</b></span>") {
|
||||
UseMarkup = true,
|
||||
Xalign = 0
|
||||
Xalign = 0,
|
||||
};
|
||||
|
||||
Label description = new Label (Description) {
|
||||
|
@ -110,6 +124,7 @@ namespace SparkleShare {
|
|||
};
|
||||
|
||||
VBox layout_vertical = new VBox (false, 0);
|
||||
layout_vertical.PackStart (new Label (""), false, false, 6);
|
||||
layout_vertical.PackStart (header, false, false, 0);
|
||||
|
||||
if (!string.IsNullOrEmpty (Description))
|
||||
|
@ -137,10 +152,24 @@ namespace SparkleShare {
|
|||
ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
new public void ShowAll ()
|
||||
{
|
||||
Present ();
|
||||
base.ShowAll ();
|
||||
}
|
||||
|
||||
|
||||
private Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio)
|
||||
{
|
||||
return new Gdk.Color (
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) +
|
||||
second_color.Red * ratio))) / 65535),
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) +
|
||||
second_color.Green * ratio))) / 65535),
|
||||
Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) +
|
||||
second_color.Blue * ratio))) / 65535)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue