1 /* Haiku window system support
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or (at
9 your option) any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
25 #include <SupportDefs.h>
27 #include <AppFileInfo.h>
28 #include <TranslationUtils.h>
29 #include <Application.h>
39 be_perror (status_t code
, char *arg
)
46 fprintf (stderr
, "%s: Bad value\n", arg
);
48 case B_ENTRY_NOT_FOUND
:
49 fprintf (stderr
, "%s: Not found\n", arg
);
51 case B_PERMISSION_DENIED
:
52 fprintf (stderr
, "%s: Permission denied\n", arg
);
55 fprintf (stderr
, "%s: No memory\n", arg
);
58 fprintf (stderr
, "%s: Link limit reached\n", arg
);
61 fprintf (stderr
, "%s: Busy\n", arg
);
64 fprintf (stderr
, "%s: No more file descriptors\n", arg
);
67 fprintf (stderr
, "%s: File error\n", arg
);
70 fprintf (stderr
, "%s: Unknown error\n", arg
);
76 fprintf (stderr
, "Setting resources failed on the `src/Emacs' binary.\n"
77 "This may result in the installed `Emacs' binary not launching\n"
78 " from the tracker, but is inconsequential during packaging.\n");
82 main (int argc
, char **argv
)
84 BApplication
app ("application/x-vnd.GNU-emacs-resource-helper");
87 BBitmap
scale32 (BRect (0, 0, 31, 31), B_RGBA32
, true);
88 BBitmap
scale16 (BRect (0, 0, 15, 15), B_RGBA32
, true);
91 struct version_info vinfo
;
92 char *v
= strdup (PACKAGE_VERSION
);
94 if (scale32
.InitCheck () != B_OK
95 || scale16
.InitCheck () != B_OK
)
97 fprintf (stderr
, "Bitmap initialization ran out of memory\n");
101 BView
scale32view (scale32
.Bounds (), NULL
,
102 B_FOLLOW_NONE
, B_WILL_DRAW
);
103 BView
scale16view (scale16
.Bounds (), NULL
,
104 B_FOLLOW_NONE
, B_WILL_DRAW
);
108 printf ("be-resources ICON FILE: make FILE appropriate for Emacs.\n");
112 code
= file
.SetTo (argv
[2], B_READ_WRITE
);
115 be_perror (code
, argv
[2]);
118 code
= info
.SetTo (&file
);
121 be_perror (code
, argv
[2]);
124 code
= info
.SetAppFlags (B_EXCLUSIVE_LAUNCH
| B_ARGV_ONLY
);
127 be_perror (code
, argv
[2]);
131 icon
= BTranslationUtils::GetBitmapFile (argv
[1], NULL
);
135 be_perror (B_ERROR
, argv
[1]);
139 scale32
.AddChild (&scale32view
);
140 scale16
.AddChild (&scale16view
);
142 if (!scale32view
.LockLooper ()
143 || !scale16view
.LockLooper ())
145 fprintf (stderr
, "Failed to lock bitmap looper\n");
149 scale32view
.DrawBitmapAsync (icon
, scale32
.Bounds ());
150 scale16view
.DrawBitmapAsync (icon
, scale16
.Bounds ());
155 info
.SetIcon (&scale16
, B_MINI_ICON
);
156 info
.SetIcon (&scale32
, B_LARGE_ICON
);
157 info
.SetSignature ("application/x-vnd.GNU-emacs");
160 vinfo
.major
= atoi (v
);
162 v
= strtok (NULL
, ".");
163 vinfo
.middle
= atoi (v
);
165 v
= strtok (NULL
, ".");
166 vinfo
.minor
= v
? atoi (v
) : 0;
171 strncpy ((char *) &vinfo
.short_info
, PACKAGE_VERSION
,
172 sizeof vinfo
.short_info
- 1);
173 strncpy ((char *) &vinfo
.long_info
, PACKAGE_STRING
,
174 sizeof vinfo
.long_info
- 1);
176 info
.SetVersionInfo (&vinfo
, B_APP_VERSION_KIND
);