intro about entry infobar: fix coding style and whitespace

This commit is contained in:
Hylke Bons 2011-05-14 00:18:57 +01:00
parent 6c354b2473
commit f7a7276fcc
4 changed files with 91 additions and 123 deletions

View file

@ -20,11 +20,11 @@ using System.Drawing;
using System.IO; using System.IO;
using System.Timers; using System.Timers;
using Mono.Unix;
using MonoMac.Foundation; using MonoMac.Foundation;
using MonoMac.AppKit; using MonoMac.AppKit;
using MonoMac.ObjCRuntime; using MonoMac.ObjCRuntime;
using MonoMac.WebKit; using MonoMac.WebKit;
using Mono.Unix;
namespace SparkleShare { namespace SparkleShare {

View file

@ -26,26 +26,26 @@ using Mono.Unix;
namespace SparkleShare { namespace SparkleShare {
public class SparkleAbout : Window { public class SparkleAbout : Window {
private Label Version; private Label Version;
// Short alias for the translations // Short alias for the translations
public static string _(string s) public static string _(string s)
{ {
return Catalog.GetString (s); return Catalog.GetString (s);
} }
public SparkleAbout () : base ("") public SparkleAbout () : base ("")
{ {
DefaultSize = new Gdk.Size (360, 260); DefaultSize = new Gdk.Size (360, 260);
BorderWidth = 0; BorderWidth = 0;
IconName = "folder-sparkleshare"; IconName = "folder-sparkleshare";
WindowPosition = WindowPosition.Center; WindowPosition = WindowPosition.Center;
Title = "About SparkleShare"; Title = "About SparkleShare";
Resizable = false; Resizable = false;
CreateAbout (); CreateAbout ();
@ -64,16 +64,14 @@ namespace SparkleShare {
}; };
SparkleShare.Controller.CheckForNewVersion (); SparkleShare.Controller.CheckForNewVersion ();
} }
private void CreateAbout () private void CreateAbout ()
{ {
Gdk.Color color = Style.Foreground (StateType.Insensitive); Gdk.Color color = Style.Foreground (StateType.Insensitive);
string secondary_text_color = SparkleUIHelpers.GdkColorToHex (color); string secondary_text_color = SparkleUIHelpers.GdkColorToHex (color);
EventBox box = new EventBox (); EventBox box = new EventBox ();
box.ModifyBg (StateType.Normal, new TreeView ().Style.Base (StateType.Normal)); box.ModifyBg (StateType.Normal, new TreeView ().Style.Base (StateType.Normal));
@ -86,7 +84,6 @@ namespace SparkleShare {
box.Add (header); box.Add (header);
Version = new Label () { Version = new Label () {
Markup = "<small>Checking for updates...</small>", Markup = "<small>Checking for updates...</small>",
Xalign = 0, Xalign = 0,
@ -152,10 +149,6 @@ namespace SparkleShare {
vbox.PackStart (button_bar, false, false, 0); vbox.PackStart (button_bar, false, false, 0);
Add (vbox); Add (vbox);
} }
}
}
} }

View file

@ -14,99 +14,79 @@
// You should have received a copy of the GNU General private License // You should have received a copy of the GNU General private License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk; using Gtk;
namespace SparkleShare { namespace SparkleShare {
public class SparkleEntry : Entry { public class SparkleEntry : Entry {
public bool ExampleTextActive; public bool ExampleTextActive;
private string pExampleText; private string pExampleText;
public SparkleEntry () public SparkleEntry ()
{ {
ExampleTextActive = true;
ExampleTextActive = true; FocusGrabbed += delegate { OnEntered (); };
ClipboardPasted += delegate { OnEntered (); };
FocusOutEvent += delegate {
FocusGrabbed += delegate { OnEntered (); }; if (Text.Equals ("") || Text == null)
ClipboardPasted += delegate { OnEntered (); }; ExampleTextActive = true;
FocusOutEvent += delegate {
if (Text.Equals ("") || Text == null) if (ExampleTextActive)
ExampleTextActive = true; UseExampleText ();
};
if (ExampleTextActive) }
UseExampleText ();
};
}
private void OnEntered () private void OnEntered ()
{ {
if (ExampleTextActive) {
if (ExampleTextActive) { ExampleTextActive = false;
Text = "";
ExampleTextActive = false; UseNormalTextColor ();
Text = ""; }
UseNormalTextColor (); }
}
}
public string ExampleText public string ExampleText
{ {
get {
return pExampleText;
}
get { set {
pExampleText = value;
return pExampleText; if (ExampleTextActive) {
} UseExampleText ();
set { }
}
pExampleText = value; }
if (ExampleTextActive) {
UseExampleText ();
}
}
}
private void UseExampleText () private void UseExampleText ()
{ {
Text = pExampleText;
Text = pExampleText; UseSecondaryTextColor ();
UseSecondaryTextColor (); }
}
private void UseSecondaryTextColor () private void UseSecondaryTextColor ()
{ {
ModifyText (StateType.Normal, Style.Foreground (StateType.Insensitive));
ModifyText (StateType.Normal, Style.Foreground (StateType.Insensitive)); }
}
private void UseNormalTextColor () private void UseNormalTextColor ()
{ {
ModifyText (StateType.Normal, Style.Foreground (StateType.Normal));
ModifyText (StateType.Normal, Style.Foreground (StateType.Normal)); }
}
}
}
} }

View file

@ -14,42 +14,37 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using Gtk; using Gtk;
namespace SparkleShare { namespace SparkleShare {
// An infobar // An infobar
public class SparkleInfobar : EventBox public class SparkleInfobar : EventBox {
{
public SparkleInfobar (string icon_name, string title, string text) public SparkleInfobar (string icon_name, string title, string text)
{ {
Window window = new Window (WindowType.Popup) {
Name = "gtk-tooltip"
};
Window window = new Window (WindowType.Popup) { window.EnsureStyle ();
Name = "gtk-tooltip" Style = window.Style;
};
window.EnsureStyle (); Label label = new Label () {
Markup = "<b>" + title + "</b>\n" + text
};
Style = window.Style; HBox hbox = new HBox (false, 12) {
BorderWidth = 12
};
Label label = new Label () { hbox.PackStart (new Image (SparkleUIHelpers.GetIcon (icon_name, 24)),
Markup = "<b>" + title + "</b>\n" + text false, false, 0);
};
HBox hbox = new HBox (false, 12) { hbox.PackStart (label, false, false, 0);
BorderWidth = 12
};
hbox.PackStart (new Image (SparkleUIHelpers.GetIcon (icon_name, 24)),
false, false, 0);
hbox.PackStart (label, false, false, 0);
Add (hbox);
}
}
Add (hbox);
}
}
} }