[ease/sourceview] Break source widgets off into their own namespace.



commit 1c16d81821d5efd977fe4ff2bdea953ccb73f331
Author: Nate Stedman <natesm gmail com>
Date:   Sat Jun 12 12:50:00 2010 -0400

    Break source widgets off into their own namespace.

 src/Main.vala        |   22 ++++++++--------
 src/SourceGroup.vala |   32 ++++++++++++------------
 src/SourceItem.vala  |   64 ++++++++++++++++++++++++++++++++------------------
 src/SourceList.vala  |   34 +++++++++++++-------------
 src/SourceView.vala  |   22 ++++++++--------
 5 files changed, 96 insertions(+), 78 deletions(-)
---
diff --git a/src/Main.vala b/src/Main.vala
index 55f556c..145d407 100644
--- a/src/Main.vala
+++ b/src/Main.vala
@@ -244,32 +244,32 @@ public static class Ease.Main : GLib.Object
 	
 	public static void test_sourceview()
 	{
-		SourceView view = new SourceView();
+		Source.View view = new Source.View();
 		
-		var group = new SourceGroup("Test Group 1");
+		var group = new Source.Group("Test Group 1");
 		var text = new Gtk.TextView();
-		var item = new SourceItem.from_stock("gtk-new", text);
+		var item = new Source.Item.from_stock("gtk-new", text);
 		group.add_item(item);
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-open", text);
+		item = new Source.Item.from_stock("gtk-open", text);
 		group.add_item(item);
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-undo", text);
+		item = new Source.Item.from_stock("gtk-undo", text);
 		group.add_item(item);
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-redo", text);
+		item = new Source.Item.from_stock("gtk-redo", text);
 		group.add_item(item);
 		view.add_group(group);
 		
-		group = new SourceGroup("Test Group 2");
+		group = new Source.Group("Test Group 2");
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-add", text);
+		item = new Source.Item.from_stock("gtk-add", text);
 		group.add_item(item);
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-about", text);
+		item = new Source.Item.from_stock("gtk-about", text);
 		group.add_item(item);
 		text = new Gtk.TextView();
-		item = new SourceItem.from_stock("gtk-floppy", text);
+		item = new Source.Item.from_stock("gtk-floppy", text);
 		group.add_item(item);
 		view.add_group(group);
 		
@@ -279,7 +279,7 @@ public static class Ease.Main : GLib.Object
 		
 		var window = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
 		window.add(view);
-		//window.add(new SourceItem.from_stock("gtk-new", text));
+		//window.add(new Source.Item.from_stock("gtk-new", text));
 		window.set_size_request(640, 480);
 		window.show_all();
 	}
diff --git a/src/SourceGroup.vala b/src/SourceGroup.vala
index 6fc3a82..94673b0 100644
--- a/src/SourceGroup.vala
+++ b/src/SourceGroup.vala
@@ -16,20 +16,20 @@
 */
 
 /**
- * A group in a { link SourceList}.
+ * A group in a { link Source.List}.
  *
- * SourceGroup can contain any amount of { link SourceItem}s. Above these items,
- * a header is shown in order to categorize a { link SourceList}.
+ * Source.Group can contain any amount of { link Source.Item}s. Above these items,
+ * a header is shown in order to categorize a { link Source.List}.
  */
-public class Ease.SourceGroup : Gtk.Alignment
+public class Source.Group : Gtk.Alignment
 {
 	/**
-	 * The group header, displayed on top of the { link SourceItem}s.
+	 * The group header, displayed on top of the { link Source.Item}s.
 	 */
 	private Gtk.Label header;
 	
 	/**
-	 * The Gtk.VBox containing all { link SourceItem}s.
+	 * The Gtk.VBox containing all { link Source.Item}s.
 	 */
 	private Gtk.VBox items_box;
 	
@@ -44,7 +44,7 @@ public class Ease.SourceGroup : Gtk.Alignment
 	private const string HEADER_FORMAT = "<b>%s</b>";
 	
 	/**
-	 * Padding between each { link SourceItem}.
+	 * Padding between each { link Source.Item}.
 	 */
 	private const int ITEM_PADDING = 2;
 	
@@ -69,18 +69,18 @@ public class Ease.SourceGroup : Gtk.Alignment
 	private const int ITEMS_PADDING_BOTTOM = 10;
 	
 	/**
-	 * Emitted when a child { link SourceItem} of this group is clicked.
+	 * Emitted when a child { link Source.Item} of this group is clicked.
 	 *
-	 * @param sender The { link SourceItem} that was clicked.
+	 * @param sender The { link Source.Item} that was clicked.
 	 */
-	public signal void clicked(SourceItem sender);
+	public signal void clicked(Item sender);
 	
 	/**
-	 * Create a new, empty, SourceGroup.
+	 * Create a new, empty, Source.Group.
 	 *
-	 * @param title The header of the SourceGroup.
+	 * @param title The header of the Source.Group.
 	 */
-	public SourceGroup(string title)
+	public Group(string title)
 	{
 		// create subwidgets
 		all_box = new Gtk.VBox(false, 0);
@@ -105,11 +105,11 @@ public class Ease.SourceGroup : Gtk.Alignment
 	}
 	
 	/**
-	 * Adds a { link SourceItem} to the end of this group.
+	 * Adds a { link Source.Item} to the end of this group.
 	 *
-	 * @param item The { link SourceItem} to add.
+	 * @param item The { link Source.Item} to add.
 	 */
-	public void add_item(SourceItem item)
+	public void add_item(Item item)
 	{
 		items_box.pack_start(item, false, false, 0);
 		
diff --git a/src/SourceItem.vala b/src/SourceItem.vala
index c2b04ff..7777dab 100644
--- a/src/SourceItem.vala
+++ b/src/SourceItem.vala
@@ -16,31 +16,31 @@
 */
 
 /**
- * An individual item in a { link SourceGroup}.
+ * An individual item in a { link Source.Group}.
  *
- * SourceItem contains a Gtk.Button, which in turn contains an image and a
- * label. When added to a { link SourceGroup}, signals are automatically set
- * up to manage the { link SourceView} this item is a part of.
+ * Source.Item contains a Gtk.Button, which in turn contains an image and a
+ * label. When added to a { link Source.Group}, signals are automatically set
+ * up to manage the { link Source.View} this item is a part of.
  */
-public class Ease.SourceItem : Gtk.HBox
+public class Source.Item : Gtk.HBox
 {
 	/**
-	 * The SourceItem's image widget, displayed on the left.
+	 * The Source.Item's image widget, displayed on the left.
 	 */
 	private Gtk.Image image;
 	
 	/**
-	 * The SourceItem's label widget, displayed to the right of the image.
+	 * The Source.Item's label widget, displayed to the right of the image.
 	 */
 	private Gtk.Label label;
 	
 	/**
-	 * The SourceItem's button widget, containing the image and label.
+	 * The Source.Item's button widget, containing the image and label.
 	 */
 	private Gtk.Button button;
 	
 	/**
-	 * The widget this SourceItem is linked with in its { link SourceView}.
+	 * The widget this Source.Item is linked with in its { link Source.View}.
 	 */
 	public Gtk.Widget widget;
 	
@@ -90,7 +90,7 @@ public class Ease.SourceItem : Gtk.HBox
 	private const Gtk.ReliefStyle RELIEF_DESELECTED = Gtk.ReliefStyle.NONE;
 	
 	/**
-	 * If this SourceItem is the selected item in its { link SourceList}.
+	 * If this Source.Item is the selected item in its { link Source.List}.
 	 */
 	public bool selected
 	{
@@ -115,22 +115,22 @@ public class Ease.SourceItem : Gtk.HBox
 	}
 	
 	/**
-	 * Emitted when the SourceItem's Gtk.Button is clicked. Generally used
-	 * internally to change { link SourceList} selection.
+	 * Emitted when the Source.Item's Gtk.Button is clicked. Generally used
+	 * internally to change { link Source.List} selection.
 	 *
-	 * @param sender The SourceItem that emitted the signal (generally, "this").
+	 * @param sender The Source.Item that emitted the signal (generally, "this").
 	 */
-	public signal void clicked(SourceItem sender);
+	public signal void clicked(Source.Item sender);
 	
 	/**
-	 * Creates a SourceItem with a customizable icon and text.
+	 * Creates a Source.Item with a customizable icon and text.
 	 *
 	 * @param text The text to display in the source item.
 	 * @param img The image widget to use (note that this icon should use
 	 * the Gtk.IconSize constant ICON_SIZE to fit in with other items).
-	 * @param widg The widget that this SourceItem should be linked with.
+	 * @param widg The widget that this Source.Item should be linked with.
 	 */
-	public SourceItem(string text, Gtk.Image img, Gtk.Widget widg)
+	public Item(string text, Gtk.Image img, Gtk.Widget widg)
 	{
 		// set properties
 		homogeneous = false;
@@ -166,24 +166,42 @@ public class Ease.SourceItem : Gtk.HBox
 	}
 	
 	/**
-	 * Creates a SourceItem with a stock icon and customizable text.
+	 * Creates a Source.Item with a stock icon and customizable text.
 	 *
 	 * @param text The text to display in the source item.
 	 * @param item The stock item to take the icon from.
-	 * @param widg The widget that this SourceItem should be linked with.
+	 * @param widg The widget that this Source.Item should be linked with.
 	 */
-	public SourceItem.stock_icon(string text, string item, Gtk.Widget widg)
+	public Item.from_stock_icon(string text, string item, Gtk.Widget widg)
 	{
 		this(text, new Gtk.Image.from_stock(item, ICON_SIZE), widg);
 	}
 	
 	/**
-	 * Creates a SourceItem with a stock icon and text.
+	 * Creates a Source.Item with a stock icon and customizable text.
+	 *
+	 * @param text The text to display in the source item.
+	 * @param item The stock item to take the label from.
+	 * @param img The image widget to use (note that this icon should use
+	 * the Gtk.IconSize constant ICON_SIZE to fit in with other items).
+	 * @param widg The widget that this Source.Item should be linked with.
+	 */
+	public Item.from_stock_text(string item, Gtk.Image img, Gtk.Widget widg)
+	{
+		Gtk.StockItem stock = Gtk.StockItem();
+		if (Gtk.stock_lookup(item, stock))
+		{
+			this(stock.label.replace("_", ""), img, widg);
+		}
+	}
+	
+	/**
+	 * Creates a Source.Item with a stock icon and text.
 	 *
 	 * @param item The stock item to take the icon and text from.
-	 * @param widg The widget that this SourceItem should be linked with.
+	 * @param widg The widget that this Source.Item should be linked with.
 	 */
-	public SourceItem.from_stock(string item, Gtk.Widget widg)
+	public Item.from_stock(string item, Gtk.Widget widg)
 	{
 		Gtk.StockItem stock = Gtk.StockItem();
 		if (Gtk.stock_lookup(item, stock))
diff --git a/src/SourceList.vala b/src/SourceList.vala
index 62578cc..31530b1 100644
--- a/src/SourceList.vala
+++ b/src/SourceList.vala
@@ -18,13 +18,13 @@
 /**
  * A widget for switching between multiple data sources.
  *
- * SourceList contains { link SourceGroup}s, which in turn contain
- * { link SourceItem}s. Each SourceItem is linked to a Gtk.Widget, which
- * is displayed in the SourceList's linked Gtk.Bin when clicked.
+ * Source.List contains { link Source.Group}s, which in turn contain
+ * { link Source.Item}s. Each Source.Item is linked to a Gtk.Widget, which
+ * is displayed in the Source.List's linked Gtk.Bin when clicked.
  *
- * For a simple SourceList next to bin implementation, use { link SourceView}.
+ * For a simple Source.List next to bin implementation, use { link Source.View}.
  */
-public class Ease.SourceList : Gtk.Alignment
+public class Source.List : Gtk.Alignment
 {
 	/**
 	 * The child of this widget, provides scrollbars if necessary.
@@ -32,20 +32,20 @@ public class Ease.SourceList : Gtk.Alignment
 	private Gtk.ScrolledWindow scroll;
 	
 	/**
-	 * Gtk.VBox to contain this SourceList's { link SourceGroup}s.
+	 * Gtk.VBox to contain this Source.List's { link Source.Group}s.
 	 */
 	private Gtk.VBox box;
 	
 	/**
-	 * The bin used by this widget's { link SourceItem}s to display their
+	 * The bin used by this widget's { link Source.Item}s to display their
 	 * linked widgets.
 	 */
 	private Gtk.Bin bin;
 	
 	/**
-	 * The currently selected { link SourceItem}.
+	 * The currently selected { link Source.Item}.
 	 */
-	private SourceItem selected;
+	private Source.Item selected;
 	
 	/**
 	 * The Gtk.ShadowType of the scrolled window.
@@ -63,18 +63,18 @@ public class Ease.SourceList : Gtk.Alignment
 	private const Gtk.PolicyType V_POLICY = Gtk.PolicyType.AUTOMATIC;
 	
 	/**
-	 * Emitted when a { link SourceItem} in this SourceList is clicked.
+	 * Emitted when a { link Source.Item} in this Source.List is clicked.
 	 *
-	 * @param sender The SourceItem that was clicked.
+	 * @param sender The Source.Item that was clicked.
 	 */
-	public signal void clicked(SourceItem sender);
+	public signal void clicked(Source.Item sender);
 
 	/**
-	 * Creates a SourceList and links it to a Gtk.Bin
+	 * Creates a Source.List and links it to a Gtk.Bin
 	 *
-	 * @param linked_bin The Gtk.Bin to link this SourceView with.
+	 * @param linked_bin The Gtk.Bin to link this Source.View with.
 	 */
-	public SourceList(Gtk.Bin linked_bin)
+	public List(Gtk.Bin linked_bin)
 	{
 		// create widgets
 		scroll = new Gtk.ScrolledWindow(null, null);
@@ -93,12 +93,12 @@ public class Ease.SourceList : Gtk.Alignment
 	}
 	
 	/**
-	 * Adds a group to the { link SourceList}, automatically setting up click
+	 * Adds a group to the { link Source.List}, automatically setting up click
 	 * signals.
 	 *
 	 * @param group The group to add.
 	 */
-	public void add_group(SourceGroup group)
+	public void add_group(Source.Group group)
 	{
 		box.pack_start(group, false, false, 0);
 		
diff --git a/src/SourceView.vala b/src/SourceView.vala
index cb6b0e5..17ea0e2 100644
--- a/src/SourceView.vala
+++ b/src/SourceView.vala
@@ -16,12 +16,12 @@
 */
 
 /**
- * A simple implementation of a widget using { link SourceList}.
+ * A simple implementation of a widget using { link Source.List}.
  *
- * SourceView consists of a { link SourceList} and a Gtk.Bin packed into a
- * Gtk.HBox.
+ * Source.View consists of a { link Source.List}, a separator and a Gtk.Bin
+ * packed into a Gtk.HBox.
  */
-public class Ease.SourceView : Gtk.HBox
+public class Source.View : Gtk.HBox
 {
 	/**
 	 * The content view.
@@ -29,18 +29,18 @@ public class Ease.SourceView : Gtk.HBox
 	private Gtk.Alignment bin;
 	
 	/**
-	 * The { link SourceList} for this SourceView.
+	 * The { link Source.List} for this Source.View.
 	 */
-	private SourceList list;
+	private Source.List list;
 	
 	/**
-	 * Creates an empty SourceView. Add groups with add_group().
+	 * Creates an empty Source.View. Add groups with add_group().
 	 */
-	public SourceView()
+	public View()
 	{
 		// create widgets
 		bin = new Gtk.Alignment(0, 0, 1, 1);
-		list = new SourceList(bin);
+		list = new Source.List(bin);
 		
 		// set properties
 		homogeneous = false;
@@ -52,11 +52,11 @@ public class Ease.SourceView : Gtk.HBox
 	}
 	
 	/**
-	 * Adds a { link SourceGroup} to this SourceView's { link SourceList}.
+	 * Adds a { link Source.Group} to this Source.View's { link Source.List}.
 	 *
 	 * @param group The group to add.
 	 */
-	public void add_group(SourceGroup group)
+	public void add_group(Source.Group group)
 	{
 		list.add_group(group);
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]