Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Adapt the Growl sample to work with Xamarin.Mac using Xamarin.Growl.d…
…ll (MonoMac still has Growl support until the next update/release of MonoDevelop)
  • Loading branch information
spouliot committed Jan 10, 2013
1 parent 802f2f1 commit ce7e1f2
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 48 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,5 +1,7 @@
bin/
obj/
mono/
xamarin/
*.dll*
*.userprefs
.DS_Store
9 changes: 8 additions & 1 deletion Growl/README.md
Expand Up @@ -3,5 +3,12 @@ Growl Bindings

This is a copy of the Growl bindings that were included directly in monomac.dll in the past. Since Growl is an external application/framework, with a different release schedule than OSX, it is being moved to a separate assembly.

The current bindings are for Growl 1.2.1. For information in:
The current bindings are for Growl 1.2.1 (a bit outdated). For information in:
http://cocoa-mono.org/archives/254/growl-my-monomac-application-says/

Notes
=====

The currently (January 2013) shipping versions of MonoMac.dll still contains the MonoMac.Growl namespace. You cannot use the Mono.Growl.dll assembly until a new release of MonoDevelop ships with a newer MonoMac.dll.

Xamarin.Mac version 1.0.40 (and later) can uses Xamarin.Growl.dll. The sample code was update to use XamMac.dll by default - but this can be changed by replacing XamMac.dll by MonoMac.dll and Xamarin.Growl.dll with Mono.Growl.dll (see above).
18 changes: 3 additions & 15 deletions Growl/samples/TwoMinuteGrowler/Main.cs
@@ -1,24 +1,12 @@
using System;
using System.Runtime;
using System.IO;
using System.Drawing;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;

namespace TwoMinuteGrowler {
class MainClass {
static void Main ( string[] args ) {

var baseAppPath = Directory.GetParent (Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ());
//var growlPath = baseAppPath + "/Frameworks/Growl-WithInstaller.framework/Growl-WithInstaller";
var growlPath = baseAppPath + "/Frameworks/Growl.framework/Growl";

Dlfcn.dlopen (growlPath, 0);

static void Main (string[] args)
{
NSApplication.Init ();
NSApplication.Main (args);
}
}
}

}
44 changes: 35 additions & 9 deletions Growl/samples/TwoMinuteGrowler/MainWindow.cs
@@ -1,15 +1,41 @@

using System;
using System.IO;
using MonoMac.AppKit;
using MonoMac.Foundation;
using MonoMac.ObjCRuntime;

namespace TwoMinuteGrowler {

public partial class MainWindow : NSWindow {

namespace TwoMinuteGrowler
{
public partial class MainWindow : MonoMac.AppKit.NSWindow
{
public MainWindow (IntPtr handle) : base(handle) {}
public MainWindow (IntPtr handle) : base (handle)
{
Initialize ();
}

[Export("initWithCoder:")]
public MainWindow (NSCoder coder) : base(coder) {}
}
}
public MainWindow (NSCoder coder) : base (coder)
{
Initialize ();
}

void Initialize ()
{
// First check if Growl is available globally
string growlPath = "/Library/Frameworks/Growl.framework/Growl";
// if not...
if (!File.Exists (growlPath)) {
// then look if the application is bundling the framework
growlPath = Path.Combine (NSBundle.MainBundle.ExecutablePath, "../../Frameworks/Growl.framework/Growl");
}
// Try loading the framework
if (Dlfcn.dlopen (growlPath, 0) == IntPtr.Zero) {
// if we can't then show some instructions
NSAlert alert = NSAlert.WithMessage ("Missing Growl.framework", "Quit", null, null,
"See README.md for the additional requirements");
alert.RunSheetModal (this);
NSApplication.SharedApplication.Terminate (this);
}
}
}
}
16 changes: 10 additions & 6 deletions Growl/samples/TwoMinuteGrowler/README.md
Expand Up @@ -10,17 +10,21 @@ Requirements:
=============
Growl application installed
Growl SDK to be linked in
And of course the MonoMac plugin for MonoDevelop
And of course either MonoMac or Xamarin.Mac

Custom Command for build:
=========================
This sample uses a custom command for After Build to link in the Growl framework.
Distributing the Growl framework:
=================================

By default the sample looks for the Growl framework installed in /Library/Frameworks

However you can also include the framework inside your own application. This will ease distribution by avoiding an extra dependency.

In this case you'll need to add a custom command for After Build:

mkdir -p ${TargetDir}/${SolutionName}.app/Contents/Frameworks; cp –r <LINK_TO_YOUR_GROWL_FRAMEWORK>/Frameworks/Growl.framework ${TargetDir}/${SolutionName}.app/Contents/Frameworks

Make sure you replace the <LINK_TO_YOUR_GROWL_FRAMEWORK> with the directory location where you copied the SDK frameworks.


For a full description of the process of linking the Growl framework can be found here:

http://cocoa-mono.org/?p=254
http://cocoa-mono.org/archives/254/growl-my-monomac-application-says/
40 changes: 23 additions & 17 deletions Growl/samples/TwoMinuteGrowler/TwoMinuteGrowler.csproj
Expand Up @@ -6,44 +6,50 @@
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{052D9378-E657-4291-BC62-D98E434B6FEB}</ProjectGuid>
<ProjectTypeGuids>{948B3504-5B70-4649-8FE4-BDE1FB46EC69};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectTypeGuids>{42C0BBD9-55CE-4FC1-8D90-A7348ABAFB23};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>TwoMinuteGrowler</RootNamespace>
<AssemblyName>TwoMinuteGrowler</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<LastXamMacNagTime>12/11/2012 10:22:26 PM</LastXamMacNagTime>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CustomCommands>
<CustomCommands>
<Command type="AfterBuild" command="mkdir -p ${TargetDir}/${SolutionName}.app/Contents/Frameworks; cp -r &lt;LINK_TO_YOUR_GROWL_FRAMEWORK&gt;/Frameworks/Growl.framework ${TargetDir}/${SolutionName}.app/Contents/Frameworks" workingdir="" externalConsole="true" />
</CustomCommands>
</CustomCommands>
<ConsolePause>False</ConsolePause>
<EnableCodeSigning>False</EnableCodeSigning>
<CreatePackage>False</CreatePackage>
<EnablePackageSigning>False</EnablePackageSigning>
<IncludeMonoRuntime>True</IncludeMonoRuntime>
<UseSGen>False</UseSGen>
<CodeSigningKey>Mac Developer</CodeSigningKey>
<PackageSigningKey>Developer ID Installer</PackageSigningKey>
<I18n />
<LinkMode>Full</LinkMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<Optimize>False</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<ConsolePause>False</ConsolePause>
<EnableCodeSigning>False</EnableCodeSigning>
<CreatePackage>False</CreatePackage>
<EnablePackageSigning>False</EnablePackageSigning>
<IncludeMonoRuntime>False</IncludeMonoRuntime>
<UseSGen>False</UseSGen>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="MonoMac">
<SpecificVersion>False</SpecificVersion>
<Reference Include="XamMac" />
<Reference Include="Xamarin.Growl">
<HintPath>..\..\binding\Xamarin.Growl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down

0 comments on commit ce7e1f2

Please sign in to comment.