[ease] Sync with libsourcelist source files.



commit 698a712b74040c8f2c438da2a2895687916baaf8
Author: Nate Stedman <natesm gmail com>
Date:   Sun Aug 22 18:08:39 2010 -0400

    Sync with libsourcelist source files.

 ease-core/Makefile.am                         |    2 +
 ease-core/sourcelist/source-item.vala         |   53 +---------
 ease-core/sourcelist/source-list.vala         |    2 +-
 ease-core/sourcelist/source-number-item.vala  |  143 +++++++++++++++++++++++++
 ease-core/sourcelist/source-spinner-item.vala |  129 ++++++++++++++++++++++
 5 files changed, 277 insertions(+), 52 deletions(-)
---
diff --git a/ease-core/Makefile.am b/ease-core/Makefile.am
index 16e9bd2..42f5230 100644
--- a/ease-core/Makefile.am
+++ b/ease-core/Makefile.am
@@ -50,7 +50,9 @@ libease_core_ EASE_CORE_VERSION@_la_SOURCES = \
 	sourcelist/source-group.vala \
 	sourcelist/source-item.vala \
 	sourcelist/source-list.vala \
+	sourcelist/source-number-item.vala \
 	sourcelist/source-pane-view.vala \
+	sourcelist/source-spinner-item.vala \
 	sourcelist/source-view.vala \
 	$(NULL)
 
diff --git a/ease-core/sourcelist/source-item.vala b/ease-core/sourcelist/source-item.vala
index 20e9f56..1b5fa7a 100644
--- a/ease-core/sourcelist/source-item.vala
+++ b/ease-core/sourcelist/source-item.vala
@@ -34,53 +34,9 @@ public class Source.Item : Gtk.HBox
 	private Gtk.Label label;
 	
 	/**
-	 * The right label widget, which can display a number if desired.
+	 * The alignment for the right widget.
 	 */
-	private Gtk.Label right_label;
-	
-	/**
-	 * The alignment for the right label.
-	 */
-	private Gtk.Alignment right_align;
-	
-	/**
-	 * A number, displayed on the righthand side of the Source.Item. If
-	 * notification is 0, the label is not displayed.
-	 */
-	public int notification
-	{
-		get { return notification_priv; }
-		set
-		{
-			if (value == notification_priv) return;
-			
-			// if value is 0, notification_priv can't be
-			if (value == 0)
-			{
-				// therefore, the widget has been added, so remove it
-				right_align.remove(right_label);
-			}
-			
-			// update the label
-			right_label.label = (selected ?
-			                     FORMAT_RIGHT_OLD : 
-			                     FORMAT_RIGHT_NEW).printf(value);
-			
-			// if necessary, add the label
-			if (notification_priv == 0)
-			{
-				right_align.add(right_label);
-			}
-			
-			// store the value
-			notification_priv = value;
-		}
-	}
-	
-	/**
-	 * Private store for notification value
-	 */
-	private int notification_priv = 0;
+	protected Gtk.Alignment right_align;
 	
 	/**
 	 * The Source.Item's button widget, containing the image and label.
@@ -169,9 +125,6 @@ public class Source.Item : Gtk.HBox
 			if (value)
 			{
 				clicked(this);
-				
-				// remove bold from notification text
-				right_label.label = FORMAT_RIGHT_OLD.printf(notification);
 			}
 		}
 	}
@@ -210,8 +163,6 @@ public class Source.Item : Gtk.HBox
 		selected = false;
 		var label_align = new Gtk.Alignment(0, LABEL_VERT_ALIGN, 0, 0);
 		label_align.set_padding(0, 0, ITEM_PADDING, ITEM_PADDING);
-		right_label = new Gtk.Label("");
-		right_label.use_markup = true;
 		right_align = new Gtk.Alignment(1, LABEL_VERT_ALIGN, 1, 1);
 		var image_align = new Gtk.Alignment(0.5f, 0.5f, 0, 1);
 		image_align.set_padding(0, 0, ITEM_PADDING, 0);
diff --git a/ease-core/sourcelist/source-list.vala b/ease-core/sourcelist/source-list.vala
index 325bdf4..b3349af 100644
--- a/ease-core/sourcelist/source-list.vala
+++ b/ease-core/sourcelist/source-list.vala
@@ -84,7 +84,7 @@ public class Source.List : Gtk.Alignment
 	 * @param linked_bin The Gtk.Bin to link this Source.View with.
 	 */
 	public List(Gtk.Bin linked_bin)
-	{	
+	{
 		// create widgets
 		scroll = new Gtk.ScrolledWindow(null, null);
 		box = new Gtk.VBox(false, GROUP_PADDING);
diff --git a/ease-core/sourcelist/source-number-item.vala b/ease-core/sourcelist/source-number-item.vala
new file mode 100644
index 0000000..1db0d4b
--- /dev/null
+++ b/ease-core/sourcelist/source-number-item.vala
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2010, Nate Stedman <natesm gmail com>
+ * 
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * A { link Item} that can display a number on the right side.
+ */
+public class Source.NumberItem : Source.Item
+{
+	/**
+	 * The right label widget, which can display a number if desired.
+	 */
+	private Gtk.Label right_label;
+	
+	/**
+	 * A number, displayed on the righthand side of the Source.Item. If
+	 * notification is 0, the label is not displayed.
+	 */
+	public int notification
+	{
+		get { return notification_priv; }
+		set
+		{
+			if (value == notification_priv) return;
+			
+			// if value is 0, notification_priv can't be
+			if (value == 0)
+			{
+				// therefore, the widget has been added, so remove it
+				right_align.remove(right_label);
+			}
+			
+			// update the label
+			right_label.label = (selected ?
+			                     FORMAT_RIGHT_OLD : 
+			                     FORMAT_RIGHT_NEW).printf(value);
+			
+			// if necessary, add the label
+			if (notification_priv == 0)
+			{
+				right_align.add(right_label);
+			}
+			
+			// store the value
+			notification_priv = value;
+		}
+	}
+	
+	/**
+	 * Private store for notification value
+	 */
+	private int notification_priv = 0;
+	
+	/**
+	 * Creates a Source.NumberItem 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 Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public NumberItem(string text, Gtk.Image img, Gtk.Widget? widg)
+	{
+		base(text, img, widg);
+		
+		right_label = new Gtk.Label("");
+		right_label.use_markup = true;
+		
+		clicked.connect((self) => {
+			// remove bold from notification text
+			right_label.label = FORMAT_RIGHT_OLD.printf(notification);
+		});
+	}
+	
+	/**
+	 * Creates a Source.NumberItem 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 Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public NumberItem.from_stock_icon(string text, string item,
+	                                  Gtk.Widget? widg)
+	{
+		this(text, new Gtk.Image.from_stock(item, ICON_SIZE), widg);
+	}
+	
+	/**
+	 * Creates a Source.NumberItem 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.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public NumberItem.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.NumberItem with a stock icon and text.
+	 *
+	 * @param item The stock item to take the icon and text from.
+	 * @param widg The widget that this Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public NumberItem.from_stock(string item, Gtk.Widget? widg)
+	{
+		Gtk.StockItem stock = Gtk.StockItem();
+		if (Gtk.stock_lookup(item, stock))
+		{
+			this(stock.label.replace("_", ""),
+			     new Gtk.Image.from_stock(item, ICON_SIZE),
+			     widg);
+		}
+	}
+}
diff --git a/ease-core/sourcelist/source-spinner-item.vala b/ease-core/sourcelist/source-spinner-item.vala
new file mode 100644
index 0000000..d0b83f6
--- /dev/null
+++ b/ease-core/sourcelist/source-spinner-item.vala
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2010, Nate Stedman <natesm gmail com>
+ * 
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * A { link Item} with a Gtk.Spinner on the right side.
+ */
+public class Source.SpinnerItem : Source.Item
+{
+	/**
+	 * The spinner on the right side of the widget.
+	 */
+	private Gtk.Spinner spinner = new Gtk.Spinner();
+	
+	/**
+	 * Stops and hides the spinner.
+	 */
+	public void stop()
+	{
+		spinner.stop();
+		if (spinner.get_parent() == right_align) right_align.remove(spinner);
+	}
+	
+	/** 
+	 * Starts and shows the spinner.
+	 */
+	public void start()
+	{
+		spinner.start();
+		if (spinner.get_parent() != right_align) right_align.add(spinner);
+	}
+	
+	/**
+	 * Whether or not the spinner is currently visible and spinning.
+	 */
+	public bool spinning
+	{
+		get { return spinner.get_parent() == right_align; }
+		set
+		{
+			spinner.visible = value;
+			if (value) spinner.start();
+			else spinner.stop();
+		}
+	}
+	 
+	/**
+	 * Creates a Source.SpinnerItem 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 Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public SpinnerItem(string text, Gtk.Image img, Gtk.Widget? widg)
+	{
+		base(text, img, widg);
+		spinner.show();
+	}
+	
+	/**
+	 * Creates a Source.SpinnerItem 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 Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public SpinnerItem.from_stock_icon(string text, string item,
+	                                   Gtk.Widget? widg)
+	{
+		this(text, new Gtk.Image.from_stock(item, ICON_SIZE), widg);
+	}
+	
+	/**
+	 * Creates a Source.SpinnerItem 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.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public SpinnerItem.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.SpinnerItem with a stock icon and text.
+	 *
+	 * @param item The stock item to take the icon and text from.
+	 * @param widg The widget that this Source.Item should be linked with.
+	 * If null, this Source.Item will only emit the clicked signal when 
+	 * clicked, without any automatic UI changes.
+	 */
+	public SpinnerItem.from_stock(string item, Gtk.Widget? widg)
+	{
+		Gtk.StockItem stock = Gtk.StockItem();
+		if (Gtk.stock_lookup(item, stock))
+		{
+			this(stock.label.replace("_", ""),
+			     new Gtk.Image.from_stock(item, ICON_SIZE),
+			     widg);
+		}
+	}
+}



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