add SparkleEntry: a widget that can have greyed out default text

This commit is contained in:
Hylke Bons 2010-08-07 17:54:10 +01:00
parent 008f6270b1
commit 404024b08a
5 changed files with 148 additions and 11 deletions

View file

@ -66,9 +66,9 @@ namespace SparkleShare {
Viewport = new Viewport ();
Viewport.Add (new Label (""));
Store = new ListStore(typeof (Gdk.Pixbuf),
typeof (string),
typeof (int));
Store = new ListStore (typeof (Gdk.Pixbuf),
typeof (string),
typeof (int));
IconView = new IconView (Store);
IconView.SelectionChanged += ChangeSelection;

View file

@ -9,6 +9,7 @@ LINK = $(REF_SPARKLESHARE)
SOURCES = \
SparkleBubble.cs \
SparkleEntry.cs \
SparkleIntro.cs \
SparkleShare.cs \
SparkleSpinner.cs \

View 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));
}
}
}

View file

@ -28,8 +28,8 @@ namespace SparkleShare {
private Entry NameEntry;
private Entry EmailEntry;
private Entry ServerEntry;
private Entry FolderEntry;
private SparkleEntry ServerEntry;
private SparkleEntry FolderEntry;
private Button NextButton;
private Button AddButton;
private bool StepTwoOnly;
@ -208,7 +208,9 @@ namespace SparkleShare {
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;
@ -252,18 +254,39 @@ namespace SparkleShare {
(radio_button_gitorious.Child as Label).UseMarkup = 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 {
if (radio_button.Active) {
ServerEntry.Sensitive = true;
FolderEntry.ExampleText = "Folder";
ServerEntry.Sensitive = true;
CheckStepTwoFields ();
} else {
ServerEntry.Sensitive = false;
CheckStepTwoFields ();
}
@ -279,7 +302,9 @@ namespace SparkleShare {
HBox layout_folder = new HBox (true, 0);
FolderEntry = new Entry ();
FolderEntry = new SparkleEntry () {
ExampleText = "Folder"
};
FolderEntry.Changed += CheckStepTwoFields;

View file

@ -170,7 +170,7 @@ namespace SparkleShare {
Menu.Add (new SeparatorMenuItem ());
FolderAction = new Gtk.Action ("", "SparkleShare Folder (" + GetSize (FolderSize) + ")") {
FolderAction = new Gtk.Action ("", "SparkleShare (" + GetSize (FolderSize) + ")") {
IconName = "folder-sparkleshare",
IsImportant = true
};