Skip to content

Commit

Permalink
Linux: Updated project after changes on other platforms.
Browse files Browse the repository at this point in the history
Related to issue #382.
  • Loading branch information
ycastonguay committed Aug 13, 2013
1 parent 595448e commit 84a5b91
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 15 deletions.
64 changes: 64 additions & 0 deletions MPfm/MPfm.GTK/Classes/LinuxSyncDeviceSpecifications.cs
@@ -0,0 +1,64 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using MPfm.Library;
using MPfm.Library.Objects;
using MPfm.Library.Services;

namespace MPfm.GTK.Classes
{
/// <summary>
/// Device specifications for Linux. Used for identifying sync devices.
/// </summary>
public class LinuxSyncDeviceSpecifications : ISyncDeviceSpecifications
{
public event NetworkStateChanged OnNetworkStateChanged;

public SyncDeviceType GetDeviceType()
{
return SyncDeviceType.Linux;
}

string _deviceName = string.Empty;
public string GetDeviceName()
{
return _deviceName;
}

public long GetFreeSpace()
{
return 0;
}

public string GetIPAddress()
{
return SyncListenerService.GetLocalIPAddress().ToString();
}

public string GetMusicFolderPath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
}

public void ReportNetworkStateChange(NetworkState networkState)
{
if (OnNetworkStateChanged != null)
OnNetworkStateChanged(networkState);
}
}
}
4 changes: 3 additions & 1 deletion MPfm/MPfm.GTK/Classes/Main.cs
Expand Up @@ -25,8 +25,9 @@
using MPfm.MVP.Bootstrap;
using MPfm.GTK.Navigation;
using MPfm.GTK.Windows;
using MPfm.Library;

namespace MPfm.GTK
namespace MPfm.GTK.Classes
{
public class MainClass
{
Expand All @@ -37,6 +38,7 @@ public static void Main (string[] args)
// Add view implementations to IoC
Application.Init();
Bootstrapper.GetContainer().Register<NavigationManager, GtkNavigationManager>().AsSingleton();
Bootstrapper.GetContainer().Register<ISyncDeviceSpecifications, LinuxSyncDeviceSpecifications>().AsSingleton();
Bootstrapper.GetContainer().Register<ISplashView, SplashWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IMainView, MainWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IUpdateLibraryView, UpdateLibraryWindow>().AsMultiInstance();
Expand Down
4 changes: 2 additions & 2 deletions MPfm/MPfm.GTK/Classes/Navigation/GtkNavigationManager.cs
Expand Up @@ -46,9 +46,9 @@ public override IMainView CreateMainView()
return view;
}

public override IPreferencesView CreatePreferencesView()
public override IDesktopPreferencesView CreatePreferencesView()
{
IPreferencesView view = null;
IDesktopPreferencesView view = null;
Gtk.Application.Invoke(delegate {
view = base.CreatePreferencesView();
});
Expand Down
1 change: 1 addition & 0 deletions MPfm/MPfm.GTK/MPfm.GTK.csproj
Expand Up @@ -100,6 +100,7 @@
<Compile Include="Classes\Main.cs" />
<Compile Include="Windows\SyncWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.SyncWindow.cs" />
<Compile Include="Classes\LinuxSyncDeviceSpecifications.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
10 changes: 9 additions & 1 deletion MPfm/MPfm.GTK/Windows/MainWindow.cs
Expand Up @@ -32,6 +32,7 @@
using MPfm.Library.UpdateLibrary;
using MPfm.GTK.Helpers;
using MPfm.MVP.Messages;
using MPfm.Player.Objects;

namespace MPfm.GTK.Windows
{
Expand Down Expand Up @@ -902,6 +903,14 @@ public void RefreshPlayerTimeShifting(PlayerTimeShiftingEntity entity)
// hscaleTimeShifting.Value = (float)entity.TimeShifting;
});
}

public void RefreshMarkers (IEnumerable<Marker> markers)
{
}

public void RefreshLoops (IEnumerable<Loop> loops)
{
}

public void PlayerError(Exception ex)
{
Expand Down Expand Up @@ -1016,6 +1025,5 @@ public void RefreshSongBrowser(IEnumerable<AudioFile> audioFiles)
}

#endregion

}
}
27 changes: 25 additions & 2 deletions MPfm/MPfm.GTK/Windows/PlaylistWindow.cs
Expand Up @@ -76,8 +76,31 @@ protected void OnActionSavePlaylistActivated (object sender, System.EventArgs e)

protected void OnActionSavePlaylistAsActivated (object sender, System.EventArgs e)
{
}
}

#region IPlaylistView implementation

public Action<Guid, int> OnChangePlaylistItemOrder { get; set; }
public Action<Guid> OnSelectPlaylistItem { get; set; }
public Action<Guid> OnRemovePlaylistItem { get; set; }
public Action OnNewPlaylist { get; set; }
public Action<string> OnLoadPlaylist { get; set; }
public Action OnSavePlaylist { get; set; }
public Action OnShufflePlaylist { get; set; }

public void PlaylistError (Exception ex)
{
}

public void RefreshPlaylist (MPfm.Sound.Playlists.Playlist playlist)
{
}

public void RefreshCurrentlyPlayingSong (int index, MPfm.Sound.AudioFiles.AudioFile audioFile)
{
}

#endregion

}
}

13 changes: 12 additions & 1 deletion MPfm/MPfm.GTK/Windows/PreferencesWindow.cs
Expand Up @@ -18,6 +18,7 @@
using System;
using MPfm.MVP;
using MPfm.MVP.Views;
using System.Collections.Generic;

namespace MPfm.GTK.Windows
{
Expand Down Expand Up @@ -53,6 +54,16 @@ protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
//this.HideAll();
Console.WriteLine("PreferencesWindow - OnDeleteEvent");
}

#region IPreferencesView implementation

public Action<string> OnSelectItem { get; set; }

public void RefreshItems (List<string> items)
{
}

#endregion

}
}

2 changes: 1 addition & 1 deletion MPfm/MPfm.GTK/Windows/SplashWindow.cs
Expand Up @@ -69,7 +69,7 @@ public void RefreshStatus(string message)
});
}

public void InitDone()
public void InitDone(bool isAppFirstStart)
{
Gtk.Application.Invoke(delegate{
this.Destroy();
Expand Down
31 changes: 25 additions & 6 deletions MPfm/MPfm.GTK/Windows/SyncWindow.cs
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using MPfm.MVP.Models;
using MPfm.GTK.Windows;
using MPfm.Library.Objects;

namespace MPfm.GTK
{
Expand Down Expand Up @@ -50,22 +51,40 @@ protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)

protected void OnSyncRefreshDeviceList(object sender, EventArgs e)
{
OnRefreshDevices();
}
OnStartDiscovery();
}

#region ISyncView implementation

public System.Action OnRefreshDevices { get; set; }
public Action<SyncDevice> OnConnectDevice { get; set; }
public Action<string> OnConnectDeviceManually { get; set; }
public Action OnStartDiscovery { get; set; }
public Action OnCancelDiscovery { get; set; }

public void RefreshDevices(IEnumerable<MPfm.MVP.Models.SyncDeviceEntity> devices)
public void SyncError (Exception ex)
{
}

public void SyncDevice(SyncDeviceEntity device)
public void RefreshIPAddress (string address)
{
}

#endregion
public void RefreshDiscoveryProgress (float percentageDone, string status)
{
}

public void RefreshDevices (IEnumerable<SyncDevice> devices)
{
}

public void RefreshDevicesEnded ()
{
}

public void SyncDevice (SyncDevice device)
{
}

#endregion
}
}
3 changes: 2 additions & 1 deletion MPfm/MPfm.GTK/Windows/UpdateLibraryWindow.cs
Expand Up @@ -29,6 +29,7 @@
using MPfm.MVP.Services;
using MPfm.MVP.Bootstrap;
using MPfm.Library.Services;
using MPfm.Library.Objects;

namespace MPfm.GTK.Windows
{
Expand Down Expand Up @@ -58,7 +59,7 @@ public partial class UpdateLibraryWindow : BaseWindow, IUpdateLibraryView
var audioFileCacheService = Bootstrapper.GetContainer().Resolve<AudioFileCacheService>();
var libraryService = Bootstrapper.GetContainer().Resolve<LibraryService>();
var updateLibraryService = Bootstrapper.GetContainer().Resolve<UpdateLibraryService>();
presenter = new UpdateLibraryPresenter(audioFileCacheService, libraryService, updateLibraryService);
presenter = new UpdateLibraryPresenter(audioFileCacheService, updateLibraryService);
presenter.BindView(this);

presenter.UpdateLibrary(mode, filePaths, folderPath);
Expand Down

0 comments on commit 84a5b91

Please sign in to comment.