Permalink
Browse files

* libstetic/wrapper/Dialog.cs (Buttons): make this a number rather

	than having an enum of standard button choices; the HIG prefers
	stronger labels than "OK"/"Yes", so we shouldn't be making it
	easier to use bad labels than good ones.
	(HelpButton): reorder the help button to be the first child so
	that it won't ever get deleted when you decrement Buttons
	(ButtonsChanged): keep the Buttons and HelpButton properties in
	sync if the user manipulates the buttonbox contents by hand

	* libstetic/wrapper/Button.cs (StockId): if the button's ReponseId
	matches its old StockId (or is unset), update it to match it's new
	StockId.
	(IsDialogButton): replaces HasResponseId and is now settable
	rather than being figured out automatically. Also, set
	button.CanDefault when turning on IsDialogButton.
	(ResponseIdForStockId): maps Gtk.Stock values to Gtk.ResponseType
	values.

	* libstetic/wrapper/ButtonBox.cs (NewButton): if the buttonbox is
	a dialog's action_area, set IsDialogButton on new child buttons.
	(AllowPlaceholders): false
	(InsertBefore, InsertAfter): Reimplement using Secondary/non-
	Secondary rather than PackType.
	(ButtonBoxChild): add InDialog property
	
	* libstetic/wrapper/Container.cs (ContextChildProps): for use in
	context-menu ops; gets the child properties corresponding to the
	ancestor of the widget that is a child of the container.

	* libstetic/wrapper/Box.cs (AllowPlaceholders): only return false
	if InternalChildId is unset. (Eg, we definitely want to allow
	placeholders in a dialog box's internal vbox).
	(InsertBefore, InsertAfter): use Container.ContextChildProps so
	that this works regardless of what descendant widget was clicked
	on.

	* libstetic/wrapper/objects.xml (Gtk.ButtonBox): Change the
	command labels to "Insert Button Before" and "Insert Button
	After".
	(Gtk.ButtonBox+ButtonBoxChild): Remove PackType, since the
	interaction of PackType and Secondary is unnecessarily annoying.
	Also add a new internal InDialog property and hide Secondary if
	that's true (since we handle Help buttons specially and nothing
	else should be secondary).
	(Gtk.Button): s/HasResponseId/IsDialogButton/
	(Gtk.Dialog): change the description of Buttons since it's now a
	number, and give it a minimum value of "1".
	(Gtk.ResponseType): add labels/descriptions for this enum
	(Stetic.Wrapper.Dialog+StandardButtons): and kill this one

	* libstetic/editor/ResponseId.cs: update this to use
	EnumDescriptor

svn path=/trunk/stetic/; revision=50784
  • Loading branch information...
1 parent ff551ac commit fe0b35e38282501965100fb5c4fa96077bfd54e7 Dan Winship committed Sep 26, 2005
View
@@ -1,3 +1,58 @@
+2005-09-26 Dan Winship <danw@novell.com>
+
+ * libstetic/wrapper/Dialog.cs (Buttons): make this a number rather
+ than having an enum of standard button choices; the HIG prefers
+ stronger labels than "OK"/"Yes", so we shouldn't be making it
+ easier to use bad labels than good ones.
+ (HelpButton): reorder the help button to be the first child so
+ that it won't ever get deleted when you decrement Buttons
+ (ButtonsChanged): keep the Buttons and HelpButton properties in
+ sync if the user manipulates the buttonbox contents by hand
+
+ * libstetic/wrapper/Button.cs (StockId): if the button's ReponseId
+ matches its old StockId (or is unset), update it to match it's new
+ StockId.
+ (IsDialogButton): replaces HasResponseId and is now settable
+ rather than being figured out automatically. Also, set
+ button.CanDefault when turning on IsDialogButton.
+ (ResponseIdForStockId): maps Gtk.Stock values to Gtk.ResponseType
+ values.
+
+ * libstetic/wrapper/ButtonBox.cs (NewButton): if the buttonbox is
+ a dialog's action_area, set IsDialogButton on new child buttons.
+ (AllowPlaceholders): false
+ (InsertBefore, InsertAfter): Reimplement using Secondary/non-
+ Secondary rather than PackType.
+ (ButtonBoxChild): add InDialog property
+
+ * libstetic/wrapper/Container.cs (ContextChildProps): for use in
+ context-menu ops; gets the child properties corresponding to the
+ ancestor of the widget that is a child of the container.
+
+ * libstetic/wrapper/Box.cs (AllowPlaceholders): only return false
+ if InternalChildId is unset. (Eg, we definitely want to allow
+ placeholders in a dialog box's internal vbox).
+ (InsertBefore, InsertAfter): use Container.ContextChildProps so
+ that this works regardless of what descendant widget was clicked
+ on.
+
+ * libstetic/wrapper/objects.xml (Gtk.ButtonBox): Change the
+ command labels to "Insert Button Before" and "Insert Button
+ After".
+ (Gtk.ButtonBox+ButtonBoxChild): Remove PackType, since the
+ interaction of PackType and Secondary is unnecessarily annoying.
+ Also add a new internal InDialog property and hide Secondary if
+ that's true (since we handle Help buttons specially and nothing
+ else should be secondary).
+ (Gtk.Button): s/HasResponseId/IsDialogButton/
+ (Gtk.Dialog): change the description of Buttons since it's now a
+ number, and give it a minimum value of "1".
+ (Gtk.ResponseType): add labels/descriptions for this enum
+ (Stetic.Wrapper.Dialog+StandardButtons): and kill this one
+
+ * libstetic/editor/ResponseId.cs: update this to use
+ EnumDescriptor
+
2005-09-22 Dan Winship <danw@novell.com>
* libstetic/ClassDescriptor.cs: Handle <contextmenu ref="..." />
View
@@ -13,8 +13,6 @@ UI-Designing UI:
- Fix up not-fully-functional wrappers:
- Dialog
- - "Buttons" should automatically switch to "Custom" if
- you add/remove them.
- action_area is currently broken on glade import
- Notebook has a few problems:
@@ -8,6 +8,7 @@ public class ResponseId : Gtk.HBox {
Gtk.ComboBoxEntry combo;
Gtk.Entry entry;
+ EnumDescriptor enm;
ArrayList values;
public ResponseId ()
@@ -20,13 +21,13 @@ public ResponseId ()
entry = combo.Child as Gtk.Entry;
entry.Changed += entry_Changed;
+ enm = Registry.LookupEnum (typeof (Gtk.ResponseType));
values = new ArrayList ();
- foreach (int i in Enum.GetValues (typeof (Gtk.ResponseType))) {
- Enum value = (Enum)Enum.ToObject (typeof (Gtk.ResponseType), i);
- string name = Enum.GetName (typeof (Gtk.ResponseType), value);
-
- combo.AppendText (name);
- values.Add (i);
+ foreach (Enum value in enm.Values) {
+ if (enm[value].Label != "") {
+ combo.AppendText (enm[value].Label);
+ values.Add ((int)enm[value].Value);
+ }
}
}
@@ -23,7 +23,7 @@ public override void Wrap (object obj, bool initialized)
protected override bool AllowPlaceholders {
get {
- return false;
+ return InternalChildId != null;
}
}
@@ -127,7 +127,7 @@ internal void InsertBefore (Gtk.Widget context)
position = 0;
type = Gtk.PackType.Start;
} else {
- Gtk.Box.BoxChild bc = box[context] as Gtk.Box.BoxChild;
+ Gtk.Box.BoxChild bc = (Gtk.Box.BoxChild)ContextChildProps (context);
position = bc.Position;
type = bc.PackType;
}
@@ -146,13 +146,13 @@ internal void InsertBefore (Gtk.Widget context)
internal void InsertAfter (Gtk.Widget context)
{
int position;
- Gtk.PackType type = Gtk.PackType.Start;
+ Gtk.PackType type;
if (context == box) {
position = 0;
type = Gtk.PackType.End;
} else {
- Gtk.Box.BoxChild bc = box[context] as Gtk.Box.BoxChild;
+ Gtk.Box.BoxChild bc = (Gtk.Box.BoxChild)ContextChildProps (context);
position = bc.Position;
type = bc.PackType;
}
@@ -217,6 +217,9 @@ void ConstructContents ()
return stockId;
}
set {
+ if (responseId == ResponseIdForStockId (stockId))
+ responseId = 0;
+
button.Label = stockId = value;
button.UseStock = true;
Gtk.StockItem item = Gtk.Stock.Lookup (value);
@@ -225,6 +228,9 @@ void ConstructContents ()
useUnderline = true;
}
EmitNotify ("StockId");
+
+ if (responseId == 0)
+ ResponseId = ResponseIdForStockId (stockId);
}
}
@@ -282,12 +288,15 @@ void ConstructContents ()
}
}
- public bool HasResponseId {
+ bool isDialogButton;
+ public bool IsDialogButton {
get {
- Stetic.Wrapper.Widget pwrap = ParentWrapper;
- if (pwrap == null)
- return false;
- return pwrap.InternalChildId == "action_area";
+ return isDialogButton;
+ }
+ set {
+ isDialogButton = value;
+ if (isDialogButton)
+ button.CanDefault = true;
}
}
@@ -301,5 +310,25 @@ void ConstructContents ()
EmitNotify ("ResponseId");
}
}
+
+ int ResponseIdForStockId (string stockId)
+ {
+ if (stockId == Gtk.Stock.Ok)
+ return (int)Gtk.ResponseType.Ok;
+ else if (stockId == Gtk.Stock.Cancel)
+ return (int)Gtk.ResponseType.Cancel;
+ else if (stockId == Gtk.Stock.Close)
+ return (int)Gtk.ResponseType.Close;
+ else if (stockId == Gtk.Stock.Yes)
+ return (int)Gtk.ResponseType.Yes;
+ else if (stockId == Gtk.Stock.No)
+ return (int)Gtk.ResponseType.No;
+ else if (stockId == Gtk.Stock.Apply)
+ return (int)Gtk.ResponseType.Apply;
+ else if (stockId == Gtk.Stock.Help)
+ return (int)Gtk.ResponseType.Help;
+ else
+ return 0;
+ }
}
}
@@ -8,33 +8,71 @@ public class ButtonBox : Box {
public override void Wrap (object obj, bool initialized)
{
base.Wrap (obj, initialized);
- FillButtons ();
- }
-
- void FillButtons ()
- {
foreach (Gtk.Widget child in buttonbox.Children) {
if (child is Placeholder)
- ReplaceChild (child, (Gtk.Button)Registry.NewInstance (typeof (Gtk.Button), proj));
+ ReplaceChild (child, NewButton ());
}
}
+ Gtk.Button NewButton ()
+ {
+ Gtk.Button button = (Gtk.Button)Registry.NewInstance (typeof (Gtk.Button), proj);
+ if (InternalChildId == "action_area")
+ ((Button)Widget.Lookup (button)).IsDialogButton = true;
+ return button;
+ }
+
protected Gtk.ButtonBox buttonbox {
get {
return (Gtk.ButtonBox)Wrapped;
}
}
+ protected override bool AllowPlaceholders {
+ get {
+ return false;
+ }
+ }
internal new void InsertBefore (Gtk.Widget context)
{
- base.InsertBefore (context);
- FillButtons ();
+ int position;
+ bool secondary;
+
+ if (context == buttonbox) {
+ position = 0;
+ secondary = false;
+ } else {
+ Gtk.ButtonBox.ButtonBoxChild bbc = (Gtk.ButtonBox.ButtonBoxChild)ContextChildProps (context);
+ position = bbc.Position;
+ secondary = bbc.Secondary;
+ }
+
+ Gtk.Button button = NewButton ();
+ buttonbox.PackStart (button, false, false, 0);
+ buttonbox.ReorderChild (button, position);
+ buttonbox.SetChildSecondary (button, secondary);
+ EmitContentsChanged ();
}
internal new void InsertAfter (Gtk.Widget context)
{
- base.InsertAfter (context);
- FillButtons ();
+ int position;
+ bool secondary;
+
+ if (context == buttonbox) {
+ position = buttonbox.Children.Length - 1;
+ secondary = false;
+ } else {
+ Gtk.ButtonBox.ButtonBoxChild bbc = (Gtk.ButtonBox.ButtonBoxChild)ContextChildProps (context);
+ position = bbc.Position;
+ secondary = bbc.Secondary;
+ }
+
+ Gtk.Button button = NewButton ();
+ buttonbox.PackStart (button, false, false, 0);
+ buttonbox.ReorderChild (button, position + 1);
+ buttonbox.SetChildSecondary (button, secondary);
+ EmitContentsChanged ();
}
public int Size {
@@ -48,10 +86,21 @@ internal new void InsertAfter (Gtk.Widget context)
while (cursize > value)
buttonbox.Remove (children[--cursize]);
while (cursize < value) {
- buttonbox.PackStart ((Gtk.Button)Registry.NewInstance (typeof (Gtk.Button), proj), false, false, 0);
+ buttonbox.PackStart (NewButton (), false, false, 0);
cursize++;
}
}
}
+
+ public class ButtonBoxChild : Box.BoxChild {
+
+ public bool InDialog {
+ get {
+ if (ParentWrapper == null)
+ return false;
+ return ParentWrapper.InternalChildId == "action_area";
+ }
+ }
+ }
}
}
@@ -213,6 +213,20 @@ public static Container LookupParent (Gtk.Widget widget)
return Stetic.ObjectWrapper.Create (parentWrapper.proj, cc) as ContainerChild;
}
+ protected Gtk.Container.ContainerChild ContextChildProps (Gtk.Widget context)
+ {
+ if (context == container)
+ return null;
+
+ do {
+ if (context.Parent == container)
+ return container[context];
+ context = context.Parent;
+ } while (context != null);
+
+ return null;
+ }
+
public delegate void ContentsChangedHandler (Container container);
public event ContentsChangedHandler ContentsChanged;
Oops, something went wrong. Retry.

0 comments on commit fe0b35e

Please sign in to comment.