After some struggle I have compiled the PHP module for wxPHP, and am writing a few scripts to see what it can do. My first demo creates a window and a task bar icon, and I cannot get the latter to work.
I am running this on Ubuntu 14.04 LTS.
Here is the script I am using:
<?php
// Create an icon (does not appear on Ubuntu 14.04 LTS)
$icon = new wxTaskBarIcon();
echo "Task bar available: " .
(wxTaskBarIcon::IsAvailable() ? 'Yes' : 'No') . "\n";
echo "Create task bar icon: " . ($icon ? 'OK' : 'Failed') . "\n";
$wxIcon = new wxIcon('icon.ico');
$ok = $icon->setIcon($wxIcon);
echo "Set image for icon: " . ($ok ? 'OK' : 'Failed') . "\n";
// Create a window (works fine)
$main = new wxFrame(null, wxID_TOP, "Title" );
$main->Show();
wxEntry();
Now, I would imagine the "task bar" in Unity is the top bar featuring the clock, sound and networks controls, and not the app dock on the left hand side. I do get a blank grey app icon in the dock, when the PHP task is running, but it's a status icon at the top I am after.
The console outputs from the above script show everything is OK:
Task bar available: Yes
Create task bar icon: OK
Set image for icon: OK
I have tried changing the icon.ico
to a non-existent file, and this pops a backtrace dialogue, which shows that the icon I am using is loading successfully (and presumably of an acceptable format).
Edit: further research indicates that:
- earlier versions of Ubuntu prevented apps from using the taskbar unless specifically whitelisted (note that the
gsettings
keys referenced here are not found in my later version of Ubuntu) - later versions require something called AppIndicators
Thus, my guess at present is that my code would work if it was not for Unity preventing the operation - and that it would immediately in other distros such as Mint.
I did find this guide that explains how to whitelist on Ubuntu 14, but this is most unsatisfying; to do something so trivial one should not need to alter the trusted repo list. If I wish to distribute an application written in wxPHP, users will (and should) find this unacceptable.
There are a couple of avenues for research, which I am now seeking advice upon:
- Do something differently in wxPHP, in case it (or upstream wxWidgets) has AppIndicators support (my guess is that it does not)
- Detect if AppIndicators is running, and if it is send DBus messages using PHP to construct an icon (though I've looked for a DBus message spec for AppIndicators in vain)
Edit again: since this is a rather niche question, and since Ask Ubuntu carries a number of programming-related questions for the Ubuntu platform, I have asked a DBus-specific question over on that site.