static gboolean draw_handler(GtkWidget *widget, cairo_t *cr, gpointer data) { gmpv_handle *ctx = data; guint signal_id = g_signal_lookup("draw", MAIN_WINDOW_TYPE); g_signal_handlers_disconnect_matched( widget, G_SIGNAL_MATCH_ID |G_SIGNAL_MATCH_DATA, signal_id, 0, 0, NULL, ctx ); mpv_init(ctx); mpv_set_wakeup_callback(ctx->mpv_ctx, mpv_wakeup_callback, ctx); if(!ctx->files) { control_box_set_enabled (CONTROL_BOX(ctx->gui->control_box), FALSE); } return FALSE; }
void remove_current_playlist_entry(gmpv_handle *ctx) { const gchar *cmd[] = {"playlist_remove", NULL, NULL}; PlaylistWidget *playlist; GtkTreePath *path; playlist = PLAYLIST_WIDGET(ctx->gui->playlist); gtk_tree_view_get_cursor ( GTK_TREE_VIEW(playlist->tree_view), &path, NULL ); if(path) { gint index; gchar *index_str; index = gtk_tree_path_get_indices(path)[0]; index_str = g_strdup_printf("%d", index); cmd[1] = index_str; g_signal_handlers_block_matched ( playlist->list_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ctx ); playlist_widget_remove(playlist, index); if(ctx->loaded) { mpv_check_error(mpv_command(ctx->mpv_ctx, cmd)); } if(playlist_widget_empty(playlist)) { control_box_set_enabled (CONTROL_BOX(ctx->gui->control_box), FALSE); } g_signal_handlers_unblock_matched ( playlist->list_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ctx ); g_free(index_str); } }