Skip to content

Commit

Permalink
fix subtitle menu check status
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Dec 18, 2023
1 parent 67c7d92 commit 86dcd10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,18 @@ static bool update_edition_menu(plugin_ctx *ctx, dyn_menu *item) {

void *tmp = talloc_new(NULL);

int pos = -1;
for (int i = 0; i < list->num_entries; i++) {
edition_item *entry = &list->entries[i];
if (entry->id == ctx->state->edition) pos = i;
append_menu(
item->hmenu, MIIM_STRING | MIIM_DATA, 0, 0,
escape_title(item->talloc_ctx, bstr0(entry->title)), NULL,
talloc_asprintf(item->talloc_ctx, "set edition %d", entry->id));
}
if (ctx->state->edition >= 0)
CheckMenuRadioItem(item->hmenu, 0, list->num_entries,
ctx->state->edition, MF_BYPOSITION);
if (pos >= 0)
CheckMenuRadioItem(item->hmenu, 0, list->num_entries, pos,
MF_BYPOSITION);

talloc_free(tmp);
return true;
Expand Down
14 changes: 13 additions & 1 deletion src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ static void handle_property_change(mpv_event *event) {
mp_state *state = ctx->state;
mpv_event_property *prop = event->data;
switch (prop->format) {
case MPV_FORMAT_NONE:
if (strcmp(prop->name, "vid") == 0) {
state->vid = -1;
} else if (strcmp(prop->name, "aid") == 0) {
state->aid = -1;
} else if (strcmp(prop->name, "sid") == 0) {
state->sid = -1;
} else if (strcmp(prop->name, "secondary-sid") == 0) {
state->sid2 = -1;
}
break;
case MPV_FORMAT_INT64:
if (strcmp(prop->name, "window-id") == 0) {
int64_t wid = *(int64_t *)prop->data;
Expand All @@ -94,7 +105,8 @@ static void handle_property_change(mpv_event *event) {
if (strcmp(prop->name, "audio-device") == 0) {
if (state->audio_device != NULL)
talloc_free(state->audio_device);
state->audio_device = talloc_strdup(state, prop->data);
char *val = *(char **)prop->data;
state->audio_device = talloc_strdup(state, val);
}
break;
case MPV_FORMAT_NODE:
Expand Down

0 comments on commit 86dcd10

Please sign in to comment.