hipo r173 - in trunk: . src
- From: bgarret svn gnome org
- To: svn-commits-list gnome org
- Subject: hipo r173 - in trunk: . src
- Date: Fri, 14 Mar 2008 22:11:46 +0000 (GMT)
Author: bgarret
Date: Fri Mar 14 22:11:46 2008
New Revision: 173
URL: http://svn.gnome.org/viewvc/hipo?rev=173&view=rev
Log:
2008-03-14 Benoit Garret <benoit garret_gnome gadz org>
* src/DeviceSource.cs:
* src/Makefile.am:
* src/PlaylistSource.cs:
* src/Source.cs:
* src/SourceList.cs:
* src/TracksContainer.cs:
* src/devicepopup.xml:
* src/playlistpopup.xml:
* src/trackpopup.xml:
Clean the (Add|Remove)Handlers mess, it was a bug nest.
The popup menus are now generated in the code.
Removed:
trunk/src/devicepopup.xml
trunk/src/playlistpopup.xml
trunk/src/trackpopup.xml
Modified:
trunk/ChangeLog
trunk/src/DeviceSource.cs
trunk/src/Makefile.am
trunk/src/PlaylistSource.cs
trunk/src/Source.cs
trunk/src/SourceList.cs
trunk/src/TracksContainer.cs
Modified: trunk/src/DeviceSource.cs
==============================================================================
--- trunk/src/DeviceSource.cs (original)
+++ trunk/src/DeviceSource.cs Fri Mar 14 22:11:46 2008
@@ -40,6 +40,7 @@
[Widget] Label firmwareLabel;
private Device device;
+ private Menu menu;
public DeviceSource (Device device)
{
@@ -60,27 +61,20 @@
capacityLabel.Text = Tools.FormatString ((double) this.device.VolumeInfo.Size);
mountLabel.Text = this.device.VolumeInfo.MountPoint;
spaceLabel.Text = String.Format ("{0}%", (int) ((double) device.VolumeInfo.SpaceUsed / (double) device.VolumeInfo.Size * 100));
+ firmwareLabel.Text = this.device.FirmwareVersion;
// remove the viewport from the window so we can add it elsewhere
deviceProperties.Remove (deviceViewport);
- // source list right click menu
- ActionEntry[] entries = {
-
- new ActionEntry ("RenameDevice",
- Gtk.Stock.Copy,
- Catalog.GetString ("Rename"),
- null,
- Catalog.GetString ("Rename the device"),
- OnRename)
- };
-
- ActionGroup group = new ActionGroup ("DevicePopup");
- group.Add (entries);
- firmwareLabel.Text = this.device.FirmwareVersion;
+ // menu creation
+ menu = new Menu();
- UIManager.Instance.InsertActionGroup (group, 0);
- UIManager.Instance.AddUiFromResource ("devicepopup.xml");
+ MenuItem item = (MenuItem)(new Action ("RenameDevice",
+ Catalog.GetString ("Rename"),
+ Catalog.GetString ("Rename the device"),
+ Gtk.Stock.Copy)).CreateMenuItem ();
+ item.Activated += OnRename;
+ menu.Add (item);
}
public override string Name
@@ -107,7 +101,7 @@
public override Menu Menu
{
get {
- return (Menu)UIManager.Instance.GetWidget ("/ui/DevicePopup");
+ return menu;
}
}
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Mar 14 22:11:46 2008
@@ -29,9 +29,6 @@
$(srcdir)/hipo.glade \
$(srcdir)/errordialog.glade \
$(srcdir)/menubar.xml \
- $(srcdir)/devicepopup.xml \
- $(srcdir)/playlistpopup.xml \
- $(srcdir)/trackpopup.xml \
$(top_srcdir)/data/hipo-logo.png \
$(top_srcdir)/data/ipod.gif
Modified: trunk/src/PlaylistSource.cs
==============================================================================
--- trunk/src/PlaylistSource.cs (original)
+++ trunk/src/PlaylistSource.cs Fri Mar 14 22:11:46 2008
@@ -29,6 +29,7 @@
public class PlaylistSource : TracksContainer
{
Playlist playlist;
+ Menu menu;
public override event SourceDeletedEventHandler Deleted;
public PlaylistSource (Playlist playlist) : base ()
@@ -46,29 +47,22 @@
playlist.TrackAdded += OnTrackAdded;
playlist.TrackRemoved += OnTrackRemoved;
- // source list right click menu
- // don't connect the handlers now but only when the source is selected
- ActionEntry[] entries = {
-
- new ActionEntry ("RenamePlaylist",
- Gtk.Stock.Copy,
- Catalog.GetString ("Rename"),
- null,
- Catalog.GetString ("Rename the playlist"),
- null),
- new ActionEntry ("DeletePlaylist",
- Gtk.Stock.Delete,
- Catalog.GetString ("Delete"),
- null,
- Catalog.GetString ("Delete the playlist"),
- null)
- };
-
- ActionGroup group = new ActionGroup ("PlaylistPopup");
- group.Add (entries);
+ // menu creation
+ menu = new Menu();
- UIManager.Instance.InsertActionGroup (group, 0);
- UIManager.Instance.AddUiFromResource ("playlistpopup.xml");
+ MenuItem item = (MenuItem)(new Action ("RenamePlaylist",
+ Catalog.GetString ("Rename"),
+ Catalog.GetString ("Rename the playlist"),
+ Gtk.Stock.Copy)).CreateMenuItem ();
+ item.Activated += OnRename;
+ menu.Add (item);
+
+ item = (MenuItem)(new Action ("DeletePlaylist",
+ Catalog.GetString ("Delete"),
+ Catalog.GetString ("Delete the playlist"),
+ Gtk.Stock.Delete)).CreateMenuItem ();
+ item.Activated += OnDelete;
+ menu.Add (item);
}
public override string Name
@@ -88,7 +82,7 @@
public override Menu Menu
{
get {
- return (Menu)UIManager.Instance.GetWidget ("/ui/PlaylistPopup");
+ return menu;
}
}
@@ -216,55 +210,6 @@
Saviour.Instance.Save ();
}
- // there is only one copy of the menu widget in the UIManager
- // add and remove right click menu handlers as the source is selected or deselected
- // TODO: find an easy way to have one copy of the menu widget per instance
- protected override void AddEventHandlers ()
- {
- Tools.Log (this, 3, "Hooking {0} source menu event handlers", this.Name);
-
- Menu menu = (Menu)UIManager.Instance.GetWidget ("/ui/PlaylistPopup");
-
- // re-bind the menu items to the correct methods
- foreach (MenuItem item in menu.Children)
- {
- switch (item.Name)
- {
- case "RenamePlaylist":
- item.Activated += OnRename;
- break;
- case "DeletePlaylist":
- item.Activated += OnDelete;
- break;
- }
- }
-
- base.AddEventHandlers ();
- }
-
- protected override void RemoveEventHandlers ()
- {
- Tools.Log (this, 3, "Unhooking {0} source menu event handlers", this.Name);
-
- Menu menu = (Menu)UIManager.Instance.GetWidget ("/ui/PlaylistPopup");
-
- // re-bind the menu items to the correct methods
- foreach (MenuItem item in menu.Children)
- {
- switch (item.Name)
- {
- case "RenamePlaylist":
- item.Activated -= OnRename;
- break;
- case "DeletePlaylist":
- item.Activated -= OnDelete;
- break;
- }
- }
-
- base.RemoveEventHandlers ();
- }
-
private void OnTrackAdded (object o, int index, Track track)
{
Tools.Log (this, 3, "Adding track {0} to playlist {1} at position {2}", track.Title, this.Name, index);
Modified: trunk/src/Source.cs
==============================================================================
--- trunk/src/Source.cs (original)
+++ trunk/src/Source.cs Fri Mar 14 22:11:46 2008
@@ -49,8 +49,6 @@
// source icon
Pixbuf Icon {get;}
- bool Selected {get; set;}
-
// source item count
int Count {get;}
@@ -73,7 +71,6 @@
private Pixbuf icon;
private int count;
private SourceType parent;
- private bool selected;
public virtual event SourceDeletedEventHandler Deleted;
@@ -90,7 +87,6 @@
searchEntry.Sensitive = false;
menu = new Menu ();
type = SourceType.None;
- selected = false;
count = 0;
name = "Default name, override me";
}
@@ -160,17 +156,6 @@
}
}
- public virtual bool Selected
- {
- get {
- return selected;
- }
-
- set {
- selected = value;
- }
- }
-
public virtual int Count
{
get {
Modified: trunk/src/SourceList.cs
==============================================================================
--- trunk/src/SourceList.cs (original)
+++ trunk/src/SourceList.cs Fri Mar 14 22:11:46 2008
@@ -185,15 +185,10 @@
else
Tools.Log (this, 2, "No source selected");
- if (selectedSource != null)
- selectedSource.Selected = false;
-
selectedSource = value;
if (selectedSource != null)
{
- selectedSource.Selected = true;
-
store.Foreach (delegate (TreeModel model, TreePath path, TreeIter iter) {
ISource source = (ISource)store.GetValue (iter, 0);
@@ -368,7 +363,7 @@
private void PopupMenu (Gdk.Event ev)
{
- Tools.Log (this, 3, "Showing popup menu for source {0}", selectedSource.Menu);
+ Tools.Log (this, 3, "Showing popup menu for source {0}", selectedSource.Name);
// build the menu and show it
Menu menu = selectedSource.Menu;
Modified: trunk/src/TracksContainer.cs
==============================================================================
--- trunk/src/TracksContainer.cs (original)
+++ trunk/src/TracksContainer.cs Fri Mar 14 22:11:46 2008
@@ -41,9 +41,10 @@
private TreeModelFilter store_filter;
private Entry search;
private SourceType type;
- private bool selected;
private IList<Track> tracks;
private Column sortColumn = Column.Artist;
+ private MenuItem addToPlaylistItem;
+ private Menu menu;
private static TargetEntry [] source_entries = {
new TargetEntry ("text/uri-list", 0, 0),
@@ -99,34 +100,28 @@
store_filter = new TreeModelFilter (view.Model, null);
store_filter.VisibleFunc = SearchFilterFunc;
- // create action entries
- ActionEntry[] entries = {
-
- new ActionEntry ("AddToPlaylist",
- Gtk.Stock.Add, Catalog.GetString ("Add to Playlist..."),
- null,
- Catalog.GetString ("Add the track to a Playlist"),
- null),
- new ActionEntry ("Remove",
- Gtk.Stock.Remove,
- null,
- null,
- Catalog.GetString ("Remove the track from your iPod"),
- null),
- new ActionEntry ("TrackProperties",
- Gtk.Stock.Properties,
- Catalog.GetString ("Track Properties"),
- null,
- Catalog.GetString ("Track Properties"),
- null),
- };
-
- // create the ui manager and the keyboard shortcuts
- ActionGroup group = new ActionGroup ("TrackPopup");
- group.Add (entries);
+ // menu creation
+ menu = new Menu();
- UIManager.Instance.InsertActionGroup (group, 0);
- UIManager.Instance.AddUiFromResource ("trackpopup.xml");
+ addToPlaylistItem = (MenuItem)(new Action ("AddToPlaylist",
+ Catalog.GetString ("Add to Playlist..."),
+ Catalog.GetString ("Add the track to a Playlist"),
+ Gtk.Stock.Add)).CreateMenuItem ();
+ menu.Add (addToPlaylistItem);
+
+ MenuItem item = (MenuItem)(new Action ("RemoveTrack",
+ Catalog.GetString ("Remove"),
+ Catalog.GetString ("Remove the track from your iPod"),
+ Gtk.Stock.Remove)).CreateMenuItem ();
+ item.Activated += OnRemove;
+ menu.Add (item);
+
+ item = (MenuItem)(new Action ("TrackProperties",
+ Catalog.GetString ("Track Properties"),
+ Catalog.GetString ("Track Properties"),
+ Gtk.Stock.Properties)).CreateMenuItem ();
+ item.Activated += OnTrackProperties;
+ menu.Add (item);
}
TreeViewColumn BuildColumn (Column column)
@@ -250,22 +245,6 @@
}
}
- public override bool Selected
- {
- get {
- return selected;
- }
-
- set {
- this.selected = value;
-
- if (this.selected)
- AddEventHandlers ();
- else
- RemoveEventHandlers ();
- }
- }
-
// the two following methods have to be implemented
// to add tracks to the source when drag and dropped to.
public virtual bool AddTracks (string[] paths, bool save)
@@ -324,7 +303,6 @@
Tools.Log (this, 3, "Building and showing track popup menu");
Menu playlistMenu = new Menu ();
- MenuItem addToPlaylistItem = (MenuItem)UIManager.Instance.GetWidget ("/ui/TrackPopup/AddToPlaylist");
foreach (ISource source in SourceList.Instance.Playlists)
{
@@ -342,8 +320,6 @@
addToPlaylistItem.Submenu = playlistMenu;
- Menu menu = (Menu)Hipo.UIManager.Instance.GetWidget ("/ui/TrackPopup");
-
menu.ShowAll ();
playlistMenu.ShowAll ();
@@ -357,48 +333,6 @@
playlistSource.AddTracks (GetSelectedTracks ());
}
- protected virtual void AddEventHandlers ()
- {
- Tools.Log (this, 3, "Hooking {0} track menu event handlers", this.Name);
-
- Menu menu = (Menu)UIManager.Instance.GetWidget ("/ui/TrackPopup");
-
- // re-bind the menu items to the correct methods
- foreach (MenuItem item in menu.Children)
- {
- switch (item.Name)
- {
- case "Remove":
- item.Activated += OnRemove;
- break;
- case "TrackProperties":
- item.Activated += OnTrackProperties;
- break;
- }
- }
- }
-
- protected virtual void RemoveEventHandlers ()
- {
- Tools.Log (this, 3, "Unhooking {0} track menu event handlers", this.Name);
-
- Menu menu = (Menu)UIManager.Instance.GetWidget ("/ui/TrackPopup");
-
- // re-bind the menu items to the correct methods
- foreach (MenuItem item in menu.Children)
- {
- switch (item.Name)
- {
- case "Remove":
- item.Activated -= OnRemove;
- break;
- case "TrackProperties":
- item.Activated -= OnTrackProperties;
- break;
- }
- }
- }
-
private List<Track> GetSelectedTracks ()
{
TreeIter iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]