add SparkleEntry: a widget that can have greyed out default text
This commit is contained in:
parent
35f1ff341b
commit
77552061c1
|
@ -66,9 +66,9 @@ namespace SparkleShare {
|
||||||
Viewport = new Viewport ();
|
Viewport = new Viewport ();
|
||||||
Viewport.Add (new Label (""));
|
Viewport.Add (new Label (""));
|
||||||
|
|
||||||
Store = new ListStore(typeof (Gdk.Pixbuf),
|
Store = new ListStore (typeof (Gdk.Pixbuf),
|
||||||
typeof (string),
|
typeof (string),
|
||||||
typeof (int));
|
typeof (int));
|
||||||
|
|
||||||
IconView = new IconView (Store);
|
IconView = new IconView (Store);
|
||||||
IconView.SelectionChanged += ChangeSelection;
|
IconView.SelectionChanged += ChangeSelection;
|
||||||
|
|
|
@ -9,6 +9,7 @@ LINK = $(REF_SPARKLESHARE)
|
||||||
|
|
||||||
SOURCES = \
|
SOURCES = \
|
||||||
SparkleBubble.cs \
|
SparkleBubble.cs \
|
||||||
|
SparkleEntry.cs \
|
||||||
SparkleIntro.cs \
|
SparkleIntro.cs \
|
||||||
SparkleShare.cs \
|
SparkleShare.cs \
|
||||||
SparkleSpinner.cs \
|
SparkleSpinner.cs \
|
||||||
|
|
111
SparkleShare/SparkleEntry.cs
Normal file
111
SparkleShare/SparkleEntry.cs
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
// SparkleShare, an instant update workflow to Git.
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
public class SparkleEntry : Entry {
|
||||||
|
|
||||||
|
private bool ExampleTextActive;
|
||||||
|
private string pExampleText;
|
||||||
|
|
||||||
|
|
||||||
|
public SparkleEntry ()
|
||||||
|
{
|
||||||
|
|
||||||
|
ExampleTextActive = true;
|
||||||
|
|
||||||
|
FocusGrabbed += delegate {
|
||||||
|
|
||||||
|
if (ExampleTextActive) {
|
||||||
|
|
||||||
|
ExampleTextActive = false;
|
||||||
|
Text = "";
|
||||||
|
UseNormalTextColor ();
|
||||||
|
// ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
FocusOutEvent += delegate {
|
||||||
|
|
||||||
|
if (Text.Equals ("") || Text == null) {
|
||||||
|
ExampleTextActive = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ExampleTextActive)
|
||||||
|
UseExampleText ();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string ExampleText
|
||||||
|
{
|
||||||
|
|
||||||
|
get {
|
||||||
|
|
||||||
|
return pExampleText;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
set {
|
||||||
|
|
||||||
|
pExampleText = value;
|
||||||
|
|
||||||
|
if (ExampleTextActive) {
|
||||||
|
|
||||||
|
UseExampleText ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void UseExampleText ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Text = pExampleText;
|
||||||
|
UseSecondaryTextColor ();
|
||||||
|
// ShowAll ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void UseSecondaryTextColor ()
|
||||||
|
{
|
||||||
|
|
||||||
|
ModifyText (StateType.Normal, Style.Foreground (StateType.Insensitive));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void UseNormalTextColor ()
|
||||||
|
{
|
||||||
|
|
||||||
|
ModifyText (StateType.Normal, Style.Foreground (StateType.Normal));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,8 +28,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
private Entry NameEntry;
|
private Entry NameEntry;
|
||||||
private Entry EmailEntry;
|
private Entry EmailEntry;
|
||||||
private Entry ServerEntry;
|
private SparkleEntry ServerEntry;
|
||||||
private Entry FolderEntry;
|
private SparkleEntry FolderEntry;
|
||||||
private Button NextButton;
|
private Button NextButton;
|
||||||
private Button AddButton;
|
private Button AddButton;
|
||||||
private bool StepTwoOnly;
|
private bool StepTwoOnly;
|
||||||
|
@ -208,7 +208,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
HBox layout_server = new HBox (true, 0);
|
HBox layout_server = new HBox (true, 0);
|
||||||
|
|
||||||
ServerEntry = new Entry (_("ssh://address-to-my-server/"));
|
ServerEntry = new SparkleEntry () {
|
||||||
|
ExampleText = _("ssh://address-to-my-server/")
|
||||||
|
};
|
||||||
|
|
||||||
ServerEntry.Changed += CheckStepTwoFields;
|
ServerEntry.Changed += CheckStepTwoFields;
|
||||||
|
|
||||||
|
@ -252,18 +254,39 @@ namespace SparkleShare {
|
||||||
(radio_button_gitorious.Child as Label).UseMarkup = true;
|
(radio_button_gitorious.Child as Label).UseMarkup = true;
|
||||||
(radio_button_gitorious.Child as Label).Wrap = true;
|
(radio_button_gitorious.Child as Label).Wrap = true;
|
||||||
|
|
||||||
|
radio_button_github.Toggled += delegate {
|
||||||
|
|
||||||
|
if (radio_button_github.Active)
|
||||||
|
FolderEntry.ExampleText = "Username/Folder";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
radio_button_gitorious.Toggled += delegate {
|
||||||
|
|
||||||
|
if (radio_button_gitorious.Active)
|
||||||
|
FolderEntry.ExampleText = "Project/Folder";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
radio_button_gnome.Toggled += delegate {
|
||||||
|
|
||||||
|
if (radio_button_gnome.Active)
|
||||||
|
FolderEntry.ExampleText = "Project";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
radio_button.Toggled += delegate {
|
radio_button.Toggled += delegate {
|
||||||
|
|
||||||
if (radio_button.Active) {
|
if (radio_button.Active) {
|
||||||
|
|
||||||
ServerEntry.Sensitive = true;
|
FolderEntry.ExampleText = "Folder";
|
||||||
|
ServerEntry.Sensitive = true;
|
||||||
CheckStepTwoFields ();
|
CheckStepTwoFields ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ServerEntry.Sensitive = false;
|
ServerEntry.Sensitive = false;
|
||||||
|
|
||||||
CheckStepTwoFields ();
|
CheckStepTwoFields ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -279,7 +302,9 @@ namespace SparkleShare {
|
||||||
|
|
||||||
HBox layout_folder = new HBox (true, 0);
|
HBox layout_folder = new HBox (true, 0);
|
||||||
|
|
||||||
FolderEntry = new Entry ();
|
FolderEntry = new SparkleEntry () {
|
||||||
|
ExampleText = "Folder"
|
||||||
|
};
|
||||||
|
|
||||||
FolderEntry.Changed += CheckStepTwoFields;
|
FolderEntry.Changed += CheckStepTwoFields;
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Menu.Add (new SeparatorMenuItem ());
|
Menu.Add (new SeparatorMenuItem ());
|
||||||
|
|
||||||
FolderAction = new Gtk.Action ("", "SparkleShare Folder (" + GetSize (FolderSize) + ")") {
|
FolderAction = new Gtk.Action ("", "SparkleShare (" + GetSize (FolderSize) + ")") {
|
||||||
IconName = "folder-sparkleshare",
|
IconName = "folder-sparkleshare",
|
||||||
IsImportant = true
|
IsImportant = true
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue