aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.m
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-12 10:30:10 -0500
committerDavid Robillard <d@drobilla.net>2023-01-14 11:53:28 -0500
commitbd4f79646f623e929e6aa22bea028952b515aeef (patch)
treee2dcc2635bb2b12b9c552755b35a0343005ce88a /src/mac.m
parent786a28e4a2bc9fce95a8d2e6cd1a4c76d2ae1a0f (diff)
downloadpugl-bd4f79646f623e929e6aa22bea028952b515aeef.tar.gz
pugl-bd4f79646f623e929e6aa22bea028952b515aeef.tar.bz2
pugl-bd4f79646f623e929e6aa22bea028952b515aeef.zip
Add general string hint interface
This replaces the window title and class name APIs with a more general one that can be easily extended to other things, like icon names, more detailed application hints, and so on.
Diffstat (limited to 'src/mac.m')
-rw-r--r--src/mac.m34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/mac.m b/src/mac.m
index 945063a..a0b2017 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1286,10 +1286,11 @@ puglRealize(PuglView* view)
impl->window = window;
[window setContentSize:framePt.size];
- if (view->title) {
+ const char* const title = view->strings[PUGL_WINDOW_TITLE];
+ if (title) {
NSString* titleString =
- [[NSString alloc] initWithBytes:view->title
- length:strlen(view->title)
+ [[NSString alloc] initWithBytes:title
+ length:strlen(title)
encoding:NSUTF8StringEncoding];
[window setTitle:titleString];
@@ -1656,17 +1657,28 @@ puglGetNativeView(PuglView* view)
}
PuglStatus
-puglSetWindowTitle(PuglView* view, const char* title)
+puglViewStringChanged(PuglView* const view,
+ const PuglStringHint key,
+ const char* const value)
{
- puglSetString(&view->title, title);
+ if (!view->impl->window) {
+ return PUGL_SUCCESS;
+ }
- if (view->impl->window) {
- NSString* titleString =
- [[NSString alloc] initWithBytes:title
- length:strlen(title)
- encoding:NSUTF8StringEncoding];
+ switch (key) {
+ case PUGL_CLASS_NAME:
+ return PUGL_UNSUPPORTED;
- [view->impl->window setTitle:titleString];
+ case PUGL_WINDOW_TITLE:
+ if (view->impl->window) {
+ NSString* const titleString =
+ [[NSString alloc] initWithBytes:value
+ length:strlen(value)
+ encoding:NSUTF8StringEncoding];
+
+ [view->impl->window setTitle:titleString];
+ }
+ break;
}
return PUGL_SUCCESS;