banshee r3165 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui src/Core/Hyena.Gui/Hyena.Query.Gui
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3165 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui src/Core/Hyena.Gui/Hyena.Query.Gui
- Date: Thu, 7 Feb 2008 18:39:30 +0000 (GMT)
Author: gburt
Date: Thu Feb 7 18:39:30 2008
New Revision: 3165
URL: http://svn.gnome.org/viewvc/banshee?rev=3165&view=rev
Log:
2008-02-07 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs: Fix bugs with
source actions being out of sync with what's highlighted/active. Open
Editor for smart playlists when OnSourceProperties.
* src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs: If
given a smart playlist, set the Hyena.Query.Gui condition.
* src/Core/Hyena.Gui/Hyena.Query.Gui/QueryTermBox.cs:
* src/Core/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs: Add a QueryNode setter
so can initialize with an existing query/smart playlist.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryTermBox.cs
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/SourceActions.cs Thu Feb 7 18:39:30 2008
@@ -50,6 +50,10 @@
get { return source_view; }
set { source_view = value; }
}
+
+ public Source ActionSource {
+ get { return SourceView.HighlightedSource ?? ServiceManager.SourceManager.ActiveSource; }
+ }
public SourceActions (InterfaceActionService actionService) : base ("Source")
{
@@ -153,7 +157,7 @@
{
UpdateActions ();
- string path = SourceView.HighlightedSource.Properties.GetString ("GtkActionPath") ?? "/SourceContextMenu";
+ string path = ActionSource.Properties.GetString ("GtkActionPath") ?? "/SourceContextMenu";
Gtk.Menu menu = action_service.UIManager.GetWidget (path) as Menu;
if (menu == null) {
return;
@@ -161,7 +165,10 @@
menu.Show ();
menu.Popup (null, null, null, 0, Gtk.Global.CurrentEventTime);
- menu.SelectionDone += delegate { SourceView.ResetHighlight (); };
+ menu.SelectionDone += delegate {
+ SourceView.ResetHighlight ();
+ UpdateActions ();
+ };
}
private void OnImportSource (object o, EventArgs args)
@@ -170,34 +177,41 @@
private void OnRenameSource (object o, EventArgs args)
{
- SourceView.BeginRenameSource (SourceView.HighlightedSource);
+ SourceView.BeginRenameSource (ActionSource);
}
private void OnUnmapSource (object o, EventArgs args)
{
- IUnmapableSource source = SourceView.HighlightedSource as IUnmapableSource;
+ IUnmapableSource source = ActionSource as IUnmapableSource;
if (source != null && source.CanUnmap && (!source.ConfirmBeforeUnmap || ConfirmUnmap (source)))
source.Unmap ();
}
private void OnSourceProperties (object o, EventArgs args)
{
+ Source source = ActionSource;
+ if (source is SmartPlaylistSource) {
+ Editor ed = new Editor (source as SmartPlaylistSource);
+ ed.RunDialog ();
+ }
}
#endregion
#region Utility Methods
+ private Source last_source = null;
private void UpdateActions ()
{
- Source source = SourceView.HighlightedSource;
+ Source source = ActionSource;
- if (source != null) {
+ if (source != last_source && source != null) {
IUnmapableSource unmapable = source as IUnmapableSource;
UpdateAction ("UnmapSourceAction", unmapable != null, unmapable != null && unmapable.CanUnmap, source);
UpdateAction ("RenameSourceAction", source.CanRename, true, null);
UpdateAction ("ImportSourceAction", source is IImportable, true, source);
UpdateAction ("SourcePropertiesAction", source.HasProperties, true, source);
+ last_source = source;
}
}
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.SmartPlaylist.Gui/Editor.cs Thu Feb 7 18:39:30 2008
@@ -35,6 +35,8 @@
public Editor (SmartPlaylistSource playlist) : base("SmartPlaylistEditorDialog")
{
this.playlist = playlist;
+ Console.WriteLine ("Loading smart playlist into editor: {0}",
+ playlist.ConditionTree == null ? "" : playlist.ConditionTree.ToXml (BansheeQuery.FieldSet, true));
Initialize();
@@ -59,6 +61,11 @@
// Add the QueryBuilder widget
//model = new TracksQueryModel(this.playlist);
builder = new BansheeQueryBox ();
+
+ if (playlist != null) {
+ builder.QueryNode = playlist.ConditionTree;
+ }
+
builder.Show();
builder.Spacing = 4;
@@ -204,7 +211,7 @@
//dialog.GetSize (out w, out h);
//Console.WriteLine ("w = {0}, h = {1}", w, h);
- QueryNode node = builder.BuildQuery ();
+ QueryNode node = builder.QueryNode;
if (node == null) {
Console.WriteLine ("Editor query is null");
} else {
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryBox.cs Thu Feb 7 18:39:30 2008
@@ -50,8 +50,40 @@
this.field_set = fieldSet;
CreateRow (false);
}
-
- public void CreateRow (bool canDelete)
+
+ public QueryNode QueryNode {
+ get {
+ QueryListNode and = new QueryListNode (Keyword.And);
+ for (int i = 0, n = Children.Length; i < n; i++) {
+ QueryTermBox term_box = Children [i] as QueryTermBox;
+ and.AddChild (term_box.QueryNode);
+ }
+ return and.Trim ();
+ }
+ set {
+ if (value is QueryListNode) {
+ // type = value.Keyword
+ foreach (QueryNode child in (value as QueryListNode).Children) {
+ AddNode (child);
+ }
+ } else {
+ // type = 'and'
+ AddNode (value);
+ }
+ }
+ }
+
+ private void AddNode (QueryNode node)
+ {
+ if (node is QueryTermNode) {
+ QueryTermBox box = CreateRow (false);
+ box.QueryNode = node as QueryTermNode;
+ } else {
+ Console.WriteLine ("Query Gui cannot handle child node: {0}", node.ToString ());
+ }
+ }
+
+ public QueryTermBox CreateRow (bool canDelete)
{
QueryTermBox row = new QueryTermBox (field_set);
row.Show();
@@ -64,6 +96,7 @@
first_row = row;
//row.FieldBox.GrabFocus();
}
+ return row;
}
public void OnRowAddRequest(object o, EventArgs args)
@@ -83,17 +116,5 @@
((QueryTermBox) Children[0]).CanDelete = Children.Length > 1;
}
- public QueryNode BuildQuery ()
- {
- QueryListNode and = new QueryListNode (Keyword.And);
-
- for (int i = 0, n = Children.Length; i < n; i++) {
- QueryTermBox term_box = Children [i] as QueryTermBox;
-
- and.AddChild (term_box.GetTermNode ());
- }
-
- return and.Trim ();
- }
}
}
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryTermBox.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryTermBox.cs (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Query.Gui/QueryTermBox.cs Thu Feb 7 18:39:30 2008
@@ -165,13 +165,23 @@
set { remove_button.Sensitive = value; }
}
- public QueryNode GetTermNode ()
- {
- QueryTermNode node = new QueryTermNode ();
- node.Field = field;
- node.Operator = op;
- node.Value = value_entry.QueryValue;
- return node;
+ public QueryTermNode QueryNode {
+ get {
+ QueryTermNode node = new QueryTermNode ();
+ node.Field = field;
+ node.Operator = op;
+ node.Value = value_entry.QueryValue;
+ return node;
+ }
+ set {
+ if (value == null) {
+ return;
+ }
+
+ field_chooser.Active = Array.IndexOf (sorted_fields, value.Field);
+ value_entry.QueryValue = value.Value;
+ op_chooser.Active = Array.IndexOf (value.Value.OperatorSet.Objects, value.Operator);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]