mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Start work on displaying progress bar in macOS dock
This commit is contained in:
@@ -1202,6 +1202,28 @@ play_system_sound_by_id_async(PyObject *self UNUSED, PyObject *which) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSView *dock_content_view = nil;
|
||||||
|
static NSImageView *dock_image_view = nil;
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
cocoa_show_progress_bar_on_dock_icon(PyObject *self UNUSED, PyObject *args) {
|
||||||
|
float percent = -100;
|
||||||
|
if (!PyArg_ParseTuple(args, "|f", &percent)) return NULL;
|
||||||
|
NSDockTile *dockTile = [NSApp dockTile];
|
||||||
|
if (!dock_content_view) {
|
||||||
|
dock_content_view = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, dockTile.size.width, dockTile.size.height)];
|
||||||
|
dock_image_view = [NSImageView.alloc initWithFrame:dock_content_view.frame];
|
||||||
|
dock_image_view.imageScaling = NSImageScaleProportionallyDown;
|
||||||
|
dock_image_view.image = NSApp.applicationIconImage;
|
||||||
|
[dock_content_view addSubview:dock_image_view];
|
||||||
|
}
|
||||||
|
[dock_content_view setFrameSize:dockTile.size];
|
||||||
|
[dock_image_view setFrameSize:dockTile.size];
|
||||||
|
[dockTile setContentView:percent < 0 ? nil : dock_content_view];
|
||||||
|
[dockTile display];
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef module_methods[] = {
|
static PyMethodDef module_methods[] = {
|
||||||
{"cocoa_play_system_sound_by_id_async", play_system_sound_by_id_async, METH_O, ""},
|
{"cocoa_play_system_sound_by_id_async", play_system_sound_by_id_async, METH_O, ""},
|
||||||
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
||||||
@@ -1213,6 +1235,7 @@ static PyMethodDef module_methods[] = {
|
|||||||
{"cocoa_set_url_handler", (PyCFunction)cocoa_set_url_handler, METH_VARARGS, ""},
|
{"cocoa_set_url_handler", (PyCFunction)cocoa_set_url_handler, METH_VARARGS, ""},
|
||||||
{"cocoa_set_app_icon", (PyCFunction)cocoa_set_app_icon, METH_VARARGS, ""},
|
{"cocoa_set_app_icon", (PyCFunction)cocoa_set_app_icon, METH_VARARGS, ""},
|
||||||
{"cocoa_set_dock_icon", (PyCFunction)cocoa_set_dock_icon, METH_VARARGS, ""},
|
{"cocoa_set_dock_icon", (PyCFunction)cocoa_set_dock_icon, METH_VARARGS, ""},
|
||||||
|
{"cocoa_show_progress_bar_on_dock_icon", (PyCFunction)cocoa_show_progress_bar_on_dock_icon, METH_VARARGS, ""},
|
||||||
{"cocoa_bundle_image_as_png", (PyCFunction)(void(*)(void))bundle_image_as_png, METH_VARARGS | METH_KEYWORDS, ""},
|
{"cocoa_bundle_image_as_png", (PyCFunction)(void(*)(void))bundle_image_as_png, METH_VARARGS | METH_KEYWORDS, ""},
|
||||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -896,6 +896,10 @@ def cocoa_set_dock_icon(icon_path: str) -> None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def cocoa_show_progress_bar_on_dock_icon(progress: float = -100) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def cocoa_hide_app() -> None:
|
def cocoa_hide_app() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user