Fix Emacs icon not appearing on Haiku

* lib-src/be_resources.cc (main): Scale input bitmap
appropriately before setting it as the mini and large icons.
* src/Makefile.in (Emacs): Add dependency on
`lib-src/be-resources'.
This commit is contained in:
Po Lu 2022-01-17 11:09:50 +00:00
parent 1cd6737a38
commit 412247c53f
2 changed files with 37 additions and 4 deletions

View file

@ -29,6 +29,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <Application.h>
#include <Catalog.h>
#include <Roster.h>
#include <Bitmap.h>
#include <Rect.h>
#include <View.h>
using namespace std;
@ -79,11 +82,25 @@ main (int argc, char **argv)
BApplication app ("application/x-vnd.GNU-emacs-resource-helper");
BFile file;
BBitmap *icon;
BBitmap scale32 (BRect (0, 0, 31, 31), B_RGBA32, true);
BBitmap scale16 (BRect (0, 0, 15, 15), B_RGBA32, true);
BAppFileInfo info;
status_t code;
struct version_info vinfo;
char *v = strdup (PACKAGE_VERSION);
if (scale32.InitCheck () != B_OK
|| scale16.InitCheck () != B_OK)
{
fprintf (stderr, "Bitmap initialization ran out of memory\n");
return EXIT_FAILURE;
}
BView scale32view (scale32.Bounds (), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
BView scale16view (scale16.Bounds (), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
if (argc != 3)
{
printf ("be-resources ICON FILE: make FILE appropriate for Emacs.\n");
@ -117,8 +134,24 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
info.SetIcon (icon, B_MINI_ICON);
info.SetIcon (icon, B_LARGE_ICON);
scale32.AddChild (&scale32view);
scale16.AddChild (&scale16view);
if (!scale32view.LockLooper ()
|| !scale16view.LockLooper ())
{
fprintf (stderr, "Failed to lock bitmap looper\n");
return EXIT_FAILURE;
}
scale32view.DrawBitmapAsync (icon, scale32.Bounds ());
scale16view.DrawBitmapAsync (icon, scale16.Bounds ());
scale32view.Sync ();
scale16view.Sync ();
info.SetIcon (&scale16, B_MINI_ICON);
info.SetIcon (&scale32, B_LARGE_ICON);
info.SetSignature ("application/x-vnd.GNU-emacs");
v = strtok (v, ".");
@ -140,5 +173,5 @@ main (int argc, char **argv)
info.SetVersionInfo (&vinfo, B_APP_VERSION_KIND);
return EXIT_SUCCESS;
exit (EXIT_SUCCESS);
}

View file

@ -616,7 +616,7 @@ endif
## icon set.
ifeq ($(HAVE_BE_APP),yes)
Emacs: emacs$(EXEEXT)
Emacs: emacs$(EXEEXT) $(libsrc)/be-resources
$(AM_V_GEN) cp -f emacs$(EXEEXT) $@
$(AM_V_at) $(libsrc)/be-resources \
$(etc)/images/icons/hicolor/32x32/apps/emacs.png $@