Bug 1518 - Cannot hide icon from Dock on Mac
Summary: Cannot hide icon from Dock on Mac
Status: NEW
Alias: None
Product: Gtk#
Classification: Mono
Component: gtk-sharp ()
Version: unspecified
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-10-16 13:45 UTC by cmre99
Modified: 2014-09-04 05:24 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (26.37 KB, application/zip)
2014-09-04 05:24 UTC, Antonius Riha
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 1518 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description cmre99 2011-10-16 13:45:08 UTC
Mac requires an app bundle that contains an Info.plist file.  This files points to a startup script that starts mono and the specified app correctly.  When building an app using the StatusIcon object the icon appears in the menu bar of the Mac correctly.  However, the app icon also appears in the Dock.  The standard way of preventing this does not work ( putting an LSUIElement node with the value of 1 in the Info.Plist file ).  The icon still appears in the Dock.

Info.plist contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>LSUIElement</key>
	<string>1</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleExecutable</key>
	<string>startTestGtk</string>
	<key>CFBundleIconFile</key>
	<string>rabbit.icns</string>
	<key>CFBundleIdentifier</key>
	<string>com.Test.TestGtk</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>TestGtk</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>1.0</string>
	<key>CFBundleSignature</key>
	<string>mmsd</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>NSAppleScriptEnabled</key>
	<string>NO</string>
</dict>
</plist>


startTestGtk contents:

#!/bin/sh

#get the bundle's MacOS directory full path
DIR=$(cd "$(dirname "$0")"; pwd)

#change these values to match your app
EXE_PATH="$DIR/TestGtk.exe"
PROCESS_NAME=TestGtk
APPNAME="TestGtk"

#set up environment
MONO_FRAMEWORK_PATH=/Library/Frameworks/Mono.framework/Versions/Current
export DYLD_FALLBACK_LIBRARY_PATH="$DIR:$MONO_FRAMEWORK_PATH/lib:/lib:/usr/lib"
export PATH="$MONO_FRAMEWORK_PATH/bin:$PATH"

#mono version check
REQUIRED_MAJOR=2
REQUIRED_MINOR=4

VERSION_TITLE="Cannot launch $APPNAME"
VERSION_MSG="$APPNAME requires the Mono Framework version $REQUIRED_MAJOR.$REQUIRED_MINOR or later."
DOWNLOAD_URL="http://www.go-mono.com/mono-downloads/download.html"

MONO_VERSION="$(mono --version | grep 'Mono JIT compiler version ' |  cut -f5 -d\ )"
MONO_VERSION_MAJOR="$(echo $MONO_VERSION | cut -f1 -d.)"
MONO_VERSION_MINOR="$(echo $MONO_VERSION | cut -f2 -d.)"
if [ -z "$MONO_VERSION" ] \
	|| [ $MONO_VERSION_MAJOR -lt $REQUIRED_MAJOR ] \
	|| [ $MONO_VERSION_MAJOR -eq $REQUIRED_MAJOR -a $MONO_VERSION_MINOR -lt $REQUIRED_MINOR ] 
then
	osascript \
	-e "set question to display dialog \"$VERSION_MSG\" with title \"$VERSION_TITLE\" buttons {\"Cancel\", \"Download...\"} default button 2" \
	-e "if button returned of question is equal to \"Download...\" then open location \"$DOWNLOAD_URL\""
	echo "$VERSION_TITLE"
	echo "$VERSION_MSG"
	exit 1
fi

#get an exec command that will work on the current OS version
OSX_VERSION=$(uname -r | cut -f1 -d.)
#echo $OSX_VERSION

if [ $OSX_VERSION -gt 9 ]; then  # If OSX version is 10.4
	MONO_EXEC="exec mono"
else
	MONO_EXEC="exec -a \"$PROCESS_NAME\" mono"
fi

#run app using mono
echo $MONO_EXEC "$EXE_PATH"
$MONO_EXEC "$EXE_PATH"
Comment 1 Mikayla Hutchinson [MSFT] 2011-10-18 04:44:37 UTC
FWIW, LSUIElement works fine with MonoMac, so this is probably a GTK bug.
Comment 2 Ilber Ibrahimi 2012-02-10 14:21:28 UTC
It's not a GTK bug. I try both, pure Windows StatusIcon and GTK StatusIcon, in both of this the icon is still on the Mac Dock. Please check why the LSUIElement does not work with mono.
Comment 3 Antonius Riha 2014-09-04 05:24:55 UTC
Created attachment 7915 [details]
Test case

I've attached a test case that shows the difference between monomac and gtk#, when using the LSUIElement in Info.plist:
 * The monomac app stays in the background and no icon is visible in the dock (and also no window).
 * The gtk# app displays the window when launched