Skip to content

Commit

Permalink
Linux: Added SyncCloudWindow and SyncWebBrowserWindow.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycastonguay committed Oct 18, 2013
1 parent 7beec80 commit 1afb3a2
Show file tree
Hide file tree
Showing 13 changed files with 729 additions and 16 deletions.
5 changes: 5 additions & 0 deletions MPfm/MPfm.GTK/Classes/LinuxSyncDeviceSpecifications.cs
Expand Up @@ -62,6 +62,11 @@ public string GetIPAddress()
return SyncListenerService.GetLocalIPAddress().ToString();
}

public string GetDeviceUniqueId()
{
return string.Empty;
}

public string GetMusicFolderPath()
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
Expand Down
21 changes: 14 additions & 7 deletions MPfm/MPfm.GTK/Classes/Main.cs
Expand Up @@ -20,25 +20,30 @@
using System.Reflection;
using Gtk;
using MPfm.MVP;
using MPfm.MVP.Views;
using MPfm.MVP.Navigation;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;
using MPfm.MVP.Services;
using MPfm.MVP.Views;
using MPfm.GTK.Navigation;
using MPfm.GTK.Windows;
using MPfm.Library;
using MPfm.Library.Services.Interfaces;
using MPfm.MVP.Config.Providers;

namespace MPfm.GTK.Classes
{
public class MainClass
{
static NavigationManager navigationManager;

public static void Main (string[] args)
{
// Add view implementations to IoC
Application.Init();
Bootstrapper.GetContainer().Register<NavigationManager, GtkNavigationManager>().AsSingleton();
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<IAppConfigProvider, XmlAppConfigProvider>().AsSingleton();
Bootstrapper.GetContainer().Register<IDropboxService, MPfm.Library.Services.DropboxCoreService>().AsSingleton();
Bootstrapper.GetContainer().Register<ISplashView, SplashWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IMainView, MainWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<IUpdateLibraryView, UpdateLibraryWindow>().AsMultiInstance();
Expand All @@ -48,6 +53,8 @@ public static void Main (string[] args)
Bootstrapper.GetContainer().Register<ISyncView, SyncWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncMenuView, SyncMenuWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncDownloadView, SyncDownloadWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncCloudView, SyncCloudWindow>().AsMultiInstance();
Bootstrapper.GetContainer().Register<ISyncWebBrowserView, SyncWebBrowserWindow>().AsMultiInstance();

// Create and start navigation manager
navigationManager = Bootstrapper.GetContainer().Resolve<NavigationManager>();
Expand Down
4 changes: 4 additions & 0 deletions MPfm/MPfm.GTK/MPfm.GTK.csproj
Expand Up @@ -128,6 +128,10 @@
<Compile Include="Classes\Helpers\ResourceHelper.cs" />
<Compile Include="Windows\SyncDownloadWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.SyncDownloadWindow.cs" />
<Compile Include="Windows\SyncCloudWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.SyncCloudWindow.cs" />
<Compile Include="Windows\SyncWebBrowserWindow.cs" />
<Compile Include="gtk-gui\MPfm.GTK.SyncWebBrowserWindow.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
17 changes: 14 additions & 3 deletions MPfm/MPfm.GTK/Windows/MainWindow.cs
Expand Up @@ -546,7 +546,6 @@ protected void OnAboutActionActivated(object sender, System.EventArgs e)
string text = Title + "\nMPfm: Music Player for Musicians is © 2011-2012 Yanick Castonguay and is released under the GPLv3 license.";
text += "\nThe BASS audio library is © 1999-2012 Un4seen Developments.";
text += "\nThe BASS.NET audio library is © 2005-2012 radio42.";


MessageDialog md = new MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, text);
md.Run();
Expand Down Expand Up @@ -632,7 +631,7 @@ protected void OnTreeLibraryBrowserRowExpanded(object sender, Gtk.RowExpandedArg
// Check for dummy node
_storeLibraryBrowser.IterChildren(out iter, args.Iter);
LibraryBrowserEntity entityChildren = (LibraryBrowserEntity)_storeLibraryBrowser.GetValue(iter, 0);
if(entityChildren.Type == LibraryBrowserEntityType.Dummy)
if(entityChildren.EntityType == LibraryBrowserEntityType.Dummy)
{
OnTreeNodeExpanded(entity, args.Iter);
}
Expand Down Expand Up @@ -682,6 +681,16 @@ protected void OnActionDeleteMarkerActivated(object sender, EventArgs e)
{
}

protected void OnActionSyncCloudActivated(object sender, EventArgs e)
{
OnOpenSyncCloudWindow();
}

protected void OnActionSyncWebBrowserActivated(object sender, EventArgs e)
{
OnOpenSyncWebBrowserWindow();
}

#endregion

private static Gdk.Pixbuf ImageToPixbuf(System.Drawing.Image image)
Expand All @@ -705,6 +714,8 @@ protected void btnTest_Click(object sender, EventArgs e)
public System.Action OnOpenEffectsWindow { get; set; }
public System.Action OnOpenPlaylistWindow { get; set; }
public System.Action OnOpenSyncWindow { get; set; }
public System.Action OnOpenSyncCloudWindow { get; set; }
public System.Action OnOpenSyncWebBrowserWindow { get; set; }

public System.Action<List<string>> OnAddFilesToLibrary { get; set; }
public System.Action<string> OnAddFolderToLibrary { get; set; }
Expand Down Expand Up @@ -925,7 +936,7 @@ public void RefreshLibraryBrowserNode(LibraryBrowserEntity entity, IEnumerable<L
TreeIter treeIterDummy;
_storeLibraryBrowser.IterNthChild(out treeIterDummy, iter, 0);

switch(entity.Type)
switch(entity.EntityType)
{
case LibraryBrowserEntityType.Artists:
foreach(LibraryBrowserEntity artist in entities)
Expand Down
69 changes: 69 additions & 0 deletions MPfm/MPfm.GTK/Windows/SyncCloudWindow.cs
@@ -0,0 +1,69 @@
// 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.GTK.Windows;
using MPfm.MVP.Views;
using MPfm.Library.Objects;
using System.Text;
using Gtk;

namespace MPfm.GTK
{
public partial class SyncCloudWindow : BaseWindow, ISyncCloudView
{
public SyncCloudWindow(Action<IBaseView> onViewReady) :
base(Gtk.WindowType.Toplevel, onViewReady)
{
this.Build();
onViewReady(this);
//btnRefreshDeviceList.GrabFocus(); // the list view changes color when focused by default. it annoys me!
this.Center();
this.Show();
}

protected void OnClickCancel(object sender, EventArgs e)
{
}

#region ISyncCloudView implementation

public void SyncCloudError(Exception ex)
{
Gtk.Application.Invoke(delegate
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("An error occured in the SyncCloud component:");
sb.AppendLine(ex.Message);
sb.AppendLine();
sb.AppendLine(ex.StackTrace);
MessageDialog md = new MessageDialog(
this,
DialogFlags.Modal,
MessageType.Error,
ButtonsType.Ok,
sb.ToString()
);
md.Run();
md.Destroy();
});
}

#endregion

}
}
77 changes: 77 additions & 0 deletions MPfm/MPfm.GTK/Windows/SyncWebBrowserWindow.cs
@@ -0,0 +1,77 @@
// 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.GTK.Windows;
using MPfm.MVP.Views;
using MPfm.Library.Objects;
using System.Text;
using Gtk;

namespace MPfm.GTK
{
public partial class SyncWebBrowserWindow : BaseWindow, ISyncWebBrowserView
{
public SyncWebBrowserWindow(Action<IBaseView> onViewReady) :
base(Gtk.WindowType.Toplevel, onViewReady)
{
this.Build();
onViewReady(this);
//btnRefreshDeviceList.GrabFocus(); // the list view changes color when focused by default. it annoys me!
this.Center();
this.Show();
}

protected void OnClickCancel(object sender, EventArgs e)
{
}

#region ISyncWebBrowserView implementation

public void SyncWebBrowserError(Exception ex)
{
Gtk.Application.Invoke(delegate
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("An error occured in the SyncCloud component:");
sb.AppendLine(ex.Message);
sb.AppendLine();
sb.AppendLine(ex.StackTrace);
MessageDialog md = new MessageDialog(
this,
DialogFlags.Modal,
MessageType.Error,
ButtonsType.Ok,
sb.ToString()
);
md.Run();
md.Destroy();
});
}

public void RefreshContent(string url, string authenticationCode)
{
Gtk.Application.Invoke(delegate
{
lblUrl.Text = url;
lblAuthenticationCode.Text = authenticationCode;
});
}

#endregion
}
}

0 comments on commit 1afb3a2

Please sign in to comment.