Permalink
Browse files

Add support to the ToolBarDropDownButton to show a label in the toolb…

…ar or not.
  • Loading branch information...
1 parent 818fa7a commit 2ad2a4768e51e743e37c8ba46a519b93ec5ca3e4 @jpobst jpobst committed May 14, 2012
Showing with 15 additions and 4 deletions.
  1. +10 −2 Pinta.Core/Widgets/MenuButton.cs
  2. +5 −2 Pinta.Core/Widgets/ToolBarDropDownButton.cs
@@ -40,6 +40,7 @@ public class MenuButton : ToolItem
private Widget button_widget;
private Menu menu;
private Widget size_widget;
+ protected Gtk.Label label_widget;
protected MenuButton (IntPtr ptr) : base (ptr) { }
@@ -52,7 +53,7 @@ public MenuButton (Widget buttonWidget, Menu menu, bool showArrow)
Construct (buttonWidget, menu, showArrow);
}
- protected void Construct (Widget buttonWidget, Menu menu, bool showArrow)
+ protected void Construct (Widget buttonWidget, Menu menu, bool showArrow, bool showLabel = false)
{
WidgetFlags |= WidgetFlags.NoWindow;
@@ -69,7 +70,14 @@ protected void Construct (Widget buttonWidget, Menu menu, bool showArrow)
box.Parent = this;
if (showArrow) {
- box.PackStart (button_widget, true, true, 5);
+ if (showLabel) {
+ box.PackStart (button_widget, true, true, 3);
+ label_widget = new Gtk.Label ();
+ box.PackStart (label_widget, true, false, 2);
+ } else {
+ box.PackStart (button_widget, true, true, 5);
+ }
+
alignment = new Alignment (0f, 0.5f, 0f, 0f);
arrow = new Arrow (ArrowType.Down, ShadowType.None);
alignment.Add (arrow);
@@ -15,14 +15,14 @@ public class ToolBarDropDownButton : MenuButton
public List<ToolBarItem> Items { get; private set; }
- public ToolBarDropDownButton ()
+ public ToolBarDropDownButton (bool showLabel = false)
{
Items = new List<ToolBarItem> ();
dropdown = new Menu ();
image = new Image ();
- Construct (image, dropdown, true);
+ Construct (image, dropdown, true, showLabel);
}
public ToolBarItem AddItem (string text, string imageId)
@@ -60,6 +60,9 @@ protected void SetSelectedItem (ToolBarItem item)
selected_item = item;
TooltipText = item.Text;
+ if (label_widget != null)
+ label_widget.Text = item.Text;
+
OnSelectedItemChanged ();
}

0 comments on commit 2ad2a47

Please sign in to comment.