Correct event error handling and add compute_expand to mpv_widget

This commit is contained in:
Brendan Szymanski 2026-06-24 00:12:46 -04:00
parent 463071ae89
commit cd2fc99c8a

View file

@ -155,9 +155,8 @@ mpv_widget_tick(gpointer user_data)
if (event->event_id == MPV_EVENT_NONE)
break;
if (event->event_id == MPV_EVENT_ERROR) {
const char *msg = "mpv playback error";
if (event->error && event->error->string)
msg = event->error->string;
mpv_event_error *err = (mpv_event_error *)event->data;
const char *msg = mpv_error_string(err->error_code);
g_signal_emit(self, signals[SIGNAL_ERROR], 0, msg);
}
if (event->event_id == MPV_EVENT_END_FILE) {
@ -216,6 +215,21 @@ mpv_widget_size_allocate(GtkWidget *widget,
gtk_widget_size_allocate(child, &alloc, baseline);
}
static void
mpv_widget_compute_expand(GtkWidget *widget,
gboolean *hexpand_p,
gboolean *vexpand_p)
{
GtkWidget *child = gtk_widget_get_first_child(widget);
if (child) {
*hexpand_p = gtk_widget_compute_expand(child, GTK_ORIENTATION_HORIZONTAL);
*vexpand_p = gtk_widget_compute_expand(child, GTK_ORIENTATION_VERTICAL);
} else {
*hexpand_p = FALSE;
*vexpand_p = FALSE;
}
}
static void
mpv_widget_measure(GtkWidget *widget,
GtkOrientation orientation,
@ -287,6 +301,7 @@ mpv_widget_class_init(MpvWidgetClass *klass)
gobject_class->dispose = mpv_widget_dispose;
widget_class->size_allocate = mpv_widget_size_allocate;
widget_class->measure = mpv_widget_measure;
widget_class->compute_expand = mpv_widget_compute_expand;
signals[SIGNAL_POSITION_CHANGED] = g_signal_new(
"position-changed",